|
1 | | -# example-mkdocs-basic |
2 | | -A basic MkDocs project for Read the Docs |
| 1 | +Example: Basic Sphinx project for Read the Docs |
| 2 | +=============================================== |
| 3 | + |
| 4 | +[](https://example-sphinx-basic.readthedocs.io/en/latest/?badge=latest) |
| 5 | + |
| 6 | +This example shows the an integration of a basic Sphinx project with |
| 7 | +Read the Docs. You\'re encouraged to view it to get inspiration and copy |
| 8 | +& paste from the files in the source code. If you are using Read the |
| 9 | +Docs for the first time, have a look at the official [Read the Docs |
| 10 | +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 | + |
| 14 | +: A basic Sphinx project lives in `docs/`, it was generated using |
| 15 | + Sphinx defaults. All the `*.rst` make up sections in the |
| 16 | + documentation. |
| 17 | + |
| 18 | +⚙️ [.readthedocs.yaml](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/.readthedocs.yaml) |
| 19 | + |
| 20 | +: Read the Docs Build configuration is stored in `.readthedocs.yaml`. |
| 21 | + |
| 22 | +📍 [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) |
| 23 | + |
| 24 | +: Python dependencies are |
| 25 | + [pinned](https://docs.readthedocs.io/en/latest/guides/reproducible-builds.html) |
| 26 | + (uses [pip-tools](https://pip-tools.readthedocs.io/en/latest/)). |
| 27 | + |
| 28 | +💡 [docs/api.rst](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/api.rst) |
| 29 | + |
| 30 | +: By adding our example Python module `lumache` in the |
| 31 | + reStructuredText directive `:autosummary:`, Sphinx will |
| 32 | + automatically scan this module and generate API docs. |
| 33 | + |
| 34 | +💡 [docs/usage.rst](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/usage.rst) |
| 35 | + |
| 36 | +: Sphinx can automatically extract API documentation directly from |
| 37 | + Python modules, using for instance the `:autofunction:` directive. |
| 38 | + |
| 39 | +💡 [lumache.py](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/lumache.py) |
| 40 | + |
| 41 | +: API docs are generated for this example Python module - they use |
| 42 | + *docstrings* directly in the documentation, notice how this shows up |
| 43 | + in the rendered documentation. |
| 44 | + |
| 45 | +🔢 Git tags versioning |
| 46 | + |
| 47 | +: We use a basic versioning mechanism by adding a git tag for every |
| 48 | + release of the example project. All releases and their version |
| 49 | + numbers are visible on |
| 50 | + [example-sphinx-basic.readthedocs.io](https://example-sphinx-basic.readthedocs.io/en/latest/). |
| 51 | + |
| 52 | +📜 [README.rst](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/README.rst) |
| 53 | + |
| 54 | +: Contents of this `README.rst` are visible on Github and included on |
| 55 | + [the documentation index |
| 56 | + page](https://example-sphinx-basic.readthedocs.io/en/latest/) |
| 57 | + (Don\'t Repeat Yourself). |
| 58 | + |
| 59 | +⁉️ Questions / comments |
| 60 | + |
| 61 | +: If you have questions related to this example, feel free to can ask |
| 62 | + them as a Github issue |
| 63 | + [here](https://github.com/readthedocs-examples/example-sphinx-basic/issues). |
| 64 | + |
| 65 | +Sphinx Example Project usage |
| 66 | +---------------------------- |
| 67 | + |
| 68 | +This project has a standard Sphinx layout which is built by Read the |
| 69 | +Docs almost the same way that you would build it locally (on your own |
| 70 | +laptop!). |
| 71 | + |
| 72 | +You can build and view this documentation project locally - we recommend |
| 73 | +that you activate [a local Python virtual environment |
| 74 | +first](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment): |
| 75 | + |
| 76 | +``` {.console} |
| 77 | +# Install required Python dependencies (Sphinx etc.) |
| 78 | +pip install -r docs/requirements.txt |
| 79 | +
|
| 80 | +# Enter the Sphinx project |
| 81 | +cd docs/ |
| 82 | +
|
| 83 | +# Run the raw sphinx-build command |
| 84 | +sphinx-build -M html . _build/ |
| 85 | +``` |
| 86 | + |
| 87 | +You can also build the documentation locally with `make`: |
| 88 | + |
| 89 | +``` {.console} |
| 90 | +# Enter the Sphinx project |
| 91 | +cd docs/ |
| 92 | +
|
| 93 | +# Build with make |
| 94 | +make html |
| 95 | +
|
| 96 | +# Open with your preferred browser, pointing it to the documentation index page |
| 97 | +firefox _build/html/index.html |
| 98 | +``` |
| 99 | + |
| 100 | +Using the example in your own project |
| 101 | +------------------------------------- |
| 102 | + |
| 103 | +If you are new to Read the Docs, you may want to refer to the [Read the |
| 104 | +Docs User documentation](https://docs.readthedocs.io/). |
| 105 | + |
| 106 | +If you are copying this code in order to get started with your |
| 107 | +documentation, you need to: |
| 108 | + |
| 109 | +- Create a new repository on Github, GitLab, Bitbucket or another host |
| 110 | + supported by Read the Docs |
| 111 | +- Customize all `docs/*.rst` files |
| 112 | +- Add your own Python project, replacing the `pyproject.toml` |
| 113 | + configuration and `lumache.py` module. |
| 114 | +- Rebuild the documenation locally to see that it works. |
| 115 | +- Register your project on Read the Docs, see [Importing Your |
| 116 | + Documentation](https://docs.readthedocs.io/en/stable/intro/import-guide.html). |
| 117 | + |
| 118 | +Read the Docs tutorial |
| 119 | +---------------------- |
| 120 | + |
| 121 | +To get started with Read the Docs, you may also refer to the [Read the |
| 122 | +Docs tutorial](https://docs.readthedocs.io/en/stable/tutorial/). It |
| 123 | +provides a full walk-through of building an example project similar to |
| 124 | +the one in this repository. |
0 commit comments