Base class for diagram generators. More...
Base class for diagram generators.
ConfigType | Configuration type |
DiagramType | Diagram model type |
Definition at line 58 of file generator.h.
#include <generator.h>
Public Member Functions | |
generator (ConfigType &config, DiagramType &model) | |
Constructor. | |
~generator () override=default | |
void | generate (std::ostream &ostr) const override |
Generate diagram. | |
virtual void | generate_diagram (std::ostream &ostr) const =0 |
Generate diagram specific part. | |
void | generate_mermaid_directives (std::ostream &ostr, const std::vector< std::string > &directives) const |
Generate MermaidJS directives from config file. | |
virtual void | generate_diagram_type (std::ostream &ostr) const =0 |
Generate the diagram type. | |
virtual void | generate_notes (std::ostream &ostr, const model::diagram_element &element) const |
Generate diagram notes. | |
void | generate_metadata (std::ostream &ostr) const |
Generate comment with diagram metadata. | |
void | generate_title (std::ostream &ostr) const |
Generate diagram title. | |
template<typename E > | |
void | generate_link (std::ostream &ostr, const E &e) const |
Generate hyper link to element. | |
void | print_debug (const common::model::source_location &e, std::ostream &ostr) const |
Print debug information in diagram comments. | |
Public Member Functions inherited from clanguml::common::generators::generator< ConfigType, DiagramType > | |
generator (ConfigType &config, DiagramType &model) | |
Constructor. | |
virtual | ~generator ()=default |
virtual void | generate (std::ostream &ostr) const =0 |
Generate diagram. | |
const ConfigType & | config () const |
Get reference to diagram config. | |
const DiagramType & | model () const |
Get reference to diagram model. | |
std::optional< std::pair< std::string, std::string > > | get_link_pattern (const common::model::source_location &sl) const |
std::optional< std::pair< std::string, std::string > > | get_tooltip_pattern (const common::model::source_location &sl) const |
std::optional< std::string > | render_link (const common::model::diagram_element &e) const |
std::optional< std::string > | render_link (const common::model::relationship &e) const |
std::optional< std::string > | render_tooltip (const common::model::diagram_element &e) const |
std::optional< std::string > | render_tooltip (const common::model::relationship &e) const |
void | init_context () |
Initialize diagram Jinja context. | |
void | update_context () const |
Update diagram Jinja context. | |
void | init_env () |
const inja::json & | context () const |
inja::Environment & | env () const |
Protected Attributes | |
std::set< std::string > | m_generated_aliases |
Protected Attributes inherited from clanguml::common::generators::generator< ConfigType, DiagramType > | |
inja::json | m_context |
inja::Environment | m_env |
|
inline |
Constructor.
config | Reference to instance of model Reference to instance of clanguml::model::diagram |
Definition at line 67 of file generator.h.
|
overridevirtualdefault |
Reimplemented from clanguml::common::generators::generator< ConfigType, DiagramType >.
|
overridevirtual |
Generate diagram.
This is the main diagram generation entrypoint. It is responsible for calling other methods in appropriate order to generate the diagram into the output stream. It generates diagram elements, that are common to all types of diagrams in a given generator.
ostr | Output stream |
Implements clanguml::common::generators::generator< ConfigType, DiagramType >.
Definition at line 177 of file generator.h.
|
pure virtual |
Generate diagram specific part.
This method must be implemented in subclasses for specific diagram types.
ostr | Output stream |
Implemented in clanguml::class_diagram::generators::mermaid::generator, clanguml::include_diagram::generators::mermaid::generator, clanguml::package_diagram::generators::mermaid::generator, and clanguml::sequence_diagram::generators::mermaid::generator.
|
pure virtual |
Generate the diagram type.
This method must be overriden for each diagram type (e.g. it renders a single line classDiagram
for Mermaid class diagrams.
ostr | Output stream |
Implemented in clanguml::class_diagram::generators::mermaid::generator, clanguml::include_diagram::generators::mermaid::generator, clanguml::package_diagram::generators::mermaid::generator, and clanguml::sequence_diagram::generators::mermaid::generator.
void clanguml::common::generators::mermaid::generator< C, D >::generate_link | ( | std::ostream & | ostr, |
const E & | e | ||
) | const |
Generate hyper link to element.
This method renders links to URL's based on templates provided in the configuration file (e.g. Git browser with specific line and column offset)
ostr | Output stream |
e | Reference to diagram element |
E | Diagram element type |
Definition at line 205 of file generator.h.
void clanguml::common::generators::mermaid::generator< C, D >::generate_mermaid_directives | ( | std::ostream & | ostr, |
const std::vector< std::string > & | directives | ||
) | const |
Generate MermaidJS directives from config file.
This method renders the MermaidJS directives provided in the configuration file, including resolving any element aliases and Jinja templates.
ostr | Output stream |
directives | List of directives from the configuration file |
Definition at line 238 of file generator.h.
void clanguml::common::generators::mermaid::generator< C, D >::generate_metadata | ( | std::ostream & | ostr | ) | const |
Generate comment with diagram metadata.
ostr | Output stream |
Definition at line 267 of file generator.h.
|
virtual |
Generate diagram notes.
This method adds any notes in the diagram, which were declared in the code using inline directives
ostr | Output stream |
element | Element to which the note should be attached |
Reimplemented in clanguml::package_diagram::generators::mermaid::generator.
Definition at line 252 of file generator.h.
void clanguml::common::generators::mermaid::generator< C, D >::generate_title | ( | std::ostream & | ostr | ) | const |
Generate diagram title.
Generates a MermaidJS diagram title directive if diagram title is provided in the diagram configuration.
ostr | Output stream |
Definition at line 280 of file generator.h.
void clanguml::common::generators::mermaid::generator< C, D >::print_debug | ( | const common::model::source_location & | e, |
std::ostream & | ostr | ||
) | const |
Print debug information in diagram comments.
m | Diagram element to describe |
ostr | Output stream |
Definition at line 292 of file generator.h.
|
mutableprotected |
Definition at line 173 of file generator.h.