Skip to content

Commit 2da7627

Browse files
docs: Move help guides to documenting.rst
1 parent b9182ab commit 2da7627

File tree

4 files changed

+315
-307
lines changed

4 files changed

+315
-307
lines changed

docs/source/cmd/index_internal.rst

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -3,150 +3,3 @@ Internal commands for developers
33

44
.. autocmdgroup:: internal
55
:members:
6-
7-
Writing command help
8-
--------------------
9-
10-
- use `chformal` as an example
11-
- generated help content below
12-
13-
.. _chformal autocmd:
14-
15-
.. autocmd:: chformal
16-
:noindex:
17-
18-
The ``formatted_help()`` method
19-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20-
21-
- ``PrettyHelp::get_current()``
22-
- ``PrettyHelp::set_group()``
23-
24-
+ used with ``.. autocmdgroup:: <group>``
25-
+ can assign group and return false
26-
+ if no group is set, will try to use ``source_location`` and assign group
27-
from path to source file
28-
29-
- return value
30-
31-
+ true means help content added to current ``PrettyHelp``
32-
+ false to use ``Pass::help()``
33-
34-
- adding content
35-
36-
+ help content is a list of ``ContentListing`` nodes, each one having a type,
37-
body, and its own list of children ``ContentListing``\ s
38-
+ ``PrettyHelp::get_root()`` returns the root ``ContentListing`` (``type="root"``)
39-
+ ``ContentListing::{usage, option, codeblock, paragraph}`` each add a
40-
``ContentListing`` to the current node, with type the same as the method
41-
42-
* the first argument is the body of the new node
43-
* ``usage`` shows how to call the command (i.e. its "signature")
44-
* ``paragraph`` content is formatted as a paragraph of text with line breaks
45-
added automatically
46-
* ``codeblock`` content is displayed verbatim, use line breaks as desired;
47-
takes an optional ``language`` argument for assigning the language in RST
48-
output for code syntax highlighting (use ``yoscrypt`` for yosys script
49-
syntax highlighting)
50-
* ``option`` lists a single option for the command, usually starting with a
51-
dash (``-``); takes an optional second argument which adds a paragraph
52-
node as a means of description
53-
54-
+ ``ContentListing::open_usage`` creates and returns a new usage node, can be
55-
used to e.g. add text/options specific to a given usage of the command
56-
+ ``ContentListing::open_option`` creates and returns a new option node, can
57-
be used to e.g. add multiple paragraphs to an option's description
58-
+ paragraphs are treated as raw RST, allowing for inline formatting and
59-
references as if it were written in the RST file itself
60-
61-
.. literalinclude:: /generated/chformal.cc
62-
:language: c++
63-
:start-at: bool formatted_help()
64-
:end-before: void execute
65-
:caption: ``ChformalPass::formatted_help()`` from :file:`passes/cmds/chformal.cc`
66-
67-
Dumping command help to json
68-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69-
70-
- `help -dump-cmds-json cmds.json`
71-
72-
+ generates a ``ContentListing`` for each command registered in Yosys
73-
+ tries to parse unformatted ``Pass::help()`` output if
74-
``Pass::formatted_help()`` is unimplemented or returns false
75-
76-
* if a line starts with four spaces followed by the name of the command then
77-
a space, it is parsed as a signature (usage node)
78-
* if a line is indented and starts with a dash (``-``), it is parsed as an
79-
option
80-
* anything else is parsed as a codeblock and added to either the root node
81-
or the current option depending on the indentation
82-
83-
+ dictionary of command name to ``ContentListing``
84-
85-
* uses ``ContentListing::to_json()`` recursively for each node in root
86-
* root node used for source location of class definition
87-
* includes flags set during pass constructor (e.g. ``experimental_flag`` set
88-
by ``Pass::experimental()``)
89-
* also title (``short_help`` argument in ``Pass::Pass``), group, and class
90-
name
91-
92-
+ dictionary of group name to list of commands in that group
93-
94-
- used by sphinx autodoc to generate help content
95-
96-
.. literalinclude:: /generated/cmds.json
97-
:language: json
98-
:start-at: "chformal": {
99-
:end-before: "chparam": {
100-
:caption: `chformal` in generated :file:`cmds.json`
101-
102-
.. note:: Synthesis command scripts are special cased
103-
104-
If the final block of help output starts with the string `"The following
105-
commands are executed by this synthesis command:\n"`, then the rest of the
106-
code block is formatted as ``yoscrypt`` (e.g. `synth_ice40`). The caveat
107-
here is that if the ``script()`` calls ``run()`` on any commands *prior* to
108-
the first ``check_label`` then the auto detection will break and revert to
109-
unformatted code (e.g. `synth_fabulous`).
110-
111-
Command line rendering
112-
~~~~~~~~~~~~~~~~~~~~~~
113-
114-
- if ``Pass::formatted_help()`` returns true, will call
115-
``PrettyHelp::log_help()``
116-
117-
+ traverse over the children of the root node and render as plain text
118-
+ effectively the reverse of converting unformatted ``Pass::help()`` text
119-
+ lines are broken at 80 characters while maintaining indentation (controlled
120-
by ``MAX_LINE_LEN`` in :file:`kernel/log_help.cc`)
121-
+ each line is broken into words separated by spaces, if a given word starts
122-
and ends with backticks they will be stripped
123-
124-
- if it returns false it will call ``Pass::help()`` which should call ``log()``
125-
directly to print and format help text
126-
127-
+ if ``Pass::help()`` is not overridden then a default message about missing
128-
help will be displayed
129-
130-
.. literalinclude:: /generated/chformal.log
131-
:lines: 2-
132-
133-
RST generated from autocmd
134-
~~~~~~~~~~~~~~~~~~~~~~~~~~
135-
136-
- below is the raw RST output from ``autocmd`` (``YosysCmdDocumenter`` class in
137-
:file:`docs/util/cmd_documenter.py`) for `chformal` command
138-
- heading will be rendered as a subheading of the most recent heading (see
139-
`chformal autocmd`_ above rendered under `Writing command help`_)
140-
- ``.. cmd:def:: <cmd>`` line is indexed for cross references with ``:cmd:ref:``
141-
directive (`chformal autocmd`_ above uses ``:noindex:`` option so that
142-
`chformal` still links to the correct location)
143-
144-
+ ``:title:`` option controls text that appears when hovering over the
145-
`chformal` link
146-
147-
- commands with warning flags (experimental or internal) add a ``.. warning``
148-
block before any of the help content
149-
- if a command has no ``source_location`` the ``.. note`` at the bottom will
150-
instead link to :doc:`/cmd/index_other`
151-
152-
.. autocmd_rst:: chformal

docs/source/yosys_internals/extending_yosys/contributing.rst

Lines changed: 0 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -176,163 +176,3 @@ Additional details
176176
+ if the design is too big for a comment, consider turning it into a `Gist`_
177177

178178
.. _Gist: https://gist.github.com/
179-
180-
Generated help messages and documentation
181-
-----------------------------------------
182-
183-
Command help
184-
~~~~~~~~~~~~
185-
186-
- `help` without arguments
187-
188-
- lists all commands with their ``Pass::short_help``
189-
190-
- ``help <command>``
191-
192-
- calls ``Pass::help()`` for ``<command>``
193-
194-
.. note::
195-
196-
A more expressive way to generate formatted help messages is `in
197-
development`_.
198-
199-
.. _in development: https://github.com/YosysHQ/yosys/pull/4860
200-
201-
Cell help
202-
~~~~~~~~~
203-
204-
- :file:`techlibs/common/simcells.v` and :file:`techlibs/common/simlib.v`
205-
- parsed by :file:`techlibs/common/cellhelp.py`
206-
- comments preceding cell type converted to a ``SimHelper`` struct, defined in
207-
:file:`kernel/register.cc`
208-
- ``#include``d in :file:`kernel/register.cc`, creating a map of cell types to
209-
their ``SimHelper`` struct.
210-
211-
- ``help -cells``
212-
213-
- lists all cells with their input/output ports
214-
215-
- ``help <celltype>``
216-
217-
- prints help message for ``<celltype>``
218-
- constructed from ``SimHelper`` content depending on version
219-
220-
- ``help <celltype>+``
221-
222-
- prints verilog code for ``<celltype>``
223-
224-
v1 (default)
225-
^^^^^^^^^^^^
226-
227-
- Legacy format
228-
- Expects formatting as follows:
229-
230-
.. code-block:: verilog
231-
232-
//-
233-
//- $<celltype> (<ports>)
234-
//* group <cellgroup>
235-
//-
236-
//- <cell description>
237-
//-
238-
module \$<celltype> (<ports>);
239-
// ...
240-
endmodule
241-
242-
- ``//* group`` line is generally after the cell signature, but can appear
243-
anywhere in the comment block
244-
245-
- determines where the cell is included in sphinx
246-
- check :file:`docs/source/cell` for current groups
247-
- a missing group will raise an error
248-
- assigning an unused group will result in the cell not being included in the
249-
sphinx docs
250-
251-
- the port signature line (``//- $<celltype> (<ports>)``) must start with (at
252-
least) 4 spaces (not tabs)
253-
254-
- the empty lines (``//-``) before/after the signature are required
255-
256-
- cell description can be multiple lines, but each line must start with ``//-``
257-
and a space
258-
259-
- description should have a trailing empty line
260-
- line breaks are preserved in `help` calls but will be rendered as text in
261-
sphinx docs, with empty lines being required between paragraphs
262-
263-
- cells in :file:`techlibs/common/simcells.v` can have optional truth table at
264-
the end of the cell description which is rendered in sphinx docs as a literal
265-
code block
266-
- e.g. `$_NOT_`:
267-
268-
.. code-block:: verilog
269-
270-
//-
271-
//- $_NOT_ (A, Y)
272-
//* group comb_simple
273-
//-
274-
//- An inverter gate.
275-
//-
276-
//- Truth table: A | Y
277-
//- ---+---
278-
//- 0 | 1
279-
//- 1 | 0
280-
//-
281-
282-
v2 (more expressive)
283-
^^^^^^^^^^^^^^^^^^^^
284-
285-
- each field of the ``SimHelper`` struct can be assigned with:
286-
287-
.. code-block:: verilog
288-
289-
//* <name> <value>
290-
291-
- ``ver`` must be explicitly set as ``2``
292-
- optional fields ``title`` and ``tags``
293-
294-
- title used for better displaying of cell
295-
- tags is a space-separated list of :doc:`/cell/properties`
296-
297-
- the port signature is automatically generated from the ``module`` definition
298-
- cell description is the same as v1
299-
- can link to commands or passes using backticks (`````)
300-
- e.g. `$nex`:
301-
302-
.. code-block:: verilog
303-
304-
//* ver 2
305-
//* title Case inequality
306-
//* group binary
307-
//* tags x-aware
308-
//- This corresponds to the Verilog '!==' operator.
309-
//-
310-
//- Refer to `$eqx` for more details.
311-
//-
312-
313-
- code blocks can be included as following:
314-
315-
.. code-block:: verilog
316-
317-
//- text
318-
//- ::
319-
//-
320-
//- monospaced text
321-
//-
322-
//- indentation and line length will be preserved, giving a scroll bar if necessary for the browser window
323-
//-
324-
//- more text
325-
326-
- the empty line after the ``::`` and before the text continues are required
327-
- the ``::`` line will be ignored in the `help` call while sphinx docs will
328-
treat everything that follows as a literal block until the next unindented
329-
line:
330-
331-
text
332-
::
333-
334-
monospaced text
335-
336-
indentation and line length will be preserved, giving a scroll bar if necessary for the browser window
337-
338-
more text

0 commit comments

Comments
 (0)