From 9d6fb15dea9b09eb7130f8c8ae8077d5116afb0c Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Thu, 15 Feb 2024 22:14:21 +0300 Subject: [PATCH] DOC: Put example notebooks in reference folder --- doc/_config.py | 6 ++++-- doc/_renderer.py | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/_config.py b/doc/_config.py index 3280be137..eb9383d28 100644 --- a/doc/_config.py +++ b/doc/_config.py @@ -9,6 +9,8 @@ from pathlib import Path DOC_DIR = Path(__file__).parent +EXAMPLES_DIR = DOC_DIR / "reference" / "examples" +TUTORIALS_DIR = DOC_DIR / "tutorials" # The varibables file holds the version variables_filepath = DOC_DIR / "_variables.yml" @@ -66,8 +68,8 @@ def copy(src_dir, dest_dir): for dest in set(cur_dest_files).difference(new_dest_files): dest.unlink() - copy(_files("plotnine_examples.examples"), DOC_DIR / "examples") - copy(_files("plotnine_examples.tutorials"), DOC_DIR / "tutorials") + copy(_files("plotnine_examples.examples"), EXAMPLES_DIR) + copy(_files("plotnine_examples.tutorials"), TUTORIALS_DIR) if __name__ == "__main__": diff --git a/doc/_renderer.py b/doc/_renderer.py index 0ef3c0df8..45d8c53cd 100644 --- a/doc/_renderer.py +++ b/doc/_renderer.py @@ -10,7 +10,8 @@ from quartodoc.pandoc.components import Attr DOC_DIR = Path(__file__).parent -EXAMPLES_DIR = DOC_DIR / "examples" +REFERENCE_DIR = DOC_DIR / "reference" +EXAMPLES_DIR = REFERENCE_DIR / "examples" usage_pattern = re.compile( r"\n\n?\*\*Usage\*\*" @@ -40,9 +41,7 @@ def render_body(self): if not notebook.exists(): return body - # path from the references directory where the qmd files - # are placed - relpath = Path("..") / notebook.relative_to(DOC_DIR) + relpath = notebook.relative_to(REFERENCE_DIR) embed_notebook = shortcode("embed", f"{relpath}", echo="true") header = Header(self.level + 1, "Examples") return Blocks([body, header, embed_notebook])