Skip to content

Commit

Permalink
Remove include_patterns monkeypatching (python#2810)
Browse files Browse the repository at this point in the history
This is included in Sphinx core from version 5.1
  • Loading branch information
AA-Turner authored Oct 5, 2022
1 parent 5fb8b28 commit 80c6905
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
11 changes: 3 additions & 8 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

sys.path.append(str(Path("pep_sphinx_extensions").absolute()))

# Add 'include_patterns' as a config variable
from sphinx.config import Config
Config.config_values["include_patterns"] = [], "env", []
del Config

# -- Project information -----------------------------------------------------

project = "PEPs"
Expand All @@ -22,9 +17,9 @@

# Add any Sphinx extension module names here, as strings.
extensions = [
"pep_sphinx_extensions",
"sphinx.ext.intersphinx",
"sphinx.ext.githubpages",
"pep_sphinx_extensions",
"sphinx.ext.intersphinx",
"sphinx.ext.githubpages",
]

# The file extensions of source files. Sphinx uses these suffixes as sources.
Expand Down
32 changes: 0 additions & 32 deletions pep_sphinx_extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from docutils.writers.html5_polyglot import HTMLTranslator
from sphinx import environment
from sphinx import project

from pep_sphinx_extensions.pep_processor.html import pep_html_builder
from pep_sphinx_extensions.pep_processor.html import pep_html_translator
Expand All @@ -18,37 +17,6 @@

if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.config import Config


def find_files(self: environment.BuildEnvironment, config: Config, _b) -> None:
"""Find all pep source files."""
import fnmatch
from pathlib import Path

root = Path(self.project.srcdir).absolute()
self.project.docnames = set()
for pattern in config.include_patterns:
for path in root.glob(pattern):
filename = str(path.relative_to(root))
if any(fnmatch.fnmatch(filename, pattern) for pattern in config.exclude_patterns):
continue

doc_name = self.project.path2doc(filename)
if not doc_name:
continue

if doc_name not in self.project.docnames:
self.project.docnames.add(doc_name)
continue

other_files = [str(f.relative_to(root)) for f in root.glob(f"{doc_name}.*")]
project.logger.warning(
f'multiple files found for the document "{doc_name}": {other_files!r}\n'
f'Use {self.doc2path(doc_name)!r} for the build.', once=True)


environment.BuildEnvironment.find_files = find_files


def _depart_maths():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Requirements for building PEPs with Sphinx
Pygments >= 2.9.0
Sphinx >= 4.0.2
Sphinx >= 5.1.1
docutils >= 0.19.0

# For RSS
Expand Down

0 comments on commit 80c6905

Please sign in to comment.