0.5.4
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-2024 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{
65 LOG_DBG("Generating directory {}", f.name());
66
67 ostr << indent(1) << "subgraph " << f.alias() << "[" << f.name()
68 << "]\n";
69
70 util::for_each(f, [this, &ostr](const auto &file) {
71 generate(dynamic_cast<const source_file &>(*file), ostr);
72 });
73
74 ostr << indent(1) << "end" << '\n';
75
76 m_generated_aliases.emplace(f.alias());
77 }
78 else {
79 LOG_DBG("Generating file {}", f.name());
80
81 ostr << indent(1) << f.alias() << "[" << f.name() << "]\n";
82
83 m_generated_aliases.emplace(f.alias());
84 }
85
86 if (config().generate_links) {
88 }
89}
90
91void generator::generate_diagram(std::ostream &ostr) const
92{
93 // Generate files and folders
94 util::for_each(model(), [this, &ostr](const auto &f) {
95 generate(dynamic_cast<source_file &>(*f), ostr);
96 });
97
98 // Process file include relationships
99 util::for_each(model(), [this, &ostr](const auto &f) {
100 generate_relationships(dynamic_cast<source_file &>(*f), ostr);
101 });
102
103 // Process file notes
104 util::for_each(model(), [this, &ostr](const auto &f) {
105 generate_notes(ostr, dynamic_cast<source_file &>(*f));
106 });
107}
108} // namespace clanguml::include_diagram::generators::mermaid