DocBook 是一个文档工具,Spring、Hibernate 等开源项目都是用它来编写、生成多格式文档的。这里主要介绍在 maven 环境中使用 maven-jdocbook-plugin 插件来使用 DocBook。
POM 中加入 jdocbook 插件:
<plugin> <groupId>org.jboss.maven.plugins</groupId> <artifactId>maven-jdocbook-plugin</artifactId> <version>2.3.8</version> <extensions>true</extensions> <configuration> <masterTranslation>zh-CN</masterTranslation> <formats> <format> <formatName>html</formatName> </format> </formats> </configuration>1<dependencies> 2 <dependency> 3 <groupId>org.jboss</groupId> 4 <artifactId>jbossorg-docbook-xslt</artifactId> 5 <version>1.1.1</version> 6 </dependency> 7 <dependency> 8 <groupId>org.jboss</groupId> 9 <artifactId>jbossorg-jdocbook-style</artifactId> 10 <version>1.1.1</version> 11 <type>jdocbook-style</type> 12 </dependency> 13</dependencies> 14 15<executions> 16 <execution> 17 <id>SDK_Manual_zh_CN</id> 18 <phase>package</phase> 19 <goals> 20 <goal>resources</goal> 21 <goal>generate</goal> 22 </goals> 23 24 <configuration> 25 <sourceDocumentName>index.xml</sourceDocumentName> 26 <sourceDirectory>${basedir}/src/main/docs</sourceDirectory> 27 <imageResource> 28 <directory>${basedir}/src/main/docs/images</directory> 29 </imageResource> 30 <cssResource> 31 <directory>${basedir}/src/main/docs/css</directory> 32 </cssResource> 33 34 <formats> 35 <format> 36 <formatName>html</formatName> 37 <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource> 38 <finalName>index.html</finalName> 39 </format> 40 <format> 41 <formatName>html_single</formatName> 42 <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource> 43 <finalName>index.html</finalName> 44 </format> 45 </formats> 46 47 <options> 48 <xincludeSupported>true</xincludeSupported> 49 </options> 50 </configuration> 51 </execution> 52</executions>
</plugin>
还需要加入 JBoos 的 mvn 库:
<repositories> <repository> <id>jboss-public-repository-group</id> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public/</url> </repository> </repositories>
目录结构:
本文主要是参考 用maven-jdocbook-plugin简单配置docbook5.0环境 所写,并修复了其中一些配置有误的地方。