Skip to content

Commit

Permalink
#7: Project created for generating PDF from Wiki-Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed Aug 28, 2014
1 parent 661bbe1 commit 634e716
Show file tree
Hide file tree
Showing 25 changed files with 3,248 additions and 0 deletions.
127 changes: 127 additions & 0 deletions cobigen-documentation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?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.oasp.java</groupId>
<artifactId>documentation</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>Documentation generation for CobiGen</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<asciidoc.source>${basedir}/../../tools-cobigen.wiki/</asciidoc.source>
<asciidoc.target>${basedir}/target/asciidoc/</asciidoc.target>
<external.images>${basedir}/target/images/</external.images>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>pre-process-asciidoc</id>
<phase>generate-sources</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
<ant antfile="${basedir}/src/main/ant/build.xml"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<!--<backend>pdf</backend>-->
<backend>docbook5</backend>
<sourceDirectory>${asciidoc.target}</sourceDirectory>
<sourceDocumentName>CobiGen.asciidoc</sourceDocumentName>
<doctype>book</doctype>
<imagesDir>./</imagesDir>
<attributes>
<docinfo>true</docinfo>
</attributes>
</configuration>
<executions>
<execution>
<id>generate-docbook</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.agilejava.docbkx</groupId>
<artifactId>docbkx-maven-plugin</artifactId>
<version>2.0.15</version>
<configuration>
<sourceDirectory>${basedir}/target/generated-docs</sourceDirectory>
<includes>CobiGen.xml</includes>
<xincludeSupported>true</xincludeSupported>
<chunkedOutput>false</chunkedOutput>
<foCustomization>${basedir}/src/main/docbook/xsl/pdf.xsl</foCustomization>
<useExtensions>1</useExtensions>
<highlightSource>1</highlightSource>
<highlightXslthlConfig>${basedir}/src/main/docbook/xsl/xslthl-config.xml</highlightXslthlConfig>
<targetDirectory>${basedir}/target/generated-docs/</targetDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.xslthl</groupId>
<artifactId>xslthl</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xml</artifactId>
<version>5.0-all</version>
<classifier>resources</classifier>
<type>zip</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<executions>
<execution>
<id>pdf</id>
<goals>
<goal>generate-pdf</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
44 changes: 44 additions & 0 deletions cobigen-documentation/src/main/ant/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project name="pre-process-asciidoc" default="main" basedir=".">
<description>Pre-process asciidocs to make inter wiki link references work in single page document.</description>

<target name="main">
<foreach target="pre-process-asciidoc" param="asciidoc-file" inheritall="true">
<path>
<fileset dir="${asciidoc.source}" casesensitive="yes">
<include name="**/*.asciidoc"/>
</fileset>
</path>
</foreach>
<copy todir="${basedir}/target/generated-docs/">
<path>
<fileset dir="${asciidoc.source}">
<exclude name="**/*.asciidoc"/>
</fileset>
</path>
</copy>
</target>
<target name="pre-process-asciidoc">
<basename property="filename" file="${asciidoc-file}" suffix=".asciidoc"/>
<echo message="${asciidoc-file}"/>
<copy file="${asciidoc-file}" todir="${asciidoc.target}">
<filterchain>
<tokenfilter>
<linetokenizer/>
<replaceregex pattern="\[\[" replace="[[${filename}_" flags="g"/>
<replaceregex pattern="^(==+) (.*)" replace="[[${filename}_\2]]${line.separator}\1 \2" flags="g"/>
<replaceregex pattern="^(=) (.*)" replace="[[${filename}]]${line.separator}\1 \2" flags="g"/>
<replaceregex pattern="xref:(\w*)" replace="xref:${filename}_\1" flags="g"/>
<replaceregex pattern="link:([^#:]*)\[" replace="xref:\1[" flags="g"/>
<replaceregex pattern="link:([^#:]*)#(\w*)" replace="xref:\1_\2" flags="g"/>
<scriptfilter language="javascript">
var text = self.getToken();
if (text.startsWith('[[')) {
var index = text.indexOf(']]');
self.setToken(text.substring(0, index).toLowerCase().replace(' ','-') + text.substring(index));
}
</scriptfilter>
</tokenfilter>
</filterchain>
</copy>
</target>
</project>
3 changes: 3 additions & 0 deletions cobigen-documentation/src/main/docbook/xsl/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The file in this folder have been copied from spring-boot
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-docs/src/main/docbook
Thanks to the original authors!
46 changes: 46 additions & 0 deletions cobigen-documentation/src/main/docbook/xsl/common.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslthl="http://xslthl.sf.net"
exclude-result-prefixes="xslthl"
version='1.0'>

<!-- Extensions -->
<xsl:param name="use.extensions">1</xsl:param>
<xsl:param name="tablecolumns.extension">0</xsl:param>
<xsl:param name="callout.extensions">1</xsl:param>

<!-- Graphics -->
<xsl:param name="admon.graphics" select="1"/>
<xsl:param name="admon.graphics.path">images/</xsl:param>
<xsl:param name="admon.graphics.extension">.png</xsl:param>

<!-- Table of Contents -->
<xsl:param name="generate.toc">book toc,title</xsl:param>
<xsl:param name="toc.section.depth">5</xsl:param>
<!--<xsl:param name="section.autolabel">1</xsl:param>-->
<xsl:param name="insert.olink.pdf.frag">0</xsl:param>

<!-- Hide revhistory -->
<xsl:template match="revhistory" mode="titlepage.mode"/>

</xsl:stylesheet>
Loading

0 comments on commit 634e716

Please sign in to comment.