diff --git a/doc/conf.py b/doc/conf.py index b7b58a2e4..edec16785 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -407,5 +407,25 @@ } +def link_to_tutorials(): + # Linking to the directory does not work well with + # nbsphinx. We link to the files themselves + from glob import glob + from plotnine_examples.tutorials import TUTPATH + + dest_dir = os.path.join(CUR_PATH, 'tutorials') + + # Unlink files from previous build + for old_file in glob(dest_dir + '/*.ipynb'): + os.unlink(old_file) + + # Link files for this build + for file in glob(TUTPATH + '/*.ipynb'): + basename = os.path.basename(file) + dest = os.path.join(dest_dir, basename) + os.symlink(file, dest) + + def setup(app): + link_to_tutorials() app.add_stylesheet('custom.css') diff --git a/doc/index.rst b/doc/index.rst index 994abfceb..a0713eda3 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -39,5 +39,6 @@ Documentation changelog about-plotnine external-resources + tutorials .. _ggplot2: http://ggplot2.org diff --git a/doc/sphinxext/examples_and_gallery.py b/doc/sphinxext/examples_and_gallery.py index b5fc68845..feff4184f 100644 --- a/doc/sphinxext/examples_and_gallery.py +++ b/doc/sphinxext/examples_and_gallery.py @@ -9,7 +9,7 @@ 1. Create a galley.rst page with a `gallery` directive. 2. Define the path to the notebooks and the notebook filenames - as `NBPATH` (str), `NBFILES` (set). Together they give + as `EXPATH` (str), `EXFILES` (set). Together they give you the path each notebook file that will converted to ReST. 3. In the Sphinx template used to generate documentation, use:: @@ -51,7 +51,7 @@ from docutils.parsers.rst import Directive from docutils.parsers.rst.directives.misc import Include from nbconvert.writers import FilesWriter -from plotnine_examples.notebooks import NBPATH, NBFILES +from plotnine_examples.examples import EXPATH, EXFILES # Use build enviroment to get the paths CUR_PATH = os.path.dirname(os.path.abspath(__file__)) @@ -227,7 +227,7 @@ def get_rstfilename(nbfilename): def notebook_to_rst(nbfilename): - nbfilepath = os.path.join(NBPATH, nbfilename) + nbfilepath = os.path.join(EXPATH, nbfilename) rstfilename = get_rstfilename(nbfilename) output_files_dir = only_filename_no_ext(rstfilename) metadata_path = os.path.dirname(rstfilename) @@ -265,7 +265,7 @@ def notebooks_to_rst(app): """ Convert notebooks to rst """ - for filename in NBFILES: + for filename in EXFILES: notebook_to_rst(filename) diff --git a/doc/tutorials.rst b/doc/tutorials.rst new file mode 100644 index 000000000..89bceee72 --- /dev/null +++ b/doc/tutorials.rst @@ -0,0 +1,14 @@ +.. _tutorials: + +######### +Tutorials +######### + +Miscellaneous +============= + +.. toctree:: + :maxdepth: 1 + :glob: + + tutorials/miscellaneous-* diff --git a/doc/tutorials/.gitignore b/doc/tutorials/.gitignore new file mode 100644 index 000000000..64f58773f --- /dev/null +++ b/doc/tutorials/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore