Skip to content

Commit 0e4078c

Browse files
authored
Merge pull request #12 from vidartf/docs2
Add docs stub, ready for RTD
2 parents 5e073bd + e24f896 commit 0e4078c

File tree

18 files changed

+505
-20
lines changed

18 files changed

+505
-20
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ language: python
22
python:
33
- 3.6
44
sudo: false
5+
addons:
6+
apt_packages:
7+
- pandoc
58
cache:
69
pip: true
710
directories:
@@ -14,7 +17,7 @@ install:
1417
- pushd $(mktemp -d)
1518
- cookiecutter $TRAVIS_BUILD_DIR --config-file $TRAVIS_BUILD_DIR/tests/testconfig.yaml --no-input
1619
- pushd jupyter-widget-testwidgets
17-
- pip install --upgrade -v -e ".[test]"
20+
- pip install --upgrade -v -e ".[test, examples, docs]"
1821
before_script:
1922
- |
2023
export CHROME_BIN=chromium-browser
@@ -23,6 +26,11 @@ before_script:
2326
script:
2427
- py.test
2528
- npm test
29+
# Check docs can be build + links
30+
- pushd docs
31+
- make html
32+
- make linkcheck
33+
- popd
2634
# Make a non-local install so the data_files get populated
2735
- pip uninstall -y ipywidgettestwidgets
2836
- pip install .

{{cookiecutter.github_project_name}}/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ instance/
6161

6262
# Sphinx documentation
6363
docs/_build/
64+
docs/source/_static/embed-bundle.js
65+
docs/source/_static/embed-bundle.js.map
6466

6567
# PyBuilder
6668
target/

{{cookiecutter.github_project_name}}/.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ matrix:
1111
include:
1212
- python: 3.5
1313
env: GROUP=js
14+
include:
15+
- python: 3.6
16+
env: GROUP=docs
1417
cache:
1518
pip: true
1619
directories:
@@ -31,6 +34,8 @@ install:
3134
pip install --upgrade ".[test]" -v
3235
elif [[ $GROUP == js ]]; then
3336
pip install --upgrade -e ".[test]" -v
37+
elif [[ $GROUP == docs ]]; then
38+
pip install --upgrade ".[test, examples, docs]" -v
3439
fi
3540
before_script:
3641
# Set up a virtual screen for Firefox browser testing:
@@ -52,6 +57,14 @@ script:
5257
(exit $EXIT_STATUS)
5358
elif [[ $GROUP == js ]]; then
5459
npm test
60+
elif [[ $GROUP == docs ]]; then
61+
EXIT_STATUS=0
62+
cd docs
63+
make html || EXIT_STATUS=$?
64+
make linkcheck || EXIT_STATUS=$?
65+
cd ..
66+
python -m pytest_check_links --links-ext=.md -o testpaths=. -o addopts= || EXIT_STATUS=$?
67+
(exit $EXIT_STATUS)
5568
fi
5669
after_success:
5770
- codecov

{{cookiecutter.github_project_name}}/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
# {{ cookiecutter.github_project_name }}
33

4-
[![Build Status](https://travis-ci.org/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.python_package_name }}.svg?branch=master)](https://travis-ci.org/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.python_package_name }})
5-
[![codecov](https://codecov.io/gh/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.python_package_name }}/branch/master/graph/badge.svg)](https://codecov.io/gh/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.python_package_name }})
4+
[![Build Status](https://travis-ci.org/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }}.svg?branch=master)](https://travis-ci.org/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.python_package_name }})
5+
[![codecov](https://codecov.io/gh/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }}/branch/master/graph/badge.svg)](https://codecov.io/gh/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }})
66

77

88
{{ cookiecutter.project_short_description }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = {{ cookiecutter.python_package_name }}
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
set SPHINXPROJ={{ cookiecutter.python_package_name }}
13+
14+
if "%1" == "" goto help
15+
16+
%SPHINXBUILD% >NUL 2>NUL
17+
if errorlevel 9009 (
18+
echo.
19+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20+
echo.installed, then set the SPHINXBUILD environment variable to point
21+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
22+
echo.may add the Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b 1
27+
)
28+
29+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34+
35+
:end
36+
popd
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var cache_require = window.require;
2+
3+
window.addEventListener('load', function() {
4+
window.require = cache_require;
5+
});
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# {{ cookiecutter.python_package_name }} documentation build configuration file
5+
#
6+
# This file is execfile()d with the current directory set to its
7+
# containing dir.
8+
#
9+
# Note that not all possible configuration values are present in this
10+
# autogenerated file.
11+
#
12+
# All configuration values have a default; values that are commented out
13+
# serve to show the default.
14+
15+
16+
# -- General configuration ------------------------------------------------
17+
18+
# If your documentation needs a minimal Sphinx version, state it here.
19+
#
20+
# needs_sphinx = '1.0'
21+
22+
# Add any Sphinx extension module names here, as strings. They can be
23+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
24+
# ones.
25+
extensions = [
26+
'sphinx.ext.autodoc',
27+
'sphinx.ext.viewcode',
28+
'sphinx.ext.intersphinx',
29+
'sphinx.ext.napoleon',
30+
'sphinx.ext.todo',
31+
'nbsphinx',
32+
'jupyter_sphinx.embed_widgets',
33+
'nbsphinx_link',
34+
]
35+
36+
# Ensure our extension is available:
37+
import sys
38+
from os.path import dirname, join as pjoin
39+
docs = dirname(dirname(__file__))
40+
root = dirname(docs)
41+
sys.path.insert(0, root)
42+
sys.path.insert(0, pjoin(docs, 'sphinxext'))
43+
44+
# Add any paths that contain templates here, relative to this directory.
45+
templates_path = ['_templates']
46+
47+
# The suffix(es) of source filenames.
48+
# You can specify multiple suffix as a list of string:
49+
#
50+
# source_suffix = ['.rst', '.md']
51+
source_suffix = '.rst'
52+
53+
# The master toctree document.
54+
master_doc = 'index'
55+
56+
# General information about the project.
57+
project = '{{ cookiecutter.python_package_name }}'
58+
copyright = '{% now 'local', '%Y' %}, {{ cookiecutter.author_name }}'
59+
author = '{{ cookiecutter.author_name }}'
60+
61+
# The version info for the project you're documenting, acts as replacement for
62+
# |version| and |release|, also used in various other places throughout the
63+
# built documents.
64+
#
65+
# The short X.Y version.
66+
67+
68+
# get version from nbdime:
69+
import os
70+
here = os.path.dirname(__file__)
71+
repo = os.path.join(here, '..', '..')
72+
_version_py = os.path.join(repo, '{{ cookiecutter.python_package_name }}', '_version.py')
73+
version_ns = {}
74+
with open(_version_py) as f:
75+
exec(f.read(), version_ns)
76+
77+
# The short X.Y version.
78+
version = '%i.%i' % version_ns['version_info'][:2]
79+
# The full version, including alpha/beta/rc tags.
80+
release = version_ns['__version__']
81+
82+
# The language for content autogenerated by Sphinx. Refer to documentation
83+
# for a list of supported languages.
84+
#
85+
# This is also used if you do content translation via gettext catalogs.
86+
# Usually you set "language" from the command line for these cases.
87+
language = None
88+
89+
# List of patterns, relative to source directory, that match files and
90+
# directories to ignore when looking for source files.
91+
# This patterns also effect to html_static_path and html_extra_path
92+
exclude_patterns = ['**.ipynb_checkpoints']
93+
94+
# The name of the Pygments (syntax highlighting) style to use.
95+
pygments_style = 'sphinx'
96+
97+
# If true, `todo` and `todoList` produce output, else they produce nothing.
98+
todo_include_todos = False
99+
100+
101+
# -- Options for HTML output ----------------------------------------------
102+
103+
104+
# Theme options are theme-specific and customize the look and feel of a theme
105+
# further. For a list of options available for each theme, see the
106+
# documentation.
107+
#
108+
# html_theme_options = {}
109+
110+
# Add any paths that contain custom static files (such as style sheets) here,
111+
# relative to this directory. They are copied after the builtin static files,
112+
# so a file named "default.css" will overwrite the builtin "default.css".
113+
html_static_path = ['_static']
114+
115+
116+
# -- Options for HTMLHelp output ------------------------------------------
117+
118+
# Output file base name for HTML help builder.
119+
htmlhelp_basename = '{{ cookiecutter.python_package_name }}doc'
120+
121+
122+
# -- Options for LaTeX output ---------------------------------------------
123+
124+
latex_elements = {
125+
# The paper size ('letterpaper' or 'a4paper').
126+
#
127+
# 'papersize': 'letterpaper',
128+
129+
# The font size ('10pt', '11pt' or '12pt').
130+
#
131+
# 'pointsize': '10pt',
132+
133+
# Additional stuff for the LaTeX preamble.
134+
#
135+
# 'preamble': '',
136+
137+
# Latex figure (float) alignment
138+
#
139+
# 'figure_align': 'htbp',
140+
}
141+
142+
# Grouping the document tree into LaTeX files. List of tuples
143+
# (source start file, target name, title,
144+
# author, documentclass [howto, manual, or own class]).
145+
latex_documents = [
146+
(master_doc, '{{ cookiecutter.python_package_name }}.tex', '{{ cookiecutter.python_package_name }} Documentation',
147+
'{{ cookiecutter.author_name }}', 'manual'),
148+
]
149+
150+
151+
# -- Options for manual page output ---------------------------------------
152+
153+
# One entry per manual page. List of tuples
154+
# (source start file, name, description, authors, manual section).
155+
man_pages = [
156+
(master_doc,
157+
'{{ cookiecutter.python_package_name }}',
158+
'{{ cookiecutter.python_package_name }} Documentation',
159+
[author], 1)
160+
]
161+
162+
163+
# -- Options for Texinfo output -------------------------------------------
164+
165+
# Grouping the document tree into Texinfo files. List of tuples
166+
# (source start file, target name, title, author,
167+
# dir menu entry, description, category)
168+
texinfo_documents = [
169+
(master_doc,
170+
'{{ cookiecutter.python_package_name }}',
171+
'{{ cookiecutter.python_package_name }} Documentation',
172+
author,
173+
'{{ cookiecutter.python_package_name }}',
174+
'{{ cookiecutter.project_short_description }}',
175+
'Miscellaneous'),
176+
]
177+
178+
179+
# Example configuration for intersphinx: refer to the Python standard library.
180+
intersphinx_mapping = {'https://docs.python.org/': None}
181+
182+
# Read The Docs
183+
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from
184+
# docs.readthedocs.org
185+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
186+
187+
if not on_rtd: # only import and set the theme if we're building docs locally
188+
import sphinx_rtd_theme
189+
html_theme = 'sphinx_rtd_theme'
190+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
191+
192+
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
193+
194+
195+
# Uncomment this line if you have know exceptions in your included notebooks
196+
# that nbsphinx complains about:
197+
#
198+
nbsphinx_allow_errors = True # exception ipstruct.py ipython_genutils
199+
200+
201+
def setup(app):
202+
app.setup_extension('jupyter_sphinx.embed_widgets')
203+
def add_scripts(app):
204+
for fname in ['helper.js', 'embed-bundle.js']:
205+
if not os.path.exists(os.path.join(here, '_static', fname)):
206+
app.warn('missing javascript file: %s' % fname)
207+
app.add_javascript(fname)
208+
app.connect('builder-inited', add_scripts)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Developer install
3+
=================
4+
5+
6+
To install a developer version of {{ cookiecutter.python_package_name }}, you will first need to clone
7+
the repository::
8+
9+
git clone https://github.com/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }}
10+
cd {{ cookiecutter.github_project_name }}
11+
12+
Next, install it with a develop install using pip::
13+
14+
pip install -e .
15+
16+
17+
If you are planning on working on the JS/frontend code, you should also do
18+
a link installation of the extension::
19+
20+
jupyter nbextension install [--sys-prefix / --user / --system] --symlink --py {{ cookiecutter.python_package_name }}
21+
22+
jupyter nbextension enable [--sys-prefix / --user / --system] --py {{ cookiecutter.python_package_name }}
23+
24+
with the `appropriate flag`_. Or, if you are using Jupyterlab::
25+
26+
jupyter labextension install .
27+
28+
29+
.. links
30+
31+
.. _`appropriate flag`: https://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html#installing-and-enabling-extensions

0 commit comments

Comments
 (0)