Skip to content

Commit 5294452

Browse files
authored
Add new asciidoc-maven-site-parser-example example (#254)
* Rename asciidoc-maven-site-example to asciidoc-maven-site-converter-example * Add new asciidoc-maven-site-parser-example
1 parent feee067 commit 5294452

File tree

22 files changed

+267
-11
lines changed

22 files changed

+267
-11
lines changed

README.adoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ Demonstrates how to convert AsciiDoc to PDF using Asciidoctor PDF with the Ascii
3131
link:asciidoctor-epub-example/README.adoc[asciidoctor-epub-example]::
3232
Demonstrates how to convert AsciiDoc to epub using Asciidoctor EPUB with the Asciidoctor Maven plugin. (contains also an example for .mobi (Kindle) output)
3333

34-
link:asciidoc-maven-site-example/README.adoc[asciidoc-maven-site-example]::
35-
Demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.
34+
link:asciidoc-maven-site-converter-example/README.adoc[asciidoc-maven-site-converter-example]::
35+
Demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Converter Doxia Module.
36+
37+
link:asciidoc-maven-site-parser-example/README.adoc[asciidoc-maven-site-parser-example]::
38+
Demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Parser Doxia Module.
3639

3740
link:asciidoc-multiple-inputs-example/README.adoc[asciidoc-multiple-inputs-example]::
3841
An example project that demonstrates how to convert multiple input AsciiDoc documents to HTML5 and PDF using the
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
= Asciidoctor Maven Plugin (Converter Module): AsciiDoc Site Example
2+
3+
An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Converter Doxia Module.
4+
5+
== Usage
6+
7+
Build the site by invoking the `site:site` goal:
8+
9+
$ mvn site:site
10+
11+
Open the file _target/site/hello.html_ to see the output generated from the AsciiDoc source _src/site/asciidoc/hello.adoc_.
12+
13+
Open the file _target/site/index.html_ to see the output generated for the entire site including the link to the `hello` document.
14+

asciidoc-maven-site-example/pom.xml asciidoc-maven-site-converter-example/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.asciidoctor.maven</groupId>
6-
<artifactId>asciidoc-maven-site-example</artifactId>
6+
<artifactId>asciidoc-maven-site-converter-example</artifactId>
77
<version>1.0.0-SNAPSHOT</version>
88
<name>AsciiDoc Maven Site Example</name>
99
<description>An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.</description>

asciidoc-maven-site-example/src/site/site.xml asciidoc-maven-site-converter-example/src/site/site.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<skin>
1111
<groupId>org.apache.maven.skins</groupId>
1212
<artifactId>maven-fluido-skin</artifactId>
13-
<version>1.11.0</version>
13+
<version>1.12.0</version>
1414
</skin>
1515
</project>

asciidoc-maven-site-example/README.adoc asciidoc-maven-site-parser-example/README.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
= Asciidoctor Maven Plugin: AsciiDoc Site Example
1+
= Asciidoctor Maven Plugin (Parser Module): AsciiDoc Site Example
22

3-
An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.
3+
An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Parser Doxia Module.
44

55
== Usage
66

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.asciidoctor.maven</groupId>
6+
<artifactId>asciidoc-maven-site-parser-example</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<name>AsciiDoc Maven Site Example</name>
9+
<description>An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.</description>
10+
11+
<!-- All Maven properties are injected as Asciidoctor attributes.
12+
Reference them with the same name replacing dots by dashes (e.g. {jruby-version}). -->
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
16+
<asciidoctor.maven.plugin.version>3.0.0</asciidoctor.maven.plugin.version>
17+
<asciidoctorj.version>2.5.11</asciidoctorj.version>
18+
<jruby.version>9.4.5.0</jruby.version>
19+
</properties>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-site-plugin</artifactId>
26+
<version>3.12.1</version>
27+
<configuration>
28+
<!-- Disable generateReports if you don't want to include the built-in reports -->
29+
<generateReports>true</generateReports>
30+
<generateSitemap>true</generateSitemap>
31+
<relativizeDecorationLinks>false</relativizeDecorationLinks>
32+
<locales>en</locales>
33+
<inputEncoding>UTF-8</inputEncoding>
34+
<outputEncoding>UTF-8</outputEncoding>
35+
<asciidoc>
36+
<!-- Optional site-wide AsciiDoc attributes -->
37+
<attributes>
38+
<icons>font</icons>
39+
<!-- Add required rouge styles in '/css/site.css' -->
40+
<source-highlighter>rouge</source-highlighter>
41+
<toclevels>2</toclevels>
42+
</attributes>
43+
</asciidoc>
44+
</configuration>
45+
<dependencies>
46+
<dependency>
47+
<groupId>org.asciidoctor</groupId>
48+
<artifactId>asciidoctor-parser-doxia-module</artifactId>
49+
<version>${asciidoctor.maven.plugin.version}</version>
50+
</dependency>
51+
<!-- Comment this section to use the default jruby artifact provided by the plugin -->
52+
<dependency>
53+
<groupId>org.jruby</groupId>
54+
<artifactId>jruby</artifactId>
55+
<version>${jruby.version}</version>
56+
</dependency>
57+
<!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin -->
58+
<dependency>
59+
<groupId>org.asciidoctor</groupId>
60+
<artifactId>asciidoctorj</artifactId>
61+
<version>${asciidoctorj.version}</version>
62+
</dependency>
63+
</dependencies>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
68+
<reporting>
69+
<plugins>
70+
<plugin>
71+
<artifactId>maven-project-info-reports-plugin</artifactId>
72+
<version>3.5.0</version>
73+
</plugin>
74+
</plugins>
75+
</reporting>
76+
77+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
== Attributes
2+
3+
.Built-in
4+
asciidoctor-version:: {asciidoctor-version}
5+
safe-mode-name:: {safe-mode-name}
6+
docdir:: {docdir}
7+
8+
.Maven properties
9+
asciidoctor.maven.plugin.version:: {asciidoctor-maven-plugin-version}
10+
asciidoctorj.version:: {asciidoctorj-version}
11+
jruby.version:: {jruby-version}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
included content
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
= AsciiDoc is Writing Zen
2+
Doc Writer <doc[email protected]>
3+
//Junior Writer <junior[email protected]>
4+
v1.0, 2014-08-08
5+
//:toc:
6+
:icons: font
7+
:source-highlighter: rouge
8+
:sectanchors:
9+
//:compat-mode:
10+
11+
_Zen_ in the *art* of writing `plain text` with https://asciidoc.org[AsciiDoc].
12+
13+
[TIP]
14+
Use https://asciidoctor.org[Asciidoctor] for the best AsciiDoc experience.footnote:[Not to mention the best looking output!]
15+
Then icon:twitter[role=aqua] about it!
16+
17+
toc::[]
18+
19+
== Sample Section
20+
21+
=== Unordered list
22+
23+
* item 1
24+
* item 2
25+
26+
=== Ordered list
27+
28+
. item 1
29+
. item 2
30+
31+
=== Table
32+
33+
[caption=]
34+
.Ruby platforms
35+
|===
36+
|Name |Language
37+
38+
|MRI |C
39+
|JRuby |Java
40+
|Opal |JavaScript
41+
|Rubinius |Ruby
42+
|===
43+
44+
=== Code blocks
45+
46+
[source,ruby]
47+
----
48+
puts "Hello, World!"
49+
----
50+
51+
[source,java]
52+
----
53+
class HelloWorld {
54+
public static void main(String[] args) {
55+
System.out.println("Hello, World!");
56+
}
57+
}
58+
----
59+
60+
include::_attributes.adoc[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
= Hello, AsciiDoc!
2+
//:icons: font
3+
4+
This file was converted from AsciiDoc to HTML by the Maven Site module of the Asciidoctor Maven Plugin.
5+
6+
image::images/tiger.png[Ghostscript Tiger]
7+
_By Ghostscript authors (GPL Ghostscript SVN: tiger.eps) [GPL (https://www.gnu.org/licenses/gpl.html)], via Wikimedia Commons_
8+
9+
[TIP]
10+
====
11+
Use the include directive to keep your content DRY!
12+
13+
include::_include.adoc[]
14+
====
15+
16+
include::_attributes.adoc[]
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<project>
2+
<body>
3+
<menu ref="reports" inherit="top"/>
4+
<menu ref="modules"/>
5+
<menu name="Asciidoctor Example">
6+
<item href="hello.html" name="Hello"/>
7+
<item href="article.html" name="Article"/>
8+
</menu>
9+
</body>
10+
<skin>
11+
<groupId>org.apache.maven.skins</groupId>
12+
<artifactId>maven-fluido-skin</artifactId>
13+
<version>1.12.0</version>
14+
</skin>
15+
</project>

pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<description>Collection of sample projects that demonstrate numerous ways to use the Asciidoctor Maven plugin in a Maven project.</description>
1313

1414
<modules>
15-
<module>asciidoc-maven-site-example</module>
15+
<module>asciidoc-maven-site-converter-example</module>
16+
<module>asciidoc-maven-site-parser-example</module>
1617
<module>asciidoc-to-html-example</module>
1718
<module>asciidoc-to-html-multipage-example</module>
1819
<module>asciidoc-to-revealjs-example</module>

tests/pom.xml

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<maven.compiler.source>1.8</maven.compiler.source>
14-
<maven.compiler.target>1.8</maven.compiler.target>
1513
<junit.version>5.10.2</junit.version>
1614
<assertj.version>3.25.3</assertj.version>
1715
</properties>
@@ -65,5 +63,14 @@
6563
</plugin>
6664
</plugins>
6765
</pluginManagement>
66+
<plugins>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-compiler-plugin</artifactId>
70+
<configuration>
71+
<release>11</release>
72+
</configuration>
73+
</plugin>
74+
</plugins>
6875
</build>
6976
</project>

tests/src/test/java/org/asciidoctor/maven/examples/AsciidocMavenSiteTest.java tests/src/test/java/org/asciidoctor/maven/examples/AsciidocMavenSiteConverterTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

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

11-
@MavenTest(projectPath = "../asciidoc-maven-site-example", goal = "site:site")
12-
class AsciidocMavenSiteTest {
11+
@MavenTest(projectPath = "../asciidoc-maven-site-converter-example", goal = "site:site")
12+
class AsciidocMavenSiteConverterTest {
1313

1414
private MavenProject mavenProject;
1515

@@ -19,6 +19,7 @@ void shouldGenerateSitePages() {
1919
assertThat(index)
2020
.isNotEmpty()
2121
.content()
22+
.contains("<link rel=\"stylesheet\" href=\"./css/site.css\" />")
2223
.contains("<h1>AsciiDoc Maven Site Example</h1>")
2324
.contains("<li class=\"nav-header\">Asciidoctor Example</li>")
2425
.contains("<a href=\"hello.html\" title=\"Hello\"><span class=\"none\"></span>Hello</a>")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.asciidoctor.maven.examples;
2+
3+
import org.asciidoctor.maven.examples.tests.MavenProject;
4+
import org.asciidoctor.maven.examples.tests.MavenTest;
5+
import org.junit.jupiter.api.Test;
6+
7+
import java.io.File;
8+
9+
import static org.assertj.core.api.Assertions.assertThat;
10+
11+
@MavenTest(projectPath = "../asciidoc-maven-site-parser-example", goal = "site:site")
12+
class AsciidocMavenSiteParserTest {
13+
14+
private MavenProject mavenProject;
15+
16+
@Test
17+
void shouldGenerateSitePages() {
18+
File index = mavenProject.getTarget(sitePage("index.html"));
19+
assertThat(index)
20+
.isNotEmpty()
21+
.content()
22+
.contains("<h1>AsciiDoc Maven Site Example</h1>")
23+
.contains("<li class=\"nav-header\">Asciidoctor Example</li>")
24+
.contains("<a href=\"hello.html\" title=\"Hello\"><span class=\"none\"></span>Hello</a>")
25+
.contains("<a href=\"article.html\" title=\"Article\"><span class=\"none\"></span>Article</a>");
26+
27+
File hello = mavenProject.getTarget(sitePage("hello.html"));
28+
assertThat(hello)
29+
.isNotEmpty()
30+
.content()
31+
.contains("<h1>Hello, AsciiDoc!</h1>")
32+
.contains("<img src=\"images/tiger.png\" alt=\"Ghostscript Tiger\">")
33+
.contains("<h2><a name=\"Attributes\"></a>Attributes</h2>");
34+
35+
File article = mavenProject.getTarget(sitePage("article.html"));
36+
assertThat(article)
37+
.isNotEmpty()
38+
.content()
39+
.contains("<h1>AsciiDoc is Writing Zen</h1>")
40+
.contains("<h3><a name=\"Unordered_list\"></a>Unordered list</h3>")
41+
.contains("<h3><a name=\"Ordered_list\"></a>Ordered list</h3>")
42+
.contains("<h3><a name=\"Table\"></a>Table</h3>")
43+
.contains("<h3><a name=\"Code_blocks\"></a>Code blocks</h3>")
44+
.contains("<h2><a name=\"Attributes\"></a>Attributes</h2>");
45+
}
46+
47+
private String sitePage(String filename) {
48+
return "site/" + filename;
49+
}
50+
}

0 commit comments

Comments
 (0)