Skip to content

Commit 7fd2887

Browse files
committed
fix: union and multiple lines in CustomFunctioins + fix links in py_term
1 parent 9dcc6a6 commit 7fd2887

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

src/pyconverter/xml2py/ast_tree.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,9 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
13831383

13841384
if "``" in py_term:
13851385
py_term = py_term.replace("``", "")
1386+
1387+
if re.finditer(r"`.+`_", py_term) is None:
1388+
py_term = f"``{py_term}``"
13861389

13871390
intersection_types = set(NO_RESIZE_LIST).intersection(self.text.children_types)
13881391
if len(intersection_types) == 0 and "* " not in py_text:
@@ -1401,7 +1404,7 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
14011404

14021405
py_text = f"{first_line}\n{rest_lines}"
14031406

1404-
lines = [f"* ``{py_term}`` - {py_text}"]
1407+
lines = [f"* {py_term} - {py_text}"]
14051408
output = "\n".join(lines)
14061409

14071410
return output

src/pyconverter/xml2py/custom_functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,16 @@ def get_docstring_lists(filename: str) -> Tuple[list[str], list[str], list[str],
7474
if bool_def and not end_def:
7575
if ")" in line:
7676
end_def = True
77+
line = re.search(r".+(?=\))", line)
78+
if line is not None:
79+
line = line.group()
80+
else:
81+
continue
7782
# TODO: Union types are ignored for now
7883
if re.search(r"\[(\w+, )+\w+\]", line) is not None:
7984
line = re.sub(r"\[(\w+, )+\w+\]", "", line)
85+
elif re.search(r'\[("\w*", )+"\w*"\]', line):
86+
line = re.sub(r'\[("\w*", )+"\w*"\]', "", line)
8087
split_def = line.split(",")
8188
for split_arg in split_def:
8289
split_arg = split_arg.strip()
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from typing import Any, Dict, Literal
2+
3+
def cmlist(
4+
self,
5+
name: str = "",
6+
key: str = "",
7+
entity: Literal["VOLU", "AREA", "LINE", "KP", "ELEM", "NODE", ""] = "",
8+
**kwargs: Dict[Any, Any],
9+
) -> None:
10+
"""Lists the contents of a component or assembly.
11+
12+
APDL Command: CMLIST
13+
14+
Parameters
15+
----------
16+
name
17+
Name of the component or assembly to be listed (if blank, list all
18+
selected components and assemblies). If Name is specified, then
19+
Entity is ignored.
20+
21+
key
22+
Expansion key:
23+
24+
0
25+
Do not list individual entities in the component.
26+
27+
1 or EXPA
28+
List individual entities in the component.
29+
30+
entity
31+
If Name is blank, then the following entity types can be specified:
32+
33+
VOLU
34+
List the volume components only.
35+
36+
AREA
37+
List the area components only.
38+
39+
LINE
40+
List the line components only.
41+
42+
KP
43+
List the keypoint components only
44+
45+
ELEM
46+
List the element components only.
47+
48+
NODE
49+
List the node components only.
50+
51+
Notes
52+
-----
53+
This command is valid in any processor. For components, it lists the
54+
type of geometric entity. For assemblies, it lists the components
55+
and/or assemblies that make up the assembly.
56+
57+
Examples of possible usage:
58+
"""
59+
command = f"CMLIST,{name},{key},{entity}"
60+
return self.run(command, **kwargs)

0 commit comments

Comments
 (0)