fix: move class members outside mermaid namespace blocks (parse error fix)
This commit is contained in:
@@ -50,9 +50,11 @@ impl MermaidRenderer {
|
|||||||
let has_namespaces = !grouped.is_empty();
|
let has_namespaces = !grouped.is_empty();
|
||||||
|
|
||||||
let mut seen: HashSet<String> = HashSet::new();
|
let mut seen: HashSet<String> = HashSet::new();
|
||||||
|
let mut deferred_members: Vec<String> = Vec::new();
|
||||||
|
|
||||||
for element in &ungrouped {
|
for element in &ungrouped {
|
||||||
if seen.insert(element.name().to_string()) {
|
if seen.insert(element.name().to_string()) {
|
||||||
Self::push_class_lines(&mut lines, element, " ");
|
Self::push_class_lines(&mut lines, &mut deferred_members, element, " ", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +64,21 @@ impl MermaidRenderer {
|
|||||||
let mut ns_seen: HashSet<String> = HashSet::new();
|
let mut ns_seen: HashSet<String> = HashSet::new();
|
||||||
for element in elements {
|
for element in elements {
|
||||||
if ns_seen.insert(element.name().to_string()) {
|
if ns_seen.insert(element.name().to_string()) {
|
||||||
Self::push_class_lines(&mut lines, element, " ");
|
Self::push_class_lines(
|
||||||
|
&mut lines,
|
||||||
|
&mut deferred_members,
|
||||||
|
element,
|
||||||
|
" ",
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lines.push(" }".to_string());
|
lines.push(" }".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lines.extend(deferred_members);
|
||||||
|
|
||||||
let mut rel_seen: HashSet<String> = HashSet::new();
|
let mut rel_seen: HashSet<String> = HashSet::new();
|
||||||
for rel in graph.relationships() {
|
for rel in graph.relationships() {
|
||||||
if rel.kind() == RelationshipKind::Import {
|
if rel.kind() == RelationshipKind::Import {
|
||||||
@@ -88,24 +98,32 @@ impl MermaidRenderer {
|
|||||||
lines.join("\n")
|
lines.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_class_lines(lines: &mut Vec<String>, element: &CodeElement, indent: &str) {
|
fn push_class_lines(
|
||||||
|
lines: &mut Vec<String>,
|
||||||
|
deferred: &mut Vec<String>,
|
||||||
|
element: &CodeElement,
|
||||||
|
indent: &str,
|
||||||
|
in_namespace: bool,
|
||||||
|
) {
|
||||||
lines.push(format!(
|
lines.push(format!(
|
||||||
"{indent}class {}",
|
"{indent}class {}",
|
||||||
Self::format_element_name(element)
|
Self::format_element_name(element)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let member_target = if in_namespace { deferred } else { lines };
|
||||||
if element.visibility() != Visibility::Public {
|
if element.visibility() != Visibility::Public {
|
||||||
lines.push(format!(
|
member_target.push(format!(
|
||||||
"{indent}<<{}>> {}",
|
" <<{}>> {}",
|
||||||
Self::format_visibility(element.visibility()),
|
Self::format_visibility(element.visibility()),
|
||||||
element.name()
|
element.name()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let name = element.name();
|
let name = element.name();
|
||||||
for field in element.fields() {
|
for field in element.fields() {
|
||||||
lines.push(format!("{indent}{name} : {field}"));
|
member_target.push(format!(" {name} : {field}"));
|
||||||
}
|
}
|
||||||
for method in element.methods() {
|
for method in element.methods() {
|
||||||
lines.push(format!("{indent}{name} : {method}"));
|
member_target.push(format!(" {name} : {method}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
graph TD
|
graph TD
|
||||||
|
Application[Application]
|
||||||
Domain[Domain]
|
Domain[Domain]
|
||||||
Presentation[Presentation]
|
Presentation[Presentation]
|
||||||
Adapters[Adapters]
|
Adapters[Adapters]
|
||||||
Application[Application]
|
|
||||||
Application --> Domain
|
|
||||||
Adapters --> Domain
|
Adapters --> Domain
|
||||||
|
Application --> Domain
|
||||||
|
Presentation --> Application
|
||||||
Presentation --> Domain
|
Presentation --> Domain
|
||||||
Presentation --> Adapters
|
Presentation --> Adapters
|
||||||
Presentation --> Application
|
|
||||||
Reference in New Issue
Block a user