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

generate diagram with java graphviz implementation #104

Merged
merged 8 commits into from
Jul 19, 2023
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
11 changes: 5 additions & 6 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build and Deploy

on:
push:
branches: [master]
branches: [ master ]
pull_request:
branches: [master]
branches: [ master ]
workflow_dispatch:

env:
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: New release - livingdoc-annotations - ci skip
commit_message: Post release - livingdoc-annotations - ci skip

livingdoc-maven-plugin:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: New release - livingdoc-maven-plugin - ci skip
commit_message: Post release - livingdoc-maven-plugin - ci skip

tests_java_plugin:
runs-on: ubuntu-latest
Expand All @@ -156,7 +156,7 @@ jobs:
if: "needs.check.outputs.plugin-status == 'deploy' && github.event_name == 'pull_request'"
strategy:
matrix:
version: [11, 15, 17]
version: [ 11, 15, 17 ]
env:
folder: livingdoc-examples
steps:
Expand Down Expand Up @@ -186,7 +186,6 @@ jobs:
- name: Test ${{ matrix.version }}
working-directory: ./livingdoc-maven-plugin/src/nonreg/example-java-x
run: |

sed -i -e "s/\${env.LIVINGDOC-MAVEN-PLUGIN_VERSION}/${{ env.LIVINGDOC-MAVEN-PLUGIN_VERSION }}/g" pom.xml
mvn --batch-mode --update-snapshots verify
env:
Expand Down
6 changes: 4 additions & 2 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ like this example : https://github.com/jboz/living-documentation/tree/master/liv
== Add gherkin description :
You can also integrate gherkin files like this example : link:livingdoc-examples/microservice/images/example_microservice_index.html.png[Microservice example generated index file]

If you want to separate gherkins files and upload to confluence for example, look at this example: link:livingdoc-examples/ddd/pom.xml[Domain Driven Design]
If you want to separate gherkins files look at this example: link:livingdoc-examples/ddd/pom.xml[Domain Driven Design]

== Also allow to publish generated docs to confluence :
Publish specific HTML version to Altassian Conlluence Server.
Publish specific HTML version to Altassian Confluence Server.
If you want to upload content to confluence look at this example: link:livingdoc-examples/ddd/pom.xml[Domain Driven Design]
Take car that you will have to use adoc format and let the publish goal to generate the html part

== With a light maven configuration :
[source,xml]
Expand Down
2 changes: 1 addition & 1 deletion livingdoc-examples/ddd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<provider>confluence</provider>
<endpoint>${CONFLUENCE_URL}</endpoint>
<spaceKey>DOCPROD</spaceKey>
<ancestorId>98392</ancestorId>
<ancestorId>98369</ancestorId>
<username>livingdoc</username>
<password>livingdoc</password>
</publish>
Expand Down
2 changes: 1 addition & 1 deletion livingdoc-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<dependency>
<groupId>ch.ifocusit</groupId>
<artifactId>plantuml-builder</artifactId>
<version>2.4</version>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.qdox</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[plantuml, diagram, format=svg, opts=interactive]
----
@startuml
!pragma layout smetana



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[plantuml, diagram, format=svg, opts=interactive]
----
@startuml
!pragma layout smetana

header

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@startuml
!pragma layout smetana



Expand Down Expand Up @@ -62,4 +63,4 @@ class "SmsAccess" [[glossary.html#glossaryid-600{SmsAccess}]]



@enduml
@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[plantuml, diagram-all, format=png, opts=interactive]
----
@startuml
!pragma layout smetana



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[plantuml, diagram, format=png, opts=interactive]
----
@startuml
!pragma layout smetana



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
*/
package ch.ifocusit.livingdoc.plugin;

import java.io.File;
import java.util.List;
import java.util.stream.Stream;

import ch.ifocusit.livingdoc.annotations.UbiquitousLanguage;
import ch.ifocusit.livingdoc.plugin.baseMojo.AbstractDocsGeneratorMojo;
import ch.ifocusit.livingdoc.plugin.diagram.PlantumlClassDiagramBuilder;
import ch.ifocusit.livingdoc.plugin.domain.Cluster;
import ch.ifocusit.livingdoc.plugin.domain.Color;
import io.github.robwin.markup.builder.asciidoc.AsciiDocBuilder;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -34,12 +36,9 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

import ch.ifocusit.livingdoc.annotations.UbiquitousLanguage;
import ch.ifocusit.livingdoc.plugin.baseMojo.AbstractDocsGeneratorMojo;
import ch.ifocusit.livingdoc.plugin.diagram.PlantumlClassDiagramBuilder;
import ch.ifocusit.livingdoc.plugin.domain.Cluster;
import ch.ifocusit.livingdoc.plugin.domain.Color;
import io.github.robwin.markup.builder.asciidoc.AsciiDocBuilder;
import java.io.File;
import java.util.List;
import java.util.stream.Stream;

/**
* @author Julien Boz
Expand Down Expand Up @@ -131,6 +130,13 @@ public class DiagramMojo extends AbstractDocsGeneratorMojo {
@Parameter(property = "livingdoc.diagram.withDeps", defaultValue = "false")
private boolean diagramWithDependencies;

/**
* The graphviz java implementation image processor will be use by default.
* Set this option to true to use external graphviz image processor.
*/
@Parameter(property = "livingdoc.diagram.useExternalGraphviz", defaultValue = "false")
private boolean diagramUseExternalGraphviz;

@Override
protected String getOutputFilename() {
return diagramOutputFilename;
Expand Down Expand Up @@ -198,6 +204,7 @@ String generateDiagram() throws MojoExecutionException {
if (diagramWithLink && !DiagramImageType.png.equals(diagramImageType)) {
builder.mapNames(glossaryMapping);
}
builder.setUseExternalGraphiz(diagramUseExternalGraphviz);
return builder.generate();
}
throw new NotImplementedException(String.format("format %s is not implemented yet", diagramType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
* @author Julien Boz
*/
public class PlantumlClassDiagramBuilder extends AbstractClassDiagramBuilder {
private static final String PRAGMA_LAYOUT_SMETANA = "!pragma layout smetana";

Logger LOG = LoggerFactory.getLogger(PlantumlClassDiagramBuilder.class);

private ClassDiagramBuilder classDiagramBuilder;
private Predicate<ClassInfo> additionalClassPredicate = a -> true; // default predicate always true
private boolean showMethods;
private boolean showFields;
private boolean useExternalGraphviz = false;

public PlantumlClassDiagramBuilder(MavenProject project, String prefix, String[] excludes,
String rootAggregateClassMatcher, Color rootAggregateColor, File header, File footer, boolean showMethods,
Expand Down Expand Up @@ -106,10 +108,12 @@ public String generate() throws MojoExecutionException {
}).filter(Objects::nonNull).collect(Collectors.toList()))
.withNamesMapper(namesMapper)
.excludes(excludes)
.setAfterStartTag(!useExternalGraphviz ? PRAGMA_LAYOUT_SMETANA : null)
.setHeader(readHeader())
.setFooter(readFooter())
.withLinkMaker(this)
.withDependencies(diagramWithDependencies).build();
.withDependencies(diagramWithDependencies)
.build();
return diagram;
}

Expand All @@ -131,4 +135,8 @@ public void filterOnAnnotation(Class<? extends Annotation> annotation) {
// add field predicate
classDiagramBuilder.addFieldPredicate(attribut -> attribut.getField().isAnnotationPresent(annotation));
}

public void setUseExternalGraphiz(boolean useExternalGraphviz) {
this.useExternalGraphviz = useExternalGraphviz;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import java.util.List;
import java.util.Map;

import static ch.ifocusit.livingdoc.plugin.utils.AsciidocUtil.NEWLINE;

@SuppressWarnings("unchecked")
public class GherkinToAsciidocTransformer {
public static final String NEWLINE = System.getProperty("line.separator");

private final StringBuilder builder = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@startuml
!pragma layout smetana

header
hide BillingService fields
Expand Down Expand Up @@ -62,4 +63,4 @@ footer
endfooter


@enduml
@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[plantuml, diagram-all, format=png, opts=interactive]
----
@startuml
!pragma layout smetana

header

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[plantuml, diagram, format=png, opts=interactive]
----
@startuml
!pragma layout smetana

header

Expand Down