Skip to content

API#

mkdocs_gen_files #

A magical module that forwards everything to mkdocs_gen_files.editor.FilesEditor.current.

Just import mkdocs_gen_files.

Then mkdocs_gen_files.open() is the same as mkdocs_gen_files.editor.FilesEditor.current.open().

config: MkDocsConfig = config instance-attribute #

The current MkDocs config.

open(name: str, mode, buffering=-1, encoding=None, *args, **kwargs) -> IO #

Open a file under docs_dir virtually.

This function, for all intents and purposes, is just an open() which pretends that it is running under docs_dir (docs/ by default), but write operations don't affect the actual files when running as part of a MkDocs build, but they do become part of the site build.

mkdocs_gen_files.editor.FilesEditor #

config: MkDocsConfig = config instance-attribute #

The current MkDocs config.

directory: str = directory instance-attribute #

The base directory for open() (docs_dir).

files: Files property #

Access the files as they currently are, as a MkDocs Files collection.

current() -> FilesEditor classmethod #

The instance of FilesEditor associated with the currently ongoing MkDocs build.

If used as part of a MkDocs build (gen-files plugin), it's an instance using virtual files that feed back into the build.

If not, this still tries to load the MkDocs config to find out the docs_dir, and then actually performs any file writes that happen via .open().

This is global (not thread-safe).

open(name: str, mode, buffering=-1, encoding=None, *args, **kwargs) -> IO #

Open a file under docs_dir virtually.

This function, for all intents and purposes, is just an open() which pretends that it is running under docs_dir (docs/ by default), but write operations don't affect the actual files when running as part of a MkDocs build, but they do become part of the site build.

set_edit_path(name: str, edit_name: str | None) -> None #

Choose a file path to use for the edit URI of this file.