Search by

virus-warnning / quick-gv

virus-warnning

Parser Hook for SVG generation by Graphviz

Package info

github.com/virus-warnning/quick-gv

pkg:composer/virus-warnning/quick-gv

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.0 2026-10-30 18:57 UTC

This package is auto-updated.

Last update: 2026-11-02 03:37:59 UTC


README

A MediaWiki extension to render SVG diagrams with minimal dot syntax.

See: https://www.mediawiki.org/wiki/Extension:QuickGV

Requirements

Runtime

  • PHP >= 8.3.36
  • MediaWiki >= 1.43
  • Graphviz โ€” the dot binary must be available in $PATH

Development

  • PHP >= 8.3.36
  • ast extension (for Phan)
  • Composer

Installation

Add to your MediaWiki root composer.local.json:

{
    "require": {
        "virus-warnning/quick-gv": "^1.0"
    }
}

Then run:

composer update

Configuration

No required configuration. The following constants in src/ExtensionConstants.php can be configured:

Constant Default Description
ENABLE_SVG_CACHE true Enable MD5-based SVG caching to skip re-conversion
DUMP_DEBUG_FILES true Write debug artifacts (.dot, .txt) to the debug/ directory

Usage

In any MediaWiki page, use the <quickgv> parser hook:

<quickgv theme="default" name="mychart">
digraph G {
    A[Start] --> B{Decision}
    B -->|Yes| C[Action]
    B -->|No| D[Other]
}
</quickgv>

Attributes

Attribute Required Default Description
theme No default Color theme (cold, warm, sakura, default)
name No G Graph name (1โ€“25 chars) used as the SVG cache filename
usage No โ€” Graphviz layout engine (dot, neato, fdp, sfdp, twopi, circo)
dump-env No false Display an environment info table below the SVG
dump-gv No false Display the generated dot syntax below the SVG

Theme Options

Theme Description
default Graphviz default color palette
cold Cool blue-green color scheme
warm Warm red-orange color scheme
sakura Sakura pink color scheme

File Structure

|-- extension.json              # ๐Ÿ“‹ MediaWiki extension registration
|-- composer.json               # ๐Ÿ“ฆ Composer dependencies
|-- phpcs.xml                   # โœ… PHPCS config (MediaWiki standard)
|-- phpunit.xml                 # ๐Ÿงช PHPUnit config
|-- LICENSE                     # ๐Ÿ“„ MIT License
|-- src/
|   |-- ExtensionConstants.php  # ๐Ÿท๏ธ Extension constants
|   |-- Hook.php                # ๐Ÿช MediaWiki hook registration & main logic
|   |-- Command.php             # ๐Ÿ–ฅ๏ธ Shell command execution (ShellBox)
|   |-- FieldResult.php         # ๐Ÿ“ Form field result wrapper
|   |-- FileSystemUtils.php     # ๐Ÿ“ File system utilities
|   |-- Validator.php           # โœ”๏ธ Dot syntax validation
|-- templates/
|   |-- gv-builder.php          # ๐Ÿ—๏ธ Composes final dot syntax from theme & usage (stdin โ†’ dot)
|-- i18n/
|   |-- en.json                 # ๐Ÿ‡ฌ๐Ÿ‡ง English translations
|   |-- zh-hant.json            # ๐Ÿ‡น๐Ÿ‡ผ Traditional Chinese translations
|   |-- ja.json                 # ๐Ÿ‡ฏ๐Ÿ‡ต Japanese translations
|-- tests/
|   |-- bootstrap.php           # ๐Ÿš€ Test bootstrap (stubs MW globals)
|   |-- FieldResultTest.php     # ๐Ÿงช FieldResult unit tests
|   |-- FileSystemUtilsTest.php # ๐Ÿงช FileSystemUtils unit tests
|   |-- ValidatorTest.php       # ๐Ÿงช Validator unit tests
|-- debug/                      # ๐Ÿ› Debug files (not in VCS)

Development

Run Tests

composer test

Code Style

# Check
composer phpcs

# Auto-fix
composer phpcbf

Static Analysis

composer phan

License

MIT