0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
include_diagram_generator.cc
Go to the documentation of this file.
1/**
2 * @file src/include_diagram/generators/mermaid/include_diagram_generator.cc
3 *
4 * Copyright (c) 2021-2025 Bartek Kryza <bkryza@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
20
21#include "util/error.h"
22
24
26
29{
30}
31
32void generator::generate_diagram_type(std::ostream &ostr) const
33{
34 ostr << "flowchart\n";
35}
36
38 const source_file &f, std::ostream &ostr) const
39{
41 return;
42
43 LOG_DBG("Generating relationships for file {}", f.full_name(true));
44
46 util::for_each(f, [this, &ostr](const auto &file) {
48 dynamic_cast<const source_file &>(*file), ostr);
49 });
50 }
51 else {
52 for (const auto &r : f.relationships()) {
53 ostr << indent(1) << f.alias() << " "
55 ? "-.->"
56 : "-->")
57 << " " << model().get(r.destination()).value().alias() << '\n';
58 }
59 }
60}
61
62void generator::generate(const source_file &f, std::ostream &ostr) const
63{
64 if (config().generate_packages && !config().generate_packages()) {
66 }
67 else {
69 }
70}
71
73 const source_file &f, std::ostream &ostr) const
74{
76 LOG_DBG("Generating directory {}", f.name());
77
78 ostr << indent(1) << "subgraph " << f.alias() << "[" << f.name()
79 << "]\n";
80
81 util::for_each(f, [this, &ostr](const auto &file) {
82 generate(dynamic_cast<const source_file &>(*file), ostr);
83 });
84
85 ostr << indent(1) << "end" << '\n';
86
87 m_generated_aliases.emplace(f.alias());
88 }
89 else {
90 LOG_DBG("Generating file {}", f.name());
91
92 ostr << indent(1) << f.alias() << "[" << f.name() << "]\n";
93
94 m_generated_aliases.emplace(f.alias());
95 }
96
97 if (config().generate_links) {
99 }
100}
101
103 const source_file &f, std::ostream &ostr) const
104{
106 util::for_each(f, [this, &ostr](const auto &file) {
107 generate(dynamic_cast<const source_file &>(*file), ostr);
108 });
109
110 m_generated_aliases.emplace(f.alias());
111 }
112 else {
113 LOG_DBG("Generating file {}", f.file_relative());
114
115 ostr << indent(1) << f.alias() << "[" << f.file_relative() << "]\n";
116
117 m_generated_aliases.emplace(f.alias());
118 }
119
120 if (config().generate_links) {
122 }
123}
124
125void generator::generate_diagram(std::ostream &ostr) const
126{
127 // Generate files and folders
128 util::for_each(model(), [this, &ostr](const auto &f) {
129 generate(dynamic_cast<source_file &>(*f), ostr);
130 });
131
132 // Process file include relationships
133 util::for_each(model(), [this, &ostr](const auto &f) {
134 generate_relationships(dynamic_cast<source_file &>(*f), ostr);
135 });
136
137 // Process file notes
138 util::for_each(model(), [this, &ostr](const auto &f) {
139 generate_notes(ostr, dynamic_cast<source_file &>(*f));
140 });
141}
142} // namespace clanguml::include_diagram::generators::mermaid