diff --git a/src/pyconverter/xml2py/ast_tree.py b/src/pyconverter/xml2py/ast_tree.py index 8e39ee7dc..e03496da8 100644 --- a/src/pyconverter/xml2py/ast_tree.py +++ b/src/pyconverter/xml2py/ast_tree.py @@ -54,7 +54,9 @@ "Caret 40?": "", '``"``': "``", "/_nolinebreak?": "", + "/_nolinebreak ?": "", "_nolinebreak?": "", + "_nolinebreak ?": "", "nbsp": " ", } @@ -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 @@ -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): @@ -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: @@ -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")