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