Skip to content

kiyoon/mkdocs-material-github-flavored-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MkDocs Material but GitHub-Flavored Markdown

This is a simple example of how to use GitHub-Flavored Markdown with MkDocs Material (almost).

📚 Example document: https://kiyoon.kim/mkdocs-material-github-flavored-template

Installation

pip install -r requirements.txt

Usage

To preview the site,

mkdocs serve

Features

Github style callouts (a.k.a. admonitions or alert)

See how it renders in the documentation!

> [!NOTE]
> This is a NOTE type alert.

> [!TIP]
> This is a TIP type alert.

> [!WARNING]
> This is a WARNING type alert.

> [!IMPORTANT]
> This is an IMPORTANT type alert.

> [!CAUTION]
> This is a CAUTION type alert.
image

Related configuration in mkdocs.yml:

markdown_extensions:
  - markdown_gfm_admonition

extra_css:
  - stylesheets/extra_admonitions.css

Latex math equations

Using MathJax defined in docs/javascripts/mathjax.js.

$a^2 + b^2 = c^2$

$$
\begin{align*}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{align*}
$$

$a^2 + b^2 = c^2$

$$ \begin{align*} \dot{x} & = \sigma(y-x) \\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{align*} $$

Flowchart with mermaid

```mermaid
graph LR
  A[Start] --> B{Error?};
  B -->|Yes| C[Hmm...];
  C --> D[Debug];
  D --> B;
  B ---->|No| E[Yay!];
```
graph LR
  A[Start] --> B{Error?};
  B -->|Yes| C[Hmm...];
  C --> D[Debug];
  D --> B;
  B ---->|No| E[Yay!];
Loading

Automatic API reference pages

Using gen-files and literate-nav. Basically scripts/gen_ref_nav.py will generate reference/SUMMARY.md file and then add to the navigation menu when you build it.

Relevant configuration in mkdocs.yml:

nav:
  # defer to gen-files + literate-nav
  - API reference:
      - mkdocstrings-python: reference/

plugins:
  - gen-files:
      scripts:
        - scripts/gen_ref_nav.py
  - literate-nav:
      nav_file: SUMMARY.md

Notice you can add modules to ignore in scripts/gen_ref_nav.py by adding to IGNORE_MODULES_* set.

IGNORE_MODULES_EXACT = {"my_project.my_module"}
IGNORE_MODULES_STARTSWITH = {"my_project.cli."}

Versioning

When publishing a new version, the older versions will be archived with Mike.

image

The gh-pages branch will have the following structure:

📂 latest/
📂 v0.1.0/
📂 v0.1.1/
📂 v0.2.0/
...

Useful GitHub Actions

Tip

Notice that you push the documentation to GitLab, because GitLab pages are free. You can use it with GitHub private repositories without the Enterprise plan. See Setting Up GitLab Pages.

About

MkDocs template with GitHub-style markdown, with useful GitHub Actions to deploy manually and automatically.

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •  

Languages