Skip to content

Commit 08138a7

Browse files
authored
Fix docs versioning relating to "v" prefix (#2018)
* version is without the "v" prefix * latest version should also be a number * add comment about version in conf.py * have update_switcher take "v" prefix into account * Update switcher.json * remove unused import * code style
1 parent 8c2f753 commit 08138a7

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

docs/_static/switcher.json

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,64 @@
44
"url": "https://python-visualization.github.io/folium/dev/"
55
},
66
{
7-
"name": "latest (v0.17.0)",
8-
"version": "latest",
7+
"name": "latest (0.18.0)",
8+
"version": "0.18.0",
99
"url": "https://python-visualization.github.io/folium/latest/"
1010
},
1111
{
12-
"version": "v0.16.0",
12+
"version": "0.17.0",
13+
"url": "https://python-visualization.github.io/folium/v0.17.0/"
14+
},
15+
{
16+
"version": "0.16.0",
1317
"url": "https://python-visualization.github.io/folium/v0.16.0/"
1418
},
1519
{
16-
"version": "v0.15.1",
20+
"version": "0.15.1",
1721
"url": "https://python-visualization.github.io/folium/v0.15.1/"
1822
},
1923
{
20-
"version": "v0.14.0",
24+
"version": "0.14.0",
2125
"url": "https://python-visualization.github.io/folium/version-v0.14.0/"
2226
},
2327
{
24-
"version": "v0.12.1",
28+
"version": "0.12.1",
2529
"url": "https://python-visualization.github.io/folium/version-v0.12.1/"
2630
},
2731
{
28-
"version": "v0.12.0",
32+
"version": "0.12.0",
2933
"url": "https://python-visualization.github.io/folium/version-v0.12.0/"
3034
},
3135
{
32-
"version": "v0.11.0",
36+
"version": "0.11.0",
3337
"url": "https://python-visualization.github.io/folium/version-v0.11.0/"
3438
},
3539
{
36-
"version": "v0.10.1",
40+
"version": "0.10.1",
3741
"url": "https://python-visualization.github.io/folium/version-v0.10.1/"
3842
},
3943
{
40-
"version": "v0.10.0",
44+
"version": "0.10.0",
4145
"url": "https://python-visualization.github.io/folium/version-v0.10.0/"
4246
},
4347
{
44-
"version": "v0.9.1",
48+
"version": "0.9.1",
4549
"url": "https://python-visualization.github.io/folium/version-v0.9.1/"
4650
},
4751
{
48-
"version": "v0.9.0",
52+
"version": "0.9.0",
4953
"url": "https://python-visualization.github.io/folium/version-v0.9.0/"
5054
},
5155
{
52-
"version": "v0.8.3",
56+
"version": "0.8.3",
5357
"url": "https://python-visualization.github.io/folium/version-v0.8.3/"
5458
},
5559
{
56-
"version": "v0.8.2",
60+
"version": "0.8.2",
5761
"url": "https://python-visualization.github.io/folium/version-v0.8.2/"
5862
},
5963
{
60-
"version": "v0.8.1",
64+
"version": "0.8.1",
6165
"url": "https://python-visualization.github.io/folium/version-v0.8.1/"
6266
}
6367
]

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060
import folium
6161

62+
# N.B. this version is without the "v" prefix
6263
version = release = folium.__version__
6364
print(f"Version: {version}")
6465

docs/update_switcher.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import argparse
77
import json
88
import os
9-
import re
109

1110

1211
def main():
@@ -16,6 +15,8 @@ def main():
1615
"--version", "-v", required=True, type=str, help="The new version to add"
1716
)
1817
args = parser.parse_args()
18+
# drop the "v" prefix
19+
new_version_without_prefix = args.version[1:]
1920

2021
# Setup path to switcher.json (relative to this script) and load it
2122
switcher_path = os.path.join(os.path.dirname(__file__), "_static", "switcher.json")
@@ -24,17 +25,18 @@ def main():
2425

2526
# first we get the version number of the previous version
2627
for i, version in enumerate(switcher):
27-
if version["version"] == "latest":
28+
if version.get("name", "").startswith("latest"):
2829
latest_index = i
29-
previous_version = re.search(
30-
r"latest \(([v.\d]+)\)", version["name"]
31-
).group(1)
32-
if previous_version == args.version:
33-
print(f"Version {args.version} already is the latest version. Exiting.")
30+
previous_version = version["version"]
31+
if previous_version == new_version_without_prefix:
32+
print(
33+
f"Version {new_version_without_prefix} already is the latest version. Exiting."
34+
)
3435
return
3536

36-
# now replace the name of this one with the new version
37-
switcher[i]["name"] = f"latest ({args.version})"
37+
# now replace the name and version of this one with the new version
38+
switcher[i]["name"] = f"latest ({new_version_without_prefix})"
39+
switcher[i]["version"] = new_version_without_prefix
3840
break
3941
else:
4042
raise ValueError("'latest' version not found in switcher.json")
@@ -47,7 +49,7 @@ def main():
4749
else:
4850
previous_version_entry = {
4951
"version": previous_version,
50-
"url": f"https://python-visualization.github.io/folium/{previous_version}/",
52+
"url": f"https://python-visualization.github.io/folium/v{previous_version}/",
5153
}
5254
switcher.insert(latest_index + 1, previous_version_entry)
5355

0 commit comments

Comments
 (0)