Skip to content

Commit 947c7a8

Browse files
author
Florian Maas
authored
Move from Sphinx to MkDocs for the cookiecutter package (#31)
1 parent cc6d075 commit 947c7a8

35 files changed

+209
-253
lines changed

.github/workflows/on-merge-to-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Documentation Test
2525
run: |
2626
source .venv/bin/activate
27-
make docs-verify
27+
make docs-test
2828
2929
tox:
3030
runs-on: ubuntu-latest

.github/workflows/on-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Documentation Test
2222
run: |
2323
source .venv/bin/activate
24-
make docs-verify
24+
make docs-test
2525
2626
tox:
2727
runs-on: ubuntu-latest

.github/workflows/on-release-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Documentation Test
2323
run: |
2424
source .venv/bin/activate
25-
make docs-verify
25+
make docs-test
2626
2727
tox:
2828
runs-on: ubuntu-latest

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ publish: ## publish a release to pypi.
4141

4242
build-and-publish: build publish ## Build and publish.
4343

44-
docs-verify: ## Check if MkDocs build does not return warnings or errors
44+
docs-test: ## Test if documentation can be built without warnings or errors
4545
@mkdocs build -s
4646

47-
docs-serve: ## Build and serve the MkDocs documentation
47+
docs: ## Build and serve the documentation
4848
@mkdocs serve
4949

50+
.PHONY: docs
51+
5052
.PHONY: help
5153

5254
help:

README.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Features
6565
+----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
6666
| **Release to Artifactory** | Release to `Artifactory <https://jfrog.com/artifactory>`_ by creating a new release on Github. |
6767
+----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
68-
| **Documentation with Sphinx** | Automatically add documentation to your project and its code with `Sphinx <https://www.sphinx-doc.org/>`_. |
68+
| **Documentation with MkDocs** | Automatically add documentation to your project and its code with `MkDocs <https://www.mkdocs.org/>`_. |
6969
+----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
7070
| **Tox testing** | Setup and CI/CD integration to easily test for different Python versions with `Tox <https://tox.wiki/>`_. |
7171
+----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
@@ -107,10 +107,13 @@ Then run the following commands, replacing ``<project-name>``, with the name tha
107107
git push -u origin main
108108
109109
110-
Finally, install the environment with ``make install``.
110+
Finally, install the environment with `make install`.
111111

112-
If you want to deploy to Pypi or Artifactory automatically on each release, you need to set
113-
some secrets in your repository on Github. For more information, see `the documentation <https://fpgmaas.github.io/cookiecutter-poetry/features/releasing.html>`_.
112+
You are now ready to start development on your project! The CI/CD pipeline will be triggered when you open a pull
113+
request, merge to main, or when you create a new release.
114+
115+
To finalize the set-up for publishing to PyPi or Artifactory through CI/CD, see `here <https://fpgmaas.github.io/cookiecutter-poetry/features/publishing/#set-up-for-pypi>`_.
116+
For activating the automatic documentation with MkDocs, see `here <https://fpgmaas.github.io/cookiecutter-poetry/features/mkdocs/#enabling-the-documentation-on-github>`_.
114117

115118

116119
Acknowledgements

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"project_description": "This is a template repository for Python projects that use Poetry for their dependency management.",
88
"include_github_actions": ["y","n"],
99
"publish_to": ["pypi", "artifactory", "none"],
10-
"sphinx_docs": ["y", "n"],
10+
"mkdocs": ["y", "n"],
1111
"tox": ["y","n"],
1212
"open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"]
1313
}

docs/features.md

Whitespace-only changes.

docs/features/cicd.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
---
2-
title: CI/CD with Github actions
3-
---
1+
2+
# CI/CD with Github actions
43

54
when `include_github_actions` is set to `"y"`, a `.github` directory is
65
added with the following structure:
@@ -28,14 +27,21 @@ formatting.
2827
made on the `main` branch. In addition, `on-release-main.yml` also
2928
publishes the project to Pypi or Artifactory if `publish_to` is set to
3029
`"pypi"` or `"artifactory"`, and it builds and deploys the documentation
31-
if `sphinx_docs` is set to `"y"`. To learn more about these features,
32-
see `Releasing to Pypi or Artifactory <./releasing>`{.interpreted-text
33-
role="doc"} and `Documentation with Sphinx
34-
<./sphinx>`{.interpreted-text role="doc"}
30+
if `mkdocs` is set to `"y"`. To learn more about these features,
31+
see [Publishing to PyPi or Artifactory](./publishing.md) and [Documentation with MkDocs](./mkdocs.md)
3532

3633
Additionally, all workflows check for compatibility with multiple Python
3734
versions if `tox` is set to `"y"`.
3835

36+
# How to trigger a release?
37+
38+
To trigger a new release, navigate to your repository on GitHub, click ``Releases`` on the right, and then select `Draft
39+
a new release`. If you fail to find the button, you could also directly visit
40+
`https://github.com/<username>/<repository-name>/releases/new`.
41+
42+
Give your release a title, and add a new tag in the form `*.*.*` where the
43+
`*`'s are alphanumeric. To finish, press `Publish release`.
44+
3945
## Example CI/CD Pipeline
4046

4147
[![Example pipeline](https://raw.githubusercontent.com/fpgmaas/cookiecutter-poetry/main/static/images/pipeline.png)](https://raw.githubusercontent.com/fpgmaas/cookiecutter-poetry/main/static/images/pipeline.png)

docs/features/makefile.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ build-and-publish Build and publish.
1919
docs-generate convert docstrings to docs
2020
docs-build Build the docs
2121
docs-open Open the docs in the browser
22-
docs Generate, build and open the docs.
23-
docs-build-test Test if the documentation can be built without errors.
22+
docs Build and serve the documentation
2423
docs-test Test if the documentation can be generated and built without errors.
2524
```

docs/features/mkdocs.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Documentation with MkDocs
2+
3+
4+
If `mkdocs` is set to `"y"`, documentation of your project is
5+
automatically added using
6+
[MkDocs](https://www.mkdocs.org/). Next to that, if
7+
`"include_github_actions"` is set to `"y"`, the documentation is
8+
automatically deployed to your `gh-pages` branch, and made available at
9+
`https://<github_handle>.github.io/<project_name>/`.
10+
11+
To view the documentation locally, simply run
12+
13+
``` bash
14+
make docs
15+
```
16+
17+
This command will generate, and build your documentation, and start the server locally so you can access it at
18+
<http://localhost:8000>.
19+
20+
## Enabling the documentation on GitHub
21+
22+
To enable your documentation on GitHub, first create a [new release](./cicd.md#how-to-trigger-a-release).
23+
24+
Then, in your repository, navigate to ``Settings > Code and Automation > Pages``. If you succesfully created a new release,
25+
you should see a notification saying `` Your site is ready to be published at https://<author_github_handle>.github.io/<project_name>/``.
26+
27+
To finalize deploying your documentation, under ``Source``, select the branch ``gh-pages``. Your documentation should then be live within a few minutes.
28+
29+
## Documenting docstrings
30+
31+
The generated project also converts all
32+
your docstrings into legible documentation. By default, the project is
33+
configured to work with
34+
[google](https://google.github.io/styleguide/pyguide.html) style
35+
docstrings.
36+
37+
An example of a Google style docstring:
38+
39+
``` python
40+
def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:
41+
"""Example function with PEP 484 type annotations.
42+
43+
Args:
44+
param1: The first parameter.
45+
param2: The second parameter.
46+
47+
Returns:
48+
The return value. True for success, False otherwise.
49+
```
50+
51+
For more examples, see
52+
[here](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).

0 commit comments

Comments
 (0)