mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
docs: improve hooks overview (#6376)
This commit is contained in:
parent
86d1f1eb70
commit
afb308bc8a
4 changed files with 22 additions and 2 deletions
|
|
@ -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(
|
||||
|
|
|
|||
18
docs/scripts/pdoc-template/custom.css
Normal file
18
docs/scripts/pdoc-template/custom.css
Normal 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 %}
|
||||
|
|
@ -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 %}
|
||||
|
|
|
|||
|
|
@ -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) }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue