Commit 5f98b91b authored by Emmanuele Bassi's avatar Emmanuele Bassi
Browse files

generate: Add "callbacks" section

parent 2a64b589
Pipeline #253464 passed with stage
in 1 minute and 59 seconds
......@@ -1256,6 +1256,27 @@ def _gen_functions(config, theme_config, output_dir, jinja_env, namespace, all_f
out.write(content)
def _gen_callbacks(config, theme_config, output_dir, jinja_env, namespace, all_callbacks):
ns_dir = os.path.join(output_dir, f"{namespace.name}", f"{namespace.version}")
func_tmpl = jinja_env.get_template(theme_config.func_template)
for func in all_callbacks:
func_file = os.path.join(ns_dir, f"callback.{func.name}.html")
log.info(f"Creating callback file for {namespace.name}.{func.name}: {func_file}")
tmpl = TemplateCallback(func)
with open(func_file, "w") as out:
content = func_tmpl.render({
'CONFIG': config,
'namespace': namespace,
'func': tmpl,
})
out.write(content)
def _gen_content_files(config, content_dir, output_dir):
content_files = []
......@@ -1281,6 +1302,7 @@ def gen_reference(config, options, repository, templates_dir, theme_config, cont
symbols = {
"aliases": sorted(namespace.get_aliases(), key=lambda alias: alias.name.lower()),
"bitfields": sorted(namespace.get_bitfields(), key=lambda bitfield: bitfield.name.lower()),
"callbacks": sorted(namespace.get_callbacks(), key=lambda callback: callback.name.lower()),
"classes": sorted(namespace.get_classes(), key=lambda cls: cls.name.lower()),
"constants": sorted(namespace.get_constants(), key=lambda const: const.name.lower()),
"domains": sorted(namespace.get_error_domains(), key=lambda domain: domain.name.lower()),
......@@ -1294,6 +1316,7 @@ def gen_reference(config, options, repository, templates_dir, theme_config, cont
all_indices = {
"aliases": _gen_aliases,
"bitfields": _gen_bitfields,
"callbacks": _gen_callbacks,
"classes": _gen_classes,
"constants": _gen_constants,
"domains": _gen_domains,
......
......@@ -221,6 +221,22 @@
</div>
</section>
<section>
<div class="toggle-wrapper default-hide">
<h4 id="callbacks">Callbacks</h4>
<div class="docblock">
{% for func in symbols.callbacks %}
{% if loop.first %}<ul>{% endif %}
<li><a href="callback.{{ func.name }}.html">{{ func.name }}</a></li>
{% if loop.last %}</ul>{% endif %}
{% else %}
<p><em>No callbacks available.</em></p>
{% endfor %}
</div>
</div>
</section>
<section>
<div class="toggle-wrapper default-hide">
<h4 id="functions">Functions</h4>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment