-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Automatically create docs PR on release #1965
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
Merged
Conengmo
merged 18 commits into
python-visualization:main
from
merschformann:merschformann/publish-docs-pr
Jun 14, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
baaa90d
Adding auto switcher bump, sending main branch docs to dev
merschformann a92b4b7
Use auto commit action to push switcher.json updates
merschformann 924fd4b
Adding switcher update script
merschformann 2221707
Using custom commit message
merschformann 1e4e8e5
Point latest to actually latest version
merschformann 9799c9f
Use PR instead of directly pushing to main
merschformann fce395c
Merge branch 'python-visualization:main' into main
merschformann c357d87
Refine comment
merschformann ad0f51d
Merge remote-tracking branch 'origin/main'
merschformann 45c5b5b
Use auto-commits
merschformann d83d74d
Remove unused permissions
merschformann 012c7aa
Remove obsolete token
merschformann e4bdbc0
Setup permission, only run on release
merschformann 8173d0f
Create PR with updated switcher.json
merschformann a1c0c07
Merge branch 'python-visualization:main' into merschformann/publish-d…
merschformann 1db339a
Format with stock black
merschformann fc380a1
Update .github/workflows/deploy-docs.yml
Conengmo 7ad7d15
Update .github/workflows/deploy-docs.yml
Conengmo 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """ | ||
| This script is used to update switcher.json on docs releases. It adds the new version to | ||
| the list of versions and sets the latest version to the new version. | ||
| """ | ||
|
|
||
| import argparse | ||
| import json | ||
| import os | ||
|
|
||
|
|
||
| def main(): | ||
| # Define CLI arguments | ||
| parser = argparse.ArgumentParser(description="Update switcher.json") | ||
| parser.add_argument( | ||
| "--version", "-v", required=True, type=str, help="The new version to add" | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| # Setup path to switcher.json (relative to this script) and load it | ||
| switcher_path = os.path.join(os.path.dirname(__file__), "_static", "switcher.json") | ||
| with open(switcher_path) as f: | ||
| switcher = json.load(f) | ||
|
|
||
| # Find index of 'latest' entry | ||
| latest_index = None | ||
| for i, version in enumerate(switcher): | ||
| if version["version"] == "latest": | ||
| latest_index = i | ||
| break | ||
| if latest_index is None: | ||
| raise ValueError("'latest' version not found in switcher.json") | ||
|
|
||
| # Add the new version to the list of versions (we always insert it after latest) | ||
| new_version = { | ||
| "version": args.version, | ||
| "url": f"https://python-visualization.github.io/folium/{args.version}/", | ||
| } | ||
|
|
||
| # Update the latest version | ||
| switcher[latest_index]["url"] = new_version["url"] | ||
|
|
||
| # Make sure version is unique | ||
| if any(version["version"] == args.version for version in switcher): | ||
| print( | ||
| f"Version {args.version} already exists in switcher.json. Not adding it again." | ||
| ) | ||
| else: | ||
| switcher.insert(latest_index + 1, new_version) | ||
|
|
||
| # Write the updated switcher.json | ||
| with open(switcher_path, "w") as f: | ||
| json.dump(switcher, f, indent=2) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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.
@Conengmo and @merschformann do you need this? That means any change in the code won't be tested in the docs until it is on
main.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.
This is here to make sure that docs are only ever released from the main branch, thus, reflecting docs in the state the main branch is in. A push to main is also a trigger of this workflow.
It does not feel fully necessary, if the events would change to only be pushes to main and
release(this one could technically result in none-main being released if release is defined on branch). I am not sure whatpull_requestis for. It is just explicit about limiting docs releases to be coming from main.(just my two cents)
Maybe the triggers of the workflow and the checkout should be revised? 🤔
cc @Conengmo