docs: improve hooks overview (#6376)

This commit is contained in:
Maximilian Hils 2023-09-21 21:27:14 +02:00 committed by GitHub
parent 86d1f1eb70
commit afb308bc8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 2 deletions

View file

@ -60,7 +60,8 @@ def category(name: str, desc: str, hooks: list[type[hooks.Hook]]) -> None:
raise RuntimeError(f"Already documented: {hook}")
known.add(hook.name)
doc = inspect.getdoc(hook)
print(f" def {hook.name}({', '.join(str(p) for p in ['self'] + params)}):")
print(f" @staticmethod")
print(f" def {hook.name}({', '.join(str(p) for p in params)}):")
print(textwrap.indent(f'"""\n{doc}\n"""', " "))
if params:
print(

View file

@ -0,0 +1,18 @@
.pdoc h1 {
margin-bottom: 1em;
}
{% if module and module.name == "events" %}
.pdoc .class {
padding-left: 0;
--name: var(--text);
background: none;
font-size: 1.2em;
}
.pdoc .classattr {
margin-left: 0;
}
{% endif %}

View file

@ -2,7 +2,7 @@
{% block style %}
<style>/*! theme.css */{% include "theme.css" %}</style>
<style>/*! content.css */{% include "content.css" %}</style>
<style>.pdoc h1 { margin-bottom: 1em; }</style>
<style>/*! custom.css */{% include "custom.css" %}</style>
{% endblock %}
{% endfilter %}
{% block content %}{% endblock %}

View file

@ -14,6 +14,7 @@ To document all event hooks, we do a bit of hackery:
{% macro view_source_state(doc) %}{% endmacro %}
{% macro view_source_button(doc) %}{% endmacro %}
{% macro view_source_code(doc) %}{% endmacro %}
{% macro decorators(doc) %}{% endmacro %}
{% macro is_public(doc) %}
{% if doc.name != "__init__" %}
{{ default_is_public(doc) }}