Skip to content

Commit f74b76e

Browse files
committed
Upgrading MkDocs example project to be almost 1:1 with Sphinx example
1 parent 018d2e9 commit f74b76e

File tree

8 files changed

+192
-93
lines changed

8 files changed

+192
-93
lines changed

README.md

Lines changed: 40 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,66 @@
1-
Example: Basic Sphinx project for Read the Docs
1+
Example: Basic MkDocs project for Read the Docs
22
===============================================
33

4-
[![Documentation Status](https://readthedocs.org/projects/example-sphinx-basic/badge/?version=latest)](https://example-sphinx-basic.readthedocs.io/en/latest/?badge=latest)
4+
[![Documentation Status](https://readthedocs.org/projects/example-mkdocs-basic/badge/?version=latest)](https://example-mkdocs-basic.readthedocs.io/en/latest/?badge=latest)
55

6-
This example shows the an integration of a basic Sphinx project with
6+
This example shows the an integration of a basic MkDocs project with
77
Read the Docs. You\'re encouraged to view it to get inspiration and copy
88
& paste from the files in the source code. If you are using Read the
99
Docs for the first time, have a look at the official [Read the Docs
1010
Tutorial](https://docs.readthedocs.io/en/stable/tutorial/index.html).
1111

12-
📚 [docs/](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/)
12+
📚 [docs/](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/)<br>
13+
A basic MkDocs project lives in `docs/`, it was generated using
14+
MkDocs defaults. All the `*.md` make up sections in the
15+
documentation.
1316

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+
⚙️ [.readthedocs.yaml](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/.readthedocs.yaml)<br>
18+
Read the Docs Build configuration is stored in `.readthedocs.yaml`.
1719

18-
⚙️ [.readthedocs.yaml](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/.readthedocs.yaml)
20+
⚙️ [mkdocs.yml](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/mkdocs.yaml)<br>
21+
A basic [MkDocs configuration](https://www.mkdocs.org/user-guide/configuration/) is stored here, including a few extensions for MkDocs and Markdown. Add your own configurations here, such as extensions and themes. Remember that many extensions and themes require additional Python packages to be installed.
1922

20-
Read the Docs Build configuration is stored in `.readthedocs.yaml`.
23+
📍 [docs/requirements.txt](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/requirements.txt) and [docs/requirements.in](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/requirements.in)<br>
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/)) here. 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 to run `pip-compile docs/requirements.in`.
2127

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)
28+
💡 [docs/api.md](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/api.md)<br>
29+
We add our example Python module `lumache` in order to auto-generate an API reference. To do this, we use the `:::` syntax, you can read more in the [mkdocstrings documentation](https://mkdocstrings.github.io/).
2330

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/)).
31+
💡 [docs/usage.md](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/usage.md)<br>
32+
We also include some direct links to a function from the API reference, as well as embedding documentation for the example function `lumache.get_random_recipe`. This functionality is also from the [mkdocstrings](https://mkdocstrings.github.io/python/) extension.
2733

28-
💡 [docs/api.rst](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/api.rst)
34+
💡 [lumache.py](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/lumache.py)<br>
35+
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. We use the [Sphinx convention](https://pythonhosted.org/an_example_pypi_project/sphinx.html#function-definitions) for docstrings, however you are free to edit `mkdocs.yml` to change this option to `google` or `numpy`.
2936

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.
37+
🔢 Git tags versioning<br>
38+
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
39+
[example-mkdocs-basic.readthedocs.io](https://example-mkdocs-basic.readthedocs.io/en/latest/).
3340

34-
💡 [docs/usage.rst](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/docs/usage.rst)
41+
📜 [README.rst](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/README.rst)<br>
42+
Contents of this `README.md` are visible on Github and included on
43+
[the documentation index
44+
page](https://example-mkdocs-basic.readthedocs.io/en/latest/)
45+
(Don\'t Repeat Yourself).
3546

36-
Sphinx can automatically extract API documentation directly from
37-
Python modules, using for instance the `:autofunction:` directive.
47+
⁉️ Questions / comments<br>
48+
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-mkdocs-basic/issues).
3849

39-
💡 [lumache.py](https://github.com/readthedocs-examples/example-sphinx-basic/blob/main/lumache.py)
4050

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.
51+
Example Project usage
52+
---------------------
4453

45-
🔢 Git tags versioning
54+
This project has a standard MkDocs layout which is built by Read the Docs almost the same way that you would build it locally (on your own laptop!).
4655

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/).
56+
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):
5157

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.)
58+
```console
59+
# Install required Python dependencies (MkDocs etc.)
7860
pip install -r docs/requirements.txt
7961

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
62+
# Run the mkdocs development server
63+
mkdocs serve
9864
```
9965

10066
Using the example in your own project
@@ -108,7 +74,7 @@ documentation, you need to:
10874

10975
- Create a new repository on Github, GitLab, Bitbucket or another host
11076
supported by Read the Docs
111-
- Customize all `docs/*.rst` files
77+
- Customize all `docs/*.md` files and copy in `mkdocs.yaml`
11278
- Add your own Python project, replacing the `pyproject.toml`
11379
configuration and `lumache.py` module.
11480
- Rebuild the documenation locally to see that it works.

docs/api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# API Reference
2+
3+
::: lumache

docs/index.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
# Welcome to MkDocs
1+
{!README.md!}
22

3-
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
3+
# Welcome to Lumache's documentation!
44

5-
## Commands
5+
**Lumache** (/lu\'make/) is a Python library for cooks and food lovers
6+
that creates recipes mixing random ingredients. It pulls data from the
7+
[Open Food Facts database](https://world.openfoodfacts.org/) and offers
8+
a *simple* and *intuitive* API.
69

7-
* `mkdocs new [dir-name]` - Create a new project.
8-
* `mkdocs serve` - Start the live-reloading docs server.
9-
* `mkdocs build` - Build the documentation site.
10-
* `mkdocs -h` - Print help message and exit.
10+
Check out the [usage](usage) section for further information, including how to [install](usage#installation) the project.
1111

12-
## Project layout
12+
!!! note
1313

14-
mkdocs.yml # The configuration file.
15-
docs/
16-
index.md # The documentation homepage.
17-
... # Other markdown pages, images and other files.
14+
This project is under active development.
1815

19-
# Reference
20-
21-
::: lumache

docs/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mkdocs
22
mkdocstrings[python]
3+
markdown-include

docs/requirements.txt

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,66 @@
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+
click==8.1.3
8+
# via mkdocs
9+
ghp-import==2.1.0
10+
# via mkdocs
11+
griffe==0.22.0
12+
# via mkdocstrings-python
13+
importlib-metadata==4.12.0
14+
# via mkdocs
15+
jinja2==3.1.2
16+
# via
17+
# mkdocs
18+
# mkdocstrings
19+
markdown==3.3.7
20+
# via
21+
# markdown-include
22+
# mkdocs
23+
# mkdocs-autorefs
24+
# mkdocstrings
25+
# pymdown-extensions
26+
markdown-include==0.6.0
27+
# via -r docs/requirements.in
28+
markupsafe==2.1.1
29+
# via
30+
# jinja2
31+
# mkdocstrings
32+
mergedeep==1.3.4
33+
# via mkdocs
134
mkdocs==1.3.0
2-
mkdocstrings==0.19.0[python]
35+
# via
36+
# -r docs/requirements.in
37+
# mkdocs-autorefs
38+
# mkdocstrings
39+
mkdocs-autorefs==0.4.1
40+
# via mkdocstrings
41+
mkdocstrings[python]==0.19.0
42+
# via
43+
# -r docs/requirements.in
44+
# mkdocstrings-python
45+
mkdocstrings-python==0.7.1
46+
# via mkdocstrings
47+
packaging==21.3
48+
# via mkdocs
49+
pymdown-extensions==9.5
50+
# via mkdocstrings
51+
pyparsing==3.0.9
52+
# via packaging
53+
python-dateutil==2.8.2
54+
# via ghp-import
55+
pyyaml==6.0
56+
# via
57+
# mkdocs
58+
# pyyaml-env-tag
59+
pyyaml-env-tag==0.1
60+
# via mkdocs
61+
six==1.16.0
62+
# via python-dateutil
63+
watchdog==2.1.9
64+
# via mkdocs
65+
zipp==3.8.0
66+
# via importlib-metadata

docs/usage.md

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+
7+
To use Lumache, first install it using pip:
8+
9+
```console
10+
(.venv) $ pip install lumache
11+
```
12+
13+
Creating recipes
14+
----------------
15+
16+
To retrieve a list of random ingredients, you can use the
17+
`lumache.get_random_ingredients()` function:
18+
19+
::: lumache.get_random_ingredients
20+
options:
21+
show_root_heading: true
22+
23+
<br>
24+
25+
The `kind` parameter should be either `"meat"`, `"fish"`, or `"veggies"`.
26+
Otherwise, [`get_random_ingredients`][lumache.get_random_ingredients] will raise an exception [`lumache.InvalidKindError`](/api#lumache.InvalidKindError).
27+
28+
For example:
29+
30+
```python
31+
>>> import lumache
32+
>>> lumache.get_random_ingredients()
33+
['shells', 'gorgonzola', 'parsley']
34+
```

mkdocs.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
site_name: My Docs
2-
theme: readthedocs
1+
site_name: Basic MkDocs Example Project
2+
theme:
3+
name: readthedocs
4+
highlightjs: true
35
plugins:
46
- search
5-
- mkdocstrings
7+
- mkdocstrings:
8+
handlers:
9+
# See: https://mkdocstrings.github.io/python/usage/
10+
python:
11+
options:
12+
docstring_style: sphinx
13+
markdown_extensions:
14+
- markdown_include.include:
15+
base_path: .
16+
- admonition

test.md

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

0 commit comments

Comments
 (0)