virus-warnning / quick-gv
Parser Hook for SVG generation by Graphviz
v1.0.0
2026-10-30 18:57 UTC
Requires
- php: >=8.3.36
Requires (Dev)
- mediawiki/mediawiki-codesniffer: ^52.0
- mediawiki/mediawiki-phan-config: ^0.14
- phpunit/phpunit: ^9.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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
dotbinary must be available in$PATH
Development
- PHP >= 8.3.36
astextension (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