Package: mkdocs-multirepo-plugin-reedsutliff
mkdocs-multirepo-pluginBuild documentation in multiple repos into one site.If you like this plugin and want me to continue maintaining it in my free time, pleasebuy me a 🍺!FeaturesDistributed Documentation: Keep docs close to the code butfindableon one site.Seperates Concerns: Separate documentation from other files that go into building your mkdocs site (e.g., theme overrides).Fast: Documentation is imported asynchronously, usingasyncio.Simple: All configuration is done within thepluginsornavsections of yourmkdocs.ymlfile.Use in Production: The plugin can be used in a CI/CD pipeline.OS SupportDependenciesNewer versions of Git preferred.SetupInstall plugin using pip:pip install mkdocs-multirepo-pluginNext, add the plugin to yourmkdocs.ymlplugins:-multirepoThe plugin introduces the!importstatement in your config'snavsection. You can now use the import statement to add a documentation section, where the docs are pulled from the source repo.!import Statement Sections{url}: Onlyrequiredpart of!importstatement (e.g.,https://github.com/{user}/{repo name}).branch={branch}: Tellsmultirepowhat branch to use. Defaults tomasterif not supplied.docs_dir={path}: The path to thedocsdirectory for the section. Defaults todocs/*(a glob) if not supplied.multi_docs={True | False}: If set toTrue, alldocsdirectories will be imported (more infohere).config={filename}.yml: Tellsmultirepothe name of the config file, containing configuration for the plugin. The default value is alsomkdocs.yml. This config file can live within the docs directoryorin the parent directory.extra_imports=["{filename | path | glob}"]: Use this if you want to import additional directories or files along with the docs.nav:-Home:'index.md'-MicroService:'!import{url}?branch={branch}&docs_dir={path}&multi_docs={True|False}&config={filename}.yml'MicroService mkdocs.yml (located within the docs directory or the parent directory)edit_uri:/blob/master/nav:-Home:index.mdThings to Note:If using!importin thenav, the imported repo must have amkdocs.yml(or another filename with a?config={filename}.yml) file with anavsection located in either thedocsdirectory or the root directory.navtakes precedence overrepos(see below).{path}can also be aglob(e.g.,docs/*).If you'd preferMkDocsto build the site nav based on the directory structure, you can define your other repos within thepluginssection.Note:
Cleanup should be set tofalsewhen developing (i.e., when callingmkdocs serve). This will prevent importing repos multiple times with livereload.plugins:-search-multirepo:# (optional) tells multirepo to cleanup the temporary directory after site is built.cleanup:truerepos:-section:Backstage# you can define the edit uri pathimport_url:'https://github.com/backstage/backstage?edit_uri=/blob/master/'-section:Monorepoimport_url:'https://github.com/backstage/mkdocs-monorepo-plugin?edit_uri=/blob/master/'-section:'Techdocs-cli'# note that the branch is still specified in the urlimport_url:'https://github.com/backstage/techdocs-cli?branch=main&edit_uri=/blob/main/'-section:FastAPIimport_url:'https://github.com/tiangolo/fastapi?docs_dir=docs/en/docs/*'-section:Monorepo Multi Docsimport_url:https://github.com/backstage/mkdocs-monorepo-plugin?multi_docs=True&docs_dir=sample-docs/*-section:'DjangoREST'import_url:'https://github.com/encode/django-rest-framework'-section:'CookiecutterPypackage'import_url:'https://github.com/zillionare/cookiecutter-pypackage'-section:'Pydantic'import_url:'https://github.com/samuelcolvin/pydantic'Once you're done configuring, run eithermkdocs serveormkdocs build. This willimportthe docs into a temporary directory and build the site.Additional Featuresα Multiple Docs Directories in Imported Repo (Alpha)If an imported repo is a monorepo (i.e., has multipledocsdirectories),multirepoautomatically includes them in the site whenmulti_docsis set toTrue.SupposeMicroservice'sdirectory structure is this.├───mkdocs.yml (required if nav section is defined)
├───README.md
├───project1
│   └───src
│   └───docs
│       └───assets
|         index.md
|         technical.md
├───project2
│   └───src
│   └───docs
│         index.mdBy default, this directory turns into this.├───mkdocs.yml (required if nav section is defined)
├───README.md
├───project1
│   └───assets
|     index.md
|     technical.md
├───project2
│     index.mdNote:If using the nav!importstatement, make sure the nav paths reflect the new directory structure, which doesn't includedocsdirectories.edit_urlswill still map to underlying markdown file based on the actual directory structure in the remote's repository.Use in CI/CDIf you want to use the plugin within Azure Pipelines or Github Actions, you'll need to define anAccessTokenenvironment variable for themkdocs buildstep. TheAccessTokenshould have access tocloneall repos.Azure Pipeline Step Example-script:|source ./env/bin/activatemkdocs buildenv:AccessToken:$(System.AccessToken)displayName:'BuildMkDocsSite'β Development in Imported Repos (Beta)Formkdocs serveto work properly in an imported repo (a repo that is imported in the parent site),you will need to add the multirepo plugin within the imported repo as well as the parent repo, including the following configuration.Notes:You will also need to havepluginsandpackagesthe parent repo uses installed within your localvenv.See documentation on thesetgit command forsparse-checkoutif you are confused with whatdirscan contain.plugins:
  multirepo:
    imported_repo: true
    url: https://github.com/squidfunk/mkdocs-material
    section_name: Backstage
    # directories and files needed for building the site
    # any path in docs will be included. For example, index.md is the
    # homepage of the parent site
    dirs: ["material/*", "mkdocs.yml", "docs/index.md"]
    custom_dir: material
    yml_file: mkdocs.yml # this can also be a relative path
    branch: masterWriters can now runmkdocs servewithin their local repo, using the main site's configuration, custom theming and features. This means all development is distributed, without technical writers having to switch repos.α Deep Navigation Importsplugins:-multirepo:deep_nav_imports:trueThis toggle allows for!importstatements to be placed in deeper levels of nav. Slightly less performant on build.nav:-Home:'index.md'-Category:-Subcategory:-MyImportedDocs:'!import...'ExamplesMultirepo with McdocstringsRunning TestsTests were modeled off ofmkdocs-monorepo-plugin. To run the test suite you'll need:PythonGitDockerMkDocsIntegration TestingThe command below will use Docker to run our test suites in numerous Python versions. It may take some time on first run, but should be very fast afterwards. When you're done, feel free to rundocker pruneto clear them from your local cache. We use theslimversions of the publicpythonimages fromDocker Hub.$ ./__tests__/test.shFor faster tests, you can opt to run in Python 3.7 rather than all supported Python versions:$ PYTHON_37_ONLY=1 ./__tests__/test.shUnit Testing$ pip install -r requirements.txt
$ python -m unittest tests.unittests