{% import "macros.html" as ui %} {# CODE › Diagrams: architecture, classes and calls as tabs of one page, each at its own URL. Every tab has the same header and the same bar: its options on the left, the language filter shown, the legend on the right; then the drawing, with its own bar (highlight, zoom, fit). #} {% set texts = { "architecture": "How the project is organized: modules inside their packages, and which module imports which (the importer above, the arrow pointing to what it imports). Imports that form a cycle are red.", "classes": "UML class diagram: each class, interface, struct, enum or trait of any language with its attributes and methods; inheritance, implementation, composition (an attribute holds another class), use (a method calls another class) and reference (named as a type).", "calls": "How a function works: what it calls and what calls it, a few calls away, or the calls that lead from it to another. Only calls that can be read from the code are shown.", } %} {# The levels both architecture and classes are drawn by: what each frame is, the closed boxes, the UNCONNECTED groups, and the lines that stand for relations inside closed boxes. #} {% macro levels_legend(relations) -%} project member package subpackage unconnected 3 ▸closed (click to open) {{ relations }} inside closed boxes {%- endmacro %} {# The filters architecture and classes share: a project, a focus and how far from it. #} {% macro filters(url, targets, placeholder) -%}
{{ ui.pick_field("Focus", "focus", "focus-targets", targets, value=params.focus or "", placeholder=placeholder) }}
{%- endmacro %}
{{ ui.view_header("code", "CODE :: Diagrams", (sections.code.pages | selectattr("name", "equalto", "diagrams") | first).text) }} {{ ui.tabs((("architecture", "Architecture", "/code/diagrams/architecture"), ("classes", "Classes", "/code/diagrams/classes"), ("calls", "Functions and Calls", "/code/diagrams/calls")), view) }}

{{ texts[view] }}

{% if view == "architecture" %} {# The filters of every tab on one line; a field with no room left goes, whole, to the next line. #} {% set bar_filters %}
{{ filters("/code/diagrams/architecture", module_targets, "A module or file…") }}
{% endset %} {% call ui.view_canvas("architecture", data_url, params.focus, layouts=true, evolution=true, filters=bar_filters, details=true) %} {{ levels_legend("relations") }} file (module) {# Each kind of relation: a click turns its lines off or on. #} {{ ui.relation_kinds(("imports", "uses", "calls", "refers", "inherits", "has")) }} import cycle {% endcall %} {% elif view == "classes" %} {% set bar_filters %}
{{ filters("/code/diagrams/classes", class_targets, "A class, interface, struct or enum…") }}
{% endset %} {% call ui.view_canvas("classes", data_url, params.focus, layouts=true, filters=bar_filters, details=true) %} {{ levels_legend("relations") }} file class {# Each kind of relation: a click turns its lines off or on. #} {{ ui.relation_kinds(("inherits", "implements", "has", "uses", "refers")) }} {% endcall %} {% else %} {% set bar_filters %}
{{ ui.pick_field("Focus", "focus", "call-targets", call_targets, value=params.focus or "", placeholder="A name or path…") }}
{% endset %} {# Nothing is drawn until a focus is chosen: the filters stay open and the drawing says so. #} {% set caption %}{% if params.focus %}Focus {{ params.focus }}{% endif %}{% endset %} {% call ui.view_canvas("calls", data_url if params.focus else "", params.focus, layouts=true, filters=bar_filters, filters_open=true, details=true, caption=caption | trim, empty="" if params.focus else "Choose a function, method or class in Focus to see its calls; Direction: what it calls, what calls it, or both.") %} focus called by the focus calls the focus {# Each kind of relation: a click turns its lines off or on. #} {{ ui.relation_kinds(("calls", "refers", "template", "css-class", "route")) }} {% endcall %} {% endif %}