Skip to content

Commit d78a455

Browse files
authored
Merge pull request #1 from readthedocs-examples/bootstrap
Version 1.0
2 parents 8de3180 + b08e0d4 commit d78a455

File tree

10 files changed

+366
-47
lines changed

10 files changed

+366
-47
lines changed

.gitignore

Lines changed: 138 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,138 @@
1-
docs/conf.py
2-
docs/_build
1+
/docs/conf.py
2+
/docs/_build
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# auto-generated Sphinx api docs
13+
/docs/generated
14+
15+
# Distribution / packaging
16+
.Python
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib/
24+
lib64/
25+
parts/
26+
sdist/
27+
var/
28+
wheels/
29+
pip-wheel-metadata/
30+
share/python-wheels/
31+
*.egg-info/
32+
.installed.cfg
33+
*.egg
34+
MANIFEST
35+
36+
# PyInstaller
37+
# Usually these files are written by a python script from a template
38+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
39+
*.manifest
40+
*.spec
41+
42+
# Installer logs
43+
pip-log.txt
44+
pip-delete-this-directory.txt
45+
46+
# Unit test / coverage reports
47+
htmlcov/
48+
.tox/
49+
.nox/
50+
.coverage
51+
.coverage.*
52+
.cache
53+
nosetests.xml
54+
coverage.xml
55+
*.cover
56+
*.py,cover
57+
.hypothesis/
58+
.pytest_cache/
59+
60+
# Translations
61+
*.mo
62+
*.pot
63+
64+
# Django stuff:
65+
*.log
66+
local_settings.py
67+
db.sqlite3
68+
db.sqlite3-journal
69+
70+
# Flask stuff:
71+
instance/
72+
.webassets-cache
73+
74+
# Scrapy stuff:
75+
.scrapy
76+
77+
# Sphinx documentation
78+
docs/_build/
79+
80+
# PyBuilder
81+
target/
82+
83+
# Jupyter Notebook
84+
.ipynb_checkpoints
85+
86+
# IPython
87+
profile_default/
88+
ipython_config.py
89+
90+
# pyenv
91+
.python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
101+
__pypackages__/
102+
103+
# Celery stuff
104+
celerybeat-schedule
105+
celerybeat.pid
106+
107+
# SageMath parsed files
108+
*.sage.py
109+
110+
# Environments
111+
.env
112+
.venv
113+
env/
114+
venv/
115+
ENV/
116+
env.bak/
117+
venv.bak/
118+
119+
# Spyder project settings
120+
.spyderproject
121+
.spyproject
122+
123+
# Rope project settings
124+
.ropeproject
125+
126+
# mkdocs documentation
127+
/site
128+
129+
# mypy
130+
.mypy_cache/
131+
.dmypy.json
132+
dmypy.json
133+
134+
# Pyre type checker
135+
.pyre/
136+
137+
# Temporary editor files
138+
*.swp

README.rst

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,34 @@ Example: Jupyter Book for Read the Docs
55
:target: https://example-jupyter-book.readthedocs.io/en/latest/?badge=latest
66
:alt: Documentation Status
77

8-
.. This README.rst should work on Github and is also included in the Sphinx documentation project in docs/ - therefore, README.rst uses absolute links for most things so it renders properly on GitHub
8+
.. This README.rst should work on GitHub and is also included in the Sphinx documentation project in docs/ - therefore, README.rst uses absolute links for most things so it renders properly on GitHub
99
10-
This example shows a Jupyter Book project with Read the Docs. You're encouraged to view it to get inspiration and copy & paste from the files in the source code. If you are using Read the Docs for the first time, have a look at the official `Read the Docs Tutorial <https://docs.readthedocs.io/en/stable/tutorial/index.html>`__.
10+
This example shows a Jupyter Book project with Read the Docs. You're encouraged to view it to get inspiration and copy & paste from the files in the source code. If you are using Read the Docs for the first time, have a look at the official `Read the Docs Tutorial <https://docs.readthedocs.io/en/stable/tutorial/index.html>`__. If you are using Jupyter Book for the first time, have a look at the `official Jupyter Book documentation <https://jupyterbook.org/en/stable/>`_.
1111

1212
📚 `docs/ <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/docs/>`_
13-
A basic Jupyter Book project lives in ``docs/``. All the ``*.md`` make up sections in the documentation.
13+
A basic Jupyter Book project lives in ``docs/``. All the ``*.md`` make up sections in the documentation, ``intro.md`` is the starting page and includes this ``README.rst``.
1414
⚙️ `.readthedocs.yaml <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/.readthedocs.yaml>`_
1515
Read the Docs Build configuration is stored in ``.readthedocs.yaml``.
16-
⚙️ `docs/config.yml <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/docs/conf.py>`_
17-
This is the configuration for Jupyter Book which is used to generate a Sphinx-configuration on-the-fly. However, the Sphinx ``conf.py`` file is NOT managed in a git repository, as it is managed by Jupyter Book!
18-
📍 `docs/requirements.txt <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/docs/requirements.txt>`_ and `docs/requirements.in <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/docs/requirements.in>`_
19-
Python dependencies are `pinned <https://docs.readthedocs.io/en/latest/guides/reproducible-builds.html>`_ (uses `pip-tools <https://pip-tools.readthedocs.io/en/latest/>`_). Make sure to add your Python dependencies to ``requirements.txt`` or if you choose [pip-tools](https://pip-tools.readthedocs.io/en/latest/), edit ``docs/requirements.in`` and remember to run ``pip-compile docs/requirements.in``.
20-
🔢 Git tags versioning
21-
We use a basic versioning mechanism by adding a git tag for every release of the example project. All releases and their version numbers are visible on `example-jupyter-book.readthedocs.io <https://example-jupyter-book.readthedocs.io/en/latest/>`__.
22-
📜 `README.rst <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/README.rst>`_
23-
Contents of this ``README.rst`` are visible on Github and included on `the documentation index page <https://example-jupyter-book.readthedocs.io/en/latest/>`_ (Don't Repeat Yourself).
16+
⚙️ `docs/_config.yml <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/docs/_config.yml>`_
17+
This is the `configuration for Jupyter Book <https://jupyterbook.org/en/stable/customize/config.html>`_ which is used to generate a Sphinx-configuration on-the-fly. However, the Sphinx ``conf.py`` file is NOT managed in a git repository, as it is managed by Jupyter Book!
18+
📍 `docs/requirements.txt <https://github.com/readthedocs-examples/example-jupyter-book/blob/main/docs/requirements.txt>`_
19+
These dependencies need to be installed for Jupyter Book to work. If you are familiar with Python, you might notice that the dependencies are *not* `pinned <https://docs.readthedocs.io/en/latest/guides/reproducible-builds.html>`_. This is the default method for Jupyter Book - on one hand it gives you the latest version each time Read the Docs builds your documentation; but on the other hand, your build can fail in the future if an incompatible version of ``jupyter-book`` is released.
20+
💡 Extension: `Intersphinx <https://docs.readthedocs.io/en/stable/guides/intersphinx.html>`_
21+
Using this extension, we refer directly to sections in other projects that use Sphinx.
22+
💡 Extension: `sphinx-hoverxref <https://sphinx-hoverxref.readthedocs.io/>`__
23+
A floating window (also known as a "tooltip" or "modal dialogue") appears when the mouse curser hovers a cross references to another section of the documentation or another documentation project referenced with Intersphinx.
24+
🔢 Simplified versioning
25+
In this example, we maintain a single version of the rendered documentation by automatically building and rendering everything that is added to the ``main`` branch. This is different from many software projects where several `versions of the docs <https://docs.readthedocs.io/en/stable/versions.html>`_ may be published for each new release.
26+
🔢 Pull Request builds
27+
Every time a change in a Pull Request on the GitHub repository happens, users can open `an automatically built Pull Request preview <https://docs.readthedocs.io/en/stable/pull-requests.html>`__.
2428
⁉️ Questions / comments
25-
If you have questions related to this example, feel free to can ask them as a Github issue `here <https://github.com/readthedocs-examples/example-jupyter-book/issues>`_.
29+
If you have questions related to this example, feel free to can ask them as a GitHub issue `here <https://github.com/readthedocs-examples/example-jupyter-book/issues>`_.
2630

2731

2832
Example Project usage
2933
---------------------
3034

31-
This project has a standard Sphinx layout which is built by Read the Docs almost the same way that you would build it locally (on your own laptop!).
35+
This project has a standard Jupyter Book layout which is built by Read the Docs almost the same way that you would build it locally (on your own laptop!).
3236

3337
You can build and view this documentation project locally - we recommend that you activate `a local Python virtual environment first <https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment>`_:
3438

@@ -37,25 +41,11 @@ You can build and view this documentation project locally - we recommend that yo
3741
# Install required Python dependencies (Sphinx etc.)
3842
pip install -r docs/requirements.txt
3943
40-
# Enter the Sphinx project
41-
cd docs/
44+
# Run Jupyter Book
45+
jupyter-book build docs/
4246
43-
# Run the raw sphinx-build command
44-
sphinx-build -M html . _build/
45-
46-
47-
You can also build the documentation locally with ``make``:
48-
49-
.. code-block:: console
50-
51-
# Enter the Sphinx project
52-
cd docs/
53-
54-
# Build with make
55-
make html
56-
57-
# Open with your preferred browser, pointing it to the documentation index page
58-
firefox _build/html/index.html
47+
# View the docs with for instance firefox
48+
firefox docs/_build/index.html
5949
6050
6151
Using the example in your own project
@@ -65,17 +55,22 @@ If you are new to Read the Docs, you may want to refer to the `Read the Docs Use
6555

6656
If you are copying this code in order to get started with your documentation, you need to:
6757

68-
#. place your ``docs/`` folder alongside your Python project. If you are starting a new project, you can adapt the `pyproject.toml` example configuration.
69-
#. use your existing project repository or create a new repository on Github, GitLab, Bitbucket or another host supported by Read the Docs
58+
#. use your existing project repository or create a new repository on GitHub, GitLab, Bitbucket or another host supported by Read the Docs
7059
#. copy ``.readthedocs.yaml`` and the ``docs/`` folder into your project.
60+
#. if you want to have a README on GitHub, create a ``README.rst`` which will be included in ``index.md``.
61+
#. if you *do not* want your README from GitHub included in the docs, edit `ìndex.md`` and remove the ``eval-rst`` block that includes it.
62+
#. if you don't already have a ``.gitignore``, use the one from the project file -- otherwise add these lines::
63+
64+
/docs/conf.py
65+
/docs/_build
66+
7167
#. customize all the files, replacing example contents.
72-
#. add your own Python project, replacing the ``pyproject.toml`` configuration and ``lumache.py`` module.
7368
#. rebuild the documenation locally to see that it works.
7469
#. *finally*, register your project on Read the Docs, see `Importing Your Documentation <https://docs.readthedocs.io/en/stable/intro/import-guide.html>`_.
7570

7671

77-
Read the Docs tutorial
72+
Read the Docs Tutorial
7873
----------------------
7974

80-
To get started with Read the Docs, you may also refer to the `Read the Docs tutorial <https://docs.readthedocs.io/en/stable/tutorial/>`__.
75+
To get started with Read the Docs, you may also refer to the `Read the Docs Tutorial <https://docs.readthedocs.io/en/stable/tutorial/>`__.
8176
It provides a full walk-through of building an example project similar to the one in this repository.

docs/_config.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Book settings
22
# Learn more at https://jupyterbook.org/customize/config.html
3+
# Comprehensive example: https://github.com/executablebooks/jupyter-book/blob/master/docs/_config.yml
34

45
title: Example Jupyter Book for Read the Docs
56
author: Read the Docs team
@@ -30,3 +31,45 @@ repository:
3031
html:
3132
use_issues_button: true
3233
use_repository_button: true
34+
35+
sphinx:
36+
config:
37+
intersphinx_mapping:
38+
ebp:
39+
- "https://executablebooks.org/en/latest/"
40+
- null
41+
myst-parser:
42+
- "https://myst-parser.readthedocs.io/en/latest/"
43+
- null
44+
myst-nb:
45+
- "https://myst-nb.readthedocs.io/en/latest/"
46+
- null
47+
sphinx:
48+
- "https://www.sphinx-doc.org/en/master"
49+
- null
50+
nbformat:
51+
- "https://nbformat.readthedocs.io/en/latest"
52+
- null
53+
sd:
54+
- "https://sphinx-design.readthedocs.io/en/latest"
55+
- null
56+
sphinxproof:
57+
- "https://sphinx-proof.readthedocs.io/en/latest/"
58+
- null
59+
hoverxref_intersphinx:
60+
- "sphinxproof"
61+
mathjax3_config:
62+
tex:
63+
macros:
64+
"N": "\\mathbb{N}"
65+
"floor": ["\\lfloor#1\\rfloor", 1]
66+
"bmat": ["\\left[\\begin{array}"]
67+
"emat": ["\\end{array}\\right]"]
68+
69+
extra_extensions:
70+
- sphinx.ext.intersphinx
71+
- sphinx_inline_tabs
72+
- sphinx_proof
73+
- sphinx_examples
74+
- hoverxref.extension
75+

docs/_toc.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33

44
format: jb-book
55
root: intro
6-
chapters:
7-
- file: markdown
8-
- file: notebooks
9-
- file: markdown-notebooks
6+
parts:
7+
- caption: Basic examples 🪄
8+
chapters:
9+
- file: markdown
10+
- file: notebooks
11+
- file: markdown-notebooks
12+
- caption: Cool extensions 🕶️
13+
chapters:
14+
- file: intersphinx
15+
- file: sphinx-examples
16+
- file: sphinx-hoverxref
17+
- file: sphinx-proof
18+

docs/intersphinx.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Intersphinx: Cross-reference other projects
2+
3+
Behind the built-in Sphinx extension `intersphinx` is a powerful tool to reference sections in other Sphinx and Jupyter Book documentation projects.
4+
5+
You can configure mappings to external Sphinx projects in your Jupyter Book configuration, the `_config.yml` file. In this example project, we have configured `ebp` to reference `https://executablebooks.org/en/latest/`. In the following code examples, we refer to the configured `ebp` mapping and link directly to a section called `tools`.
6+
7+
```{tab} MyST (Markdown)
8+
9+
```{example}
10+
We can link to pages in other documentation projects.
11+
This is a link to the
12+
[Executable Book project's list of tools they build](ebp:tools)
13+
```
14+
15+
16+
```{tab} reStructuredText
17+
18+
```{example}
19+
20+
```{eval-rst}
21+
We can link to pages in other documentation projects.
22+
This is a link to the
23+
:doc:`Executable Book project's list of tools they build <ebp:tools>`
24+
```
25+
26+
```{note}
27+
In the above `reStructuredText` example, we use `{eval-rst}` to write reST inside a `.md` file (i.e. the one you are reading now). You only need to use this directive if you are writing reST code in a `.md` file.
28+
```

0 commit comments

Comments
 (0)