8000 Migration of datatree/ops.py -> datatree_ops.py by flamingbear · Pull Request #8976 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

Migration of datatree/ops.py -> datatree_ops.py #8976

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

Merged
merged 12 commits into from
May 2, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
DAS-2065: Additonal update to make the addendum a Note
Just syntactic sugar to make that work
  • Loading branch information
flamingbear committed Apr 26, 2024
commit 5859b5c1c46ec5fc43e67ef93a11c68f0cd797ba
10 changes: 6 additions & 4 deletions xarray/core/datatree_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def method_name(self, *args, **kwargs):
def insert_doc_addendum(docstring, addendum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Is it overkill to suggest type hints for this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

probably not

Copy link
Member Author

Choose a reason for hiding this comment

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

"""Insert addendum after first paragraph or at the end of the docstring."""
pattern = re.compile(
r"^(?P<front>(\S+)?(.*?))(?P<paragraph_break>\n\s*\n)(?P<whitespace>[ ]*)(?P<rest>.*)",
r"^(?P<start>(\S+)?(.*?))(?P<paragraph_break>\n\s*\n)(?P<whitespace>[ ]*)(?P<rest>.*)",
re.DOTALL,
)
capture = re.match(pattern, docstring)
Expand All @@ -228,12 +228,14 @@ def insert_doc_addendum(docstring, addendum):

if len(capture.groups()) == 6:
return (
capture["front"]
capture["start"]
+ capture["paragraph_break"]
+ capture["whitespace"]
+ ".. note::\n"
+ textwrap.fill(
addendum,
initial_indent=capture["whitespace"],
subsequent_indent=capture["whitespace"],
initial_indent=capture["whitespace"] + " ",
subsequent_indent=capture["whitespace"] + " ",
width=79,
)
+ capture["paragraph_break"]
Expand Down
0