Skip to content

Commit 966668d

Browse files
committed
ignore files for -- watch`
1 parent bb33500 commit 966668d

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ _inv
1414
objects.json
1515
_sidebar.yml
1616
_extensions
17+
18+
/.luarc.json

quartodoc/__main__.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
from pathlib import Path
99
from watchdog.observers import Observer
1010
from functools import partial
11-
from watchdog.events import FileSystemEventHandler
11+
from watchdog.events import PatternMatchingEventHandler
1212
from quartodoc import Builder, convert_inventory
13+
from typing import List
1314

1415
def get_package_path(package_name):
1516
"""
@@ -21,11 +22,28 @@ def get_package_path(package_name):
2122
except ModuleNotFoundError:
2223
raise ModuleNotFoundError(f"Package {package_name} not found. Please install it in your environment.")
2324

24-
class FileChangeHandler(FileSystemEventHandler):
25+
class QuartoDocFileChangeHandler(PatternMatchingEventHandler):
2526
"""
2627
A handler for file changes.
2728
"""
29+
30+
# Ignore patterns for the file watcher that are not relevant to the docs
31+
py_ignore_patterns = [
32+
'*/__pycache__/*', # These are the compiled python code files which are automatically generated by Python
33+
'*/.ipynb_checkpoints/*', # This directory is created by Jupyter Notebook for auto-saving notebooks
34+
'*/.vscode/*', # If you're using Visual Studio Code, it creates this directory to store settings specific to that project.
35+
'*/.idea/*', # Similar to .vscode/, but for JetBrains IDEs like PyCharm.
36+
'*/.git/*', # i This directory is created by Git. It's not relevant to the docs.
37+
'*/venv/*', '*/env/*', '*/.env/*', # Common names for directories containing a Python virtual environment.
38+
'*/.pytest_cache/*', # This directory is created when you run Pytest.
39+
'*/.eggs/*', '*/dist/*', '*/build/*', '*/*.egg-info/*', # These are typically created when building Python packages with setuptools.
40+
'*.pyo', # These are optimized .pyc files, created when Python is run with the -O flag.
41+
'*.pyd', # This is the equivalent of a .pyc file, but for C extensions on Windows.
42+
'*/.mypy_cache/*', # This directory is created when you run mypy.
43+
]
44+
2845
def __init__(self, callback):
46+
super().__init__(ignore_patterns=self.py_ignore_patterns)
2947
self.callback = callback
3048

3149
@classmethod
@@ -71,9 +89,6 @@ def cli():
7189
pass
7290

7391

74-
75-
76-
7792
@click.command()
7893
@click.option("--config", default="_quarto.yml", help="Change the path to the configuration file. The default is `./_quarto.yml`")
7994
@click.option("--filter", nargs=1, default="*", help="Specify the filter to select specific files. The default is '*' which selects all files.")
@@ -97,7 +112,7 @@ def build(config, filter, dry_run, watch, verbose):
97112
if watch:
98113
pkg_path = get_package_path(builder.package)
99114
print(f"Watching {pkg_path} for changes...")
100-
event_handler = FileChangeHandler(callback=doc_build)
115+
event_handler = QuartoDocFileChangeHandler(callback=doc_build)
101116
observer = Observer()
102117
observer.schedule(event_handler, pkg_path, recursive=True)
103118
observer.start()

0 commit comments

Comments
 (0)