Skip to content

Keep the mkdocs command working with upstream MkDocs 2.0's launcher - #127

Merged
shenxianpeng merged 2 commits into
mainfrom
claude/project-thread-8gce4u
Nov 1, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
claude/project-thread-8gce4u

Conversation

@shenxianpeng

Copy link
Copy Markdown
Member

Problem

Upstream MkDocs 2.0 pre-releases (e.g. mkdocs==2.0.dev6) install a mkdocs launcher that runs:

from mkdocs import cli
sys.exit(cli())

Since #115 both packages provide the mkdocs command. If a plugin's dependencies (or uv pip install --prerelease allow) pull in a 2.0 pre-release, its launcher replaces ours, and with MkDocs NG loaded as mkdocs it fails with ImportError: cannot import name 'cli' from 'mkdocs'.

Fix

A module-level __getattr__ in mkdocs/__init__.py returns mkdocs.__main__.cli for cli, imported lazily so import mkdocs stays cheap. Unknown names still raise AttributeError.

Testing

  • New unit tests: from mkdocs import cli is the MkDocs NG click group; other names raise AttributeError.
  • End to end: wheel + mkdocs-material, then uv pip install --prerelease allow "mkdocs==2.0.dev6". The launcher is upstream's (from mkdocs import cli); mkdocs --version reports MkDocs NG from site-packages/mkdocs_ng/mkdocs, and a Material site with search + llms_txt builds.
  • Unit tests, mypy and pre-commit pass.

Release notes: new Version 1.10.0 (2026-xx-xx) section listing changes since 1.10.0rc1.


Generated by Claude Code

Upstream MkDocs 2.0 pre-releases install a `mkdocs` launcher that runs
`from mkdocs import cli`. When a plugin pulls one in next to MkDocs NG,
that launcher replaces ours and fails with ImportError. Provide
`mkdocs.cli` lazily so it runs the MkDocs NG command line.
@shenxianpeng shenxianpeng self-assigned this Nov 1, 2026
@codspeed

codspeed Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 28 untouched benchmarks


Comparing claude/project-thread-8gce4u (a2fc807) with main (72634bb)

Open in CodSpeed

@shenxianpeng
shenxianpeng merged commit b728a71 into main Nov 1, 2026
24 checks passed
@shenxianpeng
shenxianpeng deleted the claude/project-thread-8gce4u branch November 1, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant