scripts: migrate format strings to f-strings
This commit is contained in:
parent
ddc6ce61db
commit
4839fa6614
2 changed files with 19 additions and 27 deletions
|
@ -42,9 +42,10 @@ def render_option_value(opt, attr):
|
|||
if isinstance(opt[attr], dict) and "_type" in opt[attr]:
|
||||
if opt[attr]["_type"] == "literalExpression":
|
||||
if "\n" in opt[attr]["text"]:
|
||||
res = "\n```nix\n" + opt[attr]["text"].rstrip("\n") + "\n```"
|
||||
text = opt[attr]["text"].rstrip("\n")
|
||||
res = f"\n```nix\n{text}\n```"
|
||||
else:
|
||||
res = "```{}```".format(opt[attr]["text"])
|
||||
res = f"```{opt[attr]["text"]}```"
|
||||
elif opt[attr]["_type"] == "literalMD":
|
||||
res = opt[attr]["text"]
|
||||
else:
|
||||
|
@ -54,9 +55,9 @@ def render_option_value(opt, attr):
|
|||
if s == "":
|
||||
res = '`""`'
|
||||
elif "\n" in s:
|
||||
res = "\n```\n" + s.rstrip("\n") + "\n```"
|
||||
res = f"\n```\n{s.rstrip("\n")}\n```"
|
||||
else:
|
||||
res = "```{}```".format(s)
|
||||
res = f"```{s}```"
|
||||
|
||||
return "- " + attr + ": " + res # type: ignore
|
||||
|
||||
|
@ -70,7 +71,7 @@ def print_option(opt):
|
|||
template.format(
|
||||
key=opt["name"],
|
||||
description=description or "",
|
||||
type="- type: ```{}```".format(opt["type"]),
|
||||
type=f"- type: ```{opt["type"]}```",
|
||||
default=render_option_value(opt, "default"),
|
||||
example=render_option_value(opt, "example"),
|
||||
)
|
||||
|
@ -84,8 +85,7 @@ for opt in options:
|
|||
print_option(opt)
|
||||
|
||||
for c in groups:
|
||||
print("## `{}`".format(c))
|
||||
print()
|
||||
print(f"## `{c}`\n")
|
||||
for opt in options:
|
||||
if opt["name"].startswith(c):
|
||||
print_option(opt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue