Skip to content

Commit 56d72d4

Browse files
authored
Update the version tables in the README (#189)
* Update README tables * Remove EOL versions from the language table
1 parent 2135304 commit 56d72d4

File tree

3 files changed

+85
-78
lines changed

3 files changed

+85
-78
lines changed

README.md

+19-21
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,32 @@ of Sphinx we're using where:
2323

2424
Sphinx configuration in various branches:
2525

26-
========= ============= ============= ================== ==================
27-
version travis azure requirements.txt conf.py
28-
========= ============= ============= ================== ==================
29-
2.7 sphinx~=2.0.1 ø ø needs_sphinx='1.2'
30-
3.5 sphinx==1.8.2 ø ø needs_sphinx='1.8'
31-
3.6 sphinx==1.8.2 sphinx==1.8.2 ø needs_sphinx='1.2'
32-
3.7 ø ø ø ø
33-
3.8 ø ø sphinx==2.4.4 needs_sphinx='1.8'
34-
3.9 ø ø sphinx==2.4.4 needs_sphinx='1.8'
35-
3.1 ø ø sphinx==3.4.3 needs_sphinx='3.2'
36-
3.11 ø ø sphinx==4.5.0 needs_sphinx='4.2'
37-
3.12 ø ø sphinx==4.5.0 needs_sphinx='4.2'
38-
3.13 ø ø sphinx==6.2.1 needs_sphinx='4.2'
39-
========= ============= ============= ================== ==================
26+
========= ============= ================== ====================
27+
version travis requirements.txt conf.py
28+
========= ============= ================== ====================
29+
2.7 sphinx~=2.0.1 ø needs_sphinx='1.2'
30+
3.5 sphinx==1.8.2 ø needs_sphinx='1.8'
31+
3.6 sphinx==1.8.2 ø needs_sphinx='1.2'
32+
3.7 sphinx==1.8.2 sphinx==2.3.1 needs_sphinx="1.6.6"
33+
3.8 ø sphinx==2.4.4 needs_sphinx='1.8'
34+
3.9 ø sphinx==2.4.4 needs_sphinx='1.8'
35+
3.10 ø sphinx==3.4.3 needs_sphinx='3.2'
36+
3.11 ø sphinx~=7.2.0 needs_sphinx='4.2'
37+
3.12 ø sphinx~=8.0.0 needs_sphinx='6.2.1'
38+
3.13 ø sphinx~=8.0.0 needs_sphinx='6.2.1'
39+
3.14 ø sphinx~=8.0.0 needs_sphinx='6.2.1'
40+
========= ============= ================== ====================
4041

4142
Sphinx build as seen on docs.python.org:
4243

4344
========= ===== ===== ===== ===== ===== ===== ===== ===== ======= ===== ===== ======= =======
4445
version en es fr id it ja ko pl pt-br tr uk zh-cn zh-tw
4546
========= ===== ===== ===== ===== ===== ===== ===== ===== ======= ===== ===== ======= =======
46-
2.7 ø 2.3.1 ø 2.3.1 2.3.1 ø 2.3.1 2.3.1 ø 2.3.1 2.3.1 ø 2.3.1
47-
3.5 ø 1.8.4 1.8.4 1.8.4 1.8.4 ø 1.8.4 1.8.4 ø 1.8.4 1.8.4 1.8.4 1.8.4
48-
3.6 ø 2.3.1 2.3.1 2.3.1 2.3.1 ø 2.3.1 2.3.1 ø 2.3.1 2.3.1 2.3.1 2.3.1
49-
3.7 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1 2.3.1
5047
3.8 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4
5148
3.9 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4 2.4.4
5249
3.10 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3 3.4.3
53-
3.11 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0
54-
3.12 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0 4.5.0
55-
3.13 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1 6.2.1
50+
3.11 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6 7.2.6
51+
3.12 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2
52+
3.13 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2
53+
3.14 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2 8.0.2
5654
========= ===== ===== ===== ===== ===== ===== ===== ===== ======= ===== ===== ======= =======

build_docs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,9 @@ def parse_versions_from_devguide():
10791079
"python/devguide/main/include/release-cycle.json",
10801080
timeout=30,
10811081
).json()
1082-
return [Version.from_json(name, release) for name, release in releases.items()]
1082+
versions = [Version.from_json(name, release) for name, release in releases.items()]
1083+
versions.sort(key=Version.as_tuple)
1084+
return versions
10831085

10841086

10851087
def parse_languages_from_config():

check_versions.py

+63-56
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import build_docs
1414

1515
logger = logging.getLogger(__name__)
16+
VERSIONS = build_docs.parse_versions_from_devguide()
17+
LANGUAGES = build_docs.parse_languages_from_config()
1618

1719

1820
def parse_args():
@@ -24,102 +26,107 @@ def parse_args():
2426
return parser.parse_args()
2527

2628

27-
def remote_by_url(repo: git.Repo, url_pattern: str):
29+
def find_upstream_remote_name(repo: git.Repo) -> str:
2830
"""Find a remote of repo matching the regex url_pattern."""
2931
for remote in repo.remotes:
3032
for url in remote.urls:
31-
if re.search(url_pattern, url):
32-
return remote
33+
if "github.com/python" in url:
34+
return f"{remote.name}/"
3335

3436

3537
def find_sphinx_spec(text: str):
3638
if found := re.search(
37-
"""sphinx[=<>~]{1,2}[0-9.]{3,}|needs_sphinx = [0-9.'"]*""", text, flags=re.I
39+
"""sphinx[=<>~]{1,2}[0-9.]{3,}|needs_sphinx = [0-9.'"]*""",
40+
text,
41+
flags=re.IGNORECASE,
3842
):
3943
return found.group(0).replace(" ", "")
4044
return "ø"
4145

4246

43-
def find_sphinx_in_file(repo: git.Repo, branch, filename):
44-
upstream = remote_by_url(repo, "github.com.python").name
45-
# Just in case you don't use origin/:
46-
branch = branch.replace("origin/", upstream + "/")
47-
try:
48-
return find_sphinx_spec(repo.git.show(f"{branch}:{filename}"))
49-
except git.exc.GitCommandError:
50-
return "ø"
47+
def find_sphinx_in_files(repo: git.Repo, branch_or_tag, filenames):
48+
upstream = find_upstream_remote_name(repo)
49+
# Just in case you don't use upstream/:
50+
branch_or_tag = branch_or_tag.replace("upstream/", upstream)
51+
specs = []
52+
for filename in filenames:
53+
try:
54+
blob = repo.git.show(f"{branch_or_tag}:{filename}")
55+
except git.exc.GitCommandError:
56+
specs.append("ø")
57+
else:
58+
specs.append(find_sphinx_spec(blob))
59+
return specs
5160

5261

5362
CONF_FILES = {
5463
"travis": ".travis.yml",
55-
"azure": ".azure-pipelines/docs-steps.yml",
5664
"requirements.txt": "Doc/requirements.txt",
5765
"conf.py": "Doc/conf.py",
5866
}
5967

6068

61-
def search_sphinx_versions_in_cpython(repo: git.Repo):
62-
repo.git.fetch("https://github.com/python/cpython")
63-
table = []
64-
for version in sorted(build_docs.VERSIONS):
65-
table.append(
66-
[
67-
version.name,
68-
*[
69-
find_sphinx_in_file(repo, version.branch_or_tag, filename)
70-
for filename in CONF_FILES.values()
71-
],
72-
]
73-
)
74-
print(tabulate(table, headers=["version", *CONF_FILES.keys()], tablefmt="rst"))
69+
def branch_or_tag_for(version):
70+
if version.status == "EOL":
71+
return f"tags/{version.branch_or_tag}"
72+
return f"upstream/{version.branch_or_tag}"
7573

7674

77-
async def get_version_in_prod(language, version):
78-
url = f"https://docs.python.org/{language}/{version}/".replace("/en/", "/")
75+
def search_sphinx_versions_in_cpython(repo: git.Repo):
76+
repo.git.fetch("https://github.com/python/cpython")
77+
filenames = CONF_FILES.values()
78+
table = [
79+
[
80+
version.name,
81+
*find_sphinx_in_files(repo, branch_or_tag_for(version), filenames),
82+
]
83+
for version in VERSIONS
84+
]
85+
headers = ["version", *CONF_FILES.keys()]
86+
print(tabulate(table, headers=headers, tablefmt="rst", disable_numparse=True))
87+
88+
89+
async def get_version_in_prod(language: str, version: str) -> str:
90+
if language == "en":
91+
url = f"https://docs.python.org/{version}/"
92+
else:
93+
url = f"https://docs.python.org/{language}/{version}/"
7994
async with httpx.AsyncClient() as client:
8095
try:
81-
response = await client.get(url, timeout=10)
96+
response = await client.get(url, timeout=5)
8297
except httpx.ConnectTimeout:
8398
return "(timeout)"
84-
text = response.text.encode("ASCII", errors="ignore").decode("ASCII")
99+
# Python 2.6--3.7: sphinx.pocoo.org
100+
# from Python 3.8: www.sphinx-doc.org
85101
if created_using := re.search(
86-
r"(?:sphinx.pocoo.org|www.sphinx-doc.org).*?([0-9.]+[0-9])", text, flags=re.M
102+
r"(?:sphinx.pocoo.org|www.sphinx-doc.org).*?([0-9.]+[0-9])", response.text
87103
):
88104
return created_using.group(1)
89105
return "ø"
90106

91107

92108
async def which_sphinx_is_used_in_production():
93-
table = []
94-
for version in sorted(build_docs.VERSIONS):
95-
table.append(
96-
[
97-
version.name,
98-
*await asyncio.gather(
99-
*[
100-
get_version_in_prod(language.tag, version.name)
101-
for language in build_docs.LANGUAGES
102-
]
103-
),
104-
]
105-
)
106-
print(
107-
tabulate(
108-
table,
109-
disable_numparse=True,
110-
headers=[
111-
"version",
112-
*[language.tag for language in sorted(build_docs.LANGUAGES)],
113-
],
114-
tablefmt="rst",
115-
)
116-
)
109+
table = [
110+
[
111+
version.name,
112+
*await asyncio.gather(
113+
*[
114+
get_version_in_prod(language.tag, version.name)
115+
for language in LANGUAGES
116+
]
117+
),
118+
]
119+
for version in VERSIONS
120+
]
121+
headers = ["version", *[language.tag for language in LANGUAGES]]
122+
print(tabulate(table, headers=headers, tablefmt="rst", disable_numparse=True))
117123

118124

119125
def main():
120126
logging.basicConfig(level=logging.INFO)
121127
logging.getLogger("charset_normalizer").setLevel(logging.WARNING)
122128
logging.getLogger("asyncio").setLevel(logging.WARNING)
129+
logging.getLogger("httpx").setLevel(logging.WARNING)
123130
args = parse_args()
124131
repo = git.Repo(args.cpython_clone)
125132
print("Sphinx configuration in various branches:", end="\n\n")

0 commit comments

Comments
 (0)