Skip to content

Commit 034422f

Browse files
committed
Add tutorials
1 parent dae2054 commit 034422f

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

doc/conf.py

+20
Original file line numberDiff line numberDiff line change
@@ -407,5 +407,25 @@
407407
}
408408

409409

410+
def link_to_tutorials():
411+
# Linking to the directory does not work well with
412+
# nbsphinx. We link to the files themselves
413+
from glob import glob
414+
from plotnine_examples.tutorials import TUTPATH
415+
416+
dest_dir = os.path.join(CUR_PATH, 'tutorials')
417+
418+
# Unlink files from previous build
419+
for old_file in glob(dest_dir + '/*.ipynb'):
420+
os.unlink(old_file)
421+
422+
# Link files for this build
423+
for file in glob(TUTPATH + '/*.ipynb'):
424+
basename = os.path.basename(file)
425+
dest = os.path.join(dest_dir, basename)
426+
os.symlink(file, dest)
427+
428+
410429
def setup(app):
430+
link_to_tutorials()
411431
app.add_stylesheet('custom.css')

doc/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ Documentation
3939
changelog
4040
about-plotnine
4141
external-resources
42+
tutorials
4243

4344
.. _ggplot2: http://ggplot2.org

doc/sphinxext/examples_and_gallery.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
1. Create a galley.rst page with a `gallery` directive.
1111
2. Define the path to the notebooks and the notebook filenames
12-
as `NBPATH` (str), `NBFILES` (set). Together they give
12+
as `EXPATH` (str), `EXFILES` (set). Together they give
1313
you the path each notebook file that will converted to ReST.
1414
3. In the Sphinx template used to generate documentation, use::
1515
@@ -51,7 +51,7 @@
5151
from docutils.parsers.rst import Directive
5252
from docutils.parsers.rst.directives.misc import Include
5353
from nbconvert.writers import FilesWriter
54-
from plotnine_examples.notebooks import NBPATH, NBFILES
54+
from plotnine_examples.examples import EXPATH, EXFILES
5555

5656
# Use build enviroment to get the paths
5757
CUR_PATH = os.path.dirname(os.path.abspath(__file__))
@@ -227,7 +227,7 @@ def get_rstfilename(nbfilename):
227227

228228

229229
def notebook_to_rst(nbfilename):
230-
nbfilepath = os.path.join(NBPATH, nbfilename)
230+
nbfilepath = os.path.join(EXPATH, nbfilename)
231231
rstfilename = get_rstfilename(nbfilename)
232232
output_files_dir = only_filename_no_ext(rstfilename)
233233
metadata_path = os.path.dirname(rstfilename)
@@ -265,7 +265,7 @@ def notebooks_to_rst(app):
265265
"""
266266
Convert notebooks to rst
267267
"""
268-
for filename in NBFILES:
268+
for filename in EXFILES:
269269
notebook_to_rst(filename)
270270

271271

doc/tutorials.rst

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _tutorials:
2+
3+
#########
4+
Tutorials
5+
#########
6+
7+
Miscellaneous
8+
=============
9+
10+
.. toctree::
11+
:maxdepth: 1
12+
:glob:
13+
14+
tutorials/miscellaneous-*

doc/tutorials/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore everything in this directory
2+
*
3+
4+
# Except this file
5+
!.gitignore

0 commit comments

Comments
 (0)