-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Surface package changelogs on docs site #6636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
masenf
wants to merge
4
commits into
main
Choose a base branch
from
claude/lucid-hypatia-xq0xzi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3dee14a
Publish package changelogs on the docs site under /docs/changelog/
claude ff4d8d3
Prefer the shallowest CHANGELOG.md record in installed distributions
claude 47bf341
Bump reflex-enterprise floor to 0.9.0.post1 for the bundled changelog
claude c8aad6c
Set APP_HARNESS_FLAG for CI jobs that run the docs app in prod mode
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| """Discovery of package changelogs surfaced on the docs site. | ||
|
|
||
| The monorepo packages manage their changelogs with towncrier: the main | ||
| ``reflex`` changelog lives at the repo root and each subpackage ships its own | ||
| under ``packages/<name>/CHANGELOG.md``. The ``reflex-enterprise`` package is | ||
| developed in a separate repo, so its changelog is read from the installed | ||
| distribution instead (it only appears once the published wheel ships a | ||
| ``CHANGELOG.md``). | ||
| """ | ||
|
|
||
| from importlib.metadata import PackageNotFoundError, distribution | ||
| from pathlib import Path | ||
|
|
||
| ENTERPRISE_PACKAGE = "reflex-enterprise" | ||
|
|
||
|
|
||
| def discover_repo_changelogs(repo_root: Path) -> dict[str, Path]: | ||
| """Find the changelogs maintained in this repo. | ||
|
|
||
| Args: | ||
| repo_root: The repo checkout root (parent of the docs content tree). | ||
|
|
||
| Returns: | ||
| A mapping of package name to its CHANGELOG.md path — ``reflex`` for | ||
| the repo-root changelog plus one entry per subpackage that ships one. | ||
| """ | ||
| changelogs: dict[str, Path] = {} | ||
| root_changelog = repo_root / "CHANGELOG.md" | ||
| if root_changelog.is_file(): | ||
| changelogs["reflex"] = root_changelog | ||
| for pkg_changelog in (repo_root / "packages").glob("*/CHANGELOG.md"): | ||
| changelogs[pkg_changelog.parent.name] = pkg_changelog | ||
| return changelogs | ||
|
|
||
|
|
||
| def find_distribution_changelog(package: str) -> Path | None: | ||
| """Locate the CHANGELOG.md shipped with an installed distribution. | ||
|
|
||
| Args: | ||
| package: The distribution name (e.g. ``reflex-enterprise``). | ||
|
|
||
| Returns: | ||
| The path to the installed CHANGELOG.md, or None when the distribution | ||
| is not installed or does not ship one. | ||
| """ | ||
| try: | ||
| dist = distribution(package) | ||
| except PackageNotFoundError: | ||
| return None | ||
| candidates = [file for file in dist.files or () if file.name == "CHANGELOG.md"] | ||
| # Prefer the shallowest record — a wheel may also vendor third-party | ||
| # changelogs deeper in its tree. | ||
| for file in sorted(candidates, key=lambda file: len(file.parts)): | ||
| path = Path(str(dist.locate_file(file))) | ||
| if path.is_file(): | ||
| return path | ||
| return None | ||
|
|
||
|
|
||
| def discover_changelogs(repo_root: Path) -> dict[str, Path]: | ||
| """Find all package changelogs to publish on the docs site. | ||
|
|
||
| Args: | ||
| repo_root: The repo checkout root. | ||
|
|
||
| Returns: | ||
| A mapping of package name to CHANGELOG.md path, with ``reflex`` first | ||
| and the remaining packages in alphabetical order. | ||
| """ | ||
| changelogs = discover_repo_changelogs(repo_root) | ||
| enterprise_changelog = find_distribution_changelog(ENTERPRISE_PACKAGE) | ||
| if enterprise_changelog is not None: | ||
| changelogs[ENTERPRISE_PACKAGE] = enterprise_changelog | ||
| return { | ||
| name: changelogs[name] | ||
| for name in sorted(changelogs, key=lambda name: (name != "reflex", name)) | ||
| } | ||
|
|
||
|
|
||
| def changelog_page_title(package: str) -> str: | ||
| """Return the display title for a package changelog page. | ||
|
|
||
| Args: | ||
| package: The package name. | ||
|
|
||
| Returns: | ||
| The page title. | ||
| """ | ||
| return "Reflex Changelog" if package == "reflex" else f"{package} Changelog" | ||
|
|
||
|
|
||
| def normalize_changelog(source: str, title: str) -> str: | ||
| """Give changelog markdown a canonical top-level heading. | ||
|
|
||
| Towncrier-generated changelogs have no top-level heading, while | ||
| Keep-a-Changelog files (e.g. reflex-enterprise) start with a generic | ||
| ``# Changelog``. Replace any existing H1 with *title* so every changelog | ||
| page renders consistently. | ||
|
|
||
| Args: | ||
| source: The raw changelog markdown. | ||
| title: The canonical page title. | ||
|
|
||
| Returns: | ||
| The normalized markdown. | ||
| """ | ||
| lines = source.lstrip().splitlines() | ||
| if lines and lines[0].startswith("# "): | ||
| del lines[0] | ||
| body = "\n".join(lines).strip("\n") | ||
| return f"# {title}\n\n{body}\n" | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.