11Generated help messages and documentation
22=========================================
33
4- - (virtually) all Yosys commands and built-in cell types have help text
5- - see `help ` (or call ``yosys -h help ``)
6- - this help text is also used to generate the :doc: `/cmd_ref ` and
7- :doc: `/cell_index ` documentation, available online via `ReadtheDocs `_
4+ All Yosys commands and built-in cell types should include help text, documenting
5+ their functionality for users. This help text is made available through the
6+ `help ` command, and online via `ReadtheDocs `_ as part of the :doc: `/cmd_ref ` and
7+ :doc: `/cell_index ` documentation. When running locally, any commands provided
8+ by loaded plugins (either from the command line when calling ``yosys ``, or
9+ dynamically with the `plugin ` command) will also be available to the `help `
10+ command.
811
912.. _ReadtheDocs : https://about.readthedocs.com/
1013
11- Command help
12- ------------
14+ .. note ::
1315
14- - `help ` without arguments
16+ Since help text for commands is generated from compiled code, the online help
17+ may differ from that produced by `help `. Some commands, like `abc `, may be
18+ completely unavailable depending on compile flags; while others may limit
19+ specific features, such as whether the `synth ` script pass uses ABC.
1520
16- - lists all commands with their ``Pass::short_help ``
21+ Command help
22+ ------------
1723
18- - ``help <command> ``
24+ The first stop for command help text is the ``Pass::short_help ``. This is a
25+ short sentence describing the pass, and is set in the ``Pass `` constructor, as
26+ demonstrated here with `chformal `.
1927
20- - provides command specific help content
21- - as an example, the help content for `chformal ` is shown below
28+ .. literalinclude :: /generated/chformal.cc
29+ :language: c++
30+ :start-at: public Pass {
31+ :end-before: bool formatted_help()
32+ :caption: ``ChformalPass() `` from :file: `passes/cmds/chformal.cc `
33+ :append: // ...
34+ } ChformalPass;
35+
36+ All currently available commands are listed with their ``short_help `` string
37+ when calling `help ` without arguments, and is more or less the same as the
38+ unlisted :ref: `command index <commandindex >`. The string is also used when
39+ hovering over links to commands in the documentation, and in section headings
40+ like :ref: `chformal autocmd `.
41+
42+ The next section shows the complete help text for the `chformal ` command. This
43+ can be displayed locally by using ``help <command> `` (or ``yosys -h <command> ``
44+ from the command line). The general format is to show each usage signature,
45+ followed by a paragraph describing what the pass does, and a list of options or
46+ flags available. Additional arguments in the signature or option may use square
47+ brackets (``[] ``) to indicate optional parts, and angle brackets (``<> ``) for
48+ required parts. The pipe character ``| `` may be used to indicate mutually
49+ exclusive arguments.
50+
51+ .. todo :: decide on a formatting style for pass options
2252
2353.. _chformal autocmd :
2454
@@ -28,11 +58,22 @@ Command help
2858The ``Pass::help() `` method
2959~~~~~~~~~~~~~~~~~~~~~~~~~~~
3060
31- - call ``log() `` directly to print and format help text
32- - arbitrary formatting is possible, though some recommendations for consistency
33- and correct parsing during RST generation
34-
35- + see `Dumping command help to json `_ for details
61+ This is the original way to provide help text, and as of this writing is still
62+ the most common. The ``log() `` function should be called directly to print and
63+ format the help text, and each line should be limited to 80 (printed)
64+ characters. While it is possible to provide arbitrary formatting, it is
65+ preferred to follow the guidelines here to maintain consistency with other
66+ passes and to assist in correct parsing and formatting during RST generation
67+ (i.e. these docs).
68+
69+ The first line should always be a blank line, followed by the primary usage
70+ signature for the command. Each usage signature should be indented with 4
71+ spaces, and followed by a blank line. Each option or flag should start on a new
72+ line indented with 4 spaces, followed by a description of the option which is
73+ indented by a further 4 spaces, and then a blank line. Option descriptions
74+ typically start with lower case, and may forgo a trailing period (``. ``). Where
75+ multiple options share a description the blank line between options should be
76+ omitted.
3677
3778The ``Pass::formatted_help() `` method
3879~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -121,8 +162,8 @@ Dumping command help to json
121162
122163.. note :: Synthesis command scripts are special cased
123164
124- If the final block of help output starts with the string `"The following
125- commands are executed by this synthesis command:\n " `, then the rest of the
165+ If the final block of help output starts with the string `` "The following
166+ commands are executed by this synthesis command:\n" `` , then the rest of the
126167 code block is formatted as ``yoscrypt `` (e.g. `synth_ice40 `). The caveat
127168 here is that if the ``script() `` calls ``run() `` on any commands *prior * to
128169 the first ``check_label `` then the auto detection will break and revert to
@@ -181,7 +222,7 @@ Cell help
181222- parsed by :file: `techlibs/common/cellhelp.py `
182223- comments preceding cell type converted to a ``SimHelper `` struct, defined in
183224 :file: `kernel/register.cc `
184- - ``#include``d in :file:`kernel/register.cc`, creating a map of cell types to
225+ - ``#include ``\ d in :file: `kernel/register.cc `, creating a map of cell types to
185226 their ``SimHelper `` struct.
186227
187228- ``help -cells ``
0 commit comments