forked from tomfaulhaber/autodoc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
244 lines (212 loc) · 9.35 KB
/
build.xml
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<project name="autodoc" default="all">
<description>
Generate documentation for a project and post it to the github pages for that project.
(See the properties at the top of build.xml for info on how to customize it
for different projects.)
</description>
<!-- set force to true to build and checkin even if the source hasn't changed -->
<property name="force" value="false"/>
<!-- Properties that are (potentially) redefined for each project that we document -->
<property name="work-root-dir" value="../autodoc-work-area/clojure-contrib"/>
<property name="src-dir" value="${work-root-dir}/src/"/>
<property name="output-dir" value="${work-root-dir}/autodoc/"/>
<property name="extra-doc" value="${src-dir}/doc"/>
<property name="src-files" value="."/>
<property name="ext-dir" value="templates"/> <!-- just a dummy -->
<!-- These properties are special-cased when we're documenting clojure
contrib itself -->
<!-- <property name="clojure-contrib-jar" location="${src-dir}/clojure-contrib-slim.jar"/> -->
<property name="clojure-contrib-jar" location="../clojure-contrib/clojure-contrib.jar"/>
<property name="clojure-contrib-classes" location="${src-dir}/classes"/>
<!-- Properties that define where various resources are that we need -->
<property name="clojure-jar" location="../clojure/clojure.jar"/>
<property name="enlive-src" location="../enlive/src"/>
<property name="tagsoup-jar" location="../enlive/lib/tagsoup-1.2.jar"/>
<property name="clojure-json-jar" location="../clojure/clojure-json/clojure-json.jar"/>
<property name="ant-jar" location="/usr/share/ant/lib/ant.jar"/>
<property name="ant-launcher-jar" location="/usr/share/ant/lib/ant-launcher.jar"/>
<property name="ant-nodeps-jar" location="/usr/share/ant/lib/ant-nodeps.jar"/>
<property name="doc-tmp" value="/tmp/autodoc"/>
<!-- When building doc for clojure-core we override this in params.
Otherwise, leave it be -->
<property name="built-clojure-jar" location="${clojure-jar}"/>
<!-- Tasks for running git and deciding if we have to do work -->
<target name="pull-src"
description="do a git pull origin master of the project source">
<exec executable="git" dir="${src-dir}">
<arg value="pull"/>
<arg value="origin"/>
<arg value="master"/>
</exec>
</target>
<target name="set-is-uptodate" depends="set-base-is-uptodate"
description="Set the is-uptodate property">
<condition property="is-uptodate">
<equals arg1="${base-is-uptodate}" arg2="yes"/>
</condition>
<condition property="do-build">
<or>
<equals arg1="${base-is-uptodate}" arg2="no"/>
<equals arg1="${force}" arg2="true"/>
</or>
</condition>
<echo message="up-to-date?: ${base-is-uptodate}"/>
<echo message="force?: ${force}"/>
</target>
<target name="set-base-is-uptodate"
description="run the external program and get back a yes or no">
<exec executable="sh" outputproperty="base-is-uptodate">
<arg value="./is-uptodate.sh"/>
<arg value="${src-dir}"/>
</exec>
</target>
<target name="update-last-commit"
description="update the last version that we ran autodoc on">
<exec executable="sh">
<arg value="./update-last.sh"/>
<arg value="${src-dir}"/>
</exec>
</target>
<target name="set-commit-hash" description="Set the current commit hash!">
<exec executable="git" dir="${src-dir}" outputproperty="commit-hash">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
</target>
<target name="set-commit-comment" depends="set-commit-hash,set-is-uptodate"
description="Create an appropriate commit comment for the HTML page checkin">
<condition property="commit-comment"
value="Updated documentation for commit ${commit-hash}"
else="Manual (forced) documentation build for commit ${commit-hash}">
<equals arg1="${base-is-uptodate}" arg2="no"/>
</condition>
</target>
<target name="stage-new-api-files" description="Stage files for new namespaces">
<exec executable="git" dir="${output-dir}">
<arg value="add"/>
<arg value="*-api.html"/>
</exec>
</target>
<target name="stage-new-doc-files"
description="Stage new files added to the extra doc directory">
<exec executable="git" dir="${output-dir}">
<arg value="add"/>
<arg value="doc/*"/>
</exec>
</target>
<target name="commit-html" depends="set-commit-comment,stage-new-doc-files,stage-new-api-files"
description="Commit the rebuild HTML back to github">
<exec executable="git" dir="${output-dir}">
<arg value="commit"/>
<arg value="-a"/>
<arg value="-m${commit-comment}"/>
</exec>
<exec executable="git" dir="${output-dir}">
<arg value="push"/>
<arg value="origin"/>
<arg value="gh-pages"/>
</exec>
</target>
<target name="build-src"
description="Build the project src files, using the per-project build file">
<ant dir="${param-dir}" inheritAll="true"/>
</target>
<!-- Build the documentation stored in the extra doc directory -->
<target name="clean-doc"
description="Delete existing doc files">
<delete dir="${output-dir}/doc"/>
<delete dir="${doc-tmp}/doc"/>
</target>
<target name="set-has-doc" description="Set the has-doc variable if we have extra doc for this project">
<available property="has-doc" file="${extra-doc}"/>
</target>
<target name="make-doc-directories"
description="Make the output directories for doc files pulled from the source area"
if="has-doc">
<!-- first make the temporary directory tree -->
<apply executable="mkdir" verbose="true" force="true" addsourcefile="false"
dest="${doc-tmp}/doc">
<fileset dir="${extra-doc}"/>
<mapper type="regexp" from="(.*)/[^/]+" to="\1"/>
<arg value="-p"/>
<targetfile/>
</apply>
<!-- now make the eventual targets in the output area -->
<apply executable="mkdir" verbose="true" force="true" addsourcefile="false"
dest="${output-dir}/doc">
<fileset dir="${extra-doc}"/>
<mapper type="regexp" from="(.*)/[^/]+" to="\1"/>
<arg value="-p"/>
<targetfile/>
</apply>
</target>
<target name="build-markdown"
description="Convert additional markdown files to HTML in the dest directory."
if="has-doc">
<apply executable="markdown" verbose="true" force="true">
<fileset dir="${extra-doc}/" includes="**/*.markdown"/>
<redirector>
<outputmapper type="glob" from="*.markdown" to="${doc-tmp}/doc/*.html"/>
</redirector>
</apply>
</target>
<target name="build-extra-doc"
depends="set-has-doc,clean-doc,make-doc-directories,build-markdown"
description="Build the additional documentation that is in extra doc directories"/>
<!-- build the html documentation itself -->
<target name="clean-html-dir"
description="Delete old API files before creating new ones">
<delete>
<fileset dir="${output-dir}" includes="*-api.html"/>
</delete>
</target>
<target name="build-html" depends="set-commit-hash,clean-html-dir,build-extra-doc"
description="Build the HTML documentation and check it in">
<echo message="param-dir ${param-dir}"/>
<echo message="src-files ${src-files}"/>
<java classname="clojure.main"
fork="true" failonerror="true">
<classpath>
<pathelement location="${built-clojure-jar}"/>
<pathelement location="${clojure-contrib-jar}"/>
<pathelement location="${clojure-contrib-classes}"/>
<pathelement location="${enlive-src}"/>
<pathelement location="${tagsoup-jar}"/>
<pathelement location="${clojure-json-jar}"/>
<pathelement location="${src-files}"/>
<pathelement location="."/>
<fileset dir="${ext-dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<arg value="-e"/>
<arg value="(use 'com.infolace.gen-docs.gen-docs) (gen-docs "${param-dir}")"/>
</java>
</target>
<!-- roll-up targets -->
<target name="commit-result" depends="set-commit-comment,commit-html,update-last-commit"/>
<target name="do-build"
depends="build-src,build-html"
description="once everything is up-to-date, build the source, build the html, then commit the new documentation"/>
<target name="main-build" depends="pull-src, set-is-uptodate"
if="do-build"
description="Update the html on github based on the latest source, if appropriate">
<antcall target="do-build"/>
</target>
<target name="all">
<property name="build-target" value="main-build"/>
<antcall target="ant-wrapper"/>
</target>
<target name="ant-wrapper"
description="do a pass-through to clojure so that it can set various project-specific params">
<java classname="clojure.main"
classpath="${clojure-jar}:../clojure-contrib/clojure-contrib.jar:${clojure-contrib-classes}:${ant-jar}:${ant-launcher-jar}:/usr/lib/jvm/java-6-sun-1.6.0.07/lib/tools.jar:${ant-nodeps-jar}:."
fork="true" failonerror="true">
<arg value="-e"/>
<arg value="(use 'com.infolace.gen-docs.ant-wrapper) (ant-wrapper "${param-dir}" "${build-target}" ${force})"/>
</java>
</target>
<!--
Testing targets - should be deleted later
-->
</project>