8000 sphinxdocs: allow unqualified arg/attr name for xref (#2896) · kaycebasques/rules_python@dcf0511 · GitHub
[go: up one dir, main page]

Skip to content

Commit dcf0511

Browse filesBrowse files
authored
sphinxdocs: allow unqualified arg/attr name for xref (bazel-contrib#2896)
It's common to simply refer to an arg or attribute by its sole name, especially for ones that are unique. This fixes about ~20 broken xrefs in our docs. Also add test for this behavior.
1 parent 9cfdfd8 commit dcf0511

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

sphinxdocs/src/sphinx_bzl/bzl.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,12 @@ def _make_xrefs_for_arg_attr(
390390
descr=index_description,
391391
),
392392
),
393-
# This allows referencing an arg as e.g `funcname.argname`
394-
alt_names=[anchor_id],
393+
alt_names=[
394+
# This allows referencing an arg as e.g `funcname.argname`
395+
anchor_id,
396+
# This allows referencing an arg as simply `argname`
397+
arg_name
398+
],
395399
)
396400

397401
# Two changes to how arg xrefs are created:

sphinxdocs/tests/sphinx_stardoc/sphinx_output_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def _doc_element(self, doc):
6464
("full_repo_aspect", "@testrepo//lang:aspect.bzl%myaspect", "aspect.html#myaspect"),
6565
("full_repo_target", "@testrepo//lang:relativetarget", "target.html#relativetarget"),
6666
("tag_class_attr_using_attr_role", "myext.mytag.ta1", "module_extension.html#myext.mytag.ta1"),
67+
("tag_class_attr_using_attr_role_just_attr_name", "ta1", "module_extension.html#myext.mytag.ta1"),
68+
6769
# fmt: on
6870
)
6971
def test_xrefs(self, text, href):

sphinxdocs/tests/sphinx_stardoc/xrefs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ Various tests of cross referencing support
4545
## Tag class refs
4646

4747
* tag class attribute using attr role: {attr}`myext.mytag.ta1`
48+
* tag class attribute, just attr name, attr role: {attr}`ta1`

0 commit comments

Comments
 (0)
0