-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add script to auto-update docs contents #30
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
Draft
MalteHerrmann
wants to merge
9
commits into
main
Choose a base branch
from
add-auto-update-script
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.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d50cd99
add boilerplate for auto-updating
MalteHerrmann ceb9b30
better handling for unsupported version suffixes
MalteHerrmann 59faa4f
use uv for python venv management
MalteHerrmann e897329
add some unit tests
MalteHerrmann 61179a6
add logic to check diff between latest checked version and latest mai…
MalteHerrmann 3f3024e
move tests next into scripts sub dir and refactor code into separate …
MalteHerrmann 826be67
Merge branch 'main' into add-auto-update-script
MalteHerrmann 73ca44c
add logic to check module versions from go.mod in Noble
MalteHerrmann a07ebb4
Merge branch 'main' into add-auto-update-script
MalteHerrmann 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [tools] | ||
| # Node.js - required for Docusaurus (package.json specifies >=18.0) | ||
| node = "20.18.0" | ||
| # Python - required for version tracking script | ||
| python = "3.12" | ||
| # Bun - used for package management and running scripts | ||
| bun = "1.2.13" | ||
| # uv - fast Python package installer and resolver | ||
| uv = "latest" | ||
|
|
||
| [tasks.install] | ||
| description = "Install all dependencies" | ||
| run = [ | ||
| "bun install", | ||
| "uv venv --clear", | ||
| "uv pip install --python .venv/bin/python -r requirements.txt" | ||
| ] | ||
|
|
||
| [tasks.start] | ||
| description = "Start local development server" | ||
| run = "bun start" | ||
|
|
||
| [tasks.build] | ||
| description = "Build static content" | ||
| run = "bun build" | ||
|
|
||
| [tasks.check-version] | ||
| description = "Check Noble version and compare with tracker" | ||
| run = "uv run python scripts/check_noble_version.py" | ||
|
|
||
| [tasks.test] | ||
| description = "Run pytest unit tests" | ||
| run = "uv run pytest scripts/check_noble_version/test_*.py -v" | ||
|
|
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,4 @@ | ||
| { | ||
| "last_tracked_version": "v10.0.0", | ||
| "last_checked": "2025-11-14T14:36:58.293690+00:00" | ||
| } |
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,3 @@ | ||
| requests>=2.31.0 | ||
| pytest>=8.0.0 | ||
|
|
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,11 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Noble Documentation Version Tracker | ||
|
|
||
| Entry point script that delegates to the package CLI. | ||
| """ | ||
|
|
||
| from check_noble_version.cli import main | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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,42 @@ | ||
| """ | ||
| Noble Documentation Version Tracker | ||
|
|
||
| This package provides functionality to track Noble chain versions and | ||
| generate diffs between versions for documentation updates. | ||
| """ | ||
|
|
||
| from check_noble_version.version import parse_version, compare_versions | ||
| from check_noble_version.parser import get_latest_version_from_upgrades | ||
| from check_noble_version.tracker import load_tracker, save_tracker | ||
| from check_noble_version.github import get_diff_between_tags, format_diff_summary | ||
| from check_noble_version.modules import ( | ||
| get_relevant_module_paths, | ||
| get_module_versions_for_tag, | ||
| get_module_diffs, | ||
| MODULE_MAPPINGS, | ||
| ) | ||
| from check_noble_version.config import ( | ||
| REPO_ROOT, | ||
| MAINNET_MDX_PATH, | ||
| TRACKER_JSON_PATH, | ||
| GITHUB_REPO, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "parse_version", | ||
| "compare_versions", | ||
| "get_latest_version_from_upgrades", | ||
| "load_tracker", | ||
| "save_tracker", | ||
| "get_diff_between_tags", | ||
| "format_diff_summary", | ||
| "get_relevant_module_paths", | ||
| "get_module_versions_for_tag", | ||
| "get_module_diffs", | ||
| "MODULE_MAPPINGS", | ||
| "REPO_ROOT", | ||
| "MAINNET_MDX_PATH", | ||
| "TRACKER_JSON_PATH", | ||
| "GITHUB_REPO", | ||
| ] | ||
|
|
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,138 @@ | ||
| """Command-line interface for the version tracker.""" | ||
|
|
||
| import sys | ||
|
|
||
| from check_noble_version.config import ( | ||
| MAINNET_MDX_PATH, | ||
| GITHUB_REPO, | ||
| ) | ||
| from check_noble_version.parser import get_latest_version_from_upgrades | ||
| from check_noble_version.tracker import load_tracker, save_tracker | ||
| from check_noble_version.version import compare_versions | ||
| from check_noble_version.github import get_diff_between_tags, format_diff_summary | ||
| from check_noble_version.modules import ( | ||
| get_module_versions_for_tag, | ||
| get_module_diffs, | ||
| ) | ||
|
|
||
|
|
||
| def main(): | ||
| """Main function to check version and compare with tracker.""" | ||
| print("Noble Documentation Version Tracker") | ||
| print("=" * 50) | ||
|
|
||
| # Get latest version from upgrades table | ||
| print(f"\nReading upgrades from: {MAINNET_MDX_PATH}") | ||
| latest_version = get_latest_version_from_upgrades(MAINNET_MDX_PATH) | ||
|
|
||
| if not latest_version: | ||
| print("Error: Could not determine latest version from upgrades table", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| print(f"Latest version in upgrades table: {latest_version}") | ||
|
|
||
| # Load tracker | ||
| tracker = load_tracker() | ||
| last_tracked = tracker.get("last_tracked_version") | ||
|
|
||
| if last_tracked: | ||
| print(f"Last tracked version: {last_tracked}") | ||
|
|
||
| # Compare versions | ||
| try: | ||
| comparison = compare_versions(last_tracked, latest_version) | ||
| except ValueError as e: | ||
| print(f"\n❌ Error: {e}", file=sys.stderr) | ||
| print("\nPlease ensure both versions are in the format 'vX.Y.Z' without suffixes.", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| if comparison == 0: | ||
| print("\n✓ Versions match! Documentation is up to date.") | ||
| # Update last_checked timestamp | ||
| save_tracker(latest_version) | ||
| sys.exit(0) | ||
| elif comparison < 0: | ||
| print(f"\n⚠ Version mismatch detected!") | ||
| print(f" Last tracked: {last_tracked}") | ||
| print(f" Latest in docs: {latest_version}") | ||
| print(f"\n The documentation has been updated with a new version.") | ||
| print(f"\n Generating diff between {last_tracked} and {latest_version}...") | ||
|
|
||
| diff_data = get_diff_between_tags(GITHUB_REPO, last_tracked, latest_version) | ||
| if diff_data: | ||
| print("\n" + "=" * 50) | ||
| print("DIFF SUMMARY") | ||
| print("=" * 50) | ||
| print(format_diff_summary(diff_data)) | ||
| print("=" * 50) | ||
|
|
||
| # Get module-specific information | ||
| print("\n" + "=" * 50) | ||
| print("MODULE VERSIONS & DIFFS") | ||
| print("=" * 50) | ||
|
|
||
| # Get module versions for both tags | ||
| print(f"\nFetching module versions for {last_tracked}...") | ||
| base_modules = get_module_versions_for_tag(GITHUB_REPO, last_tracked) | ||
| print(f"Fetching module versions for {latest_version}...") | ||
| head_modules = get_module_versions_for_tag(GITHUB_REPO, latest_version) | ||
|
|
||
| if base_modules and head_modules: | ||
| print("\nModule Version Changes:") | ||
| all_module_paths = set(base_modules.keys()) | set(head_modules.keys()) | ||
| for module_path in sorted(all_module_paths): | ||
| base_version = base_modules.get(module_path, "N/A") | ||
| head_version = head_modules.get(module_path, "N/A") | ||
| if base_version != head_version: | ||
| print(f" {module_path}: {base_version} → {head_version}") | ||
| elif base_version != "N/A": | ||
| print(f" {module_path}: {base_version} (unchanged)") | ||
|
|
||
| # Get module-specific diffs | ||
| print(f"\nFetching module-specific diffs...") | ||
| module_diffs = get_module_diffs(GITHUB_REPO, last_tracked, latest_version) | ||
|
|
||
| if module_diffs: | ||
| print("\nModule-Specific Changes:") | ||
| for module_path, diff_info in sorted(module_diffs.items()): | ||
| file_count = len(diff_info['files']) | ||
| additions = diff_info['total_additions'] | ||
| deletions = diff_info['total_deletions'] | ||
| changes = diff_info['total_changes'] | ||
| print(f"\n {module_path}:") | ||
| print(f" Files changed: {file_count}") | ||
| print(f" Changes: +{additions}, -{deletions} ({changes} total)") | ||
| if file_count <= 10: | ||
| for file_info in diff_info['files']: | ||
| status = file_info.get('status', 'unknown') | ||
| filename = file_info.get('filename', 'unknown') | ||
| print(f" [{status}] {filename}") | ||
| else: | ||
| for file_info in diff_info['files'][:5]: | ||
| status = file_info.get('status', 'unknown') | ||
| filename = file_info.get('filename', 'unknown') | ||
| print(f" [{status}] {filename}") | ||
| print(f" ... and {file_count - 5} more files") | ||
| else: | ||
| print("\n No changes detected in tracked modules.") | ||
|
|
||
| print("=" * 50) | ||
| else: | ||
| print(f"\n ⚠ Could not fetch diff from GitHub API.") | ||
| print(f" You can view the comparison manually at:") | ||
| print(f" https://github.com/{GITHUB_REPO}/compare/{last_tracked}...{latest_version}") | ||
| else: | ||
| print(f"\n⚠ Warning: Last tracked version ({last_tracked}) is newer than latest in docs ({latest_version})") | ||
| print(" This shouldn't happen - the docs may have been reverted.") | ||
| else: | ||
| print("\nNo previous version tracked (first run)") | ||
| print(f"Setting initial tracked version to: {latest_version}") | ||
| save_tracker(latest_version) | ||
| print("\n✓ Tracker initialized. Run again to check for updates.") | ||
|
|
||
| print("\n" + "=" * 50) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
|
|
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,16 @@ | ||
| """Configuration constants for the version tracker.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| # Repository root (parent of scripts directory) | ||
| REPO_ROOT = Path(__file__).parent.parent.parent | ||
|
|
||
| # Path to mainnet upgrades documentation | ||
| MAINNET_MDX_PATH = REPO_ROOT / "docs" / "build" / "chain-upgrades" / "mainnet.mdx" | ||
|
|
||
| # Path to version tracker JSON file | ||
| TRACKER_JSON_PATH = REPO_ROOT / ".noble_version_tracker.json" | ||
|
|
||
| # GitHub repository | ||
| GITHUB_REPO = "noble-assets/noble" | ||
|
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell command snippets: drop the
$prompt to satisfy markdownlint and ease copy‑paste.The commands are currently written with a
$prompt (e.g.,$ bun), which triggers MD014 and makes copy‑paste slightly less convenient. I’d suggest removing the prompt symbol:This keeps the docs lint‑clean and avoids confusion about what should actually be typed.
Also applies to: 14-15, 22-23
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
8-8: Dollar signs used before commands without showing output
(MD014, commands-show-output)
🤖 Prompt for AI Agents