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 asciidoctor parser doxia module example #254

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
7 changes: 5 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ Demonstrates how to convert AsciiDoc to PDF using Asciidoctor PDF with the Ascii
link:asciidoctor-epub-example/README.adoc[asciidoctor-epub-example]::
Demonstrates how to convert AsciiDoc to epub using Asciidoctor EPUB with the Asciidoctor Maven plugin. (contains also an example for .mobi (Kindle) output)

link:asciidoc-maven-site-example/README.adoc[asciidoc-maven-site-example]::
Demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.
link:asciidoc-maven-site-converter-example/README.adoc[asciidoc-maven-site-converter-example]::
Demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Converter Doxia Module.

link:asciidoc-maven-site-parser-example/README.adoc[asciidoc-maven-site-parser-example]::
Demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Parser Doxia Module.

link:asciidoc-multiple-inputs-example/README.adoc[asciidoc-multiple-inputs-example]::
An example project that demonstrates how to convert multiple input AsciiDoc documents to HTML5 and PDF using the
Expand Down
14 changes: 14 additions & 0 deletions asciidoc-maven-site-converter-example/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= Asciidoctor Maven Plugin (Converter Module): AsciiDoc Site Example

An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Converter Doxia Module.

== Usage

Build the site by invoking the `site:site` goal:

$ mvn site:site

Open the file _target/site/hello.html_ to see the output generated from the AsciiDoc source _src/site/asciidoc/hello.adoc_.

Open the file _target/site/index.html_ to see the output generated for the entire site including the link to the `hello` document.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.asciidoctor.maven</groupId>
<artifactId>asciidoc-maven-site-example</artifactId>
<artifactId>asciidoc-maven-site-converter-example</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>AsciiDoc Maven Site Example</name>
<description>An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.11.0</version>
<version>1.12.0</version>
</skin>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Asciidoctor Maven Plugin: AsciiDoc Site Example
= Asciidoctor Maven Plugin (Parser Module): AsciiDoc Site Example

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

== Usage

Expand Down
77 changes: 77 additions & 0 deletions asciidoc-maven-site-parser-example/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.asciidoctor.maven</groupId>
<artifactId>asciidoc-maven-site-parser-example</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>AsciiDoc Maven Site Example</name>
<description>An example project that demonstrates how to process AsciiDoc in a Maven site using the Asciidoctor Maven plugin.</description>

<!-- All Maven properties are injected as Asciidoctor attributes.
Reference them with the same name replacing dots by dashes (e.g. {jruby-version}). -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<asciidoctor.maven.plugin.version>3.0.0</asciidoctor.maven.plugin.version>
<asciidoctorj.version>2.5.11</asciidoctorj.version>
<jruby.version>9.4.5.0</jruby.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<!-- Disable generateReports if you don't want to include the built-in reports -->
<generateReports>true</generateReports>
<generateSitemap>true</generateSitemap>
<relativizeDecorationLinks>false</relativizeDecorationLinks>
<locales>en</locales>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<asciidoc>
<!-- Optional site-wide AsciiDoc attributes -->
<attributes>
<icons>font</icons>
<!-- Add required rouge styles in '/css/site.css' -->
<source-highlighter>rouge</source-highlighter>
<toclevels>2</toclevels>
</attributes>
</asciidoc>
</configuration>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-parser-doxia-module</artifactId>
<version>${asciidoctor.maven.plugin.version}</version>
</dependency>
<!-- Comment this section to use the default jruby artifact provided by the plugin -->
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
<version>${jruby.version}</version>
</dependency>
<!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin -->
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>${asciidoctorj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</reporting>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
== Attributes

.Built-in
asciidoctor-version:: {asciidoctor-version}
safe-mode-name:: {safe-mode-name}
docdir:: {docdir}

.Maven properties
asciidoctor.maven.plugin.version:: {asciidoctor-maven-plugin-version}
asciidoctorj.version:: {asciidoctorj-version}
jruby.version:: {jruby-version}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
included content
60 changes: 60 additions & 0 deletions asciidoc-maven-site-parser-example/src/site/asciidoc/article.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
= AsciiDoc is Writing Zen
Doc Writer <[email protected]>
//Junior Writer <[email protected]>
v1.0, 2014-08-08
//:toc:
:icons: font
:source-highlighter: rouge
:sectanchors:
//:compat-mode:

_Zen_ in the *art* of writing `plain text` with https://asciidoc.org[AsciiDoc].

[TIP]
Use https://asciidoctor.org[Asciidoctor] for the best AsciiDoc experience.footnote:[Not to mention the best looking output!]
Then icon:twitter[role=aqua] about it!

toc::[]

== Sample Section

=== Unordered list

* item 1
* item 2

=== Ordered list

. item 1
. item 2

=== Table

[caption=]
.Ruby platforms
|===
|Name |Language

|MRI |C
|JRuby |Java
|Opal |JavaScript
|Rubinius |Ruby
|===

=== Code blocks

[source,ruby]
----
puts "Hello, World!"
----

[source,java]
----
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
----

include::_attributes.adoc[]
16 changes: 16 additions & 0 deletions asciidoc-maven-site-parser-example/src/site/asciidoc/hello.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
= Hello, AsciiDoc!
//:icons: font

This file was converted from AsciiDoc to HTML by the Maven Site module of the Asciidoctor Maven Plugin.

image::images/tiger.png[Ghostscript Tiger]
_By Ghostscript authors (GPL Ghostscript SVN: tiger.eps) [GPL (https://www.gnu.org/licenses/gpl.html)], via Wikimedia Commons_

[TIP]
====
Use the include directive to keep your content DRY!

include::_include.adoc[]
====

include::_attributes.adoc[]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions asciidoc-maven-site-parser-example/src/site/site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<project>
<body>
<menu ref="reports" inherit="top"/>
<menu ref="modules"/>
<menu name="Asciidoctor Example">
<item href="hello.html" name="Hello"/>
<item href="article.html" name="Article"/>
</menu>
</body>
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.12.0</version>
</skin>
</project>
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<description>Collection of sample projects that demonstrate numerous ways to use the Asciidoctor Maven plugin in a Maven project.</description>

<modules>
<module>asciidoc-maven-site-example</module>
<module>asciidoc-maven-site-converter-example</module>
<module>asciidoc-maven-site-parser-example</module>
<module>asciidoc-to-html-example</module>
<module>asciidoc-to-html-multipage-example</module>
<module>asciidoc-to-revealjs-example</module>
Expand Down
11 changes: 9 additions & 2 deletions tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>5.10.2</junit.version>
<assertj.version>3.25.3</assertj.version>
</properties>
Expand Down Expand Up @@ -65,5 +63,14 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

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

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

private MavenProject mavenProject;

Expand All @@ -19,6 +19,7 @@ void shouldGenerateSitePages() {
assertThat(index)
.isNotEmpty()
.content()
.contains("<link rel=\"stylesheet\" href=\"./css/site.css\" />")
.contains("<h1>AsciiDoc Maven Site Example</h1>")
.contains("<li class=\"nav-header\">Asciidoctor Example</li>")
.contains("<a href=\"hello.html\" title=\"Hello\"><span class=\"none\"></span>Hello</a>")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.asciidoctor.maven.examples;

import org.asciidoctor.maven.examples.tests.MavenProject;
import org.asciidoctor.maven.examples.tests.MavenTest;
import org.junit.jupiter.api.Test;

import java.io.File;

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

@MavenTest(projectPath = "../asciidoc-maven-site-parser-example", goal = "site:site")
class AsciidocMavenSiteParserTest {

private MavenProject mavenProject;

@Test
void shouldGenerateSitePages() {
File index = mavenProject.getTarget(sitePage("index.html"));
assertThat(index)
.isNotEmpty()
.content()
.contains("<h1>AsciiDoc Maven Site Example</h1>")
.contains("<li class=\"nav-header\">Asciidoctor Example</li>")
.contains("<a href=\"hello.html\" title=\"Hello\"><span class=\"none\"></span>Hello</a>")
.contains("<a href=\"article.html\" title=\"Article\"><span class=\"none\"></span>Article</a>");

File hello = mavenProject.getTarget(sitePage("hello.html"));
assertThat(hello)
.isNotEmpty()
.content()
.contains("<h1>Hello, AsciiDoc!</h1>")
.contains("<img src=\"images/tiger.png\" alt=\"Ghostscript Tiger\">")
.contains("<h2><a name=\"Attributes\"></a>Attributes</h2>");

File article = mavenProject.getTarget(sitePage("article.html"));
assertThat(article)
.isNotEmpty()
.content()
.contains("<h1>AsciiDoc is Writing Zen</h1>")
.contains("<h3><a name=\"Unordered_list\"></a>Unordered list</h3>")
.contains("<h3><a name=\"Ordered_list\"></a>Ordered list</h3>")
.contains("<h3><a name=\"Table\"></a>Table</h3>")
.contains("<h3><a name=\"Code_blocks\"></a>Code blocks</h3>")
.contains("<h2><a name=\"Attributes\"></a>Attributes</h2>");
}

private String sitePage(String filename) {
return "site/" + filename;
}
}