Skip to content

Docstring parsing from Google style docs#5684

Open
aaltat wants to merge 1 commit into
robotframework:masterfrom
aaltat:docstring
Open

Docstring parsing from Google style docs#5684
aaltat wants to merge 1 commit into
robotframework:masterfrom
aaltat:docstring

Conversation

@aaltat

@aaltat aaltat commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This is part of the #5604 but only implements the parsing part.

Copilot AI review requested due to automatic review settings June 12, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and ParsedDocString to extract Args/Returns sections.
  • 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.

Comment thread src/robot/running/model.py Outdated
Comment thread src/robot/running/model.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Copilot AI review requested due to automatic review settings June 12, 2026 08:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
Comment thread src/robot/utils/docstring.py Outdated
@aaltat aaltat force-pushed the docstring branch 2 times, most recently from f902887 to 2e70a55 Compare June 12, 2026 16:28
Copilot AI review requested due to automatic review settings June 12, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 14 comments.

Comment thread src/web/libdoc/styles/main.css Outdated
Comment thread src/web/libdoc/styles/main.css Outdated
Comment thread src/web/libdoc/styles/main.css Outdated
Comment thread src/web/libdoc/styles/main.css Outdated
Comment thread src/web/libdoc/styles/main.css Outdated
Comment thread src/web/libdoc/libdoc.html Outdated
Comment thread src/robot/libdocpkg/model.py Outdated
Comment thread src/web/libdoc/libdoc.html Outdated
Comment thread src/web/libdoc/libdoc.html Outdated
Comment thread src/robot/running/docstring.py

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is too big and needs to be split to at least three parts:

  1. Documentation parser and its tests.
  2. 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.
  3. Libdoc HTML UI changes.

Copilot AI review requested due to automatic review settings June 17, 2026 14:01
@aaltat aaltat force-pushed the docstring branch 2 times, most recently from 086c723 to 385e773 Compare June 17, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/robot/running/docstring.py
Comment thread src/robot/running/docstring.py Outdated
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()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be done, but we need to discuss with Pekka where and how.

Copilot AI review requested due to automatic review settings June 18, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread src/robot/running/docstring.py
Comment thread src/robot/running/docstring.py
Comment thread src/robot/running/docstring.py Outdated
Comment thread utest/running/test_docstring.py
Copilot AI review requested due to automatic review settings June 18, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

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 thread src/robot/running/docstring.py Outdated
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 thread utest/running/test_docstring.py Outdated
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants