7 个版本
0.2.2 | 2024年7月26日 |
---|---|
0.2.1 | 2024年7月12日 |
0.2.0 | 2023年6月17日 |
0.1.3 | 2023年4月29日 |
0.1.1 | 2018年10月25日 |
#40 in 可视化
每月205次下载
16KB
291 行
使用 此库 生成语法图的小型 DSL。
{...}
是连接元素的水平堆栈[...]
是连接元素的垂直序列<...>
是多个选项中的一个,必须选择一个"foobar"
是终结符'foobar'
是非终结符`foobar`
是注释...?
是可选元素...*...
是重复元素!
是空元素
可以使用反斜杠转义引号(和反斜杠)。
例如
{["CONSTRAINT" "name"]?,
<["PRIMARY" "KEY" <!, "ASC", "DESC"> 'conflict-clause' <!, "AUTOINCREMENT">],
["NOT" "NULL" 'conflict-clause'],
["UNIQUE" 'conflict-clause'],
["CHECK" "(" 'expr' ")"],
["DEFAULT" <'signed-number', 'literal-value', ["(" 'expr' ")"]>],
["COLLATE" "collation-name"],
'foreign-key-clause'>}
{[`create-table-stmt` "CREATE" <!, <"TEMP", "TEMPORARY">#`Table will be dropped when connection closes`> "TABLE"],
[[["IF" "NOT" "EXISTS"]#`If table exists, do nothing`]? [[["schema-name" "."]#`...in a foreign database`]? "table-name"]#`The table's name`],
[<["(" ['column-def'*","]#`One or more column-definitions` [!*[['table-constraint' ","]#`primary key and stuff`]]#`Zero or more table-constraints` ")" <!, ["WITHOUT" "ROWID"]>],
["AS" 'select-stmt']#`Create table definition and content directly from a query`>]}
运行 cargo run --example example_diagrams
以获取更多示例。
A small DSL to generate syntax-diagrams.
If no input files are given, act as a pipe from stdin to stdout. Otherwise, process each input file into an output file with the file extension replaced
Usage: railroad [OPTIONS] [INPUTS]...
Arguments:
[INPUTS]...
Options:
--css <CSS>
Alternative CSS file
--format <FORMAT>
Output format
[default: svg]
[possible values: svg, png]
--max-width <MAX_WIDTH>
Maximum width of the final image
--max-height <MAX_HEIGHT>
Maximum height of the final image
--theme <THEME>
Theme to use
[default: light]
[possible values: light, dark]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
依赖
~8MB
~154K SLoC