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]>
Signed-off-by: Arthur Zamarin <[email protected]>
  • Loading branch information
ferringb authored and arthurzam committed Jan 26, 2024
1 parent e3a44c9 commit 0751928
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] = []
for author in pyproj['project']['authors']:
name, email = author.get('name'), author.get('email')
if name:
if email:
authors_list.append(f'{name} <{email}>')
else:
authors_list.append(name)
elif email:
authors_list.append(email)
else:
# no name or contact info, so ignore it.
continue

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

0 comments on commit 0751928

Please sign in to comment.