Skip to content

Commit

Permalink
Add jsyntrax
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpanzer committed Jun 23, 2024
1 parent 0708071 commit cd18830
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ on:
type: boolean
default: true
required: true
publishAsciidoctorJDiagramBatik:
description: "Publish asciidoctorj-diagram-batik"
type: boolean
default: true
required: true
publishAsciidoctorJDiagramJSyntrax:
description: "Publish asciidoctorj-diagram-jsyntrax"
type: boolean
default: true
required: true

env:
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.GPG_KEY_ID }}
Expand All @@ -42,6 +52,8 @@ jobs:
if ${{ inputs.publishAsciidoctorJDiagram }}; then GOALS="publishMavenAsciidoctorJDiagramPublicationToSonatypeRepository "; fi
if ${{ inputs.publishAsciidoctorJDiagramDitaaMini }}; then GOALS="$GOALS publishMavenAsciidoctorJDiagramDitaaminiPublicationToSonatypeRepository "; fi
if ${{ inputs.publishAsciidoctorJDiagramPlantuml }}; then GOALS="$GOALS publishMavenAsciidoctorJDiagramPlantumlPublicationToSonatypeRepository "; fi
if ${{ inputs.publishAsciidoctorJDiagramBatik }}; then GOALS="$GOALS publishMavenAsciidoctorJDiagramBatikPublicationToSonatypeRepository "; fi
if ${{ inputs.publishAsciidoctorJDiagramJSyntrax }}; then GOALS="$GOALS publishMavenAsciidoctorJDiagramJSyntraxPublicationToSonatypeRepository "; fi
echo "Publishing goals: ${GOALS}"
unset GEM_PATH GEM_HOME JRUBY_OPTS
./gradlew --no-daemon clean build
Expand Down
23 changes: 23 additions & 0 deletions asciidoctorj-diagram-batik/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
dependencies {
gems("rubygems:asciidoctor-diagram-batik:${project.version}")
}

def gemFiles = fileTree("${project.buildDir}/.gems") {
include 'specifications/*.gemspec'
include 'gems/*/lib/**'
}

jrubyPrepare {
doLast {
println "Copy from $gemFiles into $preparedGems"
copy { // bundles the gems inside this artifact
from gemFiles
into preparedGems
}
}
}

ext.publicationName = "mavenAsciidoctorJDiagramBatik"

apply from: rootProject.file('gradle/publish.gradle')
apply from: rootProject.file('gradle/signing.gradle')
4 changes: 4 additions & 0 deletions asciidoctorj-diagram-batik/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
properName=AsciidoctorJ Diagram Batik
description=AsciidoctorJ Diagram Batik bundles the Asciidoctor Diagram Batik RubyGem (asciidoctor-diagram-batik) so it can be loaded into the JVM using JRuby.
version=1.17
gem_name=asciidoctor-diagram-batik
26 changes: 26 additions & 0 deletions asciidoctorj-diagram-jsyntrax/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
dependencies {
gems("rubygems:asciidoctor-diagram-jsyntrax:${project.version}") {
exclude module: "asciidoctor-diagram-batik"
}
implementation project(':asciidoctorj-diagram-batik')
}

def gemFiles = fileTree("${project.buildDir}/.gems") {
include 'specifications/*.gemspec'
include 'gems/*/lib/**'
}

jrubyPrepare {
doLast {
println "Copy from $gemFiles into $preparedGems"
copy { // bundles the gems inside this artifact
from gemFiles
into preparedGems
}
}
}

ext.publicationName = "mavenAsciidoctorJDiagramPlantuml"

apply from: rootProject.file('gradle/publish.gradle')
apply from: rootProject.file('gradle/signing.gradle')
5 changes: 5 additions & 0 deletions asciidoctorj-diagram-jsyntrax/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
properName=AsciidoctorJ Diagram JSyntrax
description=AsciidoctorJ Diagram JSyntrax bundles the Asciidoctor Diagram JSyntrax RubyGem (asciidoctor-diagram-jsyntrax) so it can be loaded into the JVM using JRuby.
version=1.38.1
gem_name=asciidoctor-diagram-jsyntrax

3 changes: 1 addition & 2 deletions asciidoctorj-diagram-plantuml/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
dependencies {
gems("rubygems:asciidoctor-diagram-plantuml:${project.version}") {
// Version resolution does not seem to work correctly for this one, therefore requiring it explicitly
exclude module: "asciidoctor-diagram-batik"
}
gems("rubygems:asciidoctor-diagram-batik:${asciidoctorDiagramBatikGemVersion}")
implementation project(':asciidoctorj-diagram-batik')
}

def gemFiles = fileTree("${project.buildDir}/.gems") {
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ subprojects {

status = _status

def _javaVersion = 8
if (project.name == "itest"
|| project.name == "asciidoctorj-diagram-jsyntrax") {
_javaVersion = 11
}
project.tasks.withType(JavaCompile).configureEach { task ->
task.options.release = 8
task.options.release = _javaVersion
}
project.tasks.withType(GroovyCompile).configureEach {task ->
task.options.release = 8
task.options.release = _javaVersion
}

repositories {
Expand Down
3 changes: 2 additions & 1 deletion itest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ dependencies {
testImplementation ("org.asciidoctor:asciidoctorj:$asciidoctorJVersion")

testImplementation project(':asciidoctorj-diagram')
testImplementation project(':asciidoctorj-diagram-jsyntrax')
}

jar.enabled = false

configurations.all {
configurations.configureEach {
artifacts.clear()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import static org.assertj.core.api.Assertions.assertThat;

public class WhenDocumentContainsDitaaDiagram {
public class WhenDocumentContainsDiagrams {

private Asciidoctor asciidoctor = Asciidoctor.Factory.create();
private final Asciidoctor asciidoctor = Asciidoctor.Factory.create();

@Test
public void png_should_be_rendered_for_diagram() {
Expand All @@ -19,10 +19,22 @@ public void png_should_be_rendered_for_diagram() {
File expectedDiagram = new File(sourceDir, "asciidoctor-diagram-process.png");
File expectedDiagramCache = new File(sourceDir, ".asciidoctor/diagram/asciidoctor-diagram-process.png.cache");

File expectedPlantumlDiagram = new File(sourceDir, "plantuml-test.svg");
File expectedPlantumlDiagramCache = new File(sourceDir, ".asciidoctor/diagram/plantuml-test.svg.cache");

File expectedJSyntraxDiagram = new File(sourceDir, "jsyntrax-test.svg");
File expectedJSyntraxDiagramCache = new File(sourceDir, ".asciidoctor/diagram/jsyntrax-test.svg.cache");

asciidoctor.requireLibrary("asciidoctor-diagram");
asciidoctor.convertFile(sourceDocument, Options.builder().backend("html5").build());

assertThat(expectedDiagram).isNotEmpty();
assertThat(expectedDiagramCache).isNotEmpty();

assertThat(expectedPlantumlDiagram).isNotEmpty();
assertThat(expectedPlantumlDiagramCache).isNotEmpty();

assertThat(expectedJSyntraxDiagram).isNotEmpty();
assertThat(expectedJSyntraxDiagramCache).isNotEmpty();
}
}
15 changes: 15 additions & 0 deletions itest/src/test/resources/sample.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@
+-----------------------------------+
....

[plantuml,plantuml-test,svg]
----
class A
class B
A --> B
----

[syntrax,jsyntrax-test,svg]
----
indentstack(10,
line(opt('-'), choice('0', line('1-9', loop(None, '0-9'))),
opt('.', loop('0-9', None))),
line(opt(choice('e', 'E'), choice(None, '+', '-'), loop('0-9', None)))
)
----
Loading

0 comments on commit cd18830

Please sign in to comment.