1- Docstrings
2- ##########
1+ .. _docstrings :
32
4- When writing docstrings for PyAnsys libraries, you should pick either
5- the ` numpydoc `_ or ` googledoc `_ documentation style. Adhering to the
6- selected style permits usage of the `sphinx.ext.napoleon
7- <https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html> `_
8- extension, which is included in Sphinx version 1.3 and later.
3+ Docstring Standards
4+ ###################
5+ When writing docstrings for PyAnsys libraries, use the `numpydoc `_
6+ documentation style. To use ` numpydoc `_ add the following to your
7+ `` conf.py ``:
98
9+ .. code :: python
10+
11+ extensions = [' numpydoc' ,
12+ # other extensions
13+ ]
14+
15+
16+ Minimum Requirements
17+ --------------------
18+ PyAnsys libary docstrings contain at a minimum the following
19+ `numpydoc `_ sections:
20+
21+ * `Short description <https://numpydoc.readthedocs.io/en/latest/format.html#short-summary >`_.
22+ * `Extended Summary <https://numpydoc.readthedocs.io/en/latest/format.html#extended-summary >`_ (if applicable)
23+ * `Parameters <https://numpydoc.readthedocs.io/en/latest/format.html#parameters >`_ if applicable
24+ * `Returns <https://numpydoc.readthedocs.io/en/latest/format.html#returns >`_ if applicable
25+ * `Examples <https://numpydoc.readthedocs.io/en/latest/format.html#examples >`_
26+
27+ These sections should follow the numpydoc standards. To avoid
28+ inconsistencies between PyAnsys libaries, adhere to the following
29+ additional standards:
30+
31+
32+ Parameters
33+ ~~~~~~~~~~
34+ Always specify the type, and whenever necessary, provide the full class name::
35+
36+ Parameters
37+ ----------
38+ my_obj : :class:`ansys.<product>.<library>.FooClass`
39+ Description of FooClass.
40+ some_int : int
41+ Some interger value.
42+
43+ .. note ::
44+ These parameter descriptions have punctuation.
45+
46+
47+ Returns
48+ ~~~~~~~
49+ Returns section contains only the return type and no the name and type::
50+
51+ Returns
52+ -------
53+ int
54+ Description of some return value.
55+
56+ Example Docstrings
57+ ------------------
1058Methods and functions should generally be documented with the
1159``Examples `` docstring section to make the usage of the method or
1260function clear. Here is a sample function:
@@ -25,12 +73,28 @@ This directive renders the sample function as:
2573.. autofunction :: pyansys_sphinx_theme.sample_func.func
2674
2775
76+ Validation
77+ ----------
78+ Enable validation of docstrings during the sphinx build by adding the
79+ following line to ``conf.py ``::
80+
81+ numpydoc_validation_checks = {"GL08"}
82+
83+ This will issue the following warning for any objects without a docstring::
84+
85+ "The object does not have a docstring"
86+
87+ The ``"GL08" `` code is required at minimum for PyAnsys projects.
88+ Other codes may be enforced at a later date; for a full listing see
89+ `numpydoc Validation Check
90+ <https://numpydoc.readthedocs.io/en/latest/validation.html#validation> `_.
91+
92+
2893Additional Information
2994----------------------
30- Additional examples and notes regarding Numpy or Google docstrings can
31- be found at `sphinx.ext.napoleon
32- <https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html> `_.
33- A consistent documentation style should be followed whenever possible.
95+ Additional examples and notes can be found at `numpydoc `_. Reference
96+ their documentation as the primary source of information regarding
97+ docstring styles aside from the directives noted here.
3498
3599.. _numpydoc : https://numpydoc.readthedocs.io/en/latest/format.html
36100.. _googledoc : https://google.github.io/styleguide/
0 commit comments