ENH: Create backreferences for default roles #1122
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When adding mini-galleries for API documentation, only the 5 roles
func
,math
,attr
,obj
andclass
were taken into consideration. It is, however, common practice to define a default role (e.g.:py:obj:
) using thedefault_role
entry inconf.py
. This PR enables the creation of backreferences for references without an explicit role if the default role inconf.py
is one of the five roles listed above. Note that only the default role definition inconf.py
is taken into consideration, i.e. setting the default role using the.. default-role::
directive is not taken into account.Further, separate titles (
Title <link>
) and suppressed link creations (!no.link
) are handled correctly now.The project listed in README.rst use the following default roles:
PySurfer, PyTorch, PyVista, SimPEG, Fury, Optuna,
Auto-sklearn, OpenML-Python, TorchIO, Biotite, Apache TVM, Tonic
Projects in the last two rows benefit from this PR as more backreferences/mini-galleries are created, see matplotlib/matplotlib#25595.
This PR comprises two commits:
TST: Refactor test_identify_names2
extended and the complete code_str tested once more)
ENH: Allow for default roles when creating backreferences
When adding mini-galleries for API documentation, only the 5 roles
func, math, attr, obj and class were taken into consideration. It is,
however, common practice to define a default role (e.g. :py:obj:) using
the default_role entry in conf.py. This commit enables the creation of
backreferences for references without an explicite role if the default
role in conf.py is one of the five roles listed above.
Please note the only the default role definition in conf.py is taken
into consideration, i.e. setting the default role using the
.. default-role:: directive is not taken into account.
Further, separate titles (
Title <link>
) and suppressed link creations(
!no.link
) are handled correctly now.