mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #1638: html: Add permalink icons to glossary terms
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -43,6 +43,7 @@ Features added
|
||||
:event:`html-page-context` event
|
||||
* #6550: html: Allow to use HTML permalink texts via
|
||||
:confval:`html_permalinks_icon`
|
||||
* #1638: html: Add permalink icons to glossary terms
|
||||
* #8649: imgconverter: Skip availability check if builder supports the image
|
||||
type
|
||||
* #8573: napoleon: Allow to change the style of custom sections using
|
||||
|
||||
@@ -394,6 +394,10 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
# there's a classifier.
|
||||
pass
|
||||
else:
|
||||
if isinstance(node.parent.parent.parent, addnodes.glossary):
|
||||
# add permalink if glossary terms
|
||||
self.add_permalink_ref(node, _('Permalink to this term'))
|
||||
|
||||
self.body.append('</dt>')
|
||||
|
||||
# overwritten
|
||||
|
||||
@@ -345,6 +345,10 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
# there's a classifier.
|
||||
pass
|
||||
else:
|
||||
if isinstance(node.parent.parent.parent, addnodes.glossary):
|
||||
# add permalink if glossary terms
|
||||
self.add_permalink_ref(node, _('Permalink to this term'))
|
||||
|
||||
self.body.append('</dt>')
|
||||
|
||||
# overwritten
|
||||
|
||||
@@ -254,6 +254,7 @@ def test_html4_output(app, status, warning):
|
||||
(".//p[@class='centered']/strong", 'LICENSE'),
|
||||
# a glossary
|
||||
(".//dl/dt[@id='term-boson']", 'boson'),
|
||||
(".//dl/dt[@id='term-boson']/a", '¶'),
|
||||
# a production list
|
||||
(".//pre/strong", 'try_stmt'),
|
||||
(".//pre/a[@href='#grammar-token-try1_stmt']/code/span", 'try1_stmt'),
|
||||
|
||||
@@ -363,8 +363,12 @@ def get_verifier(verify, verify_re):
|
||||
# glossary (description list): multiple terms
|
||||
'verify',
|
||||
'.. glossary::\n\n term1\n term2\n description',
|
||||
('<dl class="glossary docutils">\n<dt id="term-term1">term1</dt>'
|
||||
'<dt id="term-term2">term2</dt><dd>description</dd>\n</dl>'),
|
||||
('<dl class="glossary docutils">\n'
|
||||
'<dt id="term-term1">term1<a class="headerlink" href="#term-term1"'
|
||||
' title="Permalink to this term">¶</a></dt>'
|
||||
'<dt id="term-term2">term2<a class="headerlink" href="#term-term2"'
|
||||
' title="Permalink to this term">¶</a></dt>'
|
||||
'<dd>description</dd>\n</dl>'),
|
||||
None,
|
||||
),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user