Skip to content

Commit c273aa5

Browse files
committed
fix: custom_notes for cmlist
1 parent c0ea778 commit c273aa5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/pyconverter/xml2py/ast_tree.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
NO_RESIZE_LIST = [
9191
"Variablelist",
9292
"ItemizedList",
93+
"SimpleList"
9394
"Caution",
9495
"XMLWarning",
9596
"ProgramListing",
@@ -2395,15 +2396,10 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
23952396
items.append(entry_item)
23962397

23972398
entry_content = " ".join(items)
2398-
# entry_content = resize_length(
2399-
# entry_content, max_length=max_length, initial_indent=indent, subsequent_indent=" " * 2
2400-
# )
24012399

24022400
if self.morerows is not None:
24032401
entry_content = f":rspan:`{content}` " + entry_content
24042402

2405-
print(entry_content)
2406-
# to be checked - not working
24072403
return entry_content
24082404

24092405

@@ -3125,13 +3121,13 @@ def py_signature(self, custom_functions: CustomFunctions, indent="") -> str:
31253121
arg_sig = ", ".join(args)
31263122
return f"{indent}def {self.py_name}({arg_sig}, **kwargs):"
31273123

3128-
def custom_notes(self, custom_functions: CustomFunctions = None):
3124+
def custom_notes(self, custom_functions: CustomFunctions = None, automated_notes: List[str]= None) -> List[str]:
31293125
"""Customized notes for the command."""
31303126
lines = []
31313127
if custom_functions is not None and (
31323128
self.py_name in custom_functions.py_names and self.py_name in custom_functions.py_notes
31333129
):
3134-
if len("\n".join(lines)) < len("\n".join(custom_functions.py_notes[self.py_name])):
3130+
if len("\n".join(automated_notes)) < len("\n".join(custom_functions.py_notes[self.py_name])):
31353131
lines = custom_functions.py_notes[self.py_name]
31363132
return lines
31373133

@@ -3180,14 +3176,15 @@ def py_docstring(
31803176
and self.py_name in custom_functions.py_returns
31813177
):
31823178
items += [""] + custom_functions.py_returns[self.py_name]
3183-
custom_notes = self.custom_notes(custom_functions)
3179+
automated_notes = self.py_notes(self.notes, "Notes")
3180+
custom_notes = self.custom_notes(custom_functions, automated_notes)
31843181
if not custom_notes:
31853182
if self.other_parameters:
31863183
items += [""]
31873184
items.extend(self.py_notes(self.other_parameters, "Other Parameters"))
31883185
if self.notes:
31893186
items += [""]
3190-
items.extend(self.py_notes(self.notes, "Notes"))
3187+
items.extend(automated_notes)
31913188
else:
31923189
items.extend(custom_notes)
31933190
if custom_functions and (
@@ -3400,7 +3397,7 @@ def py_notes(self, note_elem_list, section_title):
34003397
resized_item = resize_length(item, self._max_length)
34013398
notes = notes.replace(item, resized_item)
34023399
lines.extend(notes.split("\n"))
3403-
3400+
34043401
return lines
34053402

34063403
@property

src/pyconverter/xml2py/custom_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ def get_docstring_lists(filename: str) -> Tuple[list[str], list[str], list[str],
3838
3939
Returns
4040
-------
41+
List[str]
42+
List containing the docstring ``Parameters`` section.
4143
List[str]
4244
List containing the docstring ``Returns`` section.
45+
List[str]
46+
List containing the docstring ``Notes`` section.
4347
List[str]
4448
List containing the docstring ``Examples`` section.
4549
List[str]

0 commit comments

Comments
 (0)