sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

exclusions from globbing

Open brook-milligan opened this issue 4 years ago • 1 comments

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.

brook-milligan avatar Dec 14 '21 03:12 brook-milligan

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.

timhoffm avatar Jul 31 '24 10:07 timhoffm