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

Allow reserved pages in toctree #2849

Closed
wants to merge 7 commits into from

Conversation

avylove
Copy link
Contributor

@avylove avylove commented Aug 13, 2016

I was looking to add the general index to a toctree and it didn't seem like that was possible, so I created this patch to allow it.

Basically this allows the special document names (genindex, modindex, search) to be used as page names in a toctree either with their default titles or custom ones.

.. toctree::

   normalpage
   genindex
   Modules <modindex>
   search

It seems I'm not the only one who was looking for this:

http://stackoverflow.com/questions/36235578/how-can-i-include-the-genindex-in-a-sphinx-toc
http://stackoverflow.com/questions/25243482/how-to-add-sphinx-generated-index-to-the-sidebar-when-using-read-the-docs-theme

@tk0miya tk0miya added this to the 4.0.0 milestone Aug 14, 2020
@tk0miya tk0miya modified the milestones: 4.0.0, 4.1.0 Apr 4, 2021
@tk0miya tk0miya modified the milestones: 4.1.0, 4.2.0 Jul 10, 2021
@tk0miya tk0miya modified the milestones: 4.2.0, 4.3.0 Sep 12, 2021
@tk0miya tk0miya modified the milestones: 4.3.0, 4.4.0 Nov 8, 2021
@tk0miya tk0miya modified the milestones: 4.4.0, 4.5.0 Jan 15, 2022
doc/markup/toctree.rst Outdated Show resolved Hide resolved
@avylove
Copy link
Contributor Author

avylove commented Feb 25, 2022

Synced upstream changes and updated code as it was originally from 5.5 years ago. Also updated tests.

@tk0miya tk0miya modified the milestones: 4.5.0, 5.0.0 Mar 27, 2022
@tk0miya tk0miya modified the milestones: 5.0.0, 5.x May 2, 2022
@AA-Turner AA-Turner modified the milestones: 5.x, some future version May 23, 2022
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you rebase on 5.x and re-target the PR to that branch?

A

@@ -220,6 +221,9 @@ tables of contents. The ``toctree`` directive is the central element.
.. versionchanged:: 1.3
Added "caption" and "name" option.

.. versionchanged:: 4.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. versionchanged:: 4.5
.. versionchanged:: 5.1

If you re-target the PR to 5.x

@@ -124,7 +124,7 @@ def parse_content(self, toctree: addnodes.toctree) -> List[Node]:
break
# absolutize filenames
docname = docname_join(self.env.docname, docname)
if url_re.match(ref) or ref == 'self':
if url_re.match(ref) or ref in ('self', 'genindex', 'modindex', 'search'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if this 4-tuple was factored out somewhere as it is used more than once, but there aren't any great locations that come to mind.

Comment on lines +153 to +154
the toctree. The special document names ``genindex``, ``modindex``, and
``search`` can also be used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps expand this, as the special names can also be used indirectly, as you illustrate in the test.

@AA-Turner
Copy link
Member

Closed by #10673

@AA-Turner AA-Turner closed this Oct 5, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants