mkdocs-gen-files is an MkDocs plugin that allows users to programmatically generate documentation pages and modify existing ones during the MkDocs build process. It's particularly useful for creating dynamic content, API documentation from code, or custom navigation structures using Python scripts. The current version is 0.6.1, and releases are often tied to MkDocs compatibility or feature enhancements, without a strict schedule.
pip install mkdocs-gen-filesVerified import paths — ran on the pinned version, not inferred.
To use mkdocs-gen-files, first configure it in your `mkdocs.yml` to specify the Python scripts it should run. Then, create a Python script (e.g., `gen_pages.py`) where you can use `mkdocs_gen_files.open` to write content to new documentation pages. The quickstart demonstrates creating a basic markdown file.
Monitor project announcements for `ProperDocs` for future changes. Be prepared for potential migration or changes in build process if full `mkdocs` compatibility diverges.
Upgrade to `mkdocs-gen-files` v0.4.0 or newer. Scripts are now correctly resolved relative to the `mkdocs.yml` file, making builds more consistent regardless of CWD.
Upgrade to `mkdocs-gen-files` v0.6.0 or newer to ensure `set_edit_path()` functions correctly even when `edit_uri_template` is used in your `mkdocs.yml`.
Upgrade to `mkdocs-gen-files` v0.5.0 or newer. Cleanup now occurs after all other plugins (on MkDocs 1.4+), ensuring better compatibility with other plugins that might access generated files.
Use `mkdocs_gen_files.set_edit_path(file, 'custom/path/to/edit.md')` within your generation script to explicitly define the edit URI for generated files, or `set_edit_path(file, None)` to explicitly remove it.