Skip to content
Snippets Groups Projects
Verified Commit 4c399b26 authored by Romain Deville's avatar Romain Deville
Browse files

:pencil: Review documentation content

Review documentation, mainly update some links and fix grammatical mistakes.
parent b05e9656
No related branches found
No related tags found
No related merge requests found
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Template to easily setup and managed [mkdocs][mkdocs] documentation in folder Mkdocs Templates scaffolding project to host documentation configuration
to have homogenous documentation. and themes to manage homogenous documentation accros multiple projects.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
...@@ -49,13 +49,13 @@ projects. ...@@ -49,13 +49,13 @@ projects.
While [mkdocs][mkdocs] is a really usefull software allowing me to While [mkdocs][mkdocs] is a really usefull software allowing me to
write clean and clear documentation in markdown and render it as static write clean and clear documentation in markdown and render it as static
website, I was tired to always copy/paste same configuration accross all my website, I was tired to always copy/paste same configuration accross all my
projects documentations. project documentations.
Even worst, when I decide to change some minor things (such as color palettes), Even worst, when I decide to change some minor things (such as color palettes),
I had to go to each projects and for each project I had to replace manually I had to go to each project and for each project I had to replace manually
every time the same two configuration lines. every time the same two configuration lines.
This project aims is to ease the management of documentation configuration by This project aim is to ease the management of documentation configuration by
allowing to create a template and easily setup or upgrade it to a newer allowing to create a template and easily setup or upgrade it to a newer
version. version.
...@@ -78,7 +78,7 @@ chmod +x /tmp/setup_mkdocs.sh ...@@ -78,7 +78,7 @@ chmod +x /tmp/setup_mkdocs.sh
``` ```
Or if you already read the content of the script `setup.sh` at the root of this Or if you already read the content of the script `setup.sh` at the root of this
repo, previous commands can be done in online: repo, previous commands can be done in one line:
``` ```
# ASSUMING YOU ARE IN THE REPO FOR WHICH YOU WANT TO WRITE A DOCUMENTATION # ASSUMING YOU ARE IN THE REPO FOR WHICH YOU WANT TO WRITE A DOCUMENTATION
...@@ -169,4 +169,4 @@ You can now browse the full documentation by visiting ...@@ -169,4 +169,4 @@ You can now browse the full documentation by visiting
<!-- END MKDOCS TEMPLATE --> <!-- END MKDOCS TEMPLATE -->
[online_doc]: https://docs.romaindeville.fr/rdeville.public/my_programs/mkdocs_template/index.html [online_doc]: https://docs.romaindeville.fr/my_programs/mkdocs_template/index.html
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
example: example:
my_repo_slug: my_repo_slug:
name: My Main Repo Name name: My Main Repo Name
desc: Description of my [Main Repo](#) desc: Description of my [Main Repo]()
subrepo: subrepo:
roles: roles:
nav_entry: "Roles" nav_entry: "Roles"
......
...@@ -15,7 +15,8 @@ To do so, click on the button ++"燎 Fork"++ as shown below: ...@@ -15,7 +15,8 @@ To do so, click on the button ++"燎 Fork"++ as shown below:
![!Fork Mkdocs Template][fork_mkdocs_template] ![!Fork Mkdocs Template][fork_mkdocs_template]
Then, choose where you want to store your fork from your accessible namespace: Then, choose where you want to store your fork in one of your accessible
namespaces:
![!Fork Mkdocs Template Destination][fork_mkdocs_template_dest] ![!Fork Mkdocs Template Destination][fork_mkdocs_template_dest]
...@@ -44,20 +45,21 @@ git clone git@gitdomain.tld:namespace/mkdocs_template.git. ...@@ -44,20 +45,21 @@ git clone git@gitdomain.tld:namespace/mkdocs_template.git.
## Add the content of your template ## Add the content of your template
Now, to setup your own template, you just have to write it in the empty folder Now, to setup your own template, you just have to write it in the empty, but
but track `user_config` folder. If you happen to add a file with the same path tracked, folder `user_config`. If you happen to add a file with the same
from `template`, the your file will override the one in `template`. path from `template`, then your file will override the one in `template`.
For instance, if you create a file `user_config/docs/index.md`, its content will For instance, if you create a file `user_config/docs/index.md`, its content will
override the content of the file `template/docs/index.md` when using template. override the content of the file `template/docs/index.md` when using template.
Moreover, you can add a `post_setup.sh` script in `user_config` to handle Moreover, you can add a `post_setup.sh` script in `user_config` to handle
customized command once `setup.sh` finish. customized command once `setup.sh` finish. The script `post_setup.sh` will be
automatically included at the end of the execution of the script `setup.sh`.
Below are some examples such as a possible structure of `user_config` folder as Below are some examples, such as a possible structure of `user_config` folder as
well as some content exaple. Note that every files, hidden or not, within folder well as some content examples. Note that every files, hidden or not, within
`user_config` are copied when installed, which can be usefull to provide folder `user_config` are copied when installed, which can be usefull to provide
configuration workflow files, such as `.editorconfig`, `.gitignore`, etc. files. configuration workflow files, such as `.editorconfig`, `.gitignore`, etc.
=== "Folder `user_config`" === "Folder `user_config`"
...@@ -398,7 +400,7 @@ git remote -v ...@@ -398,7 +400,7 @@ git remote -v
> origin <URL_TO_YOUR_ORIGIN_REMOTE> (push) > origin <URL_TO_YOUR_ORIGIN_REMOTE> (push)
``` ```
If there is not upstream, add the `upstream` remote: If there is no `upstream`, add the `upstream` remote:
```bash ```bash
git remote add upstream {{ git_platform.url }}{{ curr_repo.git_slug_with_namespace }}.git git remote add upstream {{ git_platform.url }}{{ curr_repo.git_slug_with_namespace }}.git
......
{% set curr_repo=subs("mkdocs_template") %} {% set curr_repo=subs("mkdocs_template") %}
# Example # Example
This current documentation you are reading is actually using the custom template The current documentation you are reading is actually using the custom template
[Mkdocs Template R.Deville][mkdocs_template_rdeville]. [Mkdocs Template R.Deville][mkdocs_template_rdeville].
This custom template add a lots of things such as : This custom template add a lots of things such as :
...@@ -22,12 +22,10 @@ This custom template add a lots of things such as : ...@@ -22,12 +22,10 @@ This custom template add a lots of things such as :
Below is an example of the rendering of the preview of the basic template and Below is an example of the rendering of the preview of the basic template and
the custom template. the custom template.
=== "Basic Template" === "Basic Template"
![!Basic Template Preview][basic_template_preview] ![!Basic Template Preview][basic_template_preview]
=== "Custom Template" === "Custom Template"
![!Custom Template Preview][custom_template_preview] ![!Custom Template Preview][custom_template_preview]
......
...@@ -4,9 +4,10 @@ As you may have seen, the usage of this repo install a **really** basic ...@@ -4,9 +4,10 @@ As you may have seen, the usage of this repo install a **really** basic
template, with little to no configuration, neither extra content such as extra template, with little to no configuration, neither extra content such as extra
JS nor CSS. JS nor CSS.
But, you may want to use extra plugins such as [mkdocs-mermaid2-plugin] or But, you may want to use extra plugins such as
provide a basic README.md as well as licenses or a default file [mkdocs-mermaid2-plugin][mkdocs_mermaid2_plugin] or provide a basic `README.md`
`docs/_data/vars.yml` for all your documentation. as well as licenses or a default file `docs/_data/vars.yml` for all your
documentation.
To do so, you will need to create your own template and use it. To learn how to To do so, you will need to create your own template and use it. To learn how to
do, see: do, see:
......
# Configuration of the documentation # Configuration of the documentation
Once you have install files using the script `setup.sh`, and before starting to Once you have installed files using the script `setup.sh`, and before starting
render your documentation you will need some configuration to do: to render your documentation you will need some configuration to do:
## Base mkdocs configuration ## Base mkdocs configuration
Normally, most configuration of `mkdocs` is normally done in `mkdocs.yml` file, Normally, most configuration of `mkdocs` is done in `mkdocs.yml` file, but to be
but to be able to use a templated `mkdocs.yml`, most of the configuration is able to use a templated `mkdocs.yml`, most of the configuration is handled
handled differently. differently.
Now, it is the file `templates/docs/_data/plugins.py` which will handle the Now, it is the file `templates/docs/_data/plugins.py` which will handle the
configuration. This file is automatically called with the configuration. This file is automatically called with the
...@@ -25,7 +25,8 @@ vim docs/_data/vars.yaml ...@@ -25,7 +25,8 @@ vim docs/_data/vars.yaml
The file is heavily commented allowing you to know what you are updating. Note The file is heavily commented allowing you to know what you are updating. Note
that this part is optional, as most of the `mkdocs.yml` configuration is that this part is optional, as most of the `mkdocs.yml` configuration is
automatically set based on the repo information. automatically set based on the git repo information (git remote **origin**) and
[repo variables](#repo-variables).
[mkdocs_macros_plugins]: https://mkdocs-macros-plugin.readthedocs.io/en/latest/ [mkdocs_macros_plugins]: https://mkdocs-macros-plugin.readthedocs.io/en/latest/
...@@ -33,10 +34,10 @@ automatically set based on the repo information. ...@@ -33,10 +34,10 @@ automatically set based on the repo information.
!!! important "Ensure a git remote **origin** exists" !!! important "Ensure a git remote **origin** exists"
Before continuing, your documentation MUST be a git repository with a Before continuing, your documentation **MUST** be a git repository with a
remote **origin**. Indeed, the script `docs/_data/plugins.py` will get remote remote **origin**. Indeed, the script `docs/_data/plugins.py` will get
information to have the `repo_slug` to know which file in `docs/_data/` hold the remote information to have the `repo_slug` to know which file in
repository information. `docs/_data/` hold the repository information.
So assuming that your remote **origin** is So assuming that your remote **origin** is
`https://mygit.tld/namespace/my_repo_slug.git` (this work also for ssh remote). `https://mygit.tld/namespace/my_repo_slug.git` (this work also for ssh remote).
...@@ -50,8 +51,9 @@ cp docs/_data/template/repo.tpl.yaml docs/_data/my_repo_slug.yaml ...@@ -50,8 +51,9 @@ cp docs/_data/template/repo.tpl.yaml docs/_data/my_repo_slug.yaml
vim docs/_data/my_repo_slug.yaml vim docs/_data/my_repo_slug.yaml
``` ```
You will need to update some key of the repo which will be used to automatically You will need to update some keys in the repo file which will be used to
set `mkdocs.yml` configuration if not set in `docs/_data/vars.yaml`. automatically set `mkdocs.yml` configuration if not set in
`docs/_data/vars.yaml`.
For instance key `my_repo_slug['name']` will be used to dynamically set For instance key `my_repo_slug['name']` will be used to dynamically set
`site_name` key of the `mkdocs.yml`. `site_name` key of the `mkdocs.yml`.
...@@ -87,13 +89,14 @@ my_repo_slug: ...@@ -87,13 +89,14 @@ my_repo_slug:
# (OPTIONAL) Path, relative to `docs_dir` mkdocs config, to the logo of the # (OPTIONAL) Path, relative to `docs_dir` mkdocs config, to the logo of the
# repo. If not specified, path will automatically be set to # repo. If not specified, path will automatically be set to
# `assets/img/meta/reop_name_logo.png` # `assets/img/meta/repo_name_logo.png`
#logo: "assets/img/meta/repo_template_logo.png" #logo: "assets/img/meta/repo_name_logo.png"
# Description of the repo, will be used to setup the mkdocs description. # Description of the repo, will be used to setup the mkdocs description.
desc: >- desc: >-
An explicit description to explain what my repo do. Can be a multiline An explicit description to explain what my repo do. Can be a multiline
description with **markdown** support such as [link](https://url.domain.tld) description with **markdown** support such as
[link](https://url.domain.tld) and more.
# (OPTIONAL) If you plan to use `mkdocstring` plugins to render python # (OPTIONAL) If you plan to use `mkdocstring` plugins to render python
# source code, you will need to provide the path where your source files # source code, you will need to provide the path where your source files
...@@ -111,16 +114,17 @@ my_repo_slug: ...@@ -111,16 +114,17 @@ my_repo_slug:
## Subrepo Variables ## Subrepo Variables
If you are working on a big project, with multiple subrepo you might have or If you are working on a big project, with multiple subrepo you might have or
want to split a documentation per project but render all of them from a master want to split the documentation such as each project hold its own but render all
repository. of them from a master repository.
An example could be an [ansible collection][ansible_collection] which can be An example could be an [ansible collection][ansible_collection] which can be
composed of a master repository holding specific file and folders holdings composed of a master repository holding specific files and folders holdings
things like roles, etc. In this case, you might want to keep roles in other git things like roles, etc. In this case, you might want to keep roles in other git
repository (like git submodules) and each of the role holds its own collection. repository (like git submodules) and each of the role holds its own
But you want the final rendered documentation to include these repos. documentation. But you want the final rendered documentation to include these
repos.
This can be done via a file describing such subrepo, i.e. This can be done via a file describing such subrepo, i.e. the file
`docs/_data/subrepo.yaml`. To do so, copy the template provided in `docs/_data/subrepo.yaml`. To do so, copy the template provided in
`docs/_data/template/subrepo.tpl.yml`. `docs/_data/template/subrepo.tpl.yml`.
...@@ -158,13 +162,14 @@ subrepo: ...@@ -158,13 +162,14 @@ subrepo:
git_url: https://gitdomain.tld/namespace/subnamespace/my_role_name_2 git_url: https://gitdomain.tld/namespace/subnamespace/my_role_name_2
``` ```
If you want to add link to external documentation, i.e. they will be included in If you want to add link to external documentation, i.e. a link to the home page
the `nav` of the main repo but their own `nav` will not be include, this can will be included in the `nav` of the main repo but their own `nav` will not be
also be done with the file `docs/_data/subrepo.yaml`. included, this can also be done with the file `docs/_data/subrepo.yaml`.
An example could be a main repo simply providing entry point to other repo, such An example could be a main repo simply providing entry point to other repos,
as repo holding base content of [docs.romaindeville.fr][docs.romaindeville.fr]. such as repo holding base content of
Below is an example of the content of such `subrepo.yaml` file: [docs.romaindeville.fr][docs.romaindeville.fr]. Below is an example of the
content of such `subrepo.yaml` file:
```yaml ```yaml
...@@ -196,7 +201,7 @@ subrepo: ...@@ -196,7 +201,7 @@ subrepo:
online_url: https://domain.tld/full/external/link/ online_url: https://domain.tld/full/external/link/
``` ```
Of course, both `internal` and `external` can be used as show below (click to Of course, both `internal` and `external` can be used as shown below (click to
reveal). reveal).
??? Example ??? Example
...@@ -256,22 +261,22 @@ reveal). ...@@ -256,22 +261,22 @@ reveal).
``` ```
Thus, when rendering the documentation, the script `docs/_data/plugins.py` will Thus, when rendering the documentation, the script `docs/_data/plugins.py` will
check if folders `roles/{role_name_1,role_name_2}`, if they exists and are git check if folders `roles/{role_name_1,role_name_2}` exists. If they exists and
repo, script will pull them to get the last version. If they do not exists, the are git repo, script will pull them to get the last version. If they do not
will be cloned. exists, the will be cloned.
Finally, the script `docs/_data/plugins.py` will update the `nav` of the Finally, the script `docs/_data/plugins.py` will update the `nav` of the
documentation with these repos and will load file `docs/_data/repo.yaml` documentation with these repos and will load file `docs/_data/repo.yaml`
allowing to access to the repo informations. of each repo allowing to access to the repo informations.
## Extra variables ## Extra variables
All of the above file will create variables which can be use in your All of the above files will create variables which can be used in your
documentation using [mkdocs-macros-plugin][mkdocs-macros-plugin]. If you want to documentation using [mkdocs-macros-plugin][mkdocs-macros-plugin]. If you want to
add extra variables which are not in `vars.yaml`, nor `repo.yaml`, neither in add extra variables which are not in `vars.yaml`, nor `repo.yaml`, neither in
`subrepo.yaml`, you can do it by settings them in a file `subrepo.yaml`, you can do it by settings them in a file
`docs/_data/extra.yaml`. Indeed, previously mentionned filed will be check `docs/_data/extra.yaml`. Indeed, previously mentionned filed will be checked
against a schema (provided in `docs/_data/{repo,subrepo,vars}.schema.yaml`), against a schema (provided in `docs/_data/{repo,subrepo,vars}.schema.yaml`),
thus do not allow extra variables to ensure stability of script thus do not allow extra variables to ensure stability of script
`docs/_data/plugins.py` while file `docs/_data/extra.yaml` is loaded as it is `docs/_data/plugins.py` while file `docs/_data/extra.yaml` is loaded as it is
...@@ -281,11 +286,11 @@ without schema control. ...@@ -281,11 +286,11 @@ without schema control.
## Variable usage ## Variable usage
Finally, as describe above some variables are used during the rendering of the Finally, as describe above some variables are used for the configuration to
documentation. But they can also be use in your markdown documentation files using render documentation. But they can also be use in your markdown documentation
jinja. For instance, below is a basic content of a markdown file showing the files using jinja template. For instance, below is a basic content of a markdown
name of the repo, its description and a list of roles and programs with their file showing the name of the main repo, its description and a list of roles and
description. programs with their description.
=== "Markdown" === "Markdown"
......
...@@ -25,7 +25,7 @@ chmod +x /tmp/setup_mkdocs.sh ...@@ -25,7 +25,7 @@ chmod +x /tmp/setup_mkdocs.sh
``` ```
Or if you already read the content of the script `setup.sh` at the root of this Or if you already read the content of the script `setup.sh` at the root of this
repo, previous commands can be done in online: repo, previous commands can be done in one line:
```bash ```bash
# ASSUMING YOU ARE IN THE REPO FOR WHICH YOU WANT TO WRITE A DOCUMENTATION # ASSUMING YOU ARE IN THE REPO FOR WHICH YOU WANT TO WRITE A DOCUMENTATION
...@@ -36,8 +36,8 @@ curl -sfL \ ...@@ -36,8 +36,8 @@ curl -sfL \
-r {{ git_platform.url }}{{ curr_repo.git_slug_with_namespace }} -r {{ git_platform.url }}{{ curr_repo.git_slug_with_namespace }}
``` ```
This will automatically copy the content of folder `templates` of the project in This will automatically copy the content of folder `templates` of the Mkdocs
the folder where you are located. Template project in the folder where you are located.
Note that some copied files will have comment tag automatically added if they Note that some copied files will have comment tag automatically added if they
are not present. For instance, following example content: are not present. For instance, following example content:
...@@ -48,7 +48,7 @@ are not present. For instance, following example content: ...@@ -48,7 +48,7 @@ are not present. For instance, following example content:
Sample content of a page Sample content of a page
``` ```
Wille be copied with the following tags: Will be copied with the following tags:
```md ```md
<!-- BEGIN MKDOCS TEMPLATE --> <!-- BEGIN MKDOCS TEMPLATE -->
...@@ -61,15 +61,15 @@ Sample content of a page ...@@ -61,15 +61,15 @@ Sample content of a page
<!-- END MKDOCS TEMPLATE --> <!-- END MKDOCS TEMPLATE -->
``` ```
These tags serve as delimiter of the template content, without theme, any These tags serve as delimiter of the template content, without them, any
modification you may have done on copied file will be overwritten when you will modification you may have done on copied files will be overwritten when you will
upgrade to a latest template version. upgrade to a latest template version.
So this allow you to add content before and after these tags, content you will So this allow you to add content before and after these tags, content you will
add before and after will not be modified when upgrading while content between add before and after will not be modified when upgrading while content between
tags might be updated if latest version contain updte. tags might be updated if latest version contain update.
In other words, you might do the following update: In other words, you might do the following:
```md ```md
# Previous title # Previous title
...@@ -92,7 +92,7 @@ Content added by the user, which will not be updated in case of upgrade of the ...@@ -92,7 +92,7 @@ Content added by the user, which will not be updated in case of upgrade of the
template. template.
``` ```
The tag comment depends of the extension of the file copied: The tag comment depends on the extension of the file copied:
- `*.md`, `*.html` or `*LICENSE`, will have following tags: - `*.md`, `*.html` or `*LICENSE`, will have following tags:
```html ```html
...@@ -100,7 +100,7 @@ The tag comment depends of the extension of the file copied: ...@@ -100,7 +100,7 @@ The tag comment depends of the extension of the file copied:
<!-- WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG ! --> <!-- WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG ! -->
<!-- Modified content will be overwritten when updating --> <!-- Modified content will be overwritten when updating -->
[...] []
<!-- END MKDOCS TEMPLATE --> <!-- END MKDOCS TEMPLATE -->
``` ```
...@@ -111,7 +111,7 @@ The tag comment depends of the extension of the file copied: ...@@ -111,7 +111,7 @@ The tag comment depends of the extension of the file copied:
/* WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG ! */ /* WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG ! */
/* Modified content will be overwritten when updating */ /* Modified content will be overwritten when updating */
[...] []
/* END MKDOCS TEMPLATE */ /* END MKDOCS TEMPLATE */
``` ```
...@@ -123,16 +123,16 @@ The tag comment depends of the extension of the file copied: ...@@ -123,16 +123,16 @@ The tag comment depends of the extension of the file copied:
### Modified content will be overwritten when updating ### ### Modified content will be overwritten when updating ###
### ###
[...] []
### END MKDOCS TEMPLATE ### ### END MKDOCS TEMPLATE ###
``` ```
- Other extension files will not have comment tags, this is mainly for source - Files with other extension will not have comment tags, this is mainly for
code file or svg images for instance. source code file or svg images for instance.
Moreover, is there is already mkdocs tag in the file, the complete file will be Moreover, if there is already mkdocs tags in the file, the complete file will be
copied during setup but only content between tags will be overwritten when copied during setup but only content between tags will be overwritten when
upgrading. upgrading.
...@@ -142,6 +142,6 @@ all of the file will be installed while when upgrading only content between tag ...@@ -142,6 +142,6 @@ all of the file will be installed while when upgrading only content between tag
will be overwritten. will be overwritten.
Once you have install the mkdocs template files using the script `setup.sh` you Once you have install the mkdocs template files using the script `setup.sh` you
know have some [configuration][configuration] to do. now have some [configuration][configuration] to do.
[configuration]: configure.md [configuration]: configure.md
{% set curr_repo=subs("mkdocs_template") %} {% set curr_repo=subs("mkdocs_template") %}
# Upgrade to latest template # Upgrade to latest template
If the source template get new features, like improving `plugins.py·` script, If the source template get new features, like improving `plugins.py` script,
you might want to get them. To to so is as easy as installing the documentation. you might want to get them. To do so is as easy as installing the documentation.
This is done using the script `setup.sh` with the option `-u`. Below is a recall This is done using the script `setup.sh` with the option `-u`. Below is a recall
of the usage of the script of the usage of the script
...@@ -10,11 +10,10 @@ of the usage of the script ...@@ -10,11 +10,10 @@ of the usage of the script
## How to upgrade ## How to upgrade
This is done by using the option `-u` of the script `setup.sh`. Using this This is done by using the option `-u` of the script `setup.sh`. Using this
option, the script will compare last version with old version of each files, if option, the script will compare last version with old version of each files. If
they have changed, backup the old version, to avoid losing content in case of error they have changed, backup the old version, to avoid losing content in case of
and then upgrade the files to the latest version. error and then upgrade the files to the latest version.
```bash ```bash
# ASSUMING YOU ARE IN THE REPO FOR WHICH YOU WANT TO WRITE A DOCUMENTATION # ASSUMING YOU ARE IN THE REPO FOR WHICH YOU WANT TO WRITE A DOCUMENTATION
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment