You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contrib.rst
+38-3Lines changed: 38 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -103,14 +103,49 @@ Occasionally, the documentation builder will persist in rendering an incorrect o
103
103
$ pdm run document-live -a
104
104
105
105
106
+
Documentation style guide
107
+
=========================
108
+
109
+
.. warning::
110
+
111
+
Our documentation style guidelines are evolving, and this section is incomplete.
112
+
113
+
Some of the fundamental guidelines are:
114
+
115
+
* **Document the contract and the affordances,** not the implementation. This is especially important because the Amaranth documentation is *the* source of truth for its semantics; the tests and the implementation source code are secondary to it, and the RFCs exist to record the process rather than document the outcome.
116
+
* **Shape the code to be documentable.** This is a corollary to the previous guideline. If an interface is difficult to describe in a way that is readily understood, then it may need to be changed. Many breaking changes in Amaranth were done to make the language and libraries easier to understand.
117
+
* **Be consistent.** Take inspiration from existing documentation for similar modules. However, don't be consistent at the expense of clarity.
118
+
* **Be concise.** It is easy to write boilerplate, and difficult to navigate through it.
119
+
120
+
* In particular, if the `Parameters` section of the class docstring describes a parameter, it is expected that the same parameter will be available as a class attribute (usually, but not always, read-only), and there is no need to additionally document this fact. If there isn't a corresponding attribute it should likely be added.
121
+
* There is no need to individually document every argument and every return value of every method. This mainly creates clutter. The goal in writing documentation is transferring knowledge, not ticking boxes.
122
+
123
+
Some of the formatting guidelines are:
124
+
125
+
* Limit code (including docstrings, where possible--some of the Sphinx syntax does not allow wrapping) to 100 columns in ``.py`` files, but do not break paragraphs in ``.rst`` files.
126
+
* Use ``###...#`` for first-level headings, ``===...=`` for second-level headings, ``---...-`` for third-level headings.
127
+
* Use the ``:py:`...``` syntax for inline Python code references (even trivial ones, e.g. ``:py:`var_name```), ``.. testcode::`` for most Python code blocks (use ``.. code::`` where the code cannot or should not be tested), ``.. doctest::`` for doctests.
128
+
* Use admonitions sparingly, and only of the following kinds:
129
+
130
+
* ``.. warning::`` for text which MUST be paid attention to, or else unexpected bad things may happen. This is the most noticeable kind, rendered in yellow at the moment.
131
+
* ``.. tip::`` for text which SHOULD be paid attention to, otherwise annoyance may happen. This is the second most noticeable kind, rendered in bright blue-green at the moment.
132
+
* ``.. note::`` for text which MAY be paid attention to, but which is not key for understanding of the topic as a whole. This is the least noticeable kind, rendered in faint blue at the moment.
133
+
* ``.. todo::`` may also be used for incomplete sections.
134
+
135
+
* For methods, phrase the short description (first line of docstring) like ``Do the thing.``, i.e. as an imperative sentence.
136
+
* For properties, phrase the short description (first line of docstring) like ``Value of thing.``, i.e. as a declarative sentence.
137
+
* When documenting signatures of interfaces, as well as components, use the (non-standard) `Members` section to document their interface members, and only that section; do not document them in an `Attributes` section.
138
+
* If an anchor for a section is needed, namespace it, e.g. the ``.. _lang-assignable:`` anchor is a part of the ``lang`` namespace. Anchor names are global.
139
+
140
+
106
141
Contributing your changes
107
142
=========================
108
143
109
-
.. attention::
144
+
.. warning::
110
145
111
-
Our code style guidelines are evolving, and we will eventually have a formal document listing them.
146
+
Our code style guidelines are evolving, and we do not yet have a formal document listing them.
112
147
113
-
At the moment there is no formal style guide for source code. We ask that you do your best effort to keep the code that you add or modify similar in style as well as in spirit to the code surrounding it, and we may ask you to change it during review. When in doubt, submit your code as-is.
148
+
We ask that you do your best effort to keep the code that you add or modify similar in style as well as in spirit to the code surrounding it, and we may ask you to change it during review. When in doubt, submit your code as-is.
Copy file name to clipboardExpand all lines: docs/guide.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -811,9 +811,9 @@ Crucially, this means that any Python object can be added to an array; the only
811
811
812
812
An array becomes immutable after it is indexed for the first time. The elements of the array do not themselves become immutable, but it is not recommended to mutate them as the behavior can become unpredictable.
813
813
814
-
.. important::
814
+
.. warning::
815
815
816
-
Each time an array proxy object with ``n`` elements is used in an expression, it generates a multiplexer with ``n`` branches. However, using ``k`` of such array proxy objects in an expression generates a multiplexer with ``n**k`` branches. This can generate extremely large circuits that may quickly exhaust the resources of the synthesis target or even the available RAM.
816
+
Each time an array proxy object with :py:`n` elements is used in an expression, it generates a multiplexer with :py:`n` branches. However, using :py:`k` of such array proxy objects in an expression generates a multiplexer with :py:`n**k` branches. This can generate extremely large circuits that may quickly exhaust the resources of the synthesis target or even the available RAM.
817
817
818
818
819
819
.. _lang-data:
@@ -1499,7 +1499,7 @@ The :meth:`~Elaboratable.elaborate` method must either return an instance of :cl
1499
1499
1500
1500
The :py:`platform` argument received by the :meth:`~Elaboratable.elaborate` method can be :py:`None`, an instance of :ref:`a built-in platform <platform>`, or a custom object. It is used for `dependency injection <https://en.wikipedia.org/wiki/Dependency_injection>`_ and to contain the state of a design while it is being elaborated.
1501
1501
1502
-
.. important::
1502
+
.. warning::
1503
1503
1504
1504
The :meth:`~Elaboratable.elaborate` method should not modify the ``self`` object it receives other than for debugging and experimentation. Elaborating the same design twice with two identical platform objects should produce two identical netlists. If the design needs to be modified after construction, this should happen before elaboration.
1505
1505
@@ -1665,7 +1665,7 @@ The renaming of the ``sync`` clock domain in it causes the behavior of the final
1665
1665
m.d.video += count.eq(count + 1)
1666
1666
m.d.comb += zero.eq(count == 0)
1667
1667
1668
-
.. tip::
1668
+
.. warning::
1669
1669
1670
1670
A combinatorial signal can change synchronously to a clock domain, as in the example above, in which case it may only be sampled from the same clock domain unless explicitly synchronized. Renaming a clock domain must be assumed to potentially affect any output of an elaboratable.
0 commit comments