Skip to content

Commit ccaebe7

Browse files
authored
Merge pull request #1 from readthedocs-examples/bootstrap
Bootstrap basic example contents for 1.0
2 parents 4e28434 + a531e29 commit ccaebe7

File tree

9 files changed

+245
-15
lines changed

9 files changed

+245
-15
lines changed

README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
1-
# example-mkdocs-basic
2-
A basic MkDocs project for Read the Docs
1+
Example: Basic MkDocs project for Read the Docs
2+
===============================================
3+
4+
[![Documentation Status](https://readthedocs.org/projects/example-mkdocs-basic/badge/?version=latest)](https://example-mkdocs-basic.readthedocs.io/en/latest/?badge=latest)
5+
6+
This example shows the an integration of a basic MkDocs 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-mkdocs-basic/blob/main/docs/)<br>
9+
A basic MkDocs project lives in `docs/`, it was generated using MkDocs defaults. All the `*.md` make up sections in the documentation.
10+
11+
⚙️ [.readthedocs.yaml](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/.readthedocs.yaml)<br>
12+
Read the Docs Build configuration is stored in `.readthedocs.yaml`.
13+
14+
⚙️ [mkdocs.yml](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/mkdocs.yaml)<br>
15+
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.
16+
17+
📍 [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>
18+
Python dependencies are [pinned](https://docs.readthedocs.io/en/latest/guides/reproducible-builds.html) (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`.
19+
20+
💡 [docs/api.md](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/api.md)<br>
21+
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/).
22+
23+
💡 [docs/usage.md](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/usage.md)<br>
24+
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.
25+
26+
💡 [lumache.py](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/lumache.py)<br>
27+
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`.
28+
29+
🔢 Git tags versioning<br>
30+
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
31+
[example-mkdocs-basic.readthedocs.io](https://example-mkdocs-basic.readthedocs.io/en/latest/).
32+
33+
📜 [README.rst](https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/README.rst)<br>
34+
Contents of this `README.md` are visible on Github and included on [the documentation index page](https://example-mkdocs-basic.readthedocs.io/en/latest/) (Don\'t Repeat Yourself).
35+
36+
⁉️ Questions / comments<br>
37+
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).
38+
39+
40+
Example Project usage
41+
---------------------
42+
43+
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!).
44+
45+
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):
46+
47+
```console
48+
# Install required Python dependencies (MkDocs etc.)
49+
pip install -r docs/requirements.txt
50+
51+
# Run the mkdocs development server
52+
mkdocs serve
53+
```
54+
55+
Using the example in your own project
56+
-------------------------------------
57+
58+
If you are new to Read the Docs, you may want to refer to the [Read the Docs User documentation](https://docs.readthedocs.io/).
59+
60+
If you are copying this code in order to get started with your documentation, you need to:
61+
62+
1. place your `docs/` folder alongside your Python project. If you are starting a new project, you can adapt the `pyproject.toml` example configuration.
63+
1. use your existing project repository or create a new repository on Github, GitLab, Bitbucket or another host supported by Read the Docs.
64+
1. copy in `mkdocs.yaml`, `.readthedocs.yml` and the `docs/` folder into your project. Customize all the files, replacing example contents.
65+
1. Rebuild the documenation locally to see that it works.
66+
1. *Finally*, register your project on Read the Docs, see [Importing Your Documentation](https://docs.readthedocs.io/en/stable/intro/import-guide.html).
67+
68+
69+
Read the Docs tutorial
70+
----------------------
71+
72+
To get started with Read the Docs, you may also refer to the [Read the Docs tutorial](https://docs.readthedocs.io/en/stable/tutorial/). It provides a full walk-through of building an example project similar to the one in this repository.

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: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +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
13+
14+
This project is under active development.
1315

14-
mkdocs.yml # The configuration file.
15-
docs/
16-
index.md # The documentation homepage.
17-
... # Other markdown pages, images and other files.

docs/requirements.in

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

docs/requirements.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +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
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+
```

lumache.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Lumache - Python library for cooks and food lovers.
3+
4+
This is a Python docstring, we can use Markdown syntax here because
5+
our API documentation library understands it (mkdocstrings).
6+
7+
# Import lumache
8+
import lumache
9+
10+
# Call its only function
11+
get_random_ingredients(kind=["cheeses"])
12+
13+
"""
14+
15+
__version__ = "0.1.0"
16+
17+
18+
class InvalidKindError(Exception):
19+
"""Raised if the kind is invalid."""
20+
21+
pass
22+
23+
24+
def get_random_ingredients(kind=None):
25+
"""
26+
Return a list of random ingredients as strings.
27+
28+
:param kind: Optional "kind" of ingredients.
29+
:type kind: list[str] or None
30+
:raise lumache.InvalidKindError: If the kind is invalid.
31+
:return: The ingredients list.
32+
:rtype: list[str]
33+
"""
34+
return ["shells", "gorgonzola", "parsley"]

mkdocs.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
site_name: My Docs
1+
site_name: Basic MkDocs Example Project
2+
theme:
3+
name: readthedocs
4+
highlightjs: true
5+
plugins:
6+
- search
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

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build-system]
2+
requires = ["flit_core >=3.2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "lumache"
7+
authors = [{name = "Graziella", email = "graziella@lumache"}]
8+
dynamic = ["version", "description"]

0 commit comments

Comments
 (0)