### Example: Docker Server and Maven Configuration Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/PlantumlGenerator.md This example shows how to start a PlantUML server with Docker and then configure Maven to use this server for Javadoc generation. The server URL is passed as a Maven property. ```bash # Terminal 1: Start PlantUML server docker run -d -p 8080:8080 --name plantuml-server plantuml/plantuml-server:latest # Terminal 2: Use in Maven mvn javadoc:javadoc -Dplantuml.server.url=http://localhost:8080/ ``` -------------------------------- ### Create and Configure Method Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md This example demonstrates how to create a Type, then a Method with parameters, set its abstract status, and add it to the Type. Ensure Type and TypeName are properly initialized. ```java Type myClass = new Type(namespace, Type.Classification.CLASS, new TypeName("MyClass")); Method method = new Method(myClass, "calculateTotal", new TypeName("double")); method.addParameter("items", new TypeName("java.util.List")); method.addParameter("taxRate", new TypeName("double")); method.isAbstract = false; myClass.addChild(method); ``` -------------------------------- ### Example Resource Bundle Entries Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Logging.md These are example entries for resource bundles used for message localization, demonstrating how to define messages and their parameters. ```properties doclet.usage.createpumlfiles.description=Generate PlantUML source files (.puml) doclet.usage.createpumlfiles.parameters= ``` -------------------------------- ### Create and Add Fields Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md This example shows how to create a Type and then instantiate multiple Field objects with their respective names and types, adding them to the Type. Ensure Type and TypeName are properly initialized. ```java Type myClass = new Type(namespace, Type.Classification.CLASS, new TypeName("MyClass")); Field field1 = new Field(myClass, "id", new TypeName("long")); Field field2 = new Field(myClass, "name", new TypeName("String")); myClass.addChild(field1); myClass.addChild(field2); ``` -------------------------------- ### Namespace Instantiation Examples Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/types.md Shows how to create Namespace objects, including the root namespace, package namespaces, and namespaces associated with modules. ```java Namespace root = new Namespace(null, "", Optional.empty()); Namespace comPkg = new Namespace(root, "com", Optional.empty()); Namespace examplePkg = new Namespace(comPkg, "com.example", Optional.empty()); Namespace modulePkg = new Namespace(null, "com.myapp", Optional.of("my.module")); ``` -------------------------------- ### Example Usage of HtmlPostprocessor Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/HtmlPostprocessor.md Demonstrates how to create an HtmlPostprocessor instance and run the post-processing. Logs an error message if post-processing fails. ```java Configuration config = new DocletConfig(); HtmlPostprocessor postprocessor = new HtmlPostprocessor(config); boolean success = postprocessor.postProcessHtml(); if (!success) { System.err.println("HTML post-processing failed"); } ``` -------------------------------- ### Instantiate PackageDependency Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/types.md Example of how to create an instance of the PackageDependency class, specifying the source and target packages. ```java PackageDependency dep = new PackageDependency( "com.example.service", "com.example.model" ); ``` -------------------------------- ### PackageDependency Example Usage Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Dependencies.md Demonstrates how to create and use a `PackageDependency` object, accessing its `fromPackage` and `toPackage` properties. ```java PackageDependency dep = new PackageDependency( "com.example.service", "com.example.model" ); System.out.println(dep.fromPackage); // "com.example.service" System.out.println(dep.toPackage); // "com.example.model" ``` -------------------------------- ### Example Usage of LocalizedReporter Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Logging.md This example demonstrates how to instantiate and use LocalizedReporter to log informational, warning, and error messages with localization. ```java Logger logger = new LocalizedReporter(config, reporter, Locale.ENGLISH); logger.info(Message.INFO_GENERATING_FILE, "diagram.svg"); logger.warn(Message.WARNING_PACKAGE_DEPENDENCY_CYCLES, "pkg.a -> pkg.b -> pkg.a"); logger.error(Message.ERROR_UNANTICIPATED_ERROR_GENERATING_UML, exception); ``` -------------------------------- ### TypeName Instantiation Examples Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/types.md Demonstrates how to create TypeName objects for various Java types, including simple types and generic types. ```java TypeName stringType = new TypeName("java.lang.String"); TypeName listType = new TypeName("java.util.List"); TypeName mapType = new TypeName("java.util.Map"); ``` -------------------------------- ### Example Usage of DependencyDiagram Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md Demonstrates how to create a DependencyDiagram, add package dependencies, and render the diagram. Ensure 'config' is properly initialized before use. ```java DependencyDiagram depDiagram = new DependencyDiagram( config, Optional.of("com.example.app"), "package-dependencies.puml" ); depDiagram.addPackageDependency("com.example.app.service", "com.example.app.model"); depDiagram.addPackageDependency("com.example.app.web", "com.example.app.service"); depDiagram.render(); ``` -------------------------------- ### Example: Adding Parameters to a Method Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/types.md This example demonstrates how to create a Method object and add parameters to it using the Parameters class. It shows adding parameters of different types like String, int, and a functional interface. ```java Method method = new Method(myClass, "doWork", new TypeName("void")); method.addParameter("input", new TypeName("java.lang.String")); method.addParameter("count", new TypeName("int")); method.addParameter("callback", new TypeName("java.util.function.Consumer")); ``` -------------------------------- ### Run Local PlantUML Server Source: https://github.com/talsma-ict/umldoclet/blob/main/usage.md Start a local PlantUML server using Docker for generating UML diagrams. This is recommended over using the central PlantUML server. ```shell docker run -d -p 8080:8080 plantuml/plantuml-server:latest ``` -------------------------------- ### Example: Creating and Modifying a Type Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md Demonstrates creating a class type, marking it as deprecated, and adding members like fields and methods. ```java Namespace namespace = new Namespace(null, "com.example", Optional.empty()); // Create a class type TypeName className = new TypeName("MyClass"); Type myClass = new Type(namespace, Type.Classification.CLASS, className); myClass.deprecated(); // Mark as deprecated // Add members Field field = new Field(myClass, "name", new TypeName("String")); myClass.addChild(field); Method method = new Method(myClass, "getName", new TypeName("String")); myClass.addChild(method); ``` -------------------------------- ### Example Usage of PackageDiagram Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md Demonstrates how to create a PackageDiagram, add types and sub-packages, and render the diagram. Ensure Configuration and Namespace objects are properly initialized. ```java Namespace pkgNamespace = new Namespace(null, "com.example.myapp", Optional.of("mymodule")); PackageDiagram diagram = new PackageDiagram(config, pkgNamespace, "com.example.myapp.puml"); Type classA = new Type(pkgNamespace, Type.Classification.CLASS, new TypeName("ClassA")); diagram.addType(classA); Namespace subPkg = new Namespace(pkgNamespace, "com.example.myapp.util", Optional.of("mymodule")); diagram.addSubpackage(subPkg); diagram.render(); ``` -------------------------------- ### UMLDoclet run() Method Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/HtmlPostprocessor.md Illustrates how the HtmlPostprocessor is invoked at the end of the UMLDoclet's run method after standard documentation and diagram generation. ```java @Override public boolean run(DocletEnvironment environment) { config.logger().info(DOCLET_COPYRIGHT, DOCLET_VERSION); // Generate standard HTML documentation if (!super.run(environment)) return false; try { // Generate UML diagrams generateDiagrams(environment).forEach(Diagram::render); // Post-process HTML to embed diagrams return new HtmlPostprocessor(config).postProcessHtml(); } catch (RuntimeException e) { config.logger().error(ERROR_UNANTICIPATED_ERROR_GENERATING_UML, e); return false; } } ``` -------------------------------- ### Scan Package Dependencies Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Dependencies.md Demonstrates how to use DependenciesElementScanner to scan Javadoc elements and print detected package dependencies. Ensure the DocletEnvironment is properly initialized. ```java DocletEnvironment environment = /* from Javadoc */; Configuration config = new DocletConfig(); DependenciesElementScanner scanner = new DependenciesElementScanner(environment, config); Set dependencies = scanner.scan( environment.getIncludedElements(), null ); for (PackageDependency dep : dependencies) { System.out.println(dep.fromPackage + " -> " + dep.toPackage); } ``` -------------------------------- ### ClassDiagram Usage Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md Demonstrates how to create a Type object, add fields and methods, and then use it to generate a ClassDiagram and render it to a file. ```java Type myClass = new Type(namespace, Type.Classification.CLASS, new TypeName("MyClass")); myClass.addChild(new Field(myClass, "field1", new TypeName("String"))); Method method = new Method(myClass, "doSomething", new TypeName("void")); method.addParameter("param", new TypeName("int")); myClass.addChild(method); ClassDiagram diagram = new ClassDiagram(config, myClass, "my-class.puml"); diagram.render(); ``` -------------------------------- ### StringBufferingWriter Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Utilities.md Demonstrates how to use StringBufferingWriter to capture diagram source in memory while also writing to a file. This is useful for both file output and further in-memory processing. ```java StringBufferingWriter buffer = new StringBufferingWriter(fileWriter); IndentingWriter indented = new IndentingWriter(buffer, config.indentation()); diagram.writeTo(indented); String diagramSource = buffer.getBuffer().toString(); ``` -------------------------------- ### PlantUML Class Example with UML Characters Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Utilities.md An example of PlantUML output demonstrating the usage of UML character constants for visibility and modifiers within a class definition. ```plantuml @startuml class MyClass { + publicField: String # protectedField: int - privateField: boolean ~ packageField: Object + {abstract} abstractMethod() + {static} staticMethod(): void } @enduml ``` -------------------------------- ### Maven Javadoc Plugin Output Example Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Logging.md This output shows typical messages from the Maven Javadoc Plugin when using UMLDoclet, including build information, copyright notices, file generation, and detected package dependency cycles. ```text [INFO] Building jar: /project/target/myproject-1.0-javadoc.jar [INFO] Generating UML Doclet (C) Copyright 2016-2026 Talsma ICT [INFO] PlantUML (ASL) Copyright 2009-2026 Arnaud Roques [INFO] Generating file: target/apidocs/com/example/MyClass.svg [INFO] Package dependency cycles detected: [INFO] - [com.example.a] -> [com.example.b] -> [com.example.a] ``` -------------------------------- ### Initialize UMLDoclet Logger Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Logging.md Initializes the configuration and logger for UMLDoclet. This method is called during the doclet's setup phase. ```java public void init(Locale locale, Reporter reporter) { config.init(locale, reporter); // Sets up LocalizedReporter super.init(locale, reporter); } ``` -------------------------------- ### Maven Javadoc Plugin Configuration for UMLDoclet Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UMLDoclet.md Example configuration for the maven-javadoc-plugin to use the UMLDoclet. This includes specifying the doclet class, artifact, and additional options for diagram generation. ```xml org.apache.maven.plugins maven-javadoc-plugin nl.talsmasoftware.umldoclet.UMLDoclet nl.talsmasoftware umldoclet 2.3.1 --create-puml-files --uml-image-format SVG ``` -------------------------------- ### Generate PlantUML Diagram Locally Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/PlantumlGenerator.md Example demonstrating how to generate a PlantUML diagram locally using the BuiltinPlantumlGenerator. This code snippet shows the typical usage when no external PlantUML server is configured. ```java Configuration config = new DocletConfig(); // No server URL = uses BuiltinPlantumlGenerator PlantumlGenerator generator = PlantumlGenerator.getPlantumlGenerator(config); String pumlSource = "@startuml\n" + "class User { }\n" + "class Post { }\n" + "User --> Post\n" + "@enduml"; try (OutputStream out = new FileOutputStream("diagram.svg")) { generator.generatePlantumlDiagramFromSource( pumlSource, FileFormat.SVG, out ); System.out.println("Diagram generated: diagram.svg"); } ``` -------------------------------- ### Display All UML Doclet Options Source: https://github.com/talsma-ict/umldoclet/blob/main/usage.md Run this command to list all available options for the UML Doclet, including standard Javadoc options and UML-specific parameters. ```bash javadoc --help -docletpath umldoclet-2.x.jar -doclet nl.talsmasoftware.umldoclet.UMLDoclet ``` -------------------------------- ### Create Inheritance and Implementation Links Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/types.md Demonstrates creating `Link` objects for inheritance and implementation relationships. Ensure the `Link` class is imported. ```java Link extendsLink = Link.fromType("com.example.Parent") .relatesTo("com.example.Child") .withRelationship("extends"); Link implementsLink = Link.fromType("com.example.MyClass") .relatesTo("java.util.Comparable") .withRelationship("implements"); ``` -------------------------------- ### Handle Cyclic Dependencies Based on Configuration Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Dependencies.md This code demonstrates how to check the configured action for cyclic dependencies and log warnings or errors accordingly. The action can be IGNORE, WARN, or ERROR. ```java Configuration.Action action = config.onCyclicPackageDependencies(); if (action == Configuration.Action.IGNORE) { // Do nothing } else if (action == Configuration.Action.WARN) { config.logger().warn("Cycles detected: " + cycles); } else if (action == Configuration.Action.ERROR) { config.logger().error("Cycles detected: " + cycles); // May fail build if configured } ``` -------------------------------- ### File Locations with --uml-image-directory Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/README.md Demonstrates how file locations change when the `--uml-image-directory` option is used to specify a separate directory for images. ```text docs/ ├── com.example.package.svg (images directory) ├── com.example.MyClass.svg └── package-dependencies.svg ``` -------------------------------- ### Get PlantumlGenerator Factory Method Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/PlantumlGenerator.md Use this factory method to obtain the appropriate PlantumlGenerator implementation based on the configuration. It returns either a RemotePlantumlGenerator or a BuiltinPlantumlGenerator. ```java public static PlantumlGenerator getPlantumlGenerator(Configuration config) ``` ```java Configuration config = new DocletConfig(); config.plantumlServerUrl = "http://localhost:8080/"; // Optional PlantumlGenerator generator = PlantumlGenerator.getPlantumlGenerator(config); ``` -------------------------------- ### Main Entry Point Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/README.md The primary class for integrating UMLDoclet as a Javadoc tool. ```APIDOC ## Main Entry Point ### Description This section details the main entry point for using UMLDoclet within the Javadoc process. ### Class `nl.talsmasoftware.umldoclet.UMLDoclet` ### Usage This class serves as the doclet implementation that Javadoc invokes to generate UML diagrams from source code documentation. ``` -------------------------------- ### Run UML Doclet via Commandline Source: https://github.com/talsma-ict/umldoclet/blob/main/usage.md Use this command to generate documentation with the UML Doclet from the command line. Ensure the doclet JAR is accessible via -docletpath. ```bash javadoc -sourcepath src -classpath lib -d apidocs \ -docletpath umldoclet-2.x.jar -doclet nl.talsmasoftware.umldoclet.UMLDoclet \ com.foobar ``` -------------------------------- ### HtmlPostprocessor Constructor Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/HtmlPostprocessor.md Initializes the HtmlPostprocessor with the necessary configuration. Requires a Configuration object. ```java public HtmlPostprocessor(Configuration config) ``` -------------------------------- ### Detected Package Dependencies Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Dependencies.md Illustrates the output format for detected package dependencies, showing direct and self-referential dependencies. ```text com.example.app.service -> com.example.app.model com.example.app.service -> com.example.app.service com.example.app.web -> com.example.app.service ``` -------------------------------- ### configuration.md File Size Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/MANIFEST.md Displays the file size of the configuration.md file. This is part of the overall file size breakdown for the project. ```text configuration.md 11 KB ``` -------------------------------- ### Command Line Configuration for UMLDoclet Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/configuration.md Use the javadoc command with specific options to configure UMLDoclet. Ensure the doclet JAR is in the docletpath. ```bash javadoc \ -d docs \ -docletpath umldoclet-2.3.1-full.jar \ -doclet nl.talsmasoftware.umldoclet.UMLDoclet \ --create-puml-files \ --uml-image-format SVG \ --uml-excluded-package-dependencies com.example.internal \ src/main/java ``` -------------------------------- ### Total Project Size Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/MANIFEST.md Displays the total file size of the project. This is a summary of all documented files. ```text Total 148 KB ``` -------------------------------- ### RemotePlantumlGenerator Constructor Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/PlantumlGenerator.md Initializes the RemotePlantumlGenerator with configuration and the PlantUML server URL. ```APIDOC ## RemotePlantumlGenerator Constructor ### Description Initializes the RemotePlantumlGenerator with the provided Doclet configuration and the base URL of the PlantUML server. ### Method Signature ```java public RemotePlantumlGenerator(Configuration config, String serverUrl) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java Configuration config = new DocletConfig(); config.plantumlServerUrl = "http://localhost:8080/"; PlantumlGenerator generator = new RemotePlantumlGenerator(config, "http://localhost:8080/"); ``` ### Response None (Constructor) ``` -------------------------------- ### UMLDoclet Configuration Flow Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/README.md Illustrates the flow of configuration from command-line options to the DocletConfig object, which is then passed to various components. ```text Command-line options ↓ UMLDoclet.getSupportedOptions() → UMLOptions ↓ UMLOptions parses and stores in DocletConfig ↓ DocletConfig implements Configuration interface ↓ Configuration passed to all components (Factory, Diagrams, etc.) ``` -------------------------------- ### Normal Mode Logging Configuration (Default) Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/Logging.md This is the default mode, showing standard informational messages, package dependency warnings, and errors. ```bash javadoc -doclet nl.talsmasoftware.umldoclet.UMLDoclet ... ``` -------------------------------- ### Diagram getPlantUmlFile() Method Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UML-Diagrams.md Abstract method to determine the file path for PlantUML source output. Must be implemented by subclasses. ```java protected abstract File getPlantUmlFile() ``` -------------------------------- ### Configure Gradle Javadoc Task for UML Doclet (Kotlin DSL) Source: https://github.com/talsma-ict/umldoclet/blob/main/usage.md Set up the Javadoc task in Gradle using the Kotlin DSL to include the UML Doclet. Declare the doclet as a dependency and configure the task options. ```kotlin val umlDoclet: Configuration by configurations.creating dependencies { umlDoclet("nl.talsmasoftware:umldoclet:2.0.15") } configurations { umlDoclet } tasks.javadoc { source = sourceSets.main.get().allJava val docletOptions = options as StandardJavadocDocletOptions docletOptions.docletpath = umlDoclet.files.toList() docletOptions.doclet = "nl.talsmasoftware.umldoclet.UMLDoclet" docletOptions.addStringOption("additionalParamName", "additionalParamValue") } ``` -------------------------------- ### UMLDoclet getSupportedOptions Method Source: https://github.com/talsma-ict/umldoclet/blob/main/_autodocs/UMLDoclet.md Returns all supported command-line options for this doclet, merging UML-specific options with StandardDoclet options. This method is part of the Javadoc Doclet API. ```java @Override public Set