Files
BurtandClaude Sonnet 5.5 3336e6a80d Rewrite README and add docs site, community files and CI
- README in the mcp-proton style, with banner, badges and accurate formats.
- docs/ MkDocs site published via GitHub Pages, plus logo and banners.
- SECURITY, CONTRIBUTING, CODE_OF_CONDUCT, CHANGELOG, CITATION, SUPPORT.
- Issue and PR templates, CODEOWNERS, Dependabot and release notes config.
- CI workflow (build, audit, docker build) and docs workflow.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-09 17:18:34 -05:00

44 lines
1.4 KiB
Python

"""MkDocs hooks: render README.md as the site home page.
Links that point into docs/ become site-relative; links to other repository files
become absolute GitHub URLs, so the same README works on GitHub and on the site.
"""
from __future__ import annotations
import re
from pathlib import Path
REPO = "https://github.com/w0h1v/mcp-maigret/blob/main/"
def _alerts(md: str) -> str:
"""GitHub ``> [!NOTE]`` alerts become MkDocs admonitions."""
def repl(m: re.Match[str]) -> str:
body = re.sub(r"^> ?", " ", m.group(2), flags=re.M)
return f"!!! {m.group(1).lower()}\n{body}"
return re.sub(r"^> \[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\n((?:>.*\n?)+)", repl, md,
flags=re.M)
def _rewrite(md: str) -> str:
def link(m: re.Match[str]) -> str:
attr, target = m.group(1), m.group(2)
if re.match(r"^[a-z]+:|^#", target):
return m.group(0)
if target.startswith("docs/"):
return f'{attr}{target[len("docs/"):]}'
return f"{attr}{REPO}{target}"
md = re.sub(r'(\]\()([^)\s]+)', link, md)
md = re.sub(r'((?:src|srcset|href)=")([^"]+)', link, md)
return md
def on_page_markdown(markdown: str, page, config, files): # noqa: ANN001 - mkdocs hook API
if page.file.src_uri != "index.md":
return markdown
readme = Path(config["config_file_path"]).parent / "README.md"
return _alerts(_rewrite(readme.read_text(encoding="utf-8")))