-
Notifications
You must be signed in to change notification settings - Fork 69
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
docs: fix formatting of docstring with lists #1687
Conversation
2a956d7
to
75fb83b
Compare
@@ -115,7 +123,9 @@ def wrap(text: str, width: int, *, offset: Optional[int] = None, indent: int = 0 | |||
text='\n'.join([textwrap.fill( | |||
break_long_words=False, | |||
initial_indent=' ' * indent, | |||
subsequent_indent=' ' * indent, | |||
# ensure that subsequent lines for lists are indented 2 spaces | |||
subsequent_indent=' ' * indent + \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add spaces around =
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried making this change but the style check failed
(py39) partheniou@partheniou-vm-3:~/git/gapic-generator-python$ find gapic tests -name "*.py" -not -path 'tests/**/goldens/*' | xargs autopep8 --diff --exit-code
--- original/gapic/utils/lines.py
+++ fixed/gapic/utils/lines.py
@@ -124,7 +124,7 @@
break_long_words=False,
initial_indent=' ' * indent,
# ensure that subsequent lines for lists are indented 2 spaces
- subsequent_indent = ' ' * indent + \
+ subsequent_indent=' ' * indent + \
(' ' if token.strip().startswith('-') else ''),
text=token,
width=width,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if enclosing the right side in parentheses, or breaking this down into if-else statements would work.
# as the new line is required for lists. | ||
if '\n' in text: | ||
initial_text = text.split('\n')[0] | ||
if ":" not in initial_text: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could :
appear on text line 2, and the list starts from line 3 and on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I added a test case in e08978a
Fixes #1345 🦕
The PR applies the following fixes for the function that converts documentation to RST format.
All of the changes have corresponding tests to show the behaviour without the fixes.