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 regex in toctree directive. #6650

Open
Viech opened this issue Aug 16, 2019 · 3 comments
Open

Allow regex in toctree directive. #6650

Viech opened this issue Aug 16, 2019 · 3 comments
Labels
type:enhancement enhance or introduce a new feature

Comments

@Viech
Copy link

Viech commented Aug 16, 2019

:glob: is pretty useful, but it doesn't seem to enable the following:

  • Include all documents named package.[…] but don't include any documents named package.[…].[…].

The reverse selection of only including documents that begin with package and contain two dots can be made with package.*.*. I tried package.[!.]* but the [!.] seems to not interact with the * but only affect a single character.

I propose the addition of a :regex: option to the toctree directive using Python's builtin regex package. It should be relatively easy to implement and work around any shortcomings of :glob: that users might encounter.

@Viech Viech added the type:enhancement enhance or introduce a new feature label Aug 16, 2019
@tapaswenipathak
Copy link

Hi folks: Can I please take the ticket and PR?

@rayzchen
Copy link

Is this ever going to be implemented?

@astrojuanlu
Copy link
Contributor

Duplicate of #4319, and overlapping with #9969.

I came here after looking for a way to exclude patterns from a toctree glob too. The documentation says this:

.. [#] A note on available globbing syntax: you can use the standard shell
constructs ``*``, ``?``, ``[...]`` and ``[!...]`` with the feature that
these all don't match slashes. A double star ``**`` can be used to
match any sequence of characters *including* slashes.

However, I didn't see any exclamation marks in glob_re here, so I'm unsure if the documentation reflects the reality:

glob_re = re.compile(r'.*[*?\[].*')

At least it seems that the documentation could be clarified? But I don't understand what globbing syntaxes are supported. I guess the real work is being done in sphinx.util.matching, which does check for exclamation signs in the pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

5 participants