Skip to content

Documentation doesn't render properly if a module is empty #1367

@xenoterracide

Description

@xenoterracide

Given

public class ModulithTest {
  private final Logger log = LogManager.getLogger(this.getClass());

  // this is not a test but rather a silly way to manually run documentation generation
  @Test
  void writeDocumentationSnippets() {
    // hacky hack because the test is not run by the Spring Boot Test Runner
    System.setProperty("spring.modulith.detection-strategy", "explicitly-annotated");
    var modules = ApplicationModules.of(Application.class);

    modules.forEach(module -> log.info("Module: {}", module));

    new Documenter(modules).writeDocumentation();
  }
}

When

@Module("Annotations")
@InfrastructureLayer
@NullMarked
package com.myorg.annotation;

import org.jmolecules.architecture.layered.InfrastructureLayer;
import org.jmolecules.ddd.annotation.Module;
import org.jspecify.annotations.NullMarked;
@NullMarked
@Module("Utilities")
@InfrastructureLayer
package com.myorg.tool;

import org.jmolecules.architecture.layered.InfrastructureLayer;
import org.jmolecules.ddd.annotation.Module;
import org.jspecify.annotations.NullMarked;
package com.myorg.annotation;

class A {
}

and there are no class in com.myorg.tool outside of the package-info.java

Then

the component diagram is incorrectly generated without any components

@startuml
set separator none
title Application

top to bottom direction

!include <C4/C4>
!include <C4/C4_Context>


SHOW_LEGEND(true)
@enduml

removing com.myorg.tool or adding a class that depends on the annotation package will generate the diagram correctly.

Version

modulith 1.4.3 java 21

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions