Skip to content

Commit

Permalink
Add --exclude argument to convert and skip vtk gallery examples (#7227)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Sep 3, 2024
1 parent 43b8b18 commit e1e557e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion panel/command/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Convert(Subcommand):
help = "The app directories or scripts to serve (serve empty document if not specified)",
default = None,
)),
('--exclude', dict(
nargs = '*',
help = "A list of files to exclude.",
default = None
)),
('--to', dict(
action = 'store',
type = str,
Expand Down Expand Up @@ -100,14 +105,25 @@ def invoke(self, args: argparse.Namespace) -> None:
elif req.endswith('.json'):
with open(req, encoding='utf-8') as req_file:
requirements = json.load(req_file)

excluded = [pathlib.Path(e).absolute() for e in args.exclude] if args.exclude else []
included = []
for f in args.files:
p = pathlib.Path(f).absolute()
if not p.is_file():
raise ValueError('File {f!r} not found.')
elif p not in excluded:
included.append(p)

prev_hashes = {}
built = False
while True:
hashes = {f: hash(open(f).read()) for f in args.files}
hashes = {f: hash(open(f).read()) for f in included}
if hashes == prev_hashes:
time.sleep(0.5)
continue
files = [f for f, h in hashes.items() if prev_hashes.get(f) != h]

index = args.index and not built
try:
convert_apps(
Expand Down
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ _docs-refmanual = 'python ./doc/generate_modules.py panel -d ./doc/api -n panel
_docs-convert-gallery = 'python scripts/gallery/convert_gallery.py'
_docs-generate = 'nbsite build --what=html --output=builtdocs --org holoviz --project-name panel'
_docs-copy-panel-dist = 'cp -r ./panel/dist ./builtdocs/panel_dist'
_docs-pyodide = 'panel convert examples/gallery/*.ipynb doc/how_to/*/examples/*.md --to pyodide-worker --out ./builtdocs/pyodide/ --pwa --index --requirements doc/pyodide_dependencies.json'
_docs-pyodide = 'panel convert examples/gallery/*.ipynb doc/how_to/*/examples/*.md --to pyodide-worker --out ./builtdocs/pyodide/ --pwa --index --requirements doc/pyodide_dependencies.json --exclude examples/gallery/vtk*.ipynb'
docs-server = 'python -m http.server 5500 --directory ./builtdocs'

[feature.doc.tasks.docs-build]
Expand Down

0 comments on commit e1e557e

Please sign in to comment.