Skip to content

Commit

Permalink
Set up nbsphinx.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Mar 19, 2020
1 parent 2fe863f commit 07cc682
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ binder/jupyterlab-workspace.json
*.swp
.ipython/profile_default/
my_exported_files/
docs/build

# Ignore content copied from repo route into docs/source by docs/Makefile.
docs/source/*.ipynb
docs/source/scripts
docs/source/solutions
docs/source/solutions
docs/source/static
24 changes: 24 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
cp "$(SOURCEDIR)"/../../*.ipynb "$(SOURCEDIR)"
cp -r "$(SOURCEDIR)"/../../scripts "$(SOURCEDIR)"/scripts
cp -r "$(SOURCEDIR)"/../../solutions "$(SOURCEDIR)"/solutions
cp -r "$(SOURCEDIR)"/../../static "$(SOURCEDIR)"/static
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This generates static web pages from the notebooks in this repository using
[nbsphinx](https://nbsphinx.readthedocs.io/en/0.5.1/).
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ipykernel
jupyter_client
sphinx
nbsphinx
70 changes: 70 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'Bluesky Examples'
copyright = '2020, Bluesky Contributors'
author = 'Bluesky Contributors'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'nbsphinx',
'sphinx.ext.mathjax',
]

nbsphinx_timeout = 600
nbsphinx_execute = "always"

nbsphinx_prolog = """
{% set docname = env.doc2path(env.docname, base=None) %}
.. admonition:: Live Notebook
You can run this notebook in a `live session <https://mybinder.org/v2/gh/bluesky/tutorial/master?urlpath=lab/tree/{{ docname }}>`_ |Binder| or view it `on Github <https://github.com/bluesky/tutorial/blob/master/{{ docname }}>`_.
.. |Binder| image:: https://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/bluesky/tutorial/master?urlpath=lab/tree/{{ docname }}
"""

nbsphinx_execute_arguments = [
"--InlineBackend.figure_formats={'svg', 'pdf'}",
"--InlineBackend.rc={'figure.dpi': 96}",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
19 changes: 19 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Bluesky Examples
================

These examples address a wide range of questions, such as:

* How do I configure bluesky to work with a new piece of hardware?
* How do I write a custom experiment "plan"?
* How do I visualize my data?

You can run these examples in a live session here: |Binder|

.. |Binder| image:: https://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/bluesky/tutorial/master?urlpath=lab

.. toctree::
:maxdepth: 1
:caption: Basic Examples

Hello Bluesky.ipynb

0 comments on commit 07cc682

Please sign in to comment.