spring-projects / spring-projects/spring-modulith

Documentation doesn't render properly if a module is empty

Open
#1,367 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Sep 8, 2025.

in: documentation support
Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.