| Crates.io | railroad_dsl |
| lib.rs | railroad_dsl |
| version | 0.2.2 |
| created_at | 2018-10-24 20:02:37.333265+00 |
| updated_at | 2024-07-26 19:12:41.494989+00 |
| description | A small DSL to generate syntax-diagrams |
| homepage | |
| repository | https://github.com/lukaslueg/railroad_dsl |
| max_upload_size | |
| id | 92463 |
| size | 46,097 |
A small DSL to generate syntax diagrams using this library.
{...} is a horizontal stack of connected elements[...] is a vertical sequence of connected elements<...> is a choice of multiple options, exactly one of which has to be picked"foobar" is a terminal'foobar' is a non-terminal`foobar` is a comment...? is an optional element...*... is a repeated element! is the empty elementQuotes (and backslashes) can be escaped using backslashes.
For example:
{["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`>]}

Run cargo run --example example_diagrams for more examples.
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