Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Include lines of examples that start with ... #130

Merged
merged 2 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/safeds_stubgen/stubs_generator/_generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ def _create_sds_docstring(
for example_part in docstring.example.split("\n"):
if example_part.startswith(">>>"):
example += f"{indentations} * {example_part.replace('>>>', '//')}\n"
elif example_part.startswith("..."):
example += f"{indentations} * {example_part.replace('...', '//')}\n"
example += f"{indentations} * }}\n"
if full_docstring and example:
full_docstring += f"{indentations} *\n"
Expand Down
8 changes: 6 additions & 2 deletions tests/data/docstring_parser_package/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ class NumpyClassWithExamples:
--------
>>> from tests.data.docstring_parser_package.numpydoc import NumpyClassWithExamples
This text should be ignored
>>> class_ = NumpyClassWithExamples
>>> class_ = (
... NumpyClassWithExamples
... )
This text should be ignored, too.
"""

Expand All @@ -497,7 +499,9 @@ def numpy_func_with_examples(self):
Examples
--------
>>> from tests.data.docstring_parser_package.numpydoc import NumpyClassWithExamples
>>> func = NumpyClassWithExamples.numpy_func_with_examples
>>> func = (
... NumpyClassWithExamples.numpy_func_with_examples
... )
>>> func()
This text should be ignored.
"""
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ class ClassWithVariousAttributeTypes() {
* @example
* pipeline example {
* // from tests.data.docstring_parser_package.numpydoc import NumpyClassWithExamples
* // class_ = NumpyClassWithExamples
* // class_ = (
* // NumpyClassWithExamples
* // )
* }
*/
class NumpyClassWithExamples() {
Expand All @@ -420,7 +422,9 @@ class NumpyClassWithExamples() {
* @example
* pipeline example {
* // from tests.data.docstring_parser_package.numpydoc import NumpyClassWithExamples
* // func = NumpyClassWithExamples.numpy_func_with_examples
* // func = (
* // NumpyClassWithExamples.numpy_func_with_examples
* // )
* // func()
* }
*/
Expand Down
Loading