Skip to content

Commit

Permalink
remove unnecessary permalink to depart_term() (#252)
Browse files Browse the repository at this point in the history
* use rst-example in additional_samples.rst for glossary directive
* conditionally add permalink for non-default behavior
  • Loading branch information
2bndy5 authored May 1, 2023
1 parent 5d4cdf7 commit 62bd41d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 11 additions & 9 deletions docs/additional_samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,19 @@ Alignment
Glossaries
==========

.. glossary::
.. rst-example::

.. glossary::

environment
A structure where information about all documents under the root is
saved, and used for cross-referencing. The environment is pickled
after the parsing stage, so that successive runs only need to read
and parse new and changed documents.
environment
A structure where information about all documents under the root is
saved, and used for cross-referencing. The environment is pickled
after the parsing stage, so that successive runs only need to read
and parse new and changed documents.

source directory
The directory which, including its subdirectories, contains all
source files for one Sphinx project.
source directory
The directory which, including its subdirectories, contains all
source files for one Sphinx project.

Math
====
Expand Down
8 changes: 7 additions & 1 deletion sphinx_immaterial/apidoc/object_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,13 @@ def depart_term(
node: docutils.nodes.term,
super_func: html_translator_mixin.BaseVisitCallback[docutils.nodes.term],
) -> None:
self.add_permalink_ref(node, _("Permalink to this definition"))
next_node: docutils.nodes.Element = node.next_node(descend=False, siblings=True)
if not isinstance(next_node, docutils.nodes.classifier) and not (
node.parent is not None
and node.parent.parent is not None
and isinstance(node.parent.parent.parent, sphinx.addnodes.glossary)
):
self.add_permalink_ref(node, _("Permalink to this definition"))
super_func(self, node)


Expand Down

0 comments on commit 62bd41d

Please sign in to comment.