aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2024-01-25 20:59:26 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2024-01-26 21:17:27 +0200
commit07519289999445518f9883eb2329af71d91b0aa5 (patch)
treeeb25187eda160d8383e7c71f6ac5ce98a24339be
parentci: fix doc.yml (diff)
downloadsnakeoil-07519289999445518f9883eb2329af71d91b0aa5.tar.gz
snakeoil-07519289999445518f9883eb2329af71d91b0aa5.tar.bz2
snakeoil-07519289999445518f9883eb2329af71d91b0aa5.zip
fix(sphinx_ext): email is optional.
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 <ferringb@gmail.com> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/snakeoil/dist/sphinxext.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/snakeoil/dist/sphinxext.py b/src/snakeoil/dist/sphinxext.py
index 7d04c49..36d63e2 100644
--- a/src/snakeoil/dist/sphinxext.py
+++ b/src/snakeoil/dist/sphinxext.py
@@ -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: