Skip to content
Merged
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
45 changes: 29 additions & 16 deletions src/pyconverter/xml2py/ast_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
"Caret 40?": "",
'``"``': "``",
"/_nolinebreak?": "",
"/_nolinebreak ?": "",
"_nolinebreak?": "",
"_nolinebreak ?": "",
"nbsp": " ",
}

Expand Down Expand Up @@ -696,7 +698,7 @@ def find(self, _type, terms=None):
"""Find the first type matching a given type string."""
for item in self:
if type(item).__name__ == _type:
if _type == "Refname" or _type == "Refnamediv":
if _type == "Refname":
if terms == None:
logging.error("ERROR: terms are not defined for a 'Refname' class.")
item.terms = terms
Expand All @@ -708,7 +710,9 @@ def find_all(self, _type, recursive=False, terms=None):
items = []
for item in self:
if type(item).__name__ == _type:
if _type == "Refname" or _type == "Refnamediv":
if _type == "Refname":
if not terms:
logging.error("ERROR: terms are not defined for a 'Refname' class.")
item.terms = terms
items.append(item)
elif recursive and isinstance(item, Element):
Expand Down Expand Up @@ -3085,7 +3089,21 @@ def arg_desc(self) -> List[Argument]:
refsyn = self.rec_find("Refsynopsisdiv")
# search by ID
arguments = None
if refsyn is None:
if refsyn and "Variablelist" in refsyn.children_types:
for elem in refsyn:
if isinstance(elem, Variablelist):
if arguments is None:
arguments = ArgumentList(
self.py_name, self.url, self._terms, elem, self.args
)
else:
arguments += ArgumentList(
self.py_name, self.url, self._terms, elem, self.args
)
if isinstance(elem, Paragraph):
self._is_paragraph_in_arg_desc = True

else:
refsections = self.find_all("RefSection")
for elem in refsections:
for child in elem:
Expand All @@ -3101,19 +3119,14 @@ def arg_desc(self) -> List[Argument]:
if isinstance(child, Paragraph):
self._is_paragraph_in_arg_desc = True

else:
for elem in refsyn:
if isinstance(elem, Variablelist):
if arguments is None:
arguments = ArgumentList(
self.py_name, self.url, self._terms, elem, self.args
)
else:
arguments += ArgumentList(
self.py_name, self.url, self._terms, elem, self.args
)
if isinstance(elem, Paragraph):
self._is_paragraph_in_arg_desc = True
# Check whether arguments have been caught
if not arguments:
refnamediv = self.find("Refnamediv")
available_arguments = refnamediv[0].get_children_by_type("Replaceable")
if available_arguments:
arguments = ArgumentList(
self.py_name, self.url, self._terms, available_arguments, self.args
)

arg_file = Path("args.txt")

Expand Down