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
It would be useful if source files gathered by
assign_entries()
excluded any files matched byexclude_patterns
.It looks like we could use
sphinx.util.matching.Matcher
andget_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 (likedocs/_build
), then the glob pattern inassign_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: