Document Management
Overview#
Our documentation is powered by Material for MkDocs with some additional plugins and tools:
- awesome-pages plugin
- macros plugin
- mike for multiple version support
We have support in place for multiple languages (i18n), although we currently only have documentation in English. If you're interested in contributing translations, please let us know!
Serving up documents locally#
You can view and modify our documentation in your local development environment. Simply checkout one of our branches.
You can view and modify our documentation in the branch you have checked out by using mkdocs serve
from mkdocs. We have a Python requirements file in requirements.txt
, and a Makefile target that builds a Python virtual environment and installs the requirements there. You can either install those requirements into your global Python environment or use the Makefile target. To install those requirements into your global Python environment, do the following usual thing.
Alternatively, use the following commands to use the Makefile target to construct an adequate virtual environment and enter it.
Then, using your chosen environment with the requirements installed, build and serve the documents with the following command.
Then open a browser tohttp://localhost:8000/
Another way to view (not modify - this method reflects what has been deployed to the gh-pages
branch of our repo) all branches/versions of our documentation locally using 'mike' mike for mkdocs:
git clone git@github.com:kubestellar/kubestellar.git
cd kubestellar
git checkout main
cd docs
mike set-default main
cd ..
make serve-docs
http://localhost:8000/
File structure#
All documentation-related items live in docs
(with the small exception of various make
targets and some helper
scripts in hack
).
The structure of docs
is as follows:
Path | Description |
---|---|
config/$language/mkdocs.yml | Language-specific mkdocs configuration. |
content/$language | Language-specific website content. |
generated/branch | All generated content for all languages for the current version. |
generated/branch/$language | Generated content for a single language. Never added to git. |
generated/branch/index.html | Minimal index for the current version that redirects to the default language (en) |
overrides | Global (not language-specific) content. |
Dockerfile | Builds the kubestellar-docs image containing mkdocs + associated tooling. |
mkdocs.yml | Minimal mkdocs configuration for mike for multi-version support. |
requirements.txt | List of Python modules used to build the site. |
Global Variables#
There are many global variables defined in the docs/mkdocs.yml. The following are some very common variables you are encouraged to use in our documentation. Use of these variables/macros allows our documentation to have github branch context and take advantage of our evolution without breaking
- site_name: KubeStellar
- repo_url: https://github.com/kubestellar/kubestellar
- site_url: https://docs.kubestellar.io/main
- repo_default_file_path: kubestellar
- repo_short_name: kubestellar/kubestellar
- docs_url: https://docs.kubestellar.io
- repo_raw_url: https://raw.githubusercontent.com/kubestellar/kubestellar
- edit_uri: edit/main/docs/content/
- ks_branch: main
- ks_tag: latest
to use a variables/macro in your documentation reference like this:
{{ config.<var_name> }}
and in context that can look something like this:
bash <(curl -s {{ config.repo_raw_url }}/{{ config.ks_branch }}/bootstrap/bootstrap-kubestellar.sh) --kubestellar-version {{ config.ks_tag }}
note:
- A more extensive and detailed list is located at mkdocs information
- We also check for broken links as part of our PR pipeline. For more information check out our Broken Links Crawler
Including external markdown#
We make extensive use of 'include-markdown' to help us keep our documentation modular and up-to-date. To use 'include-markdown' you must add a block in your document that refers to a block in your external document content:
In your original markdown document, add a block that refers to the external markdown you want to include:
In the document you want to include, add the start and end tags you configured in the include-markdown block in your original document:
for more information on the 'include-markdown' plugin for mkdocs look here
Supported aliases for our documentation#
We currently support 3 aliases for our documentation:
- from the release major.minor branch:
- [https://docs.kubestellar.io/stable](../../../https://docs.kubestellar.io/stable)
- from the main branch:
- [https://docs.kubestellar.io/unstable](../../../https://docs.kubestellar.io/unstable)
- [https://docs.kubestellar.io/latest](../../../https://docs.kubestellar.io/latest)
Shortcut URLs#
We have a few shortcut urls that come in handy when referring others to our project:
note: You need to join our mailing list first to get access to some of the links that follow (https://docs.kubestellar.io/joinus)
- https://kubestellar.io/agenda - our community meeting agenda google doc
- https://kubestellar.io/blog - our medium reading list
- https://kubestellar.io/code - our current GitHub repo (wherever that is)
- https://kubestellar.io/community - our stable docs community page
- https://kubestellar.io/drive - our google drive
- https://kubestellar.io/joinus - our dev mailing list where you join and get our invites
- https://kubestellar.io/join_us - also, our dev mailing list
- https://kubestellar.io/linkedin - our linkedin filter (soon, our page)
- https://kubestellar.io/tv - our youtube channel
- https://kubestellar.io/youtube - also, our youtube channel
- https://kubestellar.io/infomercial - our infomercial that premieres on June 12th at 9am
and.. the very important… - https://kubestellar.io/quickstart - our 'stable' quickstart
Codeblocks#
mkdocs has some very helpful ways to include blocks of code in a style that makes it clear to our readers that console interaction is necessary in the documentation. There are options to include a plain codeblock (```), shell (shell), console (console - no used in our documentation), language or format-specific (yaml, etc.), and others. For more detailed information, checkout the mkdocs information on codeblocks.
Here are some examples of how we use codeblocks:
-
For a codeblock that can be 'tested' (and seen by the reader) as part of our CI, use the
as seen by reader:shell
block:
codeblock:
-
For a codeblock that should be 'tested', BUT not seen by the reader, use the
as seen by reader:.bash
with the plain codeblock, and the '.hide-me' style (great for hiding a sleep command that user does not need to run, but CI does):
codeblock:
-
For a codeblock that should not be 'tested' as part of our CI, use the
as seen by reader:.bash
with the plain codeblock, and without the '.hide-me' style:
codeblock:
-
For a codeblock that should not be 'tested', be seen by the reader, and not include a 'copy' icon (great for output-only instances), use the
.bash
codeblock without the '.no-copy' style:
codeblock:as seen by reader:``` {.bash .no-copy} I0412 15:15:57.867837 94634 shared_informer.go:282] Waiting for caches to sync for placement-translator I0412 15:15:57.969533 94634 shared_informer.go:289] Caches are synced for placement-translator I0412 15:15:57.970003 94634 shared_informer.go:282] Waiting for caches to sync for what-resolver ```
I0412 15:15:57.867837 94634 shared_informer.go:282] Waiting for caches to sync for placement-translator I0412 15:15:57.969533 94634 shared_informer.go:289] Caches are synced for placement-translator I0412 15:15:57.970003 94634 shared_informer.go:282] Waiting for caches to sync for what-resolver
-
For language-specific highlighting (yaml, etc.), use the yaml codeblock
codeblock:as seen by reader:```yaml nav: - Home: index.md - QuickStart: Getting-Started/quickstart.md - Contributing: - Guidelines: Contribution guidelines/CONTRIBUTING.md ```
nav: - Home: index.md - QuickStart: Getting-Started/quickstart.md - Contributing: - Guidelines: Contribution guidelines/CONTRIBUTING.md
-
For a codeblock that has a title, and will not be tested, use the 'title' parameter in conjunction with the plain codeblock (greater for showing or prescribing contents of files):
as seen by reader:
codeblock:
(other variations are possible, PR an update to the kubestellar.css file and, once approved, use the style on the plain codeblock in your documentation.)
Testing/Running Docs#
How do we ensure that our documented examples work? Simple, we 'execute' our documentation in our CI. We built automation called 'docs-ecutable' which can be invoked to test any markdown (.md) file in our repository. You could use it in your project as well - afterall it is opensource.
The way it works:#
- create your .md file as you normally would
- add codeblocks that can be tested, tested but hidden, or not tested at all:
- use 'shell' to indicate code you want to be tested
- use '.bash' with the plain codeblock, and the '.hide-md' style for code you want to be tested, but hidden from the reader (some like this, but its not cool if you want others to run your instructions without hiccups)
- use plain codeblock (```) if you want to show sample output that is not to be tested
- you can use 'include-markdown' blocks, and they will also be executed (or not), depending on the codeblock style you use in the included markdown files.
The GitHub Workflow:#
- One example of the GitHub Workflow is located in our kubestellar/kubestellar at https://github.com/kubestellar/kubestellar/blob/main/.github/workflows/docs-ecutable-where-resolver.yml
The secret sauce:#
- The code that makes all this possible is at https://github.com/kubestellar/kubestellar/blob/main/docs/scripts/docs-ecutable.sh
- This code parses the .md file you give it to pull out all the 'shell' and '.bash .hide-me' blocks
- The code is smart enough to traverse the include-markdown blocks and include the 'shell' and '.bash .hide-me' blocks in them
- It then creates a file called 'generate_script.sh' which is then run at the end of the docs-ecutable execution.
All of this is invoke in a target in our Makefile
You give the path from that follows the 'https://github.com/kubestellar/kubestellar/docs' path, and name of the .md file you want to 'execute'/'test' as the value for the MANIFEST variable:
make MANIFEST="'docs/content/Getting-Started/quickstart.md'" docs-ecutable
note: there are single and double-quotes used here to avoid issues with 'spaces' used in files names or directories. Use the single and double-quotes as specified in the quickstart example here.
Important files in our gh-pages branch#
index.html and home.html#
In the 'gh-pages' branch there are two(2) important files that redirect the github docs url to our KubeStellar doc site hosted with GoDaddy.com.
https://github.com/kubestellar/kubestellar/blob/gh-pages/home.html https://github.com/kubestellar/kubestellar/blob/gh-pages/index.html
both files have content similar to:
<!DOCTYPE html>
<html>
<head>
<title>KubeStellar</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<meta http-equiv="refresh" content="0; URL=https://docs.kubestellar.io/stable" />
</head>
Do not remove these files!
CNAME#
The CNAME file has to be in the gh-pages root to allow github to recognize the url tls cert served by our hosting provider. Do not remove this file!
the CNAME file must have the following content in it:
versions.json#
The versions.json file contains the version and alias information required by 'mike' to properly serve our doc site. This file is maintained by the 'mike' environment and should not be edited by hand.
[{"version": "release-0.2", "title": "release-0.2", "aliases": ["stable"]}, {"version": "main", "title": "main", "aliases": ["latest", "unstable"]}]
In case of emergency#
If you find yourself in a jam and the pages are not showing up at kubestellar.io or docs.kubestellar.io, check the following 1) Is the index.html, home.html, CNAME, and versions.json file in the gh-pages branch alongside the folders for the compiled documents? If not, then recreate those files as indicated above (except for versions.json which is programmatically created by 'mike'). 2) Is GitHub settings for 'Pages' for the domain pointing at the https://docs.kubestellar.io url? If not, paste it in and check off 'enforce https'. This can happen if the CNAME file goes missing from the gh-pages branch.
How to recreate the gh-pages branch#
To recreate the gh-pages branch, do the following: - checkout the gh-pages branch to your local system
- delete all files in the branch and push it to GitHub -- switch to the 'main' branch - switch to /docs and run 'mike deploy' for the main branch for alias 'unstable' and 'latest'cd docs
mike deploy --push --rebase --update-aliases main unstable
mike deploy --push --rebase --update-aliases main latest
- if the above did not work, then you might have an issue with the GoDaddy domain (expired, files missing, etc.)
Publishing Workflow#
All documentation building and publishing is done using GitHub Actions in docs-gen-and-push.yaml. The overall sequence is: