Skip to content

Commit 0fcdecf

Browse files
committed
Improve docstrings layout
1 parent b72c5e0 commit 0fcdecf

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

doc/source/doc-style/docstrings.rst

+25-14
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,32 @@ Notice that if the definition of the function gets updated, this
227227
section needs to be updated too.
228228

229229

230-
Example Docstrings
231-
==================
232-
Methods and functions should generally be documented within the
233-
'Examples' section to make the usage of the method or function clear.
234-
Here is a sample function:
230+
Additional Directives
231+
=====================
232+
Since Python docstrings are written using RST syntax, it is possible to take
233+
advantage of some directives available in this Markup language. Among those, it
234+
is possible to find:
235235

236-
.. literalinclude:: sample_func.py
236+
- ``.. note::`` directive is useful for highlighting important
237+
information once the documentation gets rendered.
238+
239+
- ``.. warning::`` is usually used to point out an action that might result in
240+
data loss.
241+
242+
- ``.. deprecated:: X.Y.Z`` to inform the user about the deprecated status of
243+
the object or functionality.
244+
245+
You can find additional information and examples at `numpydoc`_. Reference
246+
this documentation as the primary source regarding docstring styles for directives
247+
that are not covered here.
248+
249+
250+
Example
251+
=======
252+
253+
An generic docstring example compliant with PyAnsys guidelines is shown below:
254+
255+
.. literalinclude:: code/sample_func.py
237256

238257
To include the docstring of a function within Sphinx, you use the
239258
``autofunction::`` directive:
@@ -246,13 +265,5 @@ This directive renders the sample function as:
246265

247266
.. autofunction:: pyansys_sphinx_theme.sample_func.func
248267

249-
Additional Information
250-
======================
251-
You can find additional information and examples at `numpydoc`_. Reference
252-
this documentation as the primary source regarding docstring styles for directives
253-
that are not covered here. For example, you use the ``note::`` directive to highlight
254-
important information and the ``warning::`` directive to point out an action that
255-
might result in data loss.
256-
257268
.. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html
258269
.. _googledoc: https://google.github.io/styleguide/

0 commit comments

Comments
 (0)