Skip to content

Commit ccf340d

Browse files
committed
Fix doc generator scripts
1 parent 7c334fd commit ccf340d

File tree

6 files changed

+30
-40
lines changed

6 files changed

+30
-40
lines changed

scripts/forms_doc_generate.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,18 @@ def main() -> None:
135135
parser.add_argument("--output", "-o", type=Path, required=True)
136136
args = parser.parse_args()
137137

138-
config_panel = list_config_panel(args.input)
139-
options = list_form_options(args.input)
140-
version = get_changelog_version(args.input)
141-
commit = get_current_commit(Path(__file__).parent)
138+
template_data = {
139+
"configpanel": list_config_panel(args.input),
140+
"options": list_form_options(args.input),
141+
"date": datetime.datetime.now().strftime("%d/%m/%Y"),
142+
"version": get_changelog_version(args.input),
143+
"doc_commit": get_current_commit(Path(__file__).parent),
144+
"src_commit": get_current_commit(args.input),
145+
}
142146

143147
template = Template(TEMPLATE_FILE.read_text())
144148
template.globals["now"] = datetime.datetime.utcnow
145-
146-
result = template.render(
147-
configpanel=config_panel,
148-
options=options,
149-
date=datetime.datetime.now().strftime("%d/%m/%Y"),
150-
version=version,
151-
current_commit=commit,
152-
)
153-
149+
result = template.render(**template_data)
154150
args.output.write_text(result)
155151

156152

scripts/forms_doc_template.md.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ routes:
77
default: '/dev/forms'
88
---
99

10-
Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{ current_commit }}/scripts/forms_doc_generate.py) on {{date}} (YunoHost version {{version}})
10+
Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{doc_commit}}/scripts/forms_doc_generate.py) on {{date}} (YunoHost version {{version}})
1111

1212
## Glossary
1313

scripts/helpers_doc_generate.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,18 @@ def main() -> None:
281281

282282
section["helpers"][subsection] = p.blocks # type: ignore
283283

284-
version = get_changelog_version(args.input)
285-
commit = get_current_commit(Path(__file__).parent)
284+
template_data = {
285+
"tree": TREE,
286+
"helpers_version": args.version,
287+
"date": datetime.datetime.now().strftime("%d/%m/%Y"),
288+
"version": get_changelog_version(args.input),
289+
"doc_commit": get_current_commit(Path(__file__).parent),
290+
"src_commit": get_current_commit(args.input),
291+
}
286292

287293
template = Template(TEMPLATE_FILE.read_text())
288294
template.globals["now"] = datetime.datetime.utcnow
289-
290-
result = template.render(
291-
tree=TREE,
292-
date=datetime.datetime.now().strftime("%d/%m/%Y"),
293-
version=version,
294-
helpers_version=args.version,
295-
current_commit=commit,
296-
)
297-
295+
result = template.render(**template_data)
298296
output.write_text(result)
299297

300298

scripts/helpers_doc_template.md.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ routes:
88
custom_edit_link: 'https://github.com/YunoHost/yunohost/tree/dev/helpers/helpers.v{{ helpers_version }}.d'
99
---
1010

11-
Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{ current_commit }}/scripts/helpers_doc_generate.py) on {{date}} (YunoHost version {{version}})
11+
Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{doc_commit}}/scripts/helpers_doc_generate.py) on {{date}} (YunoHost version {{version}})
1212
{% for section_id, section in tree.items() %}
1313
## {{ section["title"].title() }}
1414
{%- if section['notes'] %}
@@ -61,7 +61,7 @@ Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{ curr
6161
{{ h.details.strip() }}
6262
{%- endif %}
6363

64-
[Dude, show me the code!](https://github.com/YunoHost/yunohost/blob/{{ current_commit }}/helpers/helpers.v{{ helpers_version if helpers_version != "2" else "1" }}.d/{{ subsection }}#L{{ h.line + 1 }})
64+
[Dude, show me the code!](https://github.com/YunoHost/yunohost/blob/{{src_commit}}/helpers/helpers.v{{helpers_version if helpers_version != "2" else "1"}}.d/{{subsection}}#L{{h.line + 1}})
6565
[/details]
6666
{%- endfor %}
6767

scripts/resources_doc_generate.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,17 @@ def main() -> None:
8282
parser.add_argument("--output", "-o", type=Path, required=True)
8383
args = parser.parse_args()
8484

85-
resources = list_resources(args.input)
86-
87-
version = get_changelog_version(args.input)
88-
commit = get_current_commit(Path(__file__).parent)
85+
template_data = {
86+
"resources": list_resources(args.input),
87+
"date": datetime.datetime.now().strftime("%d/%m/%Y"),
88+
"version": get_changelog_version(args.input),
89+
"doc_commit": get_current_commit(Path(__file__).parent),
90+
"src_commit": get_current_commit(args.input),
91+
}
8992

9093
template = Template(TEMPLATE_FILE.read_text())
9194
template.globals["now"] = datetime.datetime.utcnow
92-
93-
result = template.render(
94-
resources=resources,
95-
date=datetime.datetime.now().strftime("%d/%m/%Y"),
96-
version=version,
97-
current_commit=commit,
98-
)
99-
95+
result = template.render(**template_data)
10096
args.output.write_text(result)
10197

10298

scripts/resources_doc_template.md.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ routes:
88
custom_edit_link: 'https://github.com/YunoHost/yunohost/blob/dev/src/utils/resources.py'
99
---
1010

11-
Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{current_commit}}/scripts/resources_doc_generate.py) on {{date}} (YunoHost version {{version}})
11+
Doc auto-generated by [this script](https://github.com/YunoHost/doc/blob/{{doc_commit}}/scripts/resources_doc_generate.py) on {{date}} (YunoHost version {{version}})
1212
{% for section_id, docstring in resources.items() %}
1313
## {{section_id}}
1414

0 commit comments

Comments
 (0)