Repository navigation
Roadmap items 13, 18, 20: root docs_dir, Jinja env in on_page_context, markdown_extensions_path - #143
Merged
Merged
Conversation
Handlers with an `env` keyword (or **kwargs) now receive the Jinja environment that renders the page. Other handlers are called exactly as before, so existing plugins keep working.
The listed directories are added to sys.path before markdown_extensions is validated, so small project-specific extensions can live next to the docs without PYTHONPATH or a package.
docs_dir may now be the directory of mkdocs.yml. The config file and the site_dir are left out of the docs, also the configured site_dir when a command builds elsewhere (mkdocs serve). A site_dir inside the docs_dir is therefore allowed too; the docs_dir inside the site_dir is still an error.
On PyPy, builtins such as max have a signature, so the test now uses an object whose __signature__ makes inspect.signature raise.
Contributor
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small roadmap items, one commit each.
#18:
on_page_contextcan get the Jinja environment. Handlers that take anenvkeyword (or**kwargs) now get the environment that renders the page. Other handlers are called exactly as before. The check uses the handler's signature and is cached.BasePlugin.on_page_context's signature is unchanged, so typed plugins don't get mypy override errors. The docstring documents the new keyword.#20:
markdown_extensions_path. This new setting takes a list of directories, relative tomkdocs.yml. They are added tosys.pathbeforemarkdown_extensionsis validated, so a project-specific extension can live next to the docs:Each directory must exist. A path is added only once, so
mkdocs serverebuilds don't stack duplicates. The JSON Schema is regenerated.#13: the project root as
docs_dir.docs_dir: .is now allowed.get_filesskips the config file and thesite_dir. It also skips thesite_dirset inmkdocs.ymlwhen a command builds somewhere else (mkdocs servebuilds into a temporary directory), so a site built earlier doesn't turn into docs. As a result, asite_dirinside thedocs_diris allowed too. Adocs_dirinside thesite_diris still an error.Related Issue
Roadmap #59, items 13, 18 and 20.
Checklist
on_page_contextdocstring, upstream-issues pagedocs/about/release-notes.mdupdated (if applicable)Checks run locally: unit tests (985 OK), prek, mypy, integration builds, and a strict build of the docs. I also built real sites end to end: one with a local extension, and one with
docs_dir: .built twice, which gives no nestedsite/and nomkdocs.ymlin the output.