Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copyright comment to generated uml diagrams and make footer clickable #638

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/main/java/nl/talsmasoftware/umldoclet/uml/Diagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package nl.talsmasoftware.umldoclet.uml;

import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.version.Version;
import nl.talsmasoftware.umldoclet.configuration.Configuration;
import nl.talsmasoftware.umldoclet.configuration.ImageConfig;
import nl.talsmasoftware.umldoclet.logging.Message;
Expand All @@ -27,8 +28,12 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Stream;

Expand Down Expand Up @@ -61,6 +66,7 @@ protected Diagram(Configuration config) {
public <IPW extends IndentingPrintWriter> IPW writeTo(IPW output) {
output.append("@startuml").newline();
IndentingPrintWriter indented = output.indent();
writeCopyrightStatement(indented);
writeCustomDirectives(config.customPlantumlDirectives(), indented);
writeChildrenTo(indented);
writeFooterTo(indented);
Expand All @@ -77,9 +83,17 @@ protected <IPW extends IndentingPrintWriter> IPW writeCustomDirectives(List<Stri
}

private <IPW extends IndentingPrintWriter> IPW writeFooterTo(IPW output) {
output.append("center footer").whitespace().append("\\n")
.append(config.logger().localize(Message.DOCLET_UML_FOOTER, Message.DOCLET_VERSION))
.newline();
String footerText = config.logger().localize(Message.DOCLET_UML_FOOTER, Message.DOCLET_VERSION);
String footerLink = "https://github.com/talsma-ict/umldoclet";
output.newline().append("<style>").indent().newline()
.append("footer {").indent().newline()
.append("HyperLinkColor #8").newline() // default footer FontColor
.append("HyperLinkUnderlineThickness 0").newline()
.unindent().append("}").newline()
.unindent().append("</style>").newline()
.append("footer").whitespace()
.append("\\n[[").append(footerLink).whitespace().append(footerText).append("]]").newline()
.append("' Generated ").append(ZonedDateTime.now().toString()).newline();
return output;
}

Expand Down Expand Up @@ -210,4 +224,14 @@ private FileFormat toFileFormat(ImageConfig.Format format) {
return null;
}

private void writeCopyrightStatement(PrintWriter output) {
String version = Message.DOCLET_VERSION.toString(Locale.ENGLISH);
int year = LocalDate.now().getYear();
output.println("' Copyright to this UML and generated images belongs to the author of the corresponding Java sources.");
output.println();
output.println("' This UML was generated by UMLDoclet (C) Copyright 2016-" + year + " Talsma ICT.");
output.println("' UMLDoclet " + version + " is licensed under the Apache License, version 2.0");
output.println("' and contains parts of PlantUML " + Version.versionString() + " (ASL) Copyright 2009-" + year + ", Arnaud Roques.");
output.println();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ doclet.version=${project.version}

# Messages
doclet.copyright=UML Doclet (C) Copyright Talsma ICT, version: {0}.
doclet.uml.footer=UMLDoclet {0}, PlantUML %version()
doclet.uml.footer=UMLDoclet {0}
plantuml.copyright=This software uses PlantUML (C) Copyright Arnaud Roques.
debug.configured.image.formats=Configured image formats to generate: {0}.
debug.skipping.file=Skipping {0}...
Expand Down