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 from glob import glob
26 import platform
27 from os import F_OK, access, chdir, getcwd, path, remove, sep, system
28 from shutil import move
29 import sys
30
31 from version import version
32
33
34
36 """Builder action for removing the temporary manual files."""
37
38
39 print
40 print "##########################################"
41 print "# Cleaning up the temporary manual files #"
42 print "##########################################\n\n"
43
44
45 files = ["relax.bbl",
46 "relax.blg",
47 "relax.dvi",
48 "relax.idx",
49 "relax.ilg",
50 "relax.ind",
51 "relax.lof",
52 "relax.log",
53 "relax.lot",
54 "relax.out",
55 "relax.toc"]
56
57
58 for i in xrange(len(files)):
59 files[i] = path.join(env['LATEX_DIR'], files[i])
60
61
62 for file in glob(env['LATEX_DIR'] + '*.aux'):
63 files.append(file)
64
65
66 for file in files:
67 try:
68 remove(file)
69 except OSError, message:
70
71 if message.errno == 2:
72 pass
73
74
75 else:
76 raise
77 else:
78 print "Removing the file " + `file` + "."
79
80
81 print "\n\n\n"
82
83
85 """Builder action for compiling the API documentation manual (HTML version) using Epydoc."""
86
87
88 print
89 print "#####################################################"
90 print "# Compiling API documentation manual (HTML version) #"
91 print "#####################################################\n\n"
92
93
94
95
96
97
98
99 modules = ['relax',
100 '*.py',
101 'docs/*.py',
102 'docs/latex/*.py',
103 'dx/*.py',
104 'generic_fns/*.py',
105 'maths_fns/*.py',
106 'prompt/*.py',
107 'specific_fns/*.py',
108 'test_suite/*.py',
109 'sconstruct',
110 'scons/*.py']
111
112
113
114
115 output = 'html'
116
117
118
119 target = 'docs/api'
120
121
122
123
124 docformat = 'epytext'
125
126
127
128
129 css = 'white'
130
131
132
133 name = 'relax'
134
135
136
137 url = 'http://nmr-relax.com'
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 frames = 1
159
160
161
162
163 private = 1
164
165
166
167 imports = 1
168
169
170
171
172
173 verbosity = 1
174
175
176
177 parse = 1
178
179
180
181 introspect = 1
182
183
184
185
186
187
188 graph = 'all'
189
190
191
192
193
194
195
196
197
198 sourcecode = 1
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216 epydoc_cmd = 'epydoc' + ' --' + output + ' -o ' + target + ' --docformat ' + docformat + ' --css ' + css + ' --name ' + name + ' --url ' + url
217
218
219 if frames:
220 epydoc_cmd = epydoc_cmd + ' --show-frames'
221 else:
222 epydoc_cmd = epydoc_cmd + ' --no-frames'
223
224
225 if private:
226 epydoc_cmd = epydoc_cmd + ' --show-private'
227 else:
228 epydoc_cmd = epydoc_cmd + ' --no-private'
229
230
231 if imports:
232 epydoc_cmd = epydoc_cmd + ' --show-imports'
233 else:
234 epydoc_cmd = epydoc_cmd + ' --no-imports'
235
236
237 if verbosity > 0:
238 for i in range(verbosity):
239 epydoc_cmd = epydoc_cmd + ' -v'
240 elif verbosity < 0:
241 for i in range(-verbosity):
242 epydoc_cmd = epydoc_cmd + ' -q'
243
244
245 if parse and not introspect:
246 epydoc_cmd = epydoc_cmd + ' --parse-only'
247 elif not parse and introspect:
248 epydoc_cmd = epydoc_cmd + ' --introspect-only'
249
250
251 epydoc_cmd = epydoc_cmd + ' --graph ' + graph
252
253
254 if sourcecode:
255 epydoc_cmd = epydoc_cmd + ' --show-sourcecode'
256 else:
257 epydoc_cmd = epydoc_cmd + ' --no-sourcecode'
258
259
260 for module in modules:
261 epydoc_cmd = epydoc_cmd + ' ' + module
262
263
264
265
266
267
268 print "Running the command:\n$ " + epydoc_cmd + "\n\n\n"
269
270
271 system(epydoc_cmd)
272
273
274
275
276
277
278
279 css_file = open(target + '/epydoc.css', 'a')
280
281
282 css_file.write("\n\n\n\n/* Edward */\n\n")
283
284
285 css_file.write("a { text-decoration:none; color:#0017aa; font-weight:normal; }\n")
286 css_file.write("a:hover { color:#316fff; }\n")
287
288
289 css_file.close()
290
291
292 print "\n\n\n"
293
294
296 """Builder action for compiling the user manual (HTML version) from the LaTeX sources."""
297
298
299 print
300 print "############################################"
301 print "# Compiling the user manual (HTML version) #"
302 print "############################################\n\n"
303
304
305 base_dir = getcwd()
306 chdir(env['LATEX_DIR'])
307
308
309 print "Running the command:\n$ latex2html -split +3 -html_version 4.0 -dir " + path.pardir + path.sep + "html relax.tex\n\n\n"
310 system("latex2html -split +3 -html_version 4.0 -dir " + path.pardir + path.sep + "html relax.tex")
311
312
313 chdir(base_dir)
314
315
316 print "\n\n\n"
317
318
320 """Builder action for compiling the user manual (PDF version) from the LaTeX sources."""
321
322
323 print
324 print "###########################################"
325 print "# Compiling the user manual (PDF version) #"
326 print "###########################################\n\n"
327
328
329 base_dir = getcwd()
330 chdir(env['LATEX_DIR'])
331
332 print "\n\n\n <<< LaTeX (first round) >>>\n\n\n"
333 system('latex relax')
334
335 print "\n\n\n <<< Bibtex >>>\n\n\n"
336 system('bibtex relax')
337
338 print "\n\n\n <<< Makeindex >>>\n\n\n"
339 system('makeindex relax')
340
341 print "\n\n\n <<< LaTeX (second round) >>>\n\n\n"
342 system('latex relax')
343
344 print "\n\n\n <<< LaTeX (third round) >>>\n\n\n"
345 system('latex relax')
346
347 print "\n\n\n <<< LaTeX (fourth round) >>>\n\n\n"
348 system('latex relax')
349
350 print "\n\n\n <<< dvips >>>\n\n\n"
351 system('dvips -o relax.ps relax.dvi')
352
353 print "\n\n\n <<< ps2pdf >>>\n\n\n"
354 if env['SYSTEM'] == 'Windows':
355
356
357
358 assign = '#'
359 else:
360 assign = '='
361 system('ps2pdf -dAutoFilterColorImages' + assign + 'false -dAutoFilterGrayImages' + assign + 'false -dColorImageFilter' + assign + '/FlateEncode -dColorImageFilter' + assign + '/FlateEncode -dGrayImageFilter' + assign + '/FlateEncode -dMonoImageFilter' + assign + '/FlateEncode -dPDFSETTINGS' + assign + '/prepress relax.ps relax.pdf')
362
363 print "\n\n\n <<< Removing the PS file and shifting the PDF down a directory >>>\n\n\n"
364 if access('relax.ps', F_OK):
365 remove('relax.ps')
366 if access('relax.pdf', F_OK):
367 move('relax.pdf', path.pardir)
368
369
370 chdir(base_dir)
371
372
373 print "\n\n\n"
374
375
377 """Builder action for fetching the relax user function docstrings."""
378
379
380 print
381 print "###############################################"
382 print "# Fetching the relax user function docstrings #"
383 print "###############################################\n\n"
384
385
386 sys.path.append(getcwd())
387 from docs.latex.fetch_docstrings import Fetch_docstrings
388
389
390 Fetch_docstrings(env['LATEX_DIR'] + sep + 'docstring.tex')
391
392
393 del Fetch_docstrings
394
395
396 print "\n\n\n"
397
398
400 """Builder action for creating the LaTeX relax version file."""
401
402
403 print
404 print "################################################"
405 print "# Creating the LaTeX relax version number file #"
406 print "################################################"
407
408
409 file = open(env['LATEX_DIR'] + sep + 'relax_version.tex', 'w')
410 file.write("Version " + version + '\n')
411 file.close()
412
413
414 print "\n\n\n"
415