Skip to content

Commit

Permalink
Add tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed Jun 8, 2017
1 parent dae2054 commit 034422f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
20 changes: 20 additions & 0 deletions doc/conf.py
Expand Up @@ -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')
1 change: 1 addition & 0 deletions doc/index.rst
Expand Up @@ -39,5 +39,6 @@ Documentation
changelog
about-plotnine
external-resources
tutorials

.. _ggplot2: http://ggplot2.org
8 changes: 4 additions & 4 deletions doc/sphinxext/examples_and_gallery.py
Expand Up @@ -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::
Expand Down Expand Up @@ -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__))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)


Expand Down
14 changes: 14 additions & 0 deletions doc/tutorials.rst
@@ -0,0 +1,14 @@
.. _tutorials:

#########
Tutorials
#########

Miscellaneous
=============

.. toctree::
:maxdepth: 1
:glob:

tutorials/miscellaneous-*
5 changes: 5 additions & 0 deletions doc/tutorials/.gitignore
@@ -0,0 +1,5 @@
# Ignore everything in this directory
*

# Except this file
!.gitignore

0 comments on commit 034422f

Please sign in to comment.