Writing productivity
productivity 5 min read 5 January 2022

Markdown Publishing: MkDocs, Jupyter Book, and Formatting Tricks

Building documentation sites with MkDocs and Jupyter Book - setup commands, the plugins worth using, admonition syntax, and the badge and icon formatting that makes docs look professional.

MkDocs

MkDocs generates a static documentation site from a folder of markdown files. It’s the fastest way to turn a collection of notes into a searchable, navigable site.

pip install -r requirements.txt       # Install dependencies
mkdocs serve -f mkdocs.yml            # Local preview at localhost:8000
mkdocs serve -f mkdocs.yml --dev-addr 0.0.0.0:80   # Serve on local network
mkdocs build -f mkdocs.yml            # Build static site to /site

Plugins Worth Using

table {
    display: block;
    max-width: fit-content;
    margin: 0 auto;
    overflow-x: auto;
    white-space: nowrap;
}

More plugins: MkDocs Plugins Wiki

Jupyter Book

Jupyter Book builds documentation sites from Jupyter notebooks and markdown files, with native support for executable code, math, and interactive outputs.

Key libraries used alongside Jupyter Book:

Reference: Jupyter Book Documentation

MkDocs Material Admonitions

Admonitions are styled callout boxes for highlighting important content:

!!! warning "Title"
    Warning text here.

!!! note
    A note without a custom title.

!!! info
    Informational callout.

!!! question
    A question callout.

Available types: warning, note, info, error, question, example.

Collapsible admonition (starts collapsed):

??? note "Click to expand"
    ### Heading inside
    - **Key**: Value

Tabbed Content

Useful for showing the same concept in multiple languages or configurations:

=== "Python"
    ```python
    print("hello")
    ```

=== "R"
    ```r
    print("hello")
    ```

Mixed Admonition and Tabs

!!! warning "Auto-generated files"
    === "Unordered List"
        ```markdown
        * Sed sagittis eleifend rutrum
        ```
    === "Ordered List"
        ```markdown
        1. Sed sagittis eleifend rutrum
        ```

Badges and Icons

Markdown badges (shields.io style) for README files and documentation: Reference: Markdown Badges Repository

Font Awesome icons in MkDocs Material:

[:fontawesome-solid-globe: Live Demo][demo]
[Github Repo][repository]

[repository]: https://github.com/user/repo "GitHub Repository"
[demo]: https://demo.example.com "Live Demo"

Quote Block Pattern

For attributed quotes in documentation:

!!! quote
    The text of the quote.

    -- <cite>Author Name ([source](https://source-url.com))</cite>
markdown mkdocs jupyter-book documentation tools
← All articles

Have a problem worth solving?

Whether you need a quantitative researcher, a Machine Learning systems builder, or a technical advisor, I take a small number of consulting engagements at a time.

Book a call →