From 9d81555ad1bfa31208e20ea8837b69d7fd29de45 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Thu, 25 Jan 2024 20:59:26 -0800 Subject: [PATCH] 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 --- src/snakeoil/dist/sphinxext.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/snakeoil/dist/sphinxext.py b/src/snakeoil/dist/sphinxext.py index 7d04c49d..36d63e23 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: