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 ]
112
113
114
115
116 output = 'html'
117
118
119
120 target = 'docs'+sep+'api'
121
122
123
124
125 docformat = 'epytext'
126
127
128
129
130 css = 'white'
131
132
133
134 name = 'relax'
135
136
137
138 url = 'http://www.nmr-relax.com'
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 frames = 1
160
161
162
163
164 private = 1
165
166
167
168 imports = 1
169
170
171
172
173
174 verbosity = 1
175
176
177
178 parse = 1
179
180
181
182 introspect = 1
183
184
185
186
187
188
189 graph = 'all'
190
191
192
193
194
195
196
197
198
199 sourcecode = 1
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217 epydoc_cmd = 'epydoc' + ' --' + output + ' -o ' + target + ' --docformat ' + docformat + ' --css ' + css + ' --name ' + name + ' --url ' + url
218
219
220 if frames:
221 epydoc_cmd = epydoc_cmd + ' --show-frames'
222 else:
223 epydoc_cmd = epydoc_cmd + ' --no-frames'
224
225
226 if private:
227 epydoc_cmd = epydoc_cmd + ' --show-private'
228 else:
229 epydoc_cmd = epydoc_cmd + ' --no-private'
230
231
232 if imports:
233 epydoc_cmd = epydoc_cmd + ' --show-imports'
234 else:
235 epydoc_cmd = epydoc_cmd + ' --no-imports'
236
237
238 if verbosity > 0:
239 for i in range(verbosity):
240 epydoc_cmd = epydoc_cmd + ' -v'
241 elif verbosity < 0:
242 for i in range(-verbosity):
243 epydoc_cmd = epydoc_cmd + ' -q'
244
245
246 if parse and not introspect:
247 epydoc_cmd = epydoc_cmd + ' --parse-only'
248 elif not parse and introspect:
249 epydoc_cmd = epydoc_cmd + ' --introspect-only'
250
251
252 epydoc_cmd = epydoc_cmd + ' --graph ' + graph
253
254
255 if sourcecode:
256 epydoc_cmd = epydoc_cmd + ' --show-sourcecode'
257 else:
258 epydoc_cmd = epydoc_cmd + ' --no-sourcecode'
259
260
261 for name in exclude:
262 epydoc_cmd = epydoc_cmd + ' --exclude=' + name
263
264
265 blacklist = ['README', 'relax.bat', 'relax_gui_mode.py']
266 files = listdir(getcwd())
267 for file in files:
268
269 if file in blacklist:
270 continue
271
272
273 if file in exclude:
274 continue
275
276
277 if search('^\.', file):
278 continue
279
280
281 epydoc_cmd = "%s %s" % (epydoc_cmd, file)
282
283
284
285
286
287
288 print("Running the command:\n$ " + epydoc_cmd + "\n\n\n")
289
290
291 system(epydoc_cmd)
292
293
294
295
296
297
298
299 css_file = open(target + sep+'epydoc.css', 'a')
300
301
302 css_file.write("\n\n\n\n/* Edward */\n\n")
303
304
305 css_file.write("a { text-decoration:none; color:#0017aa; font-weight:normal; }\n")
306 css_file.write("a:hover { color:#316fff; }\n")
307
308
309 css_file.close()
310
311
312
313
314
315
316 print("\n\nModifying the <head> tag of all HTML files.\n")
317
318
319 head_lines = []
320
321
322 file = open(status.install_path + sep + 'devel_scripts' + sep + 'google_analytics.js')
323 for line in file.readlines():
324 head_lines.append(line)
325 file.close()
326
327
328 for file_name in listdir(status.install_path + sep + 'docs' + sep + 'api'):
329
330 full_path = status.install_path + sep + 'docs' + sep + 'api' + sep + file_name
331
332
333 if not search('.html$', full_path):
334 continue
335
336
337 file = open(full_path)
338 lines = file.readlines()
339 file.close()
340
341
342 file = open(full_path, 'w')
343
344
345 found = False
346 for i in range(len(lines)):
347
348 if not found and search('</head>', lines[i]):
349
350 for j in range(len(head_lines)):
351 file.write(head_lines[j])
352
353
354 found = True
355
356
357 file.write(lines[i])
358
359
360 file.close()
361
362
363 print("\n\n\n")
364
365
367 """Builder action for compiling the user manual (HTML version) from the LaTeX sources."""
368
369
370 compile_user_manual_pdf(target, source, env, convert=False)
371
372
373 print('')
374 print("############################################")
375 print("# Compiling the user manual (HTML version) #")
376 print("############################################\n\n")
377
378
379 base_dir = getcwd()
380 chdir(env['LATEX_DIR'])
381
382
383 dir = path.pardir + path.sep + "html"
384
385
386 cmd = "latex2html -dir %s relax.tex" % (dir)
387 print("Running the command:\n$ %s\n\n\n" % cmd)
388 system(cmd)
389
390
391 cmd = "cp -vp %s%srelax_user_manual.html %s%sindex.html" % (dir, path.sep, dir, path.sep)
392 print("Running the command:\n$ %s\n\n\n" % cmd)
393 system(cmd)
394
395
396 chdir(base_dir)
397
398
399 print("\n\n\n")
400
401
403 """Builder action for compiling the user manual (PDF version) from the LaTeX sources."""
404
405
406 print('')
407 print("###########################################")
408 print("# Compiling the user manual (PDF version) #")
409 print("###########################################\n\n")
410
411
412 base_dir = getcwd()
413 chdir(env['LATEX_DIR'])
414
415 print("\n\n\n <<< LaTeX (first round) >>>\n\n\n")
416 system('latex relax')
417
418 print("\n\n\n <<< Bibtex >>>\n\n\n")
419 system('bibtex relax')
420
421 print("\n\n\n <<< Makeindex >>>\n\n\n")
422 system('makeindex relax')
423
424 print("\n\n\n <<< LaTeX (second round) >>>\n\n\n")
425 system('latex relax')
426
427 print("\n\n\n <<< LaTeX (third round) >>>\n\n\n")
428 system('latex relax')
429
430 print("\n\n\n <<< Makeindex >>>\n\n\n")
431 system('makeindex relax')
432
433 print("\n\n\n <<< LaTeX (fourth round) >>>\n\n\n")
434 system('latex relax')
435
436
437 if not convert:
438
439 chdir(base_dir)
440
441
442 return
443
444 print("\n\n\n <<< dvips >>>\n\n\n")
445 system('dvips -R0 -o relax.ps relax.dvi')
446
447 print("\n\n\n <<< ps2pdf >>>\n\n\n")
448 if env['SYSTEM'] == 'Windows':
449
450
451
452 assign = '#'
453 else:
454 assign = '='
455 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')
456
457 print("\n\n\n <<< Removing the PS file and shifting the PDF down a directory >>>\n\n\n")
458 if access('relax.ps', F_OK):
459 remove('relax.ps')
460 if access('relax.pdf', F_OK):
461 rename('relax.pdf', path.pardir+path.sep+'relax.pdf')
462
463
464 chdir(base_dir)
465
466
467 print("\n\n\n")
468
469
471 """Builder action for fetching the relax user function docstrings."""
472
473
474 print('')
475 print("###############################################")
476 print("# Fetching the relax user function docstrings #")
477 print("###############################################\n\n")
478
479
480 sys.path.append(getcwd())
481 from docs.latex.fetch_docstrings import Fetch_docstrings
482
483
484 Fetch_docstrings(env['LATEX_DIR'] + sep + 'docstring.tex')
485
486
487 del Fetch_docstrings
488
489
490 print("\n\n\n")
491
492
494 """Builder action for creating the LaTeX relax version file."""
495
496
497 print('')
498 print("################################################")
499 print("# Creating the LaTeX relax version number file #")
500 print("################################################")
501
502
503 text = version.version
504 if text == 'repository checkout':
505 text += ' r%s' % version.revision()
506
507
508 file = open(env['LATEX_DIR'] + sep + 'relax_version.tex', 'w')
509 file.write("Version " + text + '\n')
510 file.close()
511
512
513 print("\n\n\n")
514