use of org.moduliths.model.Module in project moduliths by moduliths.
the class DocumenterTest method writesSingleModuleDocumentation.
@Test
void writesSingleModuleDocumentation() throws IOException {
Module module = //
documenter.getModules().getModuleByName("moduleB").orElseThrow(() -> new IllegalArgumentException());
documenter.writeModuleAsPlantUml(module, //
Options.defaults().withColorSelector(//
it -> Optional.of("#ff0000")).withDefaultDisplayName(it -> it.getDisplayName().toUpperCase()));
Options options = //
Options.defaults().withComponentFilter(component -> component.getRelationships().stream().anyMatch(it -> it.getTagsAsSet().contains(DependencyType.EVENT_LISTENER.toString())));
documenter.writeModulesAsPlantUml(options);
}
use of org.moduliths.model.Module in project moduliths by moduliths.
the class Documenter method addComponentsToView.
private void addComponentsToView(Supplier<Stream<Module>> modules, ComponentView view, Options options, Consumer<ComponentView> afterCleanup) {
Styles styles = view.getViewSet().getConfiguration().getStyles();
Map<Module, Component> components = getComponents(options);
//
modules.get().distinct().filter(//
options.getExclusions().negate()).map(//
it -> applyBackgroundColor(it, components, options, styles)).filter(//
options.getComponentFilter()).forEach(view::add);
// view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getBackground()
// Remove filtered dependency types
//
DependencyType.allBut(options.getDependencyTypes()).map(//
Object::toString).forEach(it -> view.removeRelationshipsWithTag(it));
afterCleanup.accept(view);
// Filter outgoing relationships of target-only modules
//
modules.get().filter(options.getTargetOnly()).forEach(module -> {
Component component = components.get(module);
//
view.getRelationships().stream().map(//
RelationshipView::getRelationship).filter(//
it -> it.getSource().equals(component)).forEach(it -> view.remove(it));
});
// … as well as all elements left without a relationship
if (options.hideElementsWithoutRelationships()) {
view.removeElementsWithNoRelationships();
}
afterCleanup.accept(view);
// Remove default relationships if more qualified ones exist
//
view.getRelationships().stream().map(//
RelationshipView::getRelationship).collect(//
Collectors.groupingBy(Connection::of)).values().stream().forEach(it -> potentiallyRemoveDefaultRelationship(view, it));
}
use of org.moduliths.model.Module in project moduliths by moduliths.
the class Documenter method addDependencies.
private void addDependencies(Module module, Component component, Options options) {
DEPENDENCY_DESCRIPTIONS.entrySet().stream().forEach(entry -> {
//
module.getDependencies(modules, entry.getKey()).stream().map(//
it -> getComponents(options).get(it)).forEach(it -> {
Relationship relationship = component.uses(it, entry.getValue());
relationship.addTags(entry.getKey().toString());
});
});
//
module.getBootstrapDependencies(modules).forEach(it -> {
Relationship relationship = component.uses(getComponents(options).get(it), "uses");
relationship.addTags(DependencyType.USES_COMPONENT.toString());
});
}
use of org.moduliths.model.Module in project moduliths by moduliths.
the class Documenter method applyBackgroundColor.
private static Component applyBackgroundColor(Module module, Map<Module, Component> components, Options options, Styles styles) {
Component component = components.get(module);
Function<Module, Optional<String>> selector = options.getColorSelector();
// Apply custom color if configured
selector.apply(module).ifPresent(color -> {
String tag = module.getName() + "-" + color;
component.addTags(tag);
// Add or update background color
styles.getElements().stream().filter(it -> it.getTag().equals(tag)).findFirst().orElseGet(() -> styles.addElementStyle(tag)).background(color);
});
return component;
}
use of org.moduliths.model.Module in project moduliths by moduliths.
the class Asciidoctor method toOptionalLink.
private String toOptionalLink(JavaClass source, Optional<String> methodSignature) {
Module module = modules.getModuleByType(source).orElse(null);
String typeAndMethod = toCode(toTypeAndMethod(FormatableJavaClass.of(source).getAbbreviatedFullName(module), methodSignature));
if (module == null || !source.getModifiers().contains(JavaModifier.PUBLIC) || !module.contains(source)) {
return typeAndMethod;
}
String classPath = //
convertClassNameToResourcePath(source.getFullName()).replace('$', '.');
return //
Optional.ofNullable(javaDocBase == PLACEHOLDER ? null : javaDocBase).map(//
it -> it.concat("/").concat(classPath).concat(".html")).map(//
it -> toLink(typeAndMethod, it)).orElseGet(() -> typeAndMethod);
}
Aggregations