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