Advanced WikiText
In my recent posting, I showed you how to use Mylyn WikiText to easily create documentation for your project.
In this installment, we’re going to look at four things:
- How to create PDFs
- How to automate your publishing process
- How to split your documents to facilitate team work
- How to use DocBook as an intermediary format to add even more flexibility to your publishing process
Lots of stuff, so let’s get started!
How to create PDFs
The WikiText documentation states you can create DocBook, HTML and Eclipse Help from Wiki markup. So, how to create PDFs? Well, there are many ways to create PDFs. If you just want to create PDFs inside the IDE, you can download the Textile-J PDF add-on for WikiText. Textile-J is the predecessor of WikiText. The reason why the PDF output is not included in WikiText is that some of the required frameworks need to transform to PDF are not yet IP-approved (see bug 258349 for more information).
To install the Textile-J PDF add-on, proceed as follows:
- Make sure you have WikiText 1.1.0 or better installed
- Add the Textile-J update site to your Update Manager: https://textile-j.dev.java.net/builds/wikitext/site
- Refresh the Update Manager. You should now see Textile-J WikiText PDF in the list of available features.
- Select Textile-J WikiText PDF and click Install
- Restart Eclipse as requested
You can now right-click on any wiki file (*.textile, *.mediawiki, *.confluence, *.twiki, *.tracwiki and select Textile-J -> Generate PDF from the context menu.
How to automate the process
If you want to create PDFs outside the IDE (e.g. on your CI server using ANT), you need to create a build file:
<project name="how-to-use-wikitext" default="wikitext2pdf" basedir=".">
<property name="wikitext.standalone" value="lib"/><!-- path to wikitext standalone package -->
<path id="wikitext.classpath">
<fileset dir="${wikitext.standalone}">
<include name="org.eclipse.mylyn.wikitext.*core*.jar"/>
<include name="net.java.dev.textilej.wikitext.*core*.jar"/>
<include name="net.java.dev.textilej.wikitext.*lib*.jar"/>
</fileset>
</path>
<taskdef classpathref="wikitext.classpath"
resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties" />
<taskdef classpathref="wikitext.classpath"
resource="net/java/dev/textilej/wikitext/pdf/core/util/anttask/tasks.properties" />
<target name="wikitext2pdf" description="Generate PDF from textile">
<wikitext-to-pdf markupLanguage="Textile">
<fileset dir="${basedir}">
<include name="documentation.textile"/>
</fileset>
</wikitext-to-pdf>
</target>
</project>
By the way, there are ANT tasks for all other output formats as well, so you can automate the creation of Eclipse Help, HTML and DocBook, too:
<wikitext-to-docbook markupLanguage="Textile">
<fileset dir="${basedir}">
<include name="documentation.textile"/>
</fileset>
</wikitext-to-docbook>
How to split your documents to facilitate team work
Now that you know how to transform Wiki markup to various output formats, you might wonder how to split your Wiki files into smaller chunks so the members of your team can work on them separately. This is something which is very easy with, say, LaTeX or DocBook because they both have the concept of importing other documents. In Wikis, there usually is no such thing as importing another Wiki page – you rather link to that other page. If you’re writing a documentation, this isn’t sufficient, however. You really need to be able to import document fragments.
Instead of adding the notion of imports to WikiText, I decided to control the assembling of the master document by using a little bit of ANT wizardry and a text file.
The text file (named index.txt controls the order in which the document fragments ned to be glued together:
introduction.textile grammar_language.textile newnoteworthy.textile
The build.xml now needs to be enhanced so that it reads the control file and use this information to assemble the Wiki files in the order requested:
<target name="assemble">
<loadfile srcfile="doc/index.txt" property="inputfiles">
<filterchain>
<tokenfilter>
<replacestring from="\n" to=","/>
</tokenfilter>
</filterchain>
</loadfile>
<concat destfile="documentation.textile" append="false" fixlastline="yes">
<filelist dir="doc" files="${inputfiles}"/>
</concat>
</target>
So what happens here is that we read in the contents of the index.txt file, concatenate all file names, separated with a comma to one large line and feed that large line into the concatenate task that will then concatenate the contents of all those files in the given order so we get one big file.
After that, the big file can now be processed as usual:
<target name="generate-pdf" depends="assemble" description="Generate PDF from textile">
<wikitext-to-pdf markupLanguage="Textile">
<fileset dir="${basedir}">
<include name="documentation.textile"/>
</fileset>
</wikitext-to-pdf>
</target>
How to use DocBook to gain more flexibility
DocBook has been around for quite some years now and together with LaTeX still will give you the most flexibility when it comes to documentation engineering. I have been using both LaTeX and DocBook to write all sorts of documentation, ranging from my diploma thesis to open source project documentation and have found both the be versatile and reliable, but also quite verbose. Regarding flexibility, both give you the possibility to choose a document template / style of your liking. If none of the existing document styles match your needs, you can more or less easily create you own.
As WikiText supports creating DocBook from your Wiki files, we’ll have a look at how to use this DocBook output to further process it. Here is what we need to do:
- Enhance our build script so it downloads the relevant DocBook files (libraries, basic styles and XSL transformations)
- Add targets to our build script that allow you to choose the output to be created: PDF, HTML or Eclipse Help
The whole process will look like this:

Let’s have a look at some crucial parts of the script.
We already saw how to assemble multiple Wiki files into one big Wiki file. The next step is to convert this file to DocBook:
<target name="wikitext2docbook" depends="assemble" description="Generate DocBook from textile">
<wikitext-to-docbook markupLanguage="Textile">
<fileset dir="${basedir}">
<include name="documentation.textile"/>
</fileset>
</wikitext-to-docbook>
</target>
After that, we need to convert the DocBook file to PDF:
<target name="docbook2pdf">
<echo>Converting article to PDF...</echo>
<delete file="${dest.dir}${file.separator}${documenat.name}.pdf"/>
<delete file="${dest.dir}${file.separator}${documenat.name}.fo"/>
<xslt in="${documenat.name}.xml"
extension="xml"
out="${dest.dir}${file.separator}${documenat.name}.fo"
style="${document.stylesheet}">
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
</factory>
<xmlcatalog>
<entity
publicId="docbook.xsl"
location="${docbook.dir}${file.separator}fo${file.separator}docbook.xsl"/>
</xmlcatalog>
<param name="generate.toc" expression="book toc" />
<param name="show.comments" expression="0" />
<param name="header.rule" expression="1" />
<param name="admon.graphics.extension" expression=".gif"/>
<param name="admon.textlabel" expression="0"/>
<param name="admon.graphics" expression="1"/>
</xslt>
<docbook2pdf
source="${dest.dir}${file.separator}${documenat.name}.fo"
target="${dest.dir}${file.separator}${documenat.name}.pdf"/>
<delete file="${dest.dir}${file.separator}${documenat.name}.fo" />
</target>
You can now control the output by supplying different stylesheets. DocBook XSLT comes with a variety of stylesheets for articles, books and online help systems. You can now easily create printed documentation AND online help from one source. DocBook XSLT supports EclipseHelp, JavaHelp, HTMLHelp (the Windows Help System) and even man pages!
So, next time you need to write documentation for a project you’re working on, don’t let it get you down. Instead, set up a trusty WikiText / DocBook toolchain and write down that documentation in Wiki markup in no time!
The whole build script and the sample document are available for download for free. If you need help setting up a tool chain or want to book me for consulting, drop me a line (peter dot friese at itemis dot com).
Many thanks to David Green and Steffen Pingel of WikiText and Mylyn who tirelessly fixed bugs I found, applied patches and created EA builds!
Thanks for reading this post. Follow me on twitter here to be notified about updates and other posts I write. Or, subscribe to my RSS feed here. If you want to get in touch with me, use the contact form.






You forgot one other very important tool to add in their. The XSL Tools eclipse plugins, for editing, testing, debuggin, and customizing your DocBook Stylesheets. XSL Tools will be available with Galileo and WTP 3.1.
@David: good you mention it! Feel free to provide any pointers on how to integrate XSL Tools in the tool chain I describe.
peter,
thx for great work. I’ll try it next weeks, sound good.
every solution I tried before doesn’t satisfy me,
but using WikiText in the context you described seems to be a good way
ekke
Some links:
http://wiki.eclipse.org/Authoring_Eclipse_Help_Using_DocBook
In addition, using the Customization option mentioned in the DocBook XSL: The Complete Guide, http://www.sagehill.net/docbookxsl/index.html, one can use XSL Tools to:
* Create the Customization Layer.
* Launch XSL transformations using the Eclipse Debug/Launch configurations.
* Content Assistance and Navigation through editor.
* XInclude ANT Task supoort.
* Debug XSL Transformations using Xalan and XSLT 1.0.
Basically create a customization stylesheet, and then replace the docbook.xsl with your customized version that overrides the templates as needed.
The ant tasks seem to work fine (prints BUILD SUCCESSFUL) but I dont see any HTML file under the project direcotry…
I am not a ANT guy…i use Maven…so excuse my ignorance
@pangea: try to refresh your workspace (press F5), this should do the trick.
Hi,
I can’t download the zip-file?
When I try to manually recreate your example, I get a “taskdef class org.eclipse.mylyn.wikitext.pdf.core.util.anttask.MarkupToPdfTask cannot be found” error.
I would love some help since the ability to generate PDFs is really a necessity, if I am going to introduce wikitext on my current project.
Anders, the ZIP file works fine for me (I just downloaded it, unzipped it and sucessfully ran the build file). Please retry downloading it. If this still fails, ping me at peter d o t friese a t itemis d o t d e and we can try to figure out where the problem is.
Hi again,
I managed to download the zip-file. It must have been some sort of temporary server malfunction.
Anyway, when I unpack and run ant, I get an error:
C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext>ant
Buildfile: build.xml
init:
check-docbook:
get-docbook-xsl:
check-fop:
get-fop:
build-doc:
[echo] Building Output…
assemble:
wikitext2docbook:
docbook2html:
[echo] Converting article to HTML…
[xslt] Processing C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext\documentation.xml to C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext\documentation.html
[xslt] Loading stylesheet C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext\styles\article.xsl
[xslt] Failed to process C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext\documentation.xml
BUILD FAILED
C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext\build.xml:106: The following error occurred while executing this line:
C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext\build.xml:136: java.lang.ClassNotFoundException: org.apache.xalan.processor.TransformerFactoryImpl
Total time: 0 seconds
C:\TEMP\FirefoxDownloads\wikitext_blogpost\how-to-use-wikitext>
Look’s really great. Trying to reproduce but …
Neither https://textile-j.dev.java.net/builds/wikitext/index.html nor the zip file are accessible since 2 days. Can you check this?
Hi There
Thanks for a very helpful set of posts. One thing is eluding me though. Have not tried turning into pdf, but simply using ant to create html, I found that the ant task just put the resulting html set of files in the same directory as the source files. I am using
and everything goes into basedir/src
Very confusing as soon as there is a few pages. I just could not find any attribute or configuration that would tell wikitext-to-html task to store resulting files into a separate target directory. Do such attribute exists ?
Thanks
Hi
Moving into pdf generation, I have found that these plugins have now moved into Mylyn, and can be installed from the update site at https://textile-j.dev.java.net/builds/wikitext/site
However, the path are a bit different. path should be defined as
However, the taskdef is not correct anymore, with the following message:
taskdef class org.eclipse.mylyn.wikitext.pdf.core.util.anttask.MarkupToPdfTask
cannot be found
Can you please update ? I could not find any reference to this online
Thanks
ok, this appears to install version 1.0.0 of the plugin, which seems to have a small gltich whereby the path to MarkupToPdfTask is not correct. I have found traces of commits of a fix, applied to version 1.0.1, but the update site does not seem to have that version yet. Been unable to fix. Thanks for updating the plugin if possible
Rgds
Peter,
I’ve been trying for a couple of days now to get the PDF target to treat my images nicely. I’m using the (barely modified) xtext target. I’ve played around with every imaginable scaling setting for doxbook xsl. With scalefit it looks terrible because everything gets expanded to the same size, and without it the images are all way too large for the document. I guess the issue is that docbook can’t find the graphics.extension. And (I think) got the xalan and xerces graphics extensions installed. (I wasn’t able to get the Saxon version working) but apparantly docbook doesn’t even report when it can’t find the extensions so I don’t know if I have that.
Anyway, I’m wondering if you’ve run into the same issue and if you’ve been able to resolve it what the magic formula is.
cheers,
Miles
Just a note that I got the scaling to work right by doing an additional XSL transform. I’ll try to blog about it in the not to distant future.
Hi,
Informative article. I think we are kind of going in a similar way. My question is, we have a lot of stuff in xml already (very similar to Docbook) is there a way to get this into wikitext/textile? Once there, i can see how we could generate pdf.
Any help is greatly appreciated!
Thanks,
Russ
Hi
I was trying to build the documentation, and I also downloaded your zip file; however, both with your project and mine, I always get this error:
BUILD FAILED
how-to-use-wikitext/build.xml:49: java.lang.NoClassDefFoundError: org/apache/fop/apps/FopFactory
Hi – make sure you’ve got the right version of FOP installed. I assume I’ve been using FOP 0.20.5
Hi Peter,
It seems that Textile-J update site is no more available (https://textile-j.dev.java.net/builds/wikitext/site) . Do you know if this project is still maintained and update site available or move to another place ?
Regards,
Jerome