mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9998 from tk0miya/9993_inline_target
Close #9993: std domain: Allow to refer an inline target via ref role
This commit is contained in:
commit
94acb1921c
2
CHANGES
2
CHANGES
@ -31,6 +31,8 @@ Features added
|
||||
checking in matched documents.
|
||||
* #9793: sphinx-build: Allow to use the parallel build feature in macOS on macOS
|
||||
and Python3.8+
|
||||
* #9993: std domain: Allow to refer an inline target (ex. ``_`target name```)
|
||||
via :rst:role:`ref` role
|
||||
* #9391: texinfo: improve variable in ``samp`` role
|
||||
* #9578: texinfo: Add :confval:`texinfo_cross_references` to disable cross
|
||||
references for readability with standalone readers
|
||||
|
@ -770,10 +770,11 @@ class StandardDomain(Domain):
|
||||
sectname = clean_astext(title)
|
||||
elif node.tagname == 'rubric':
|
||||
sectname = clean_astext(node)
|
||||
elif node.tagname == 'target' and len(node) > 0:
|
||||
# inline target (ex: blah _`blah` blah)
|
||||
sectname = clean_astext(node)
|
||||
elif self.is_enumerable_node(node):
|
||||
sectname = self.get_numfig_title(node)
|
||||
if not sectname:
|
||||
continue
|
||||
else:
|
||||
toctree = next(iter(node.traverse(addnodes.toctree)), None)
|
||||
if toctree and toctree.get('caption'):
|
||||
@ -781,7 +782,8 @@ class StandardDomain(Domain):
|
||||
else:
|
||||
# anonymous-only labels
|
||||
continue
|
||||
self.labels[name] = docname, labelid, sectname
|
||||
if sectname:
|
||||
self.labels[name] = docname, labelid, sectname
|
||||
|
||||
def add_program_option(self, program: str, name: str, docname: str, labelid: str) -> None:
|
||||
self.progoptions[program, name] = (docname, labelid)
|
||||
|
@ -452,3 +452,12 @@ def test_labeled_rubric(app):
|
||||
domain = app.env.get_domain("std")
|
||||
assert 'label' in domain.labels
|
||||
assert domain.labels['label'] == ('index', 'label', 'blah blah blah')
|
||||
|
||||
|
||||
def test_inline_target(app):
|
||||
text = "blah _`inline target` blah\n"
|
||||
restructuredtext.parse(app, text)
|
||||
|
||||
domain = app.env.get_domain("std")
|
||||
assert 'inline target' in domain.labels
|
||||
assert domain.labels['inline target'] == ('index', 'inline-target', 'inline target')
|
||||
|
Loading…
Reference in New Issue
Block a user