Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bin/docs_scripts/generate_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ def nest(markdown: str) -> str:
return "\n".join(out)


def migration_page(guides: list[str]) -> list[str]:
"""The migration page. One guide's H1 becomes the page title, so the page shows one title."""
title = "PostHog Python SDK migration guides"
if len(guides) == 1 and guides[0].startswith("# "):
heading, _, rest = guides[0].partition("\n")
title, guides = heading[2:].strip(), [rest.strip()]
head = f"---\ntitle: {json.dumps(title)}\nsidebar: Docs\nshowTitle: true\n---"
return [head, *guides]


def write(name: str, sections: list[str]) -> None:
(ROOT / "references" / name).write_text("\n\n".join(sections) + "\n")
print(f"wrote references/{name}")
Expand Down Expand Up @@ -255,10 +265,9 @@ def main() -> None:
[front_matter("PostHog Python SDK", body), *body],
)
if guides := sorted((ROOT / "docs").glob("migration-*.md"), reverse=True):
head = "---\ntitle: PostHog Python SDK migration guides\nsidebar: Docs\nshowTitle: true\n---"
write(
"posthog-python-migration.md",
[head, *(g.read_text().strip() for g in guides)],
migration_page([g.read_text().strip() for g in guides]),
)


Expand Down
Loading
Loading