From e1e557eabbe01c9b7bde870a43f009dcb601a208 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 3 Sep 2024 12:10:03 +0200 Subject: [PATCH] Add --exclude argument to convert and skip vtk gallery examples (#7227) --- panel/command/convert.py | 18 +++++++++++++++++- pixi.toml | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/panel/command/convert.py b/panel/command/convert.py index 1af9e4309b..4ba0cfac38 100644 --- a/panel/command/convert.py +++ b/panel/command/convert.py @@ -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, @@ -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( diff --git a/pixi.toml b/pixi.toml index eb90e7ec52..94e55f7c1e 100644 --- a/pixi.toml +++ b/pixi.toml @@ -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]