Skip to content

Commit d706368

Browse files
committed
Add SPHINX_AUTOBUILD_DEBUG to aid debugging
Currently, changed paths and the ignore expressions are shown. Closes #188
1 parent cc58cc1 commit d706368

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ or passing relevant ``filenames`` in addition to source and output directory in
167167

168168
__ https://github.com/sphinx-doc/sphinx-autobuild/issues/34
169169

170+
Debugging
171+
=========
172+
173+
If the ``SPHINX_AUTOBUILD_DEBUG`` environment variable is present
174+
and a file change is detected,
175+
its path and the currently active ignore expressions are printed.
176+
This is to help setting up the ignore expressions correctly.
177+
170178
Acknowledgements
171179
================
172180

sphinx_autobuild/filter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import fnmatch
6+
import os
67
import re
78
from pathlib import Path
89

@@ -23,6 +24,11 @@ def __repr__(self):
2324
def __call__(self, filename: str, /):
2425
"""Determine if 'path' should be ignored."""
2526
normalised_path = Path(filename).resolve().as_posix()
27+
if "SPHINX_AUTOBUILD_DEBUG" in os.environ:
28+
print(
29+
f"SPHINX_AUTOBUILD_DEBUG: {normalised_path!r} has changed; "
30+
f"ignores are {self}"
31+
)
2632
# Any regular pattern matches.
2733
for pattern in self.regular_patterns:
2834
# separators are normalised before creating the IgnoreFilter

0 commit comments

Comments
 (0)