Skip to content

Commit aad4ea4

Browse files
committed
fixing the generator to avoid listing an empty author
1 parent 1207ced commit aad4ea4

File tree

4 files changed

+13
-31
lines changed

4 files changed

+13
-31
lines changed

arkdoc/generator/html.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ def generate_one(self, path: str, functions: List[spec.Function]):
139139

140140
for func in functions:
141141
links += html.nav_item(func.name, html.anchorize(func.name))
142+
authors = html.div(
143+
html.h4(html.plural("Author", len(func.desc.authors))),
144+
", ".join(
145+
[html.a(f"@{a.split('/')[-1]}", a) for a in func.desc.authors]
146+
),
147+
) if func.desc.authors else ""
142148
content = html.div(
143149
html.inline_code(func.signature),
144150
"<br>",
@@ -153,12 +159,7 @@ def generate_one(self, path: str, functions: List[spec.Function]):
153159
]
154160
),
155161
),
156-
html.div(
157-
html.h4(html.plural("Author", len(func.desc.authors))),
158-
", ".join(
159-
[html.a(f"@{a.split('/')[-1]}", a) for a in func.desc.authors]
160-
),
161-
),
162+
authors,
162163
)
163164
if func.desc.code:
164165
content += html.div(html.h4("Example"), html.code(func.desc.code))

arkdoc/generator/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ def extractor(data: Dict, doc: Documentation) -> Tuple[Dict, str]:
2020
if tag in comment.value:
2121
res = re.sub(fr"#+ *{tag}", "", comment.value).strip()
2222

23-
if isinstance(data[key], list):
24-
data[key].append(res)
25-
else:
26-
data[key] = res
23+
if res:
24+
if isinstance(data[key], list):
25+
data[key].append(res)
26+
else:
27+
data[key] = res
2728
else:
2829
if "=begin" in comment.value:
2930
in_code = True
@@ -41,7 +42,7 @@ def extractor(data: Dict, doc: Documentation) -> Tuple[Dict, str]:
4142
param_name, desc = param.split(" ", 1)
4243
data["param"][i] = spec.Param(param_name, desc)
4344

44-
data["author"] = [el.strip() for el in data["author"].split(",")]
45+
data["author"] = [el.strip() for el in data["author"].split(",") if data["author"]]
4546

4647
return data, "\n".join(code)
4748

templates/404.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

templates/temp.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)