thibaultmarin / hpp2plantuml

Convert C++ header files to PlantUML
MIT License
223 stars 35 forks source link

Is it possible to add subparts for every class block? #14

Closed BitFis closed 3 years ago

BitFis commented 3 years ago

Hey guys

Plantuml has the feature of including subparts, is it somehow possible to create a template which uses that feature?

I tryed to override the objects block, but that seemed to have not worked. any suggestions?

Thanks a lot

Cheers

ref:

BitFis commented 3 years ago

Was able to get it running through pure jinja2:

template.uml


{% block objects %}
/' Objects '/
{% set ns = namespace(name=false) %}
{% for object in objects recursive %}
{% if 'Namespace' in object.__class__.__name__ %}
{% set ns.name = object._name %}
{{- loop(object) }}
{% else %}
/' {{ ns.name }}::{{ object._name }} '/
!startsub {{ ns.name | replace("::", "_") }}_{{ object._name }}
{{ object.render() }}
!endsub
{% endif %}

Given a class with namespace Com::Example::Server::Session and class Server, will remove any namespaces and add startsub as Com_Example_Server_Session_Server, which enables to include it in other plantuml diagrams as:

!includesub ../puml/knxiot_handshake_responder.hpp.puml!Com_Example_Server_Session_Server