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

Exclude sources matching exclude_patterns #58

Closed
JWCook opened this issue Jul 24, 2023 · 1 comment · Fixed by #57
Closed

Exclude sources matching exclude_patterns #58

JWCook opened this issue Jul 24, 2023 · 1 comment · Fixed by #57
Labels
bug Something isn't working enhancement New feature or request

Comments

@JWCook
Copy link
Collaborator

JWCook commented Jul 24, 2023

It would be useful if source files gathered by assign_entries() excluded any files matched by exclude_patterns.

It looks like we could use sphinx.util.matching.Matcher and get_matching_files() to match those patterns the same way Sphinx does. I found an example of another extension that does this here. If that sounds reasonable to you, I'd be willing to make a PR for that.

Example

Example use case (which I found completely by accident):

When building tag pages with Jupyter Notebooks, it's possible to have tags in a notebook counted twice. This is because the doctree build directory ({build_dir}/doctrees/nbsphinx/) may, depending on output format, include a copy of any .ipynb files as-is. If the build directory is under the source directory (like docs/_build), then the glob pattern in assign_entries() will match those extra files and count their tags again.

For example, for a single notebook with a tag tag_1, the generated tag page will look like this:

My tags: tag_1
##############

.. toctree::
    :maxdepth: 1
    :caption: With this tag

    ../_build/doctrees/nbsphinx/page_1.ipynb
    ../page_1.ipynb
@JWCook JWCook added bug Something isn't working enhancement New feature or request labels Jul 24, 2023
@melissawm
Copy link
Owner

Sounds good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants