Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit a1b362d

Browse files
dandhleeparthea
andauthored
fix: support parsing summary docstring that is not well formed (#200)
* fix: support parsing summary docstring even if it not well formed * test: update unit test * chore: remove unneeded TODO comment Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 0d1da9d commit a1b362d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

docfx_yaml/extension.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,10 @@ def _parse_docstring_summary(summary):
469469
continue
470470

471471
# Parse keywords if found.
472-
if part.startswith(".."):
472+
# lstrip is added to parse code blocks that are not formatted well.
473+
if part.lstrip('\n').startswith('..'):
473474
try:
474-
keyword = extract_keyword(part)
475+
keyword = extract_keyword(part.lstrip('\n'))
475476
except ValueError:
476477
raise ValueError(f"Please check the docstring: \n{summary}")
477478
# Works for both code-block and code

tests/test_unit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ def test_extract_header_from_markdown_bad_headers(self):
736736

737737
self.assertEqual(header_line_want, header_line_got)
738738

739+
739740
def test_parse_docstring_summary(self):
740741
# Check that the summary gets parsed correctly.
741742
attributes_want = []
@@ -794,7 +795,7 @@ def get_client_cert():
794795
You can also pass a mapping object.
795796
796797
797-
.. code-block:: ruby
798+
\n.. code-block:: ruby
798799
799800
\n from google.cloud.vision_v1 import ImageAnnotatorClient
800801
\n client = ImageAnnotatorClient(

0 commit comments

Comments
 (0)