Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2113fd7

Browse files
authored
Allow passing multiple branches to build via CLI (#235)
1 parent946b6bc commit2113fd7

File tree

6 files changed

+104
-11
lines changed

6 files changed

+104
-11
lines changed

‎.coveragerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .coveragerc to control coverage.py
2+
3+
[report]
4+
# Regexes for lines to exclude from consideration
5+
exclude_also =
6+
# Don't complain if non-runnable code isn't run:
7+
if__name__ == .__main__.:

‎.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ jobs:
3333
-name:Tox tests
3434
run:|
3535
uvx --with tox-uv tox -e py
36+
37+
-name:Upload coverage
38+
uses:codecov/codecov-action@v5
39+
with:
40+
flags:${{ matrix.os }}
41+
name:${{ matrix.os }} Python ${{ matrix.python-version }}
42+
token:${{ secrets.CODECOV_ORG_TOKEN }}

‎README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#docsbuild-scripts
2+
3+
[![GitHub Actions status](https://github.com/python/docsbuild-scripts/actions/workflows/test.yml/badge.svg)](https://github.com/python/docsbuild-scripts/actions/workflows/test.yml)
4+
[![Codecov](https://codecov.io/gh/python/docsbuild-scripts/branch/main/graph/badge.svg)](https://codecov.io/gh/python/docsbuild-scripts)
5+
16
This repository contains scripts for automatically building the Python
27
documentation on[docs.python.org](https://docs.python.org).
38

@@ -12,7 +17,7 @@ python3 ./build_docs.py --quick --build-root ./build_root --www-root ./www --log
1217
```
1318

1419
If you don't need to build all translations of all branches, add
15-
`--language en --branch main`.
20+
`--languages en --branches main`.
1621

1722

1823
##Check current version

‎build_docs.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ def from_json(cls, data) -> Versions:
8787
)
8888
returncls(versions)
8989

90-
deffilter(self,branch:str="")->Sequence[Version]:
90+
deffilter(self,branches:Sequence[str]=())->Sequence[Version]:
9191
"""Filter the given versions.
9292
93-
If *branch* is given, only *versions* matching *branch* are returned.
93+
If *branches* is given, only *versions* matching *branches* are returned.
9494
9595
Else all live versions are returned (this means no EOL and no
9696
security-fixes branches).
9797
"""
98-
ifbranch:
99-
return [vforvinselfifbranchin (v.name,v.branch_or_tag)]
98+
ifbranches:
99+
branches=frozenset(branches)
100+
return [vforvinselfif {v.name,v.branch_or_tag}&branches]
100101
return [vforvinselfifv.statusnotin {"EOL","security-fixes"}]
101102

102103
@property
@@ -936,9 +937,10 @@ def parse_args():
936937
)
937938
parser.add_argument(
938939
"-b",
939-
"--branch",
940+
"--branches",
941+
nargs="*",
940942
metavar="3.12",
941-
help="Version to build (defaults to all maintained branches).",
943+
help="Versions to build (defaults to all maintained branches).",
942944
)
943945
parser.add_argument(
944946
"-r",
@@ -972,7 +974,6 @@ def parse_args():
972974
)
973975
parser.add_argument(
974976
"--languages",
975-
"--language",
976977
nargs="*",
977978
help="Language translation, as a PEP 545 language tag like"
978979
" 'fr' or 'pt-br'. "
@@ -1046,10 +1047,10 @@ def build_docs(args: argparse.Namespace) -> bool:
10461047
# This runs languages in config.toml order and versions newest first.
10471048
todo= [
10481049
(version,language)
1049-
forversioninversions.filter(args.branch)
1050+
forversioninversions.filter(args.branches)
10501051
forlanguageinreversed(languages.filter(args.languages))
10511052
]
1052-
delargs.branch
1053+
delargs.branches
10531054
delargs.languages
10541055

10551056
build_succeeded=set()

‎tests/test_build_docs_versions.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
frombuild_docsimportVersions,Version
2+
3+
4+
deftest_filter_default()->None:
5+
# Arrange
6+
versions=Versions([
7+
Version("3.14",status="feature"),
8+
Version("3.13",status="bugfix"),
9+
Version("3.12",status="bugfix"),
10+
Version("3.11",status="security"),
11+
Version("3.10",status="security"),
12+
Version("3.9",status="security"),
13+
])
14+
15+
# Act
16+
filtered=versions.filter()
17+
18+
# Assert
19+
assertfiltered== [
20+
Version("3.14",status="feature"),
21+
Version("3.13",status="bugfix"),
22+
Version("3.12",status="bugfix"),
23+
]
24+
25+
26+
deftest_filter_one()->None:
27+
# Arrange
28+
versions=Versions([
29+
Version("3.14",status="feature"),
30+
Version("3.13",status="bugfix"),
31+
Version("3.12",status="bugfix"),
32+
Version("3.11",status="security"),
33+
Version("3.10",status="security"),
34+
Version("3.9",status="security"),
35+
])
36+
37+
# Act
38+
filtered=versions.filter(["3.13"])
39+
40+
# Assert
41+
assertfiltered== [Version("3.13",status="security")]
42+
43+
44+
deftest_filter_multiple()->None:
45+
# Arrange
46+
versions=Versions([
47+
Version("3.14",status="feature"),
48+
Version("3.13",status="bugfix"),
49+
Version("3.12",status="bugfix"),
50+
Version("3.11",status="security"),
51+
Version("3.10",status="security"),
52+
Version("3.9",status="security"),
53+
])
54+
55+
# Act
56+
filtered=versions.filter(["3.13","3.14"])
57+
58+
# Assert
59+
assertfiltered== [
60+
Version("3.14",status="feature"),
61+
Version("3.13",status="security"),
62+
]

‎tox.ini

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,19 @@ skip_install = true
1212
deps =
1313
-r requirements.txt
1414
pytest
15+
pytest-cov
16+
pass_env =
17+
FORCE_COLOR
18+
set_env =
19+
COVERAGE_CORE = sysmon
1520
commands =
16-
{envpython} -m pytest {posargs}
21+
{envpython} -m pytest \
22+
--cov . \
23+
--cov tests \
24+
--cov-report html \
25+
--cov-report term \
26+
--cov-report xml \
27+
{posargs}
1728

1829
[testenv:lint]
1930
skip_install = true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp