diff --git a/sphinx_autobuild/__main__.py b/sphinx_autobuild/__main__.py index 99655e0..347f2ce 100644 --- a/sphinx_autobuild/__main__.py +++ b/sphinx_autobuild/__main__.py @@ -50,11 +50,14 @@ def main(argv=()): ) watch_dirs = [src_dir] + args.additional_watched_dirs - ignore_dirs = args.ignore + [out_dir, args.warnings_file, args.doctree_dir] - ignore_handler = IgnoreFilter( - [Path(p).as_posix() for p in ignore_dirs if p], - args.re_ignore, - ) + ignore_dirs = [ + *args.ignore, + out_dir, + args.warnings_file, + args.doctree_dir, + ] + ignore_dirs = list(filter(None, ignore_dirs)) + ignore_handler = IgnoreFilter(ignore_dirs, args.re_ignore) app = _create_app(watch_dirs, ignore_handler, builder, out_dir, url_host) if not args.no_initial_build: diff --git a/sphinx_autobuild/filter.py b/sphinx_autobuild/filter.py index 03a6b34..2b61ca4 100644 --- a/sphinx_autobuild/filter.py +++ b/sphinx_autobuild/filter.py @@ -2,12 +2,14 @@ import fnmatch import re +from pathlib import Path class IgnoreFilter: def __init__(self, regular, regex_based): """Prepare the function that determines whether a path should be ignored.""" - self.regular_patterns = [*dict.fromkeys(regular)] + normalised_paths = [Path(p).resolve().as_posix() for p in regular] + self.regular_patterns = list(dict.fromkeys(normalised_paths)) self.regex_based_patterns = [*map(re.compile, dict.fromkeys(regex_based))] def __repr__(self): @@ -18,6 +20,7 @@ def __repr__(self): def __call__(self, path): """Determine if 'path' should be ignored.""" + path = Path(path).resolve().as_posix() # Any regular pattern matches. for pattern in self.regular_patterns: # separators are normalised before creating the IgnoreFilter