Skip to content

Commit 97791c3

Browse files
authored
Merge pull request #1 from readthedocs-examples/bootstrap
Initial structure for documentation project
2 parents 6abe22e + 423d608 commit 97791c3

14 files changed

+398
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ __pycache__/
66
# C extensions
77
*.so
88

9+
# auto-generated Sphinx api docs
10+
/docs/generated
11+
912
# Distribution / packaging
1013
.Python
1114
build/

.readthedocs.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.10"
13+
# You can also specify other tool versions:
14+
# nodejs: "16"
15+
# rust: "1.55"
16+
# golang: "1.17"
17+
18+
# Build documentation in the docs/ directory with Sphinx
19+
sphinx:
20+
configuration: docs/conf.py
21+
22+
# If using Sphinx, optionally build your docs in additional formats such as PDF
23+
# formats:
24+
# - pdf
25+
26+
# Optionally declare the Python requirements required to build your docs
27+
python:
28+
install:
29+
- requirements: docs/requirements.txt
30+
- method: pip
31+
path: .

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
Example: Basic Sphinx project for Read the Docs
2+
===============================================
3+
4+
.. 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
5+
6+
This example shows the an integration of a basic Sphinx 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>`_.
7+
8+
📚 `docs/ <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/>`_
9+
A basic Sphinx project lives in ``docs/``, it was generated using Sphinx defaults. All the ``*.rst`` make up sections in the documentation.
10+
⚙️ `.readthedocs.yaml <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/.readthedocs.yaml>`_
11+
Read the Docs Build configuration is stored in ``.readthedocs.yaml``.
12+
📍 `docs/requirements.txt <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/requirements.txt>`_ and `docs/requirements.in <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/requirements.in>`_
13+
Python dependencies are `pinned <https://docs.readthedocs.io/en/latest/guides/reproducible-builds.html>`_ (uses `pip-tools <https://pip-tools.readthedocs.io/en/latest/>`_).
14+
💡 `docs/api.rst <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/api.rst>`_
15+
By adding our example Python module ``lumache`` in the reStructuredText directive ``:autosummary:``, Sphinx will automatically scan this module and generate API docs.
16+
💡 `docs/usage.rst <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/usage.rst>`_
17+
Sphinx can automatically extract API documentation directly from Python modules, using for instance the ``:autofunction:`` directive.
18+
💡 `lumache.py <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/lumache.py>`_
19+
API docs are generated for this example Python module - they use *docstrings* directly in the documentation, notice how this shows up in the rendered documentation.
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-sphinx-basic.readthedocs.io <https://example-sphinx-basic.readthedocs.io/en/latest/>`__.
22+
📜 `README.rst <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/README.rst>`_
23+
Contents of this ``README.rst`` are visible on Github and included on `the documentation index page <https://example-sphinx-basic.readthedocs.io/en/latest/>`_ (Don't Repeat Yourself).
24+
⁉️ 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-sphinx-basic/issues>`_.
26+
27+
28+
Sphinx Example Project usage
29+
----------------------------
30+
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!).
32+
33+
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>`_:
34+
35+
.. code-block:: console
36+
37+
# Install required Python dependencies (Sphinx etc.)
38+
pip install -r docs/requirements.txt
39+
40+
# Enter the Sphinx project
41+
cd docs/
42+
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
59+
60+
61+
Using the example in your own project
62+
-------------------------------------
63+
64+
If you are new to Read the Docs, you may want to refer to the `Read the Docs User documentation <https://docs.readthedocs.io/>`_.
65+
66+
If you are copying this code in order to get started with your documentation, you need to:
67+
68+
* Create a new repository on Github, GitLab, Bitbucket or another host supported by Read the Docs
69+
* Customize all ``docs/*.rst`` files
70+
* Add your own Python project, replacing the ``pyproject.toml`` configuration and ``lumache.py`` module.
71+
* Rebuild the documenation locally to see that it works.
72+
* Register your project on Read the Docs, see `Importing Your Documentation <https://docs.readthedocs.io/en/stable/intro/import-guide.html>`_.
73+
74+
75+
Read the Docs tutorial
76+
----------------------
77+
78+
To get started with Read the Docs, you may also refer to the `Read the Docs tutorial <https://docs.readthedocs.io/en/stable/tutorial/>`_.
79+
It provides a full walk-through of building an example project similar to the one in this repository.

docs/Makefile

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, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
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)

docs/api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
API
2+
===
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
lumache

docs/conf.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = "Basic Sphinx Example Project"
21+
copyright = "2022, Read the Docs core team"
22+
author = "Read the Docs core team"
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
# -- General configuration
27+
28+
extensions = [
29+
"sphinx.ext.duration",
30+
"sphinx.ext.doctest",
31+
"sphinx.ext.autodoc",
32+
"sphinx.ext.autosummary",
33+
"sphinx.ext.intersphinx",
34+
]
35+
36+
intersphinx_mapping = {
37+
"rtd": ("https://docs.readthedocs.io/en/stable/", None),
38+
"python": ("https://docs.python.org/3/", None),
39+
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
40+
}
41+
intersphinx_disabled_domains = ["std"]
42+
43+
templates_path = ["_templates"]
44+
45+
# -- Options for EPUB output
46+
epub_show_urls = "footnote"
47+
48+
# List of patterns, relative to source directory, that match files and
49+
# directories to ignore when looking for source files.
50+
# This pattern also affects html_static_path and html_extra_path.
51+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
52+
53+
# -- Options for HTML output -------------------------------------------------
54+
55+
# The theme to use for HTML and HTML Help pages. See the documentation for
56+
# a list of builtin themes.
57+
#
58+
html_theme = "sphinx_rtd_theme"
59+
60+
# Add any paths that contain custom static files (such as style sheets) here,
61+
# relative to this directory. They are copied after the builtin static files,
62+
# so a file named "default.css" will overwrite the builtin "default.css".
63+
html_static_path = ["_static"]

docs/index.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. include:: ../README.rst
2+
3+
Welcome to Lumache's documentation!
4+
===================================
5+
6+
**Lumache** (/lu'make/) is a Python library for cooks and food lovers
7+
that creates recipes mixing random ingredients.
8+
It pulls data from the `Open Food Facts database <https://world.openfoodfacts.org/>`_
9+
and offers a *simple* and *intuitive* API.
10+
11+
Check out the :doc:`usage` section for further information, including
12+
how to :ref:`installation` the project.
13+
14+
.. note::
15+
16+
This project is under active development.
17+
18+
Contents
19+
--------
20+
21+
.. toctree::
22+
23+
usage
24+
api

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sphinx>=5,<6
2+
sphinx_rtd_theme

docs/requirements.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.10
3+
# To update, run:
4+
#
5+
# pip-compile docs/requirements.in
6+
#
7+
alabaster==0.7.12
8+
# via sphinx
9+
babel==2.10.3
10+
# via sphinx
11+
certifi==2022.6.15
12+
# via requests
13+
charset-normalizer==2.1.0
14+
# via requests
15+
docutils==0.17.1
16+
# via
17+
# sphinx
18+
# sphinx-rtd-theme
19+
idna==3.3
20+
# via requests
21+
imagesize==1.4.1
22+
# via sphinx
23+
jinja2==3.1.2
24+
# via sphinx
25+
markupsafe==2.1.1
26+
# via jinja2
27+
packaging==21.3
28+
# via sphinx
29+
pygments==2.12.0
30+
# via sphinx
31+
pyparsing==3.0.9
32+
# via packaging
33+
pytz==2022.1
34+
# via babel
35+
requests==2.28.1
36+
# via sphinx
37+
snowballstemmer==2.2.0
38+
# via sphinx
39+
sphinx==5.0.2
40+
# via
41+
# -r docs/requirements.in
42+
# sphinx-rtd-theme
43+
sphinx-rtd-theme==1.0.0
44+
# via -r docs/requirements.in
45+
sphinxcontrib-applehelp==1.0.2
46+
# via sphinx
47+
sphinxcontrib-devhelp==1.0.2
48+
# via sphinx
49+
sphinxcontrib-htmlhelp==2.0.0
50+
# via sphinx
51+
sphinxcontrib-jsmath==1.0.1
52+
# via sphinx
53+
sphinxcontrib-qthelp==1.0.3
54+
# via sphinx
55+
sphinxcontrib-serializinghtml==1.1.5
56+
# via sphinx
57+
urllib3==1.26.9
58+
# via requests

docs/usage.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Usage
2+
=====
3+
4+
.. _installation:
5+
6+
Installation
7+
------------
8+
9+
To use Lumache, first install it using pip:
10+
11+
.. code-block:: console
12+
13+
(.venv) $ pip install lumache
14+
15+
Creating recipes
16+
----------------
17+
18+
To retrieve a list of random ingredients,
19+
you can use the ``lumache.get_random_ingredients()`` function:
20+
21+
.. autofunction:: lumache.get_random_ingredients
22+
23+
The ``kind`` parameter should be either ``"meat"``, ``"fish"``,
24+
or ``"veggies"``. Otherwise, :py:func:`lumache.get_random_ingredients`
25+
will raise an exception.
26+
27+
.. autoexception:: lumache.InvalidKindError
28+
29+
For example:
30+
31+
>>> import lumache
32+
>>> lumache.get_random_ingredients()
33+
['shells', 'gorgonzola', 'parsley']
34+

0 commit comments

Comments
 (0)