GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow passing multiple branches to build via CLI by hugovk · Pull Request #235 · python/docsbuild-scripts

Allow passing multiple branches to build via CLI #235

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.

Sign up for GitHub

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
AA-Turner merged 12 commits into python:main from hugovk:version-filter
Apr 11, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

Allow passing multiple branches to build via CLI #235

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
12 commits
Select commit Hold shift + click to select a range
f70b86d
Measure test coverage
hugovk Dec 8, 2024
22d1fba
Add a test for Version.filter for single version
hugovk Dec 8, 2024
08cf923
Add a test for Versions.filter for single version
hugovk Apr 11, 2025
6979d6c
Add a test for Version.filter with default branch
hugovk Dec 8, 2024
174c46d
Add a test for Versions.filter with default branch
hugovk Apr 11, 2025
40dc145
Allow passing multiple branches build via CLI
hugovk Dec 8, 2024
f7e617d
Use argparse's 'deprecated', added in 3.13
hugovk Apr 11, 2025
f85bbfc
Upgrade action
hugovk Apr 11, 2025
5b5d21a
Correct --language to --languages in README
hugovk Dec 8, 2024
7aef3ec
Just remove --branch
hugovk Apr 11, 2025
212ec60
Apply suggestions from code review
hugovk Apr 11, 2025
36e1eb5
Format
AA-Turner Apr 11, 2025
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

7 changes: 7 additions & 0 deletions 7 .coveragerc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .coveragerc to control coverage.py

[report]
# Regexes for lines to exclude from consideration
exclude_also =
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
7 changes: 7 additions & 0 deletions 7 .github/workflows/test.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ jobs:
- name: Tox tests
run: |
uvx --with tox-uv tox -e py

- name: Upload coverage
uses: codecov/codecov-action@v5
with:
flags: ${{ matrix.os }}
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
token: ${{ secrets.CODECOV_ORG_TOKEN }}
7 changes: 6 additions & 1 deletion 7 README.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# docsbuild-scripts

[![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)
[![Codecov](https://codecov.io/gh/python/docsbuild-scripts/branch/main/graph/badge.svg)](https://codecov.io/gh/python/docsbuild-scripts)

This repository contains scripts for automatically building the Python
documentation on [docs.python.org](https://docs.python.org).

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

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


## Check current version
Expand Down
19 changes: 10 additions & 9 deletions 19 build_docs.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ def from_json(cls, data) -> Versions:
)
return cls(versions)

def filter(self, branch: str = "") -> Sequence[Version]:
def filter(self, branches: Sequence[str] = ()) -> Sequence[Version]:
"""Filter the given versions.

If *branch* is given, only *versions* matching *branch* are returned.
If *branches* is given, only *versions* matching *branches* are returned.

Else all live versions are returned (this means no EOL and no
security-fixes branches).
"""
if branch:
return [v for v in self if branch in (v.name, v.branch_or_tag)]
if branches:
branches = frozenset(branches)
return [v for v in self if {v.name, v.branch_or_tag} & branches]
return [v for v in self if v.status not in {"EOL", "security-fixes"}]

@property
Expand Down Expand Up @@ -935,9 +936,10 @@ def parse_args():
)
parser.add_argument(
"-b",
"--branch",
"--branches",
nargs="*",
metavar="3.12",
help="Version to build (defaults to all maintained branches).",
help="Versions to build (defaults to all maintained branches).",
)
parser.add_argument(
"-r",
Expand Down Expand Up @@ -971,7 +973,6 @@ def parse_args():
)
parser.add_argument(
"--languages",
"--language",
nargs="*",
help="Language translation, as a PEP 545 language tag like"
" 'fr' or 'pt-br'. "
Expand Down Expand Up @@ -1045,10 +1046,10 @@ def build_docs(args: argparse.Namespace) -> bool:
# This runs languages in config.toml order and versions newest first.
todo = [
(version, language)
for version in versions.filter(args.branch)
for version in versions.filter(args.branches)
for language in reversed(languages.filter(args.languages))
]
del args.branch
del args.branches
del args.languages

build_succeeded = set()
Expand Down
62 changes: 62 additions & 0 deletions 62 tests/test_build_docs_versions.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from build_docs import Versions, Version


def test_filter_default() -> None:
# Arrange
versions = Versions([
Version("3.14", status="feature"),
Version("3.13", status="bugfix"),
Version("3.12", status="bugfix"),
Version("3.11", status="security"),
Version("3.10", status="security"),
Version("3.9", status="security"),
])

# Act
filtered = versions.filter()

# Assert
assert filtered == [
Version("3.14", status="feature"),
Version("3.13", status="bugfix"),
Version("3.12", status="bugfix"),
]


def test_filter_one() -> None:
# Arrange
versions = Versions([
Version("3.14", status="feature"),
Version("3.13", status="bugfix"),
Version("3.12", status="bugfix"),
Version("3.11", status="security"),
Version("3.10", status="security"),
Version("3.9", status="security"),
])

# Act
filtered = versions.filter(["3.13"])

# Assert
assert filtered == [Version("3.13", status="security")]


def test_filter_multiple() -> None:
# Arrange
versions = Versions([
Version("3.14", status="feature"),
Version("3.13", status="bugfix"),
Version("3.12", status="bugfix"),
Version("3.11", status="security"),
Version("3.10", status="security"),
Version("3.9", status="security"),
])

# Act
filtered = versions.filter(["3.13", "3.14"])

# Assert
assert filtered == [
Version("3.14", status="feature"),
Version("3.13", status="security"),
]
13 changes: 12 additions & 1 deletion 13 tox.ini
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ skip_install = true
deps =
-r requirements.txt
pytest
pytest-cov
pass_env =
FORCE_COLOR
set_env =
COVERAGE_CORE = sysmon
commands =
{envpython} -m pytest {posargs}
{envpython} -m pytest \
--cov . \
--cov tests \
--cov-report html \
--cov-report term \
--cov-report xml \
{posargs}

[testenv:lint]
skip_install = true
Expand Down
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.