File tree Expand file tree Collapse file tree 2 files changed +31
-21
lines changed Expand file tree Collapse file tree 2 files changed +31
-21
lines changed Original file line number Diff line number Diff line change 24
24
".txt" : "pep" ,
25
25
}
26
26
27
- # List of patterns (relative to source dir) to ignore when looking for source files.
28
- exclude_patterns = [
29
- # Windows:
30
- "Thumbs.db" ,
31
- ".DS_Store" ,
32
- # Python:
33
- ".venv" ,
34
- "venv" ,
35
- "requirements.txt" ,
36
- # Sphinx:
37
- "build" ,
38
- "output.txt" , # Link-check output
39
- # PEPs:
40
- "pep-0012" ,
41
- "README.rst" ,
42
- "CONTRIBUTING.rst" ,
43
- "pep_sphinx_extensions/LICENCE.rst" ,
44
- # Miscellaneous
45
- ".codespell" ,
46
- ]
47
-
48
27
# -- Options for HTML output -------------------------------------------------
49
28
50
29
# HTML output settings
Original file line number Diff line number Diff line change 6
6
7
7
from docutils .writers .html5_polyglot import HTMLTranslator
8
8
from sphinx import environment
9
+ from sphinx import project
9
10
10
11
from pep_sphinx_extensions .pep_processor .html import pep_html_builder
11
12
from pep_sphinx_extensions .pep_processor .html import pep_html_translator
17
18
if TYPE_CHECKING :
18
19
from sphinx .application import Sphinx
19
20
21
+ INCLUDE_PATTERNS = ("contents.rst" , "pep-????.???" , "docs/*.rst" )
22
+
23
+
24
+ def _discover (self , _exclude_paths = None ) -> set [str ]:
25
+ """Find all pep files."""
26
+ from pathlib import Path
27
+
28
+ root = Path (self .srcdir ).absolute ()
29
+ self .docnames = set ()
30
+ for pattern in INCLUDE_PATTERNS :
31
+ for path in root .glob (pattern ):
32
+ filename = str (path .relative_to (root ))
33
+ doc_name = self .path2doc (filename )
34
+ if not doc_name :
35
+ continue
36
+
37
+ if doc_name not in self .docnames :
38
+ self .docnames .add (doc_name )
39
+ continue
40
+
41
+ other_files = [str (f .relative_to (root )) for f in root .glob (f"{ doc_name } .*" )]
42
+ project .logger .warning (
43
+ f'multiple files found for the document "{ doc_name } ": { other_files !r} \n '
44
+ f'Use { self .doc2path (doc_name )!r} for the build.' , once = True )
45
+
46
+ return self .docnames
47
+
48
+
49
+ project .Project .discover = _discover
50
+
20
51
21
52
def _depart_maths ():
22
53
pass # No-op callable for the type checker
You can’t perform that action at this time.
0 commit comments