sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.41k stars 2.09k forks source link

exclusions from globbing #9969

Open brook-milligan opened 2 years ago

brook-milligan commented 2 years ago

Problem description I have run into a situation that seems not to be handled by sphinx globbing. I have two toctrees that use globbing to define their contents. The intent is two sets of non-overlapping pages, one per toctree. However, I cannot get the globbing to avoid including some pages in both.

Potential solution / feature request It would be nice to have a mechanism for excluding some patterns in addition to including them. For example, one might be able to write something like the following to include all the docs minus the details:

:glob:
docs/*
!docs/details_*

Recognizing that a leading character to select exclusion (! in this example) might conflict with an existing filename, it seems that there should be an option to redefine it:

:exclusion_char: !

Perhaps all of this is already implemented and I have just never run across it. If not, I hope you will consider the idea, as it would make globbing more broadly useful, especially in situations where moving files about is not possible.

timhoffm commented 1 month ago

I believe an explicit exclusion is worth adding. For simple cases like excluding single files or excluding files following a simple pattern (which I assume the majority of of exclusions falls under), this is easier to read and understand than a regex (as proposed in #6650).

API: I would refrain from adding a configurable :exclusion_char:. Either we decide that files/dirs starting with ! are very unlikely and live with that limitation, or we make the prefix more unlikely: ! filename, not: filename, exclude: filename

@AA-Turner If this is a desired feature (and we can agree on the API) I could come up with a PR.