Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aca49c1

Browse filesBrowse files
ArturoAmorQArturoAmorQStefanieSenger
authored
DOC Improve Contributer guide for writting docstrings (scikit-learn#31330)
Co-authored-by: ArturoAmorQ <arturo.amor-quiroz@polytechnique.edu> Co-authored-by: Stefanie Senger <91849487+StefanieSenger@users.noreply.github.com>
1 parent da0dac3 commit aca49c1
Copy full SHA for aca49c1

File tree

1 file changed

+22
-1
lines changed
Filter options

1 file changed

+22
-1
lines changed

‎doc/developers/contributing.rst

Copy file name to clipboardExpand all lines: doc/developers/contributing.rst
+22-1
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,19 @@ We are glad to accept any sort of documentation:
726726

727727
.. dropdown:: Guidelines for writing docstrings
728728

729+
* You can use `pytest` to test docstrings, e.g. assuming the
730+
`RandomForestClassifier` docstring has been modified, the following command
731+
would test its docstring compliance:
732+
733+
.. prompt:: bash
734+
735+
pytest --doctest-modules sklearn/ensemble/_forest.py -k RandomForestClassifier
736+
737+
* The correct order of sections is: Parameters, Returns, See Also, Notes, Examples.
738+
See the `numpydoc documentation
739+
<https://numpydoc.readthedocs.io/en/latest/format.html#sections>`_ for
740+
information on other possible sections.
741+
729742
* When documenting the parameters and attributes, here is a list of some
730743
well-formatted examples
731744

@@ -791,7 +804,15 @@ We are glad to accept any sort of documentation:
791804
SelectKBest : Select features based on the k highest scores.
792805
SelectFpr : Select features based on a false positive rate test.
793806
794-
* Add one or two snippets of code in "Example" section to show how it can be used.
807+
* The "Notes" section is optional. It is meant to provide information on
808+
specific behavior of a function/class/classmethod/method.
809+
810+
* A `Note` can also be added to an attribute, but in that case it requires
811+
using the `.. rubric:: Note` directive.
812+
813+
* Add one or two **snippets** of code in "Example" section to show how it can
814+
be used. The code should be runable as is, i.e. it should include all
815+
required imports. Keep this section as brief as possible.
795816

796817

797818
.. dropdown:: Guidelines for writing the user guide and other reStructuredText documents

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.