diff --git a/NEWS.rst b/NEWS.rst index 87c4a9a..a618ab7 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -5,6 +5,8 @@ unreleased ---------- * Set ``Cache-Control`` header to ```no-cache``` for served files. +* Add new option ``--watch-glob`` to watch multiple directories by + glob pattern. 2025.08.25 - 2025-08-25 ----------------------- diff --git a/README.rst b/README.rst index 190b9a1..ed6f916 100644 --- a/README.rst +++ b/README.rst @@ -66,6 +66,8 @@ which can seen by running ``sphinx-autobuild --help``: --open-browser open the browser after building documentation --delay DELAY how long to wait before opening the browser --watch DIR additional directories to watch + --watch-glob DIR_GLOB + glob pattern for additional directories to watch --pre-build COMMAND additional command(s) to run prior to building the documentation --post-build COMMAND additional command(s) to run after building the documentation diff --git a/sphinx_autobuild/__main__.py b/sphinx_autobuild/__main__.py index b1f058f..a543f5e 100644 --- a/sphinx_autobuild/__main__.py +++ b/sphinx_autobuild/__main__.py @@ -58,6 +58,11 @@ def main(argv=()): ) watch_dirs = [src_dir] + args.additional_watched_dirs + cwd = Path.cwd() + for dir_glob in args.additional_watched_dir_globs: + for directory in cwd.glob(dir_glob): + if directory.is_dir(): + watch_dirs.append(directory.resolve()) ignore_dirs = [ ".git", ".hg", @@ -231,6 +236,14 @@ def _add_autobuild_arguments(parser): help="additional directories to watch", dest="additional_watched_dirs", ) + group.add_argument( + "--watch-glob", + action="append", + metavar="DIR_GLOB", + default=[], + help="glob pattern for additional directories to watch", + dest="additional_watched_dir_globs", + ) group.add_argument( "--pre-build", action="append",