docs: generate hierarchical per-module API reference pages (#2103)
This commit is contained in:
parent
20dd94632e
commit
5388bea53a
7 changed files with 74 additions and 7 deletions
|
|
@ -1 +0,0 @@
|
||||||
::: mcp
|
|
||||||
35
docs/hooks/gen_ref_pages.py
Normal file
35
docs/hooks/gen_ref_pages.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
"""Generate the code reference pages and navigation."""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import mkdocs_gen_files
|
||||||
|
|
||||||
|
nav = mkdocs_gen_files.Nav()
|
||||||
|
|
||||||
|
root = Path(__file__).parent.parent.parent
|
||||||
|
src = root / "src"
|
||||||
|
|
||||||
|
for path in sorted(src.rglob("*.py")):
|
||||||
|
module_path = path.relative_to(src).with_suffix("")
|
||||||
|
doc_path = path.relative_to(src).with_suffix(".md")
|
||||||
|
full_doc_path = Path("api", doc_path)
|
||||||
|
|
||||||
|
parts = tuple(module_path.parts)
|
||||||
|
|
||||||
|
if parts[-1] == "__init__":
|
||||||
|
parts = parts[:-1]
|
||||||
|
doc_path = doc_path.with_name("index.md")
|
||||||
|
full_doc_path = full_doc_path.with_name("index.md")
|
||||||
|
elif parts[-1].startswith("_"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
nav[parts] = doc_path.as_posix()
|
||||||
|
|
||||||
|
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
|
||||||
|
ident = ".".join(parts)
|
||||||
|
fd.write(f"::: {ident}")
|
||||||
|
|
||||||
|
mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(root))
|
||||||
|
|
||||||
|
with mkdocs_gen_files.open("api/SUMMARY.md", "w") as nav_file:
|
||||||
|
nav_file.writelines(nav.build_literate_nav())
|
||||||
|
|
@ -64,4 +64,4 @@ npx -y @modelcontextprotocol/inspector
|
||||||
|
|
||||||
## API Reference
|
## API Reference
|
||||||
|
|
||||||
Full API documentation is available in the [API Reference](api.md).
|
Full API documentation is available in the [API Reference](api/mcp/index.md).
|
||||||
|
|
|
||||||
|
|
@ -883,6 +883,6 @@ The lowlevel `Server` also now exposes a `session_manager` property to access th
|
||||||
|
|
||||||
If you encounter issues during migration:
|
If you encounter issues during migration:
|
||||||
|
|
||||||
1. Check the [API Reference](api.md) for updated method signatures
|
1. Check the [API Reference](api/mcp/index.md) for updated method signatures
|
||||||
2. Review the [examples](https://github.com/modelcontextprotocol/python-sdk/tree/main/examples) for updated usage patterns
|
2. Review the [examples](https://github.com/modelcontextprotocol/python-sdk/tree/main/examples) for updated usage patterns
|
||||||
3. Open an issue on [GitHub](https://github.com/modelcontextprotocol/python-sdk/issues) if you find a bug or need further assistance
|
3. Open an issue on [GitHub](https://github.com/modelcontextprotocol/python-sdk/issues) if you find a bug or need further assistance
|
||||||
|
|
|
||||||
11
mkdocs.yml
11
mkdocs.yml
|
|
@ -25,7 +25,7 @@ nav:
|
||||||
- Introduction: experimental/tasks.md
|
- Introduction: experimental/tasks.md
|
||||||
- Server Implementation: experimental/tasks-server.md
|
- Server Implementation: experimental/tasks-server.md
|
||||||
- Client Usage: experimental/tasks-client.md
|
- Client Usage: experimental/tasks-client.md
|
||||||
- API Reference: api.md
|
- API Reference: api/
|
||||||
|
|
||||||
theme:
|
theme:
|
||||||
name: "material"
|
name: "material"
|
||||||
|
|
@ -115,10 +115,15 @@ plugins:
|
||||||
- social:
|
- social:
|
||||||
enabled: !ENV [ENABLE_SOCIAL_CARDS, false]
|
enabled: !ENV [ENABLE_SOCIAL_CARDS, false]
|
||||||
- glightbox
|
- glightbox
|
||||||
|
- gen-files:
|
||||||
|
scripts:
|
||||||
|
- docs/hooks/gen_ref_pages.py
|
||||||
|
- literate-nav:
|
||||||
|
nav_file: SUMMARY.md
|
||||||
- mkdocstrings:
|
- mkdocstrings:
|
||||||
handlers:
|
handlers:
|
||||||
python:
|
python:
|
||||||
paths: [src/mcp]
|
paths: [src]
|
||||||
options:
|
options:
|
||||||
relative_crossrefs: true
|
relative_crossrefs: true
|
||||||
members_order: source
|
members_order: source
|
||||||
|
|
@ -126,8 +131,6 @@ plugins:
|
||||||
show_signature_annotations: true
|
show_signature_annotations: true
|
||||||
signature_crossrefs: true
|
signature_crossrefs: true
|
||||||
group_by_category: false
|
group_by_category: false
|
||||||
# 3 because docs are in pages with an H2 just above them
|
|
||||||
heading_level: 3
|
|
||||||
inventories:
|
inventories:
|
||||||
- url: https://docs.python.org/3/objects.inv
|
- url: https://docs.python.org/3/objects.inv
|
||||||
- url: https://docs.pydantic.dev/latest/objects.inv
|
- url: https://docs.pydantic.dev/latest/objects.inv
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ dev = [
|
||||||
]
|
]
|
||||||
docs = [
|
docs = [
|
||||||
"mkdocs>=1.6.1",
|
"mkdocs>=1.6.1",
|
||||||
|
"mkdocs-gen-files>=0.5.0",
|
||||||
"mkdocs-glightbox>=0.4.0",
|
"mkdocs-glightbox>=0.4.0",
|
||||||
|
"mkdocs-literate-nav>=0.6.1",
|
||||||
"mkdocs-material[imaging]>=9.5.45",
|
"mkdocs-material[imaging]>=9.5.45",
|
||||||
"mkdocstrings-python>=2.0.1",
|
"mkdocstrings-python>=2.0.1",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
28
uv.lock
generated
28
uv.lock
generated
|
|
@ -840,7 +840,9 @@ dev = [
|
||||||
]
|
]
|
||||||
docs = [
|
docs = [
|
||||||
{ name = "mkdocs" },
|
{ name = "mkdocs" },
|
||||||
|
{ name = "mkdocs-gen-files" },
|
||||||
{ name = "mkdocs-glightbox" },
|
{ name = "mkdocs-glightbox" },
|
||||||
|
{ name = "mkdocs-literate-nav" },
|
||||||
{ name = "mkdocs-material", extra = ["imaging"] },
|
{ name = "mkdocs-material", extra = ["imaging"] },
|
||||||
{ name = "mkdocstrings-python" },
|
{ name = "mkdocstrings-python" },
|
||||||
]
|
]
|
||||||
|
|
@ -888,7 +890,9 @@ dev = [
|
||||||
]
|
]
|
||||||
docs = [
|
docs = [
|
||||||
{ name = "mkdocs", specifier = ">=1.6.1" },
|
{ name = "mkdocs", specifier = ">=1.6.1" },
|
||||||
|
{ name = "mkdocs-gen-files", specifier = ">=0.5.0" },
|
||||||
{ name = "mkdocs-glightbox", specifier = ">=0.4.0" },
|
{ name = "mkdocs-glightbox", specifier = ">=0.4.0" },
|
||||||
|
{ name = "mkdocs-literate-nav", specifier = ">=0.6.1" },
|
||||||
{ name = "mkdocs-material", extras = ["imaging"], specifier = ">=9.5.45" },
|
{ name = "mkdocs-material", extras = ["imaging"], specifier = ">=9.5.45" },
|
||||||
{ name = "mkdocstrings-python", specifier = ">=2.0.1" },
|
{ name = "mkdocstrings-python", specifier = ">=2.0.1" },
|
||||||
]
|
]
|
||||||
|
|
@ -1501,6 +1505,18 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/9f/4d/7123b6fa2278000688ebd338e2a06d16870aaf9eceae6ba047ea05f92df1/mkdocs_autorefs-1.4.3-py3-none-any.whl", hash = "sha256:469d85eb3114801d08e9cc55d102b3ba65917a869b893403b8987b601cf55dc9", size = 25034, upload-time = "2025-08-26T14:23:15.906Z" },
|
{ url = "https://files.pythonhosted.org/packages/9f/4d/7123b6fa2278000688ebd338e2a06d16870aaf9eceae6ba047ea05f92df1/mkdocs_autorefs-1.4.3-py3-none-any.whl", hash = "sha256:469d85eb3114801d08e9cc55d102b3ba65917a869b893403b8987b601cf55dc9", size = 25034, upload-time = "2025-08-26T14:23:15.906Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mkdocs-gen-files"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "mkdocs" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/61/35/f26349f7fa18414eb2e25d75a6fa9c7e3186c36e1d227c0b2d785a7bd5c4/mkdocs_gen_files-0.6.0.tar.gz", hash = "sha256:52022dc14dcc0451e05e54a8f5d5e7760351b6701eff816d1e9739577ec5635e", size = 8642, upload-time = "2025-11-23T12:13:22.124Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8d/ec/72417415563c60ae01b36f0d497f1f4c803972f447ef4fb7f7746d6e07db/mkdocs_gen_files-0.6.0-py3-none-any.whl", hash = "sha256:815af15f3e2dbfda379629c1b95c02c8e6f232edf2a901186ea3b204ab1135b2", size = 8182, upload-time = "2025-11-23T12:13:20.756Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mkdocs-get-deps"
|
name = "mkdocs-get-deps"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -1527,6 +1543,18 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/30/cf/e9a0ce9da269746906fdc595c030f6df66793dad1487abd1699af2ba44f1/mkdocs_glightbox-0.5.1-py3-none-any.whl", hash = "sha256:f47af0daff164edf8d36e553338425be3aab6e34b987d9cbbc2ae7819a98cb01", size = 26431, upload-time = "2025-09-04T13:10:27.933Z" },
|
{ url = "https://files.pythonhosted.org/packages/30/cf/e9a0ce9da269746906fdc595c030f6df66793dad1487abd1699af2ba44f1/mkdocs_glightbox-0.5.1-py3-none-any.whl", hash = "sha256:f47af0daff164edf8d36e553338425be3aab6e34b987d9cbbc2ae7819a98cb01", size = 26431, upload-time = "2025-09-04T13:10:27.933Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mkdocs-literate-nav"
|
||||||
|
version = "0.6.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "mkdocs" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/f6/5f/99aa379b305cd1c2084d42db3d26f6de0ea9bf2cc1d10ed17f61aff35b9a/mkdocs_literate_nav-0.6.2.tar.gz", hash = "sha256:760e1708aa4be86af81a2b56e82c739d5a8388a0eab1517ecfd8e5aa40810a75", size = 17419, upload-time = "2025-03-18T21:53:09.711Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8a/84/b5b14d2745e4dd1a90115186284e9ee1b4d0863104011ab46abb7355a1c3/mkdocs_literate_nav-0.6.2-py3-none-any.whl", hash = "sha256:0a6489a26ec7598477b56fa112056a5e3a6c15729f0214bea8a4dbc55bd5f630", size = 13261, upload-time = "2025-03-18T21:53:08.1Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mkdocs-material"
|
name = "mkdocs-material"
|
||||||
version = "9.7.2"
|
version = "9.7.2"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue