Skip to content

Commit

Permalink
Merge pull request #1 from SingularityX-ai/fix_bad_docstring
Browse files Browse the repository at this point in the history
Fix bad docstring
  • Loading branch information
sumansaurabh authored Feb 6, 2024
2 parents 2d7fc33 + 2ca227d commit d819b4f
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit d819b4f

Please sign in to comment.