Skip to content

Commit

Permalink
fix(sphinx_ext): email is optional.
Browse files Browse the repository at this point in the history
It's not obvious, but both name and email are optional for
authors.  NFC what one does with an author field lacking both,
but that's for the PEP authors to resolve.

We have authors in the pkgcore project that don't have email
listed, which now breaks html generation.  Thus this change.

The only hanky point here is that if it's just email, we output
that w/out the usual `<{email}>` brackets per standards.

Signed-off-by: Brian Harring <[email protected]>
  • Loading branch information
ferringb committed Jan 26, 2024
1 parent b1e318b commit 9d81555
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/snakeoil/dist/sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ def prepare_scripts_man(repo_dir: Path, man_pages: list[tuple]):
with open(repo_dir / 'pyproject.toml', 'rb') as file:
pyproj = tomllib.load(file)

authors_list = [
f'{author["name"]} <{author["email"]}>' for author in pyproj['project']['authors']
]
authors_list: list[str] = []

Check warning on line 33 in src/snakeoil/dist/sphinxext.py

View check run for this annotation

Codecov / codecov/patch

src/snakeoil/dist/sphinxext.py#L33

Added line #L33 was not covered by tests
for author in pyproj['project']['authors']:
name, email = author.get('name'), author.get('email')

Check warning on line 35 in src/snakeoil/dist/sphinxext.py

View check run for this annotation

Codecov / codecov/patch

src/snakeoil/dist/sphinxext.py#L35

Added line #L35 was not covered by tests
if name:
if email:
authors_list.append(f'{name} <{email}>')

Check warning on line 38 in src/snakeoil/dist/sphinxext.py

View check run for this annotation

Codecov / codecov/patch

src/snakeoil/dist/sphinxext.py#L38

Added line #L38 was not covered by tests
else:
authors_list.append(name)

Check warning on line 40 in src/snakeoil/dist/sphinxext.py

View check run for this annotation

Codecov / codecov/patch

src/snakeoil/dist/sphinxext.py#L40

Added line #L40 was not covered by tests
elif email:
authors_list.append(email)

Check warning on line 42 in src/snakeoil/dist/sphinxext.py

View check run for this annotation

Codecov / codecov/patch

src/snakeoil/dist/sphinxext.py#L42

Added line #L42 was not covered by tests
else:
# no name or contact info, so ignore it.
continue

Check warning on line 45 in src/snakeoil/dist/sphinxext.py

View check run for this annotation

Codecov / codecov/patch

src/snakeoil/dist/sphinxext.py#L45

Added line #L45 was not covered by tests

for i, man_page in enumerate(man_pages):
if man_page[3] is None:
Expand Down

0 comments on commit 9d81555

Please sign in to comment.