Skip to main content
summaryrefslogtreecommitdiffstats
blob: 125b4634095c5b5eafd551edd97236fe3c9a8483 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?xml version="1.0" encoding="UTF-8"?><!--
    Copyright (c) 2009 Tasktop Technologies and others.
    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v1.0
    which accompanies this distribution, and is available at
    http://www.eclipse.org/legal/epl-v10.html
   
    Contributors:
         Tasktop Technologies - initial API and implementation
 -->

<project name="org.eclipse.mylyn.help.ui" default="all">
    <description>
            Generate Eclipse help content for the Mylyn user guide
    </description>

	<property name="mylyn.help.doc.url.base" value="http://wiki.eclipse.org"/>
	<property name="mylyn.wiki.url.base" value="${mylyn.help.doc.url.base}/Mylyn"/>
	<property name="imageFolder" value="images"/>
	
	<path id="tasks.classpath" path="bin"/>
	<path id="wikitext.tasks.classpath">
		<pathelement location="../org.eclipse.mylyn.wikitext.core/@dot"/>
		<pathelement location="../org.eclipse.mylyn.wikitext.core/bin"/>
		<pathelement location="../org.eclipse.mylyn.wikitext.mediawiki.core/@dot"/>
		<pathelement location="../org.eclipse.mylyn.wikitext.mediawiki.core/bin"/>
	</path>
	
	<taskdef classpathref="tasks.classpath" resource="org/eclipse/mylyn/internal/help/ui/anttask/tasks.properties"/>
	<taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties"/>
	
	<target name="init">
		<mkdir dir="tmp"/>
	</target>
	
	<target name="clean" depends="init">
		<delete includeemptydirs="true" failonerror="false">
			<fileset dir="tmp"/>
		</delete>
	</target>

    <target name="all" depends="init" description="Generate Eclipse help content for the Mylyn user guide">
        <eclipse-wiki-to-help
        	help.doc.filenamenoextension="Mylyn Reference"
        	help.doc.url.base="${mylyn.help.doc.url.base}"
        	help.doc.url.html="${mylyn.help.doc.url.base}/Mylyn/User_Guide"
        	help.doc.url.xml="${mylyn.help.doc.url.base}/Special:Export/Mylyn/User_Guide"
        	help.imagefolder="${imageFolder}"
        	targetfolder="userguide"
        	wiki.url.base="${mylyn.help.doc.url.base}/Mylyn"/>
    </target>
	
	<macrodef name="eclipse-wiki-to-help">
		<attribute name="help.doc.url.base"/>
		<attribute name="wiki.url.base"/>
		<attribute name="help.doc.url.html"/>
		<attribute name="help.doc.url.xml"/>
		<attribute name="help.doc.filenameNoExtension"/>
		<attribute name="help.imageFolder"/>
		<attribute name="targetFolder"/>
		<sequential>
			<get dest="tmp/help.doc.xml" src="@{help.doc.url.xml}"/>
	    	<get dest="tmp/help.doc.html" src="@{help.doc.url.html}"/>
	    	
	    	<copy todir="tmp">
	    		<fileset dir="images"/>
	    	</copy>
	    	<mediawiki-fetch-images src="tmp/help.doc.html" dest="tmp" base="@{help.doc.url.base}"/>
	    	
	    	<xslt style="extract-markup.xsl" in="tmp/help.doc.xml" out="tmp/@{help.doc.filenameNoExtension}.mediawiki"/>
			<echo append="true" file="tmp/@{help.doc.filenameNoExtension}.mediawiki">

= Updating This Document =

This document is maintained in a collaborative wiki.  If you wish to update or modify this document please visit 
@{help.doc.url.html}
			</echo>
			
			<wikitext-to-eclipse-help markupLanguage="org.eclipse.mylyn.wikitext.mediawiki.core.MediaWikiLanguage" 
				multipleOutputFiles="true"
				navigationImages="true"
				helpPrefix="@{targetFolder}"
				internallinkpattern="@{wiki.url.base}/{0}"
				validate="true"
				failonvalidationerror="true"
				prependImagePrefix="${imageFolder}"
				formatoutput="true"
				defaultAbsoluteLinkTarget="mylyn_external">
				<fileset dir="tmp" includes="**/*.mediawiki"/>
				<stylesheet url="book.css"/>
			</wikitext-to-eclipse-help>
	    	
	    	<mkdir dir="@{targetFolder}/${imageFolder}"/>
			<copy todir="@{targetFolder}/${imageFolder}" overwrite="true">
				<fileset dir="tmp">
					<include name="*.gif"/>
					<include name="*.png"/>
				</fileset>
			</copy>
	    	<copy todir="@{targetFolder}" overwrite="true">
				<fileset dir="tmp">
					<include name="*.html"/>
					<include name="*toc.xml"/>
					<exclude name="help.doc.html"/>
				</fileset>
			</copy>
	    	<antcall target="test"/>
		</sequential>			
	</macrodef>
	

	<target name="test" depends="init" description="verify that all of the HTML files are well-formed XML">
		<echo level="info">
Validating help content XML and HTML files: The Eclipse help system expects well-formed XML
			
If validation fails it is because either:
			
* the userguide source code is poorly formed, or
* the WikiText MediaWiki parser has a bug
			
Problems with userguide source are usually caused by improper use of HTML markup in the MediaWiki source,
or inadvertently starting a line with a space character (in MediaWiki this starts a preformatted block)
		</echo>

		<!-- 
		Don't bother with DTD validation: we only care if the files are well-formed.
		We therefore provide an empty DTD 
		-->
		<echo file="tmp/__empty.dtd" message=""/>
		<xmlvalidate lenient="true">
			<fileset dir="userguide">
				<include name="**/*.xml"/>
			</fileset>
			<fileset dir="userguide">
				<include name="**/*.html"/>
			</fileset>
			<dtd publicid="-//W3C//DTD XHTML 1.0 Transitional//EN" location="${basedir}/tmp/__empty.dtd"/>
		</xmlvalidate>
	</target>
</project>

Back to the top