backstage / mkdocs-monorepo-plugin

✚ Build multiple documentation folders in a single Mkdocs. Designed for large codebases.
https://backstage.github.io/mkdocs-monorepo-plugin/
Apache License 2.0
319 stars 74 forks source link
documentation mkdocs mkdocs-monorepo-plugin monoliths monorepos plugin

backstage/mkdocs-monorepo-plugin

PyPI PyPI - License

✚ This plugin enables you to build multiple sets of documentation in a single Mkdocs. It is designed to address writing documentation in Spotify's largest and most business-critical codebases (typically monoliths or monorepos).

✏️ Blog Post | 🐍 Python Package | ✚ Demo | πŸ“• Docs

Features

Install

It's easy to get started using PyPI and pip using Python:

$ pip install mkdocs-monorepo-plugin

Usage

Take a look in our sample project for an example implementation, or see what it looks like after running mkdocs build.

In general, this plugin introduces the !include syntax in your Mkdocs navigation structure and then merges them together.

# /mkdocs.yml
site_name: Cats API

nav:
  - Intro: 'index.md'
  - Authentication: 'authentication.md'
  - API:
    - v1: '!include ./v1/mkdocs.yml'
    - v2: '!include ./v2/mkdocs.yml'

plugins:
  - monorepo
# /src/v1/mkdocs.yml
site_name: versions/v1

nav:
  - Reference: "reference.md"
  - Changelog: "changelog.md"
# /src/v2/mkdocs.yml
site_name: versions/v2

nav:
  - Migrating to v2: "migrating.md"
  - Reference: "reference.md"
  - Changelog: "changelog.md"

Example Source Filetree

$ tree .

β”œβ”€β”€ docs
β”‚Β Β  β”œβ”€β”€ authentication.md
β”‚Β Β  └── index.md
β”œβ”€β”€ mkdocs.yml
β”œβ”€β”€ v1
β”‚Β Β  β”œβ”€β”€ docs
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ changelog.md
β”‚Β Β  β”‚Β Β  └── reference.md
β”‚Β Β  └── mkdocs.yml
└── v2
    β”œβ”€β”€ docs
    β”‚Β Β  β”œβ”€β”€ changelog.md
    β”‚Β Β  β”œβ”€β”€ migrating.md
    β”‚Β Β  └── reference.md
    └── mkdocs.yml

5 directories, 10 files

Example Rendered Filetree

$ mkdocs build
$ tree ./site

β”œβ”€β”€ 404.html
β”œβ”€β”€ authentication
β”‚Β Β  └── index.html
β”œβ”€β”€ css
β”‚Β Β  β”œβ”€β”€ base.css
β”‚Β Β  β”œβ”€β”€ bootstrap-custom.min.css
β”‚Β Β  └── font-awesome.min.css
β”œβ”€β”€ fonts
β”‚Β Β  β”œβ”€β”€ fontawesome-webfont.eot
β”‚Β Β  β”œβ”€β”€ fontawesome-webfont.svg
β”‚Β Β  β”œβ”€β”€ fontawesome-webfont.ttf
β”‚Β Β  β”œβ”€β”€ fontawesome-webfont.woff
β”‚Β Β  β”œβ”€β”€ fontawesome-webfont.woff2
β”‚Β Β  β”œβ”€β”€ glyphicons-halflings-regular.eot
β”‚Β Β  β”œβ”€β”€ glyphicons-halflings-regular.svg
β”‚Β Β  β”œβ”€β”€ glyphicons-halflings-regular.ttf
β”‚Β Β  β”œβ”€β”€ glyphicons-halflings-regular.woff
β”‚Β Β  └── glyphicons-halflings-regular.woff2
β”œβ”€β”€ img
β”‚Β Β  β”œβ”€β”€ favicon.ico
β”‚Β Β  └── grid.png
β”œβ”€β”€ index.html
β”œβ”€β”€ js
β”‚Β Β  β”œβ”€β”€ base.js
β”‚Β Β  β”œβ”€β”€ bootstrap-3.0.3.min.js
β”‚Β Β  └── jquery-1.10.2.min.js
β”œβ”€β”€ sitemap.xml
β”œβ”€β”€ sitemap.xml.gz
└── versions
    β”œβ”€β”€ v1
    β”‚Β Β  β”œβ”€β”€ changelog
    β”‚Β Β  β”‚Β Β  └── index.html
    β”‚Β Β  └── reference
    β”‚Β Β      └── index.html
    └── v2
        β”œβ”€β”€ changelog
        β”‚Β Β  └── index.html
        β”œβ”€β”€ migrating
        β”‚Β Β  └── index.html
        └── reference
            └── index.html

13 directories, 28 files

Note that, as of v0.5.2, the *include syntax can be used in place of !include in order to compile any number of mkdocs.yml files that match a glob-like pattern, without having to specify every one individually. For example:

# /mkdocs.yml
site_name: Cats System

nav:
  - Intro: 'index.md'
  - Components: '*include ./components/*/mkdocs.yml'

Example Source Filetree

$ tree .

β”œβ”€β”€ components
β”‚Β Β  β”œβ”€β”€ belly-rubs
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ docs
β”‚   β”‚   |   └── index.md
β”‚Β Β  β”‚Β Β  └── mkdocs.yml
|   β”œβ”€β”€ purring
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ docs
β”‚   β”‚   |   └── index.md
β”‚Β Β  β”‚Β Β  └── mkdocs.yml
|   └── skritches
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ docs
β”‚   β”‚   |   └── index.md
β”‚Β Β  β”‚Β Β  └── mkdocs.yml
β”œβ”€β”€ docs
β”‚Β Β  └── index.md
└── mkdocs.yml

8 directories, 8 files

Release

  1. Update the CHANGELOG.md.
  2. Bump up the version number in setup.py which triggers the release workflow on GitHub Actions to publish a new version in PyPI.

Supported Versions

Changelog

Check out our CHANGELOG.md for details.

License

Copyright 2020-2021 Β© The Backstage Authors. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page: https://www.linuxfoundation.org/trademark-usage

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Contributing

Check out our CONTRIBUTING for more details.