Mkdocs plugin to include stubs (single pages) from multiple GitHub branches of a repo within a mkdocs website build. A stub consists of a file in either of the supported file formats.
Important
This plugin adds stub files to the website structure using the on_files mkdocs hook.
Make sure you include this plugin in the mkdocs.yml file before any other plugin that uses included files (for example the macros plugin), if you want the files included by this plugin to be processed by those other plugins.
- MarkDown (`.md`)
- HTML (`.html`)
The name of the stub pages in the website navigation and url will be inferred following the logic below:
- If the stub contains a title (
#heading or<h1>block), that title will be used. - If no title is found, the stub file name will be used instead.
In addition to the requirements specified in the pyproject.toml file, this plugin requires and uses the following executables:
gitgh
-
repoThe GitHub repository URL used to retrieve branches and tags for the stubs to be included in the MkDocs site. It can be specified in one of the following formats:- GitHub URL (
https://github.com/OWNER/REPO) - GitHub SSH (
git@github.com:OWNER/REPO.git) OWNER/REPOIf not specified, the output ofgit remote get-url originfor the local directory will be used. Only GitHub repositories are supported.
- GitHub URL (
-
main_websiteConfiguration parameters for the main website. Sub-parameters:patternGit Glob pattern for Git refs to be included when searching for stubs. To match multiple patterns, separate them with a space (e.g., "first-pattern second-pattern"). An empty pattern will match no Git refs. Default value isrelease-*.ref_typeType of Git ref to be used when searching for stubs. Possible values arebranch,tag,all. Default value istag.branchGit branch where the main website documentation resides. Default value is the repository's default branch.
-
preview_websiteConfiguration parameters for the PR preview and local preview websites.[!IMPORTANT] Stubs found for the
main_websiteare also included automatically when building preview websites. To avoid this, setno_maintotrue.Sub-parameters:
patternGit Glob pattern for Git refs to be included when searching for stubs. To match multiple patterns, separate them with a space (e.g., "first-pattern second-pattern"). Default value isdev-*.ref_typeType of Git ref to be used when searching for stubs. Possible values arebranch,tag,all. Default value isbranch.no_mainIf set totrue, don't includemain_websiteconfigurations in the preview websites. Default value isfalse.
-
stubs_dirPath to the directory containing the stubs, relative to the root of the repository. Thestubs_dirmust contain exactly one file in one of the supported file formats. It may also include other files or directories, as long as only one file matches a supported format. When filtering the Git refs to determine which to include, the following are excluded:- Refs that do not contain the
stubs_dirpath - Refs whose
stubs_dircontains multiple files of the same supported file format - Refs whose
stubs_dircontains files from multiple supported file format Default value isdocumentation/stub.
- Refs that do not contain the
-
stubs_parent_urlParent url path, relative to the website root url, for the stubs. Use an empty string ("") to specify the website root url. Default value is an empty string.Example: If the root url is
www.examplesite.organdstubs_parent_urlis set toadded_pages/stubs, then a stub file namedstub1.mdwould be added to the URL:www.examplesite.org/added_pages/stubs/stub1 -
stubs_nav_pathStructure that defines where the stubs reside within the site navigation. Each navigation section should be connected to its subsection with a "greater than" (>) symbol. Use an empty string ("") to place the stubs directly at the top level of the navigation. If omitted, the value is derived fromstubs_parent_urlby capitalizing each path segment, replacing underscores with spaces and forward slashes (/) with "greather than" (>) symbols.Example 1: If
stubs_nav_pathis set toAdded pages > Stubs, the stubs will be placed inside theStubssubsection, under the top-levelAdded pagessection of the site navigation.Example 2: If no
stubs_nav_pathis specified andstubs_parent_urlis set tocustom/navigation/added_stubs, thestubs_nav_pathbecomesCustom > Navigation > Added stubs, placing the stubs inside theAdded stubssubsection, within theNavigationsection, under the top-levelCustomsection of the site navigation.
This plugin also installs a mkdocs command line executable, which wraps around the default mkdocs command.
For more information, run:
mkdocs --help
Apache Software License 2.0