Skip to content

Commit

Permalink
allow to skip generating the rst item that uses the notebook directive (
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Feb 25, 2024
1 parent e823aec commit 2a6a5f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions nbsite/gallery/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
'enable_download': True,
'only_use_existing': False,
'as_pyodide': False,
'skip_rst_notebook_directive': False,
'examples_dir': os.path.join('..', 'examples'),
'labels_dir': 'labels',
'galleries': {
Expand Down Expand Up @@ -455,6 +456,10 @@ def generate_file_rst(
endpoint = content.get('deployment_url', gallery_conf.get('deployment_url', None))
extensions = content.get('extensions', gallery_conf['default_extensions'])
as_pyodide = content.get('as_pyodide', gallery_conf.get('as_pyodide', False))
skip_rst_notebook_directive = content.get(
'skip_rst_notebook_directive',
gallery_conf.get('skip_rst_notebook_directive', False)
)

deployed_examples = get_deployed_examples(endpoint)

Expand All @@ -475,9 +480,15 @@ def generate_file_rst(
deployed_file = None

# Generate document
gen = generate_pyodide_markdown if as_pyodide else generate_item_rst
gen(app, page, section, backend, filename, src_dir, dest_dir,
img_extension, deployed_file, deployed, skip)
if as_pyodide:
gen = generate_pyodide_markdown
elif not skip_rst_notebook_directive:
gen = generate_item_rst
else:
gen = None
if gen:
gen(app, page, section, backend, filename, src_dir, dest_dir,
img_extension, deployed_file, deployed, skip)


REDIRECT = """.. raw:: html
Expand Down
1 change: 1 addition & 0 deletions site/doc/user_guide/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ following options:
- `orphans`
- `thumbnail_url`
- `within_subsection_order`
- `skip_rst_notebook_directive`

A sample configuration might look something like this:

Expand Down

0 comments on commit 2a6a5f2

Please sign in to comment.