Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the sphinx-better-subsection extension to use explicit targets for section permalinks #38

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
Changelog
=========

Unreleased
==========

The ``sphinx-better-subsection`` extension is installed and automatically set
up to prefer explicit targets for a section heading over auto-generated targets
(e.g. from the title) when producing HTML permalinks. This change is backwards
compatible as both targets still work in both rST and HTML pages. An example
can be seen below for the `previous release heading <v2023.1_>`__.
(`#38 <https://github.com/nextstrain/sphinx-theme/pull/38>`_)


.. _v2023.1:

2023.1 (16 February 2023)
=========================

Expand Down
6 changes: 5 additions & 1 deletion doc/demo/demo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ This is a glossary with definition terms for thing like :term:`Writing`:
Writing
The process of putting thoughts into a medium for other people to :term:`read <Reading>`.


.. _preferred:

Targets
-------

Expand All @@ -318,7 +321,8 @@ A reference can be found under `Inline Markup`_, above. `Inline
hyperlink targets`_ are also possible.

Section headers are implicit targets, referred to by name. See
Targets_, which is a subsection of `Paragraph Level Markup`_.
Targets_, which is a subsection of `Paragraph Level Markup`_. Explicit targets
before a section heading are preferred_ when generating HTML permalinks.

Explicit external targets are interpolated into references such as "Python_".

Expand Down
1 change: 1 addition & 0 deletions lib/nextstrain/sphinx/theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

def setup(app):
app.add_html_theme('nextstrain-sphinx-theme', str(package_dir))
app.setup_extension('sphinx_better_subsection')
app.setup_extension('sphinx_copybutton')
# customize sphinx_copybutton https://sphinx-copybutton.readthedocs.io/en/latest/use.html
app.config['copybutton_prompt_text'] = '$ '
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
install_requires = [
'sphinx_rtd_theme >=1.0.0',
'sphinx-copybutton'
'sphinx-better-subsection',
'sphinx-copybutton',
],
classifiers = [
'Framework :: Sphinx',
Expand Down