Skip to content

Commit 9c2dd6f

Browse files
committed
build(docs): add warning for parsing \n in exmaple response
1 parent 5b71f73 commit 9c2dd6f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs_parser.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,15 @@ def gen_method(method: dict, file_content: str) -> str:
283283
return content + SEPARATOR
284284

285285
description = text(docstring.short_description or '', newline=True)
286-
description += text(docstring.long_description or '', newline=True)
286+
# In some cases, the whole docstring text will be parsed in the long_description.
287+
# Avoid appending it in that case.
288+
if isinstance(docstring.long_description, str) and docstring.long_description.find('Parameters') != -1:
289+
print(docstring.params)
290+
print('========>', docstring.long_description)
291+
warnings.warn(f'[{method["name"]}] failed to parse docstrings. Make sure the format is correct. Check guidelines if needed.', UserWarning)
292+
else:
293+
description += text(docstring.long_description or '', newline=True)
294+
287295
description = dedup_newlines(description)
288296

289297
internal_api = parse_method_api(method['name'], file_content)

documentation/docs/contribute/docs_guidelines.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ We use the [numpy convention](https://numpydoc.readthedocs.io/en/latest/format.h
4545
- Always use double quotes for the docstrings
4646
- Always use backticks (`) to display data types or objects, you can use code blocks specifying the language.
4747
- Don't use HTML tags, or keywords enclosed by gt/lt, instead use backticks.
48+
- Sometimes, return objects contain strings with `\n` inside of them, please remove them as they may avoid the docstring to be parsed.
4849

4950
#### Information
5051
- Try to keep the first line of the description brief. You can add more information in new lines.

0 commit comments

Comments
 (0)