Skip to content

Commit 7f71804

Browse files
committed
Improve Faust doc index extraction heuristics
1 parent 70a39d8 commit 7f71804

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

scripts/build_faust_doc_index.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ def parse_doc_body(body_lines: Iterable[str]) -> dict[str, object]:
359359
section = "summary"
360360
in_fence = False
361361
fence_buffer: list[str] = []
362+
current_param: dict[str, str] | None = None
362363

363364
def flush_fence() -> None:
364365
"""Commit the current fenced code block into the active logical section."""
@@ -395,6 +396,7 @@ def flush_fence() -> None:
395396

396397
if re.match(r"^where\s*:?\s*$", trimmed, flags=re.IGNORECASE):
397398
section = "where"
399+
current_param = None
398400
continue
399401

400402
if trimmed.startswith("```"):
@@ -422,7 +424,10 @@ def flush_fence() -> None:
422424
if section == "where":
423425
match = PARAM_RE.match(trimmed)
424426
if match:
425-
params.append({"name": match.group(1).strip(), "description": match.group(2).strip()})
427+
current_param = {"name": match.group(1).strip(), "description": match.group(2).strip()}
428+
params.append(current_param)
429+
elif current_param and trimmed and not trimmed.startswith("* "):
430+
current_param["description"] = f"{current_param['description']} {trimmed}".strip()
426431
continue
427432

428433
if section == "reference":
@@ -462,9 +467,13 @@ def parse_usage_io(usage: str | None) -> dict[str, int | str | None]:
462467
if not usage:
463468
return {"inSignals": None, "outSignals": None, "raw": None}
464469

465-
parts = usage.split(":", 1)
466-
lhs = parts[0].strip() if parts else ""
467-
rhs = parts[1].strip() if len(parts) > 1 else ""
470+
parts = [part.strip() for part in usage.split(":")]
471+
if len(parts) >= 3:
472+
lhs = parts[0]
473+
rhs = parts[-1]
474+
else:
475+
lhs = ""
476+
rhs = parts[-1] if parts else ""
468477

469478
def count_signals(expr: str) -> int | None:
470479
if not expr:

0 commit comments

Comments
 (0)