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