8000 DOC Add section to contributing.rst on cross referencing syntax (#24092) · rusdes/scikit-learn@7781299 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7781299

Browse files
authored
DOC Add section to contributing.rst on cross referencing syntax (scikit-learn#24092)
1 parent c8bef4b commit 7781299

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

doc/developers/contributing.rst

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,13 +846,67 @@ Finally, follow the formatting rules below to make it consistently good:
846846
* When editing reStructuredText (``.rst``) files, try to keep line length under
847847
80 characters when possible (exceptions include links and tables).
848848

849-
* Do not modify sphinx labels as this would break existing cross references and
850-
external links pointing to specific sections in the
851-
scikit-learn documentation.
852-
853849
* Before submitting your pull request check if your modifications have
854850
introduced new sphinx warnings and try to fix them.
855851

852+
Cross-referencing
853+
-----------------
854+
855+
It is often useful to cross-reference to other pages in the scikit-learn
856+
documentation. This should be done with reStructuredText cross-referencing
857+
syntax:
858+
859+
* Section - to link to an arbitrary section in the documentation, use reference
860+
labels (see
861+
`Sphinx docs <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#ref-role>`_).
862+
For example:
863+
864+
.. code-block:: rst
865+
866+
.. _my-section:
867+
868+
My section
869+
----------
870+
871+
This is the text of the section.
872+
873+
To refer to itself use :ref:`my-section`.
874+
875+
You should not modify existing sphinx reference labels as this would break
876+
existing cross references and external links pointing to specific sections in
877+
the scikit-learn documentation.
878+
879+
* Glossary - linking to a term in the :ref:`glossary`:
880+
881+
.. code-block:: rst
882+
883+
:term:`cross_validation`
884+
885+
* Function - to link to the documentation of a function, use the full
886+
import path to the function:
887+
888+
.. code-block:: rst
889+
890+
:func:`~sklearn.model_selection.cross_val_score`
891+
892+
However, if there is a 'currentmodule' directive above you in the document,
893+
you will only need to use the path to the function succeeding the current
894+
module specified. For example:
895+
896+
.. code-block:: rst
897+
898+
.. currentmodule:: sklearn.model_selection
899+
900+
:func:`cross_val_score`
901+
902+
* Class - to link to documentation of a class, use the full import path to the
903+
class, unless there is a 'currentmodule' directive in the document above
904+
(see above):
905+
906+
.. code-block:: rst
907+
908+
:class:`~sklearn.preprocessing.StandardScaler`
909+
856910
.. _generated_doc_CI:
857911

858912
Generated documentation on GitHub Actions

0 commit comments

Comments
 (0)
0