Docstring parsing from Google style docs#5684
Open
aaltat wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new Google-style docstring parser utility and its unit tests, while also applying widespread test string formatting cleanups and collapsing some generic type annotations to one-liners.
Changes:
- Introduce
robot.utils.docstring.parse_docstring()andParsedDocStringto extractArgs/Returnssections. - Add comprehensive unit tests for docstring parsing and add
assert_in()to test assertions utilities. - Refactor various tests and a few model type declarations to remove extra parentheses / collapse multi-line constructs.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| utest/utils/test_markuputils.py | Simplifies expected table HTML string construction in tests. |
| utest/utils/test_importer_util.py | Simplifies temporary module file content generation in tests. |
| utest/utils/test_docstring.py | Adds unit tests covering docstring parsing behavior and edge cases. |
| utest/utils/test_deprecations.py | Simplifies multi-line string construction in a deprecation test. |
| utest/utils/test_argumentparser.py | Simplifies multi-line help/usage string construction in tests. |
| utest/running/test_markdownparser.py | Simplifies multi-line markdown fixture strings in tests. |
| utest/result/test_visitor.py | Simplifies nested calls that embed multi-line model strings. |
| utest/parsing/test_model.py | Simplifies embedded model text strings in tests. |
| utest/output/test_jsonlogger.py | Simplifies expected JSON fragments as multi-line strings in tests. |
| src/robot/utils/docstring.py | Adds new docstring parsing implementation. |
| src/robot/utils/asserts.py | Adds assert_in() helper used by new tests. |
| src/robot/running/model.py | Collapses long generic base class type parameters into one line. |
| src/robot/result/model.py | Collapses long generic base class type parameters into one line. |
| src/robot/model/control.py | Collapses long generic base class type parameters into one line. |
| src/robot/model/body.py | Collapses long generic base class type parameters into one line. |
| atest/testdata/libdoc/DynamicLibrary.py | Simplifies returned multi-line documentation string construction. |
| atest/testdata/libdoc/Annotations.py | Simplifies exec() multi-line string usage for annotations. |
| atest/genrunner.py | Simplifies generated robot file header string writes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f902887 to
2e70a55
Compare
pekkaklarck
requested changes
Jun 16, 2026
Member
There was a problem hiding this comment.
This PR is too big and needs to be split to at least three parts:
- Documentation parser and its tests.
- Integrating parser to rest of the Robot and Libdoc code. This probably should include writing docs to Libdoc specs, but that part could also be in a separate PR.
- Libdoc HTML UI changes.
086c723 to
385e773
Compare
Comment on lines
+832
to
+834
| if __name__ == "__main__": | ||
| # TODO: Add library that contains 10 000 keywords and see how performance is affected. | ||
| unittest.main() |
Contributor
Author
There was a problem hiding this comment.
This needs to be done, but we need to discuss with Pekka where and how.
| def _parse(doc: str) -> ParsedDocString: | ||
| lines = doc.splitlines() | ||
| doc_parts = [] | ||
| args: dict[str, str] = {} |
Comment on lines
+125
to
+126
| inline_parts: list[str] = [] | ||
| raw_body: list[str] = [] |
Comment on lines
+39
to
+40
| def parse_docstring(doc: str) -> ParsedDocString: | ||
| """Always returns a ParsedDocString — never raises.""" |
Comment on lines
+148
to
+152
| is_rf_var = (len(raw_name) >= 3 and raw_name[0] in "$@&" | ||
| and raw_name[1] == "{" and raw_name[-1] == "}") | ||
| bare = _bare_arg_name(raw_name) | ||
| if is_rf_var and bare.strip() or not is_rf_var and bare.isidentifier(): | ||
| if name is not None: |
Comment on lines
+1
to
+6
| from pydoc import doc | ||
| import unittest | ||
|
|
||
| from robot import result | ||
| from robot.running.docstring import parse_docstring, ParsedDocString | ||
| from robot.utils.asserts import assert_equal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is part of the #5604 but only implements the parsing part.