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 print(full_path)
328
329
330 file = open(full_path)
331 lines = file.readlines()
332 file.close()
333
334
335 file = open(full_path, 'w')
336
337
338 found = False
339 for i in range(len(lines)):
340
341 if not found and search('</head>', lines[i]):
342
343 for j in range(len(head_lines)):
344 file.write(head_lines[j])
345
346
347 found = True
348
349
350 file.write(lines[i])
351
352
353 file.close()
354
355
356 print("\n\n\n")
357
358
360 """Builder action for compiling the user manual (HTML version) from the LaTeX sources."""
361
362
363 compile_user_manual_pdf(target, source, env, convert=False)
364
365
366 print('')
367 print("############################################")
368 print("# Compiling the user manual (HTML version) #")
369 print("############################################\n\n")
370
371
372 base_dir = getcwd()
373 chdir(env['LATEX_DIR'])
374
375
376 dir = path.pardir + path.sep + "html"
377
378
379 cmd = "latex2html -dir %s relax.tex" % (dir)
380 print("Running the command:\n$ %s\n\n\n" % cmd)
381 system(cmd)
382
383
384 cmd = "cp -vp %s%srelax_user_manual.html %s%s index.html" % (dir, path.sep, dir, path.sep)
385 print("Running the command:\n$ %s\n\n\n" % cmd)
386 system(cmd)
387
388
389 chdir(base_dir)
390
391
392 print("\n\n\n")
393
394
396 """Builder action for compiling the user manual (PDF version) from the LaTeX sources."""
397
398
399 print('')
400 print("###########################################")
401 print("# Compiling the user manual (PDF version) #")
402 print("###########################################\n\n")
403
404
405 base_dir = getcwd()
406 chdir(env['LATEX_DIR'])
407
408 print("\n\n\n <<< LaTeX (first round) >>>\n\n\n")
409 system('latex relax')
410
411 print("\n\n\n <<< Bibtex >>>\n\n\n")
412 system('bibtex relax')
413
414 print("\n\n\n <<< Makeindex >>>\n\n\n")
415 system('makeindex relax')
416
417 print("\n\n\n <<< LaTeX (second round) >>>\n\n\n")
418 system('latex relax')
419
420 print("\n\n\n <<< LaTeX (third round) >>>\n\n\n")
421 system('latex relax')
422
423 print("\n\n\n <<< LaTeX (fourth round) >>>\n\n\n")
424 system('latex relax')
425
426
427 if not convert:
428
429 chdir(base_dir)
430
431
432 return
433
434 print("\n\n\n <<< dvips >>>\n\n\n")
435 system('dvips -R0 -o relax.ps relax.dvi')
436
437 print("\n\n\n <<< ps2pdf >>>\n\n\n")
438 if env['SYSTEM'] == 'Windows':
439
440
441
442 assign = '#'
443 else:
444 assign = '='
445 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')
446
447 print("\n\n\n <<< Removing the PS file and shifting the PDF down a directory >>>\n\n\n")
448 if access('relax.ps', F_OK):
449 remove('relax.ps')
450 if access('relax.pdf', F_OK):
451 rename('relax.pdf', path.pardir+path.sep+'relax.pdf')
452
453
454 chdir(base_dir)
455
456
457 print("\n\n\n")
458
459
461 """Builder action for fetching the relax user function docstrings."""
462
463
464 print('')
465 print("###############################################")
466 print("# Fetching the relax user function docstrings #")
467 print("###############################################\n\n")
468
469
470 sys.path.append(getcwd())
471 from docs.latex.fetch_docstrings import Fetch_docstrings
472
473
474 Fetch_docstrings(env['LATEX_DIR'] + sep + 'docstring.tex')
475
476
477 del Fetch_docstrings
478
479
480 print("\n\n\n")
481
482
484 """Builder action for creating the LaTeX relax version file."""
485
486
487 print('')
488 print("################################################")
489 print("# Creating the LaTeX relax version number file #")
490 print("################################################")
491
492
493 file = open(env['LATEX_DIR'] + sep + 'relax_version.tex', 'w')
494 file.write("Version " + version + '\n')
495 file.close()
496
497
498 print("\n\n\n")
499