Skip to content

Commit 9cfdfd8

Browse files
authored
sphinxdocs: make xrefs to tag class attributes using attr role work (#2895)
The role assigned to attributes within the tag class directive were being given the role `arg`, when they should be `attr`. This caused xrefs using the attr role to be unable to find them. To fix, set them to have the correct role, like the repo rule and regular rule directives do. Also add a test.
1 parent d91e9b2 commit 9cfdfd8

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

sphinxdocs/src/sphinx_bzl/bzl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,10 +1156,10 @@ class _BzlTagClass(_BzlCallable):
11561156

11571157
doc_field_types = [
11581158
_BzlGroupedField(
1159-
"arg",
1159+
"attr",
11601160
label=_("Attributes"),
11611161
names=["attr"],
1162-
rolename="arg",
1162+
rolename="attr",
11631163
can_collapse=False,
11641164
),
11651165
]

sphinxdocs/tests/sphinx_stardoc/sphinx_output_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def _doc_element(self, doc):
6363
("full_repo_provider", "@testrepo//lang:provider.bzl%LangInfo", "provider.html#LangInfo"),
6464
("full_repo_aspect", "@testrepo//lang:aspect.bzl%myaspect", "aspect.html#myaspect"),
6565
("full_repo_target", "@testrepo//lang:relativetarget", "target.html#relativetarget"),
66+
("tag_class_attr_using_attr_role", "myext.mytag.ta1", "module_extension.html#myext.mytag.ta1"),
6667
# fmt: on
6768
)
6869
def test_xrefs(self, text, href):

sphinxdocs/tests/sphinx_stardoc/xrefs.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ Various tests of cross referencing support
4141
## Any xref
4242

4343
* {any}`LangInfo`
44+
45+
## Tag class refs
46+
47+
* tag class attribute using attr role: {attr}`myext.mytag.ta1`

0 commit comments

Comments
 (0)