Skip to content

Commit 663e567

Browse files
committed
add readthedocs sphinx documentation
1 parent 9b91ba7 commit 663e567

37 files changed

+4280
-5
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ node_modules/
6363
npm-debug*
6464

6565
# vim
66-
*.swp
66+
*.swp
67+
68+
docs/_build/

.readthedocs.yaml

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

README.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Example: Basic Sphinx project for Read the Docs
2+
===============================================
3+
4+
.. image:: https://readthedocs.org/projects/example-sphinx-basic/badge/?version=latest
5+
:target: https://example-sphinx-basic.readthedocs.io/en/latest/?badge=latest
6+
:alt: Documentation Status
7+
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
9+
10+
This example shows 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>`__.
11+
12+
📚 `docs/ <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/>`_
13+
A basic Sphinx project lives in ``docs/``. All the ``*.rst`` make up sections in the documentation.
14+
⚙️ `.readthedocs.yaml <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/.readthedocs.yaml>`_
15+
Read the Docs Build configuration is stored in ``.readthedocs.yaml``.
16+
⚙️ `docs/conf.py <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/conf.py>`_
17+
Both the configuration and the folder layout follow Sphinx default conventions. You can change the `Sphinx configuration values <https://www.sphinx-doc.org/en/master/usage/configuration.html>`_ in this file
18+
📍 `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>`_
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+
💡 `docs/api.rst <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/api.rst>`_
21+
By adding our example Python module ``lumache`` in the reStructuredText directive ``:autosummary:``, Sphinx will automatically scan this module and generate API docs.
22+
💡 `docs/usage.rst <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/usage.rst>`_
23+
Sphinx can automatically extract API documentation directly from Python modules, using for instance the ``:autofunction:`` directive.
24+
💡 `lumache.py <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/lumache.py>`_
25+
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.
26+
🔢 Git tags versioning
27+
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/>`__.
28+
📜 `README.rst <https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/README.rst>`_
29+
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).
30+
⁉️ Questions / comments
31+
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>`_.
32+
33+
34+
Example Project usage
35+
---------------------
36+
37+
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!).
38+
39+
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>`_:
40+
41+
.. code-block:: console
42+
43+
# Install required Python dependencies (Sphinx etc.)
44+
pip install -r docs/requirements.txt
45+
46+
# Enter the Sphinx project
47+
cd docs/
48+
49+
# Run the raw sphinx-build command
50+
sphinx-build -M html . _build/
51+
52+
53+
You can also build the documentation locally with ``make``:
54+
55+
.. code-block:: console
56+
57+
# Enter the Sphinx project
58+
cd docs/
59+
60+
# Build with make
61+
make html
62+
63+
# Open with your preferred browser, pointing it to the documentation index page
64+
firefox _build/html/index.html
65+
66+
67+
Using the example in your own project
68+
-------------------------------------
69+
70+
If you are new to Read the Docs, you may want to refer to the `Read the Docs User documentation <https://docs.readthedocs.io/>`_.
71+
72+
If you are copying this code in order to get started with your documentation, you need to:
73+
74+
#. place your ``docs/`` folder alongside your Python project. If you are starting a new project, you can adapt the `pyproject.toml` example configuration.
75+
#. use your existing project repository or create a new repository on Github, GitLab, Bitbucket or another host supported by Read the Docs
76+
#. copy ``.readthedocs.yaml`` and the ``docs/`` folder into your project.
77+
#. customize all the files, replacing example contents.
78+
#. add your own Python project, replacing the ``pyproject.toml`` configuration and ``lumache.py`` module.
79+
#. rebuild the documenation locally to see that it works.
80+
#. *finally*, register your project on Read the Docs, see `Importing Your Documentation <https://docs.readthedocs.io/en/stable/intro/import-guide.html>`_.
81+
82+
83+
Read the Docs tutorial
84+
----------------------
85+
86+
To get started with Read the Docs, you may also refer to the `Read the Docs tutorial <https://docs.readthedocs.io/en/stable/tutorial/>`__.
87+
It provides a full walk-through of building an example project similar to the one in this repository.

docs/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
SPHINXAUTOBUILD ?= sphinx-autobuild
9+
SOURCEDIR = .
10+
BUILDDIR = _build
11+
12+
# Put it first so that "make" without argument is like "make help".
13+
help:
14+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15+
16+
.PHONY: help Makefile
17+
18+
# Catch-all target: route all unknown targets to Sphinx using the new
19+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
20+
%: Makefile
21+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
"""Configuration file for the Sphinx documentation builder."""
2+
# Configuration file for the Sphinx documentation builder.
3+
#
4+
# This file only contains a selection of the most common options. For a full
5+
# list see the documentation:
6+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
7+
8+
# -- Path setup --------------------------------------------------------------
9+
10+
# If extensions (or modules to document with autodoc) are in another directory,
11+
# add these directories to sys.path here. If the directory is relative to the
12+
# documentation root, use os.path.abspath to make it absolute, like shown here.
13+
#
14+
# import os
15+
# import sys
16+
# sys.path.insert(0, os.path.abspath('.'))
17+
18+
import toml
19+
20+
with open("../pyproject.toml") as f:
21+
data = toml.load(f)
22+
23+
# -- Project information -----------------------------------------------------
24+
25+
project = "SlashML"
26+
copyright = "2023, slashml.com"
27+
author = "slashml.com"
28+
29+
version = data["tool"]["poetry"]["version"]
30+
release = version
31+
32+
html_title = project + " " + version
33+
html_last_updated_fmt = "%b %d, %Y"
34+
35+
36+
# -- General configuration ---------------------------------------------------
37+
38+
# Add any Sphinx extension module names here, as strings. They can be
39+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
40+
# ones.
41+
extensions = [
42+
"sphinx.ext.autodoc",
43+
"sphinx.ext.autodoc.typehints",
44+
"sphinx.ext.autosummary",
45+
"sphinx.ext.napoleon",
46+
"sphinx.ext.viewcode",
47+
"sphinxcontrib.autodoc_pydantic",
48+
"m2r2",
49+
"myst_nb",
50+
"sphinx_copybutton",
51+
"sphinx_panels",
52+
"IPython.sphinxext.ipython_console_highlighting",
53+
]
54+
source_suffix = [".ipynb", ".html", ".md", ".rst"]
55+
56+
autodoc_pydantic_model_show_json = False
57+
autodoc_pydantic_field_list_validators = False
58+
autodoc_pydantic_config_members = False
59+
autodoc_pydantic_model_show_config_summary = False
60+
autodoc_pydantic_model_show_validator_members = False
61+
autodoc_pydantic_model_show_field_summary = False
62+
autodoc_pydantic_model_members = False
63+
autodoc_pydantic_model_undoc_members = False
64+
# autodoc_typehints = "signature"
65+
# autodoc_typehints = "description"
66+
67+
# Add any paths that contain templates here, relative to this directory.
68+
templates_path = ["_templates"]
69+
70+
# List of patterns, relative to source directory, that match files and
71+
# directories to ignore when looking for source files.
72+
# This pattern also affects html_static_path and html_extra_path.
73+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
74+
75+
76+
# -- Options for HTML output -------------------------------------------------
77+
78+
# The theme to use for HTML and HTML Help pages. See the documentation for
79+
# a list of builtin themes.
80+
#
81+
html_theme = "sphinx_book_theme"
82+
83+
html_theme_options = {
84+
"path_to_docs": "docs",
85+
"repository_url": "https://github.com/slashml/slashml-python-client",
86+
"use_repository_button": True,
87+
}
88+
89+
html_context = {
90+
"display_github": True, # Integrate GitHub
91+
"github_user": "slashml", # Username
92+
"github_repo": "slashml-python-client", # Repo name
93+
"github_version": "main", # Version
94+
"conf_py_path": "/docs/", # Path in the checkout to the docs root
95+
}
96+
97+
# Add any paths that contain custom static files (such as style sheets) here,
98+
# relative to this directory. They are copied after the builtin static files,
99+
# so a file named "default.css" will overwrite the builtin "default.css".
100+
html_static_path = ["_static"]
101+
102+
# These paths are either relative to html_static_path
103+
# or fully qualified paths (eg. https://...)
104+
html_css_files = [
105+
"css/custom.css",
106+
]
107+
108+
html_js_files = [
109+
"js/mendablesearch.js",
110+
]
111+
112+
nb_execution_mode = "off"
113+
myst_enable_extensions = ["colon_fence"]

docs/deployment/dash_render.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Dash + Render Deployment
2+
3+
### Render
4+
5+
[Render](https://render.com/) is a unified cloud to build and run all your apps and websites with free TLS certificates, a global CDN, DDoS protection, private networks, and auto deploys from Git.
6+
7+
### Create Account
8+
9+
To deploy this demo on [Render](https://render.com/), you first need to login or create an account on [Render](https://render.com/) and navigate to your Render [Dashboard](https://dashboard.render.com/).
10+
11+
### Blueprint Instances
12+
13+
Then, naviagate to `Blueprints` &rarr; `New Blueprint Instance`
14+
15+
![Navigate Blueprints](render-navigate-blueprints.jpeg)
16+
17+
### Connect Repo
18+
19+
Under `Public Git repository`, set the URL to `https://github.com/slashml/dash-demo`
20+
21+
![Connect Repo](render-connect-repo.png)
22+
23+
`Blueprint Name`: Give your Blueprint a unique name.
24+
25+
`Branch`: Each demo is on a different branch. Select the demo that you want to deploy from the dropdown
26+
27+
### Create Blueprint
28+
29+
Once you have set `Blueprint Name` and `Branch`, press `Apply`
30+
31+
![Create Blueprint](render-create-blueprint.png)
32+
33+
Wait for the blueprint to deploy the web-service, which you can see in the Dashboard.
34+
35+
### View Deployment
36+
37+
Navigate to [Dashboard](https://dashboard.render.com/) and click on your newly created service.
38+
39+
You can find the URL of the deployed web-service at the top of the page.
40+
41+
![Deployed URL](render-deployed-url.jpg)
36.6 KB
Loading
67.4 KB
Loading
25.9 KB
Loading
18.7 KB
Loading

0 commit comments

Comments
 (0)