Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions PyDocSmith/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,19 @@ def _build_meta(self, text: str, title: str) -> DocstringMeta:
"""

section = self.sections[title]
if text.strip() == "":
return

if (
section.type == SectionType.SINGULAR_OR_MULTIPLE
and not MULTIPLE_PATTERN.match(text)
) or section.type == SectionType.SINGULAR:
if not text[0].isalnum():
return
return self._build_single_meta(section, text)

if ":" not in text:
return
raise ParseError(f"Expected a colon in {text!r}.")

# Split spec and description
Expand All @@ -119,7 +124,12 @@ def _build_meta(self, text: str, title: str) -> DocstringMeta:
first_line, rest = desc.split("\n", 1)
desc = first_line + "\n" + inspect.cleandoc(rest)
desc = desc.strip("\n")


if before and not before[0].isalnum():
return

if desc and not desc[0].isalnum():
return
return self._build_multi_meta(section, before, desc)

@staticmethod
Expand Down Expand Up @@ -283,7 +293,7 @@ def parse(self, text: str) -> Docstring:
for j, (start, end) in enumerate(c_splits):
part = chunk[start:end].strip("\n")
ret.meta.append(self._build_meta(part, title))

ret.meta = [m for m in ret.meta if m]
return ret


Expand Down