Skip to content

Commit 571a65e

Browse files
committed
handle more pathtypes
1 parent 3d14d18 commit 571a65e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

resources/scripts/apidocs.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ def print_cmd(cmd, super=""):
2626
p["name"],
2727
p["type"]["param_type"] if p["type"]["param_type"] != "Unprocessed" else "String",
2828
"yes" if p["required"] else "",
29-
'"' + p["default"] + '"'
30-
if p["default"] and p["type"]["param_type"] == "String"
31-
else Path(p["default"]).relative_to(Path.cwd())
32-
if p["default"] and p["type"]["param_type"] == "Path"
33-
else p["default"],
29+
format_default_value(p["default"], p["type"]["param_type"]),
3430
]
3531
for p in cmd["params"]
3632
if p["name"] != "help"
@@ -39,6 +35,16 @@ def print_cmd(cmd, super=""):
3935
doc += "\n\n"
4036

4137

38+
def format_default_value(default, param_type):
39+
if default is None:
40+
return ""
41+
if param_type == "String":
42+
return f'"{default}"'
43+
if param_type == "Path":
44+
return str(default)
45+
return default
46+
47+
4248
with Context(cli) as ctx:
4349
info = ctx.to_info_dict()
4450
# root-level commands first

0 commit comments

Comments
 (0)