1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """SCons targets for building the relax manuals."""
25
26
27 from glob import glob
28 from os import F_OK, access, chdir, getcwd, listdir, path, remove, rename, sep, system
29 from re import search
30 import sys
31
32
33 from status import Status; status = Status()
34 from version import version
35
36
38 """Builder action for removing the temporary manual files."""
39
40
41 print('')
42 print("##########################################")
43 print("# Cleaning up the temporary manual files #")
44 print("##########################################\n\n")
45
46
47 files = ["relax.bbl",
48 "relax.blg",
49 "relax.dvi",
50 "relax.idx",
51 "relax.ilg",
52 "relax.ind",
53 "relax.lof",
54 "relax.log",
55 "relax.lot",
56 "relax.out",
57 "relax.toc"]
58
59
60 for i in xrange(len(files)):
61 files[i] = path.join(env['LATEX_DIR'], files[i])
62
63
64 for file in glob(env['LATEX_DIR'] + '*.aux'):
65 files.append(file)
66
67
68 for file in files:
69 try:
70 remove(file)
71 except OSError, message:
72
73 if message.errno == 2:
74 pass
75
76
77 else:
78 raise
79 else:
80 print(("Removing the file " + repr(file) + "."))
81
82
83 print("\n\n\n")
84
85
87 """Builder action for compiling the API documentation manual (HTML version) using Epydoc."""
88
89
90 print('')
91 print("#####################################################")
92 print("# Compiling API documentation manual (HTML version) #")
93 print("#####################################################\n\n")
94
95
96
97
98
99
100
101 exclude = [
102 'extern',
103 'graphics',
104 'minfx.scipy_subset',
105 'multi.test_implementation',
106 'multi.test_implementation2',
107 'sample_scripts',
108 'scripts'
109 ]
110
111
112
113
114 output = 'html'
115
116
117
118 target = 'docs'+sep+'api'
119
120
121
122
123 docformat = 'epytext'
124
125
126
127
128 css = 'white'
129
130
131
132 name = 'relax'
133
134
135
136 url = 'http://www.nmr-relax.com'
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 frames = 1
158
159
160
161
162 private = 1
163
164
165
166 imports = 1
167
168
169
170
171
172 verbosity = 1
173
174
175
176 parse = 1
177
178
179
180 introspect = 1
181
182
183
184
185
186
187 graph = 'all'
188
189
190
191
192
193
194
195
196
197 sourcecode = 1
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215 epydoc_cmd = 'epydoc' + ' --' + output + ' -o ' + target + ' --docformat ' + docformat + ' --css ' + css + ' --name ' + name + ' --url ' + url
216
217
218 if frames:
219 epydoc_cmd = epydoc_cmd + ' --show-frames'
220 else:
221 epydoc_cmd = epydoc_cmd + ' --no-frames'
222
223
224 if private:
225 epydoc_cmd = epydoc_cmd + ' --show-private'
226 else:
227 epydoc_cmd = epydoc_cmd + ' --no-private'
228
229
230 if imports:
231 epydoc_cmd = epydoc_cmd + ' --show-imports'
232 else:
233 epydoc_cmd = epydoc_cmd + ' --no-imports'
234
235
236 if verbosity > 0:
237 for i in range(verbosity):
238 epydoc_cmd = epydoc_cmd + ' -v'
239 elif verbosity < 0:
240 for i in range(-verbosity):
241 epydoc_cmd = epydoc_cmd + ' -q'
242
243
244 if parse and not introspect:
245 epydoc_cmd = epydoc_cmd + ' --parse-only'
246 elif not parse and introspect:
247 epydoc_cmd = epydoc_cmd + ' --introspect-only'
248
249
250 epydoc_cmd = epydoc_cmd + ' --graph ' + graph
251
252
253 if sourcecode:
254 epydoc_cmd = epydoc_cmd + ' --show-sourcecode'
255 else:
256 epydoc_cmd = epydoc_cmd + ' --no-sourcecode'
257
258
259 for name in exclude:
260 epydoc_cmd = epydoc_cmd + ' --exclude=' + name
261
262
263 blacklist = ['README', 'relax.bat', 'relax_gui_mode.py']
264 files = listdir(getcwd())
265 for file in files:
266
267 if file in blacklist:
268 continue
269
270
271 epydoc_cmd = "%s %s" % (epydoc_cmd, file)
272
273
274
275
276
277
278 print(("Running the command:\n$ " + epydoc_cmd + "\n\n\n"))
279
280
281 system(epydoc_cmd)
282
283
284
285
286
287
288
289 css_file = open(target + sep+'epydoc.css', 'a')
290
291
292 css_file.write("\n\n\n\n/* Edward */\n\n")
293
294
295 css_file.write("a { text-decoration:none; color:#0017aa; font-weight:normal; }\n")
296 css_file.write("a:hover { color:#316fff; }\n")
297
298
299 css_file.close()
300
301
302
303
304
305
306 print("\n\nModifying the <head> tag of all HTML files.\n")
307
308
309 head_lines = []
310
311
312 file = open(status.install_path + sep + 'scripts' + sep + 'google_analytics.js')
313 for line in file.readlines():
314 head_lines.append(line)
315 file.close()
316
317
318 for file_name in listdir(status.install_path + sep + 'docs' + sep + 'api'):
319
320 full_path = status.install_path + sep + 'docs' + sep + 'api' + sep + file_name
321
322
323 if not search('.html$', full_path):
324 continue
325
326
327 file = open(full_path)
328 lines = file.readlines()
329 file.close()
330
331
332 file = open(full_path, 'w')
333
334
335 found = False
336 for i in range(len(lines)):
337
338 if not found and search('</head>', lines[i]):
339
340 for j in range(len(head_lines)):
341 file.write(head_lines[j])
342
343
344 found = True
345
346
347 file.write(lines[i])
348
349
350 file.close()
351
352
353 print("\n\n\n")
354
355
357 """Builder action for compiling the user manual (HTML version) from the LaTeX sources."""
358
359
360 compile_user_manual_pdf(target, source, env, convert=False)
361
362
363 print('')
364 print("############################################")
365 print("# Compiling the user manual (HTML version) #")
366 print("############################################\n\n")
367
368
369 base_dir = getcwd()
370 chdir(env['LATEX_DIR'])
371
372
373 dir = path.pardir + path.sep + "html"
374
375
376 cmd = "latex2html -dir %s relax.tex" % (dir)
377 print("Running the command:\n$ %s\n\n\n" % cmd)
378 system(cmd)
379
380
381 cmd = "cp -vp %s%srelax_user_manual.html %s%sindex.html" % (dir, path.sep, dir, path.sep)
382 print("Running the command:\n$ %s\n\n\n" % cmd)
383 system(cmd)
384
385
386 chdir(base_dir)
387
388
389 print("\n\n\n")
390
391
393 """Builder action for compiling the user manual (PDF version) from the LaTeX sources."""
394
395
396 print('')
397 print("###########################################")
398 print("# Compiling the user manual (PDF version) #")
399 print("###########################################\n\n")
400
401
402 base_dir = getcwd()
403 chdir(env['LATEX_DIR'])
404
405 print("\n\n\n <<< LaTeX (first round) >>>\n\n\n")
406 system('latex relax')
407
408 print("\n\n\n <<< Bibtex >>>\n\n\n")
409 system('bibtex relax')
410
411 print("\n\n\n <<< Makeindex >>>\n\n\n")
412 system('makeindex relax')
413
414 print("\n\n\n <<< LaTeX (second round) >>>\n\n\n")
415 system('latex relax')
416
417 print("\n\n\n <<< LaTeX (third round) >>>\n\n\n")
418 system('latex relax')
419
420 print("\n\n\n <<< LaTeX (fourth round) >>>\n\n\n")
421 system('latex relax')
422
423
424 if not convert:
425
426 chdir(base_dir)
427
428
429 return
430
431 print("\n\n\n <<< dvips >>>\n\n\n")
432 system('dvips -R0 -o relax.ps relax.dvi')
433
434 print("\n\n\n <<< ps2pdf >>>\n\n\n")
435 if env['SYSTEM'] == 'Windows':
436
437
438
439 assign = '#'
440 else:
441 assign = '='
442 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')
443
444 print("\n\n\n <<< Removing the PS file and shifting the PDF down a directory >>>\n\n\n")
445 if access('relax.ps', F_OK):
446 remove('relax.ps')
447 if access('relax.pdf', F_OK):
448 rename('relax.pdf', path.pardir+path.sep+'relax.pdf')
449
450
451 chdir(base_dir)
452
453
454 print("\n\n\n")
455
456
458 """Builder action for fetching the relax user function docstrings."""
459
460
461 print('')
462 print("###############################################")
463 print("# Fetching the relax user function docstrings #")
464 print("###############################################\n\n")
465
466
467 sys.path.append(getcwd())
468 from docs.latex.fetch_docstrings import Fetch_docstrings
469
470
471 Fetch_docstrings(env['LATEX_DIR'] + sep + 'docstring.tex')
472
473
474 del Fetch_docstrings
475
476
477 print("\n\n\n")
478
479
481 """Builder action for creating the LaTeX relax version file."""
482
483
484 print('')
485 print("################################################")
486 print("# Creating the LaTeX relax version number file #")
487 print("################################################")
488
489
490 file = open(env['LATEX_DIR'] + sep + 'relax_version.tex', 'w')
491 file.write("Version " + version + '\n')
492 file.close()
493
494
495 print("\n\n\n")
496