Skip to content

Commit 285ddd0

Browse files
committed
Use MkDocs to build the documentation
The documentation is generated using MkDocs, using the Material theme plus mkdocstrings (and a few minor supporting extensions) to build the API documentation extracted from code comments. For now the home page is a place holder, and the supporting script `docs/mkdocstrings-autoapi.py` should eventually be moved to a common repository. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 7584469 commit 285ddd0

File tree

14 files changed

+265
-5
lines changed

14 files changed

+265
-5
lines changed

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
"part:docs":
2323
- "**/*.md"
24+
- "docs/**"
2425
- LICENSE
2526

2627
"part:microgrid":
@@ -35,11 +36,14 @@
3536
"part:tooling":
3637
- "**/*.ini"
3738
- "**/*.toml"
39+
- "**/*.yaml"
40+
- "**/*.yml"
3841
- "*requirements*.txt"
3942
- ".git*"
4043
- ".git*/**"
4144
- CODEOWNERS
4245
- MANIFEST.in
46+
- docs/mkdocstrings_autoapi.py
4347
- noxfile.py
4448
- setup.cfg
4549
- setup.py

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,7 @@ cython_debug/
140140

141141
# PyCharm
142142
.idea
143+
144+
# Automatically generated documentation
145+
docs/reference/
146+
site/

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ python -m pip install pytest pytest-asyncio
4141
pytest tests/test_sdk.py
4242
```
4343

44+
To build the documentation, first install the dependencies:
45+
46+
```sh
47+
python -m pip install -e .[docs]
48+
```
49+
50+
Then you can build the documentation (it will be written in the `site/`
51+
directory):
52+
53+
```sh
54+
mkdocs build
55+
```
56+
57+
Or you can just serve the documentation without building it using:
58+
59+
```sh
60+
mkdocs serve
61+
```
62+
4463
## Releasing
4564

4665
These are the steps to create a new release:

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ A development kit to interact with the Frequenz development platform.
1010
## Contributing
1111

1212
If you want to know how to build this project and contribute to it, please
13-
check out the [Contributing
14-
Guide](https://github.com/frequenz-floss/frequenz-sdk-python/CONTRIBUTING.md).
13+
check out the [Contributing Guide](CONTRIBUTING.md).

docs/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--8<-- "CONTRIBUTING.md"

docs/SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* [Home](index.md)
2+
* [API Reference](reference/)
3+
* [Development](CONTRIBUTING.md)

docs/css/mkdocstrings.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* Recommended style from:
2+
* https://mkdocstrings.github.io/python/customization/#recommended-style-material
3+
* With some additions from:
4+
* https://github.com/mkdocstrings/mkdocstrings/blob/master/docs/css/mkdocstrings.css
5+
*/
6+
7+
/* Indentation. */
8+
div.doc-contents:not(.first) {
9+
padding-left: 25px;
10+
border-left: .05rem solid var(--md-typeset-table-color);
11+
}
12+
13+
/* Indentation. */
14+
div.doc-contents:not(.first) {
15+
padding-left: 25px;
16+
border-left: 4px solid rgba(230, 230, 230);
17+
margin-bottom: 80px;
18+
}
19+
20+
/* Avoid breaking parameters name, etc. in table cells. */
21+
td code {
22+
word-break: normal !important;
23+
}
24+
25+
/* Mark external links as such. */
26+
a.autorefs-external::after {
27+
/* https://primer.style/octicons/arrow-up-right-24 */
28+
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="rgb(0, 0, 0)" d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
29+
content: ' ';
30+
31+
display: inline-block;
32+
position: relative;
33+
top: 0.1em;
34+
margin-left: 0.2em;
35+
margin-right: 0.1em;
36+
37+
height: 1em;
38+
width: 1em;
39+
border-radius: 100%;
40+
background-color: var(--md-typeset-a-color);
41+
}
42+
a.autorefs-external:hover::after {
43+
background-color: var(--md-accent-fg-color);
44+
}

docs/css/style.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Based on:
2+
* https://github.com/mkdocstrings/mkdocstrings/blob/master/docs/css/style.css
3+
*/
4+
5+
/* Increase logo size */
6+
.md-header__button.md-logo {
7+
padding-bottom: 0.2rem;
8+
padding-right: 0;
9+
}
10+
.md-header__button.md-logo img {
11+
height: 1.5rem;
12+
}
13+
14+
/* Mark external links as such (also in nav) */
15+
a.external:hover::after, a.md-nav__link[href^="https:"]:hover::after {
16+
/* https://primer.style/octicons/link-external-16 */
17+
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="rgb(233, 235, 252)" d="M10.604 1h4.146a.25.25 0 01.25.25v4.146a.25.25 0 01-.427.177L13.03 4.03 9.28 7.78a.75.75 0 01-1.06-1.06l3.75-3.75-1.543-1.543A.25.25 0 0110.604 1zM3.75 2A1.75 1.75 0 002 3.75v8.5c0 .966.784 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 12.25v-3.5a.75.75 0 00-1.5 0v3.5a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25v-8.5a.25.25 0 01.25-.25h3.5a.75.75 0 000-1.5h-3.5z"></path></svg>');
18+
height: 0.8em;
19+
width: 0.8em;
20+
margin-left: 0.2em;
21+
content: ' ';
22+
display: inline-block;
23+
}
24+
25+
/* More space at the bottom of the page */
26+
.md-main__inner {
27+
margin-bottom: 1.5rem;
28+
}

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--8<-- "README.md"

docs/logo.png

55.9 KB
Loading

0 commit comments

Comments
 (0)