@@ -311,28 +311,22 @@ else:
311
311
copy_dbfiles (env , toolpath , [], 'gs.py' )
312
312
copy_dbfiles (env , toolpath , [], 'zip.py' )
313
313
314
- # Each document will live in its own subdirectory "build/doc/xxx".
315
- # List them here by their subfolder names. Note how the specifiers
316
- # for each subdir (=DOCTARGETS) have nothing to do with which
317
- # formats get created, but which of the outputs get installed
318
- # to the build folder and added to the different source and binary
319
- # packages in the end.
314
+ # Each document will build in its own subdirectory of "build/doc/".
315
+ # The *docs* dictionary entries have the document (and thus directory)
316
+ # name as the key, and a tuple of lists as the value.
320
317
#
321
- # In addition to the list of target formats (DOCTARGETS), we also
322
- # store some dependency information in this dict. The DOCDEPENDS
323
- # list contains all files from each local "MANIFEST", after
324
- # installing/copying them to the build directory. It basically
325
- # links the original sources to the respective build folder,
326
- # such that a simple 'python bootstrap.py' rebuilds the
327
- # documentation when a file, like 'doc/user/depends.xml'
328
- # for example, changes.
318
+ # The first list is the document formats enabled ("targets"). Note this
319
+ # isn't what gets built, but what gets installed into the build folder
320
+ # source/target lists.
321
+ #
322
+ # The second list ("depends") is for dependency information. Dependencies
323
+ # are extracted from each local "MANIFEST" and added to this list.
324
+ # This basically links the original sources to the respective build folder.
325
+ #
326
+ # The third list ("nodes") stores the created PDF and HTML files,
327
+ # so that we can then install them in the proper places for getting
328
+ # picked up by the archiving/packaging stages.
329
329
#
330
- # Finally, in DOCNODES we store the created PDF and HTML files,
331
- # such that we can then install them in the proper places for
332
- # getting picked up by the archiving/packaging stages.
333
- DOCTARGETS = 0
334
- DOCDEPENDS = 1
335
- DOCNODES = 2
336
330
docs = {
337
331
# 'design': (['chunked', 'pdf'], [], []),
338
332
# 'python10' : (['chunked','html','pdf'], [], []),
@@ -401,7 +395,7 @@ else:
401
395
else :
402
396
revaction ([env .File (os .path .join (build , s ))], [env .File (s )], env )
403
397
404
- for doc in docs :
398
+ for doc , ( targets , depends , nodes ) in docs . items () :
405
399
# Read MANIFEST file and copy the listed files to the build directory,
406
400
# while branding them with the SCons copyright and the current
407
401
# revision number...
@@ -423,82 +417,74 @@ else:
423
417
else :
424
418
target_dir = os .path .join (build , doc )
425
419
if ext in ['.fig' , '.jpg' , '.svg' ]:
426
- docs [ doc ][ DOCDEPENDS ] .extend (
420
+ depends .extend (
427
421
env .Command (build_s , doc_s , Copy ("$TARGET" , "$SOURCE" ))
428
422
)
429
423
else :
430
424
btarget = env .File (build_s )
431
- docs [ doc ][ DOCDEPENDS ] .append (btarget )
425
+ depends .append (btarget )
432
426
revaction ([btarget ], [env .File (doc_s )], env )
433
427
434
- #
435
- # For each document, build the document itself in HTML,
436
- # and PDF formats.
437
- #
438
- for doc in docs :
439
-
440
- #
428
+ # For each document, add targets for each of the selected formats
429
+ for doc , (targets , depends , nodes ) in docs .items ():
441
430
# Call SCons in each local doc folder
442
- #
443
431
cleanopt = ''
444
432
if env .GetOption ('clean' ):
445
433
cleanopt = ' -c'
446
434
scdir = os .path .join (build , doc )
447
435
sctargets = []
448
- if 'html' in docs [ doc ][ DOCTARGETS ] :
436
+ if 'html' in targets :
449
437
sctargets .append (env .File (os .path .join (scdir , 'index.html' )))
450
- if 'chunked' in docs [ doc ][ DOCTARGETS ] :
438
+ if 'chunked' in targets :
451
439
sctargets .append (
452
440
env .File (os .path .join (scdir , f'scons-{ doc } ' , 'index.html' ))
453
441
)
454
- if 'pdf' in docs [ doc ][ DOCTARGETS ] :
442
+ if 'pdf' in targets :
455
443
sctargets .append (env .File (os .path .join (scdir , f'scons-{ doc } .pdf' )))
456
- if 'epub' in docs [ doc ][ DOCTARGETS ] :
444
+ if 'epub' in targets :
457
445
sctargets .append (env .File (os .path .join (scdir , f'scons-{ doc } .epub' )))
458
446
459
- if 'man' in docs [ doc ][ DOCTARGETS ] :
447
+ if 'man' in targets :
460
448
for m in man_page_list :
461
449
sctargets .append (os .path .join (scdir , m ))
462
450
man , _1 = os .path .splitext (m )
463
-
464
451
sctargets .append (os .path .join (scdir , f'scons-{ man } .pdf' ))
465
452
sctargets .append (os .path .join (scdir , f'scons-{ man } .html' ))
466
453
467
- docs [ doc ][ DOCNODES ] .extend (
454
+ nodes .extend (
468
455
env .Command (
469
456
target = sctargets ,
470
- source = buildsuite + docs [ doc ][ DOCDEPENDS ] ,
457
+ source = buildsuite + depends ,
471
458
action = "cd %s && $PYTHON ${SCONS_PY.abspath}%s" % (scdir , cleanopt ),
472
459
)
473
460
)
474
461
475
462
install_css = False
476
- for doc in docs :
477
-
463
+ for doc , (targets , depends , nodes ) in docs .items ():
478
464
# Collect the output files for this subfolder
479
465
htmldir = os .path .join (build , 'HTML' , f'scons-{ doc } ' )
480
466
htmlindex = os .path .join (htmldir , 'index.html' )
481
467
html = os .path .join (build , 'HTML' , f'scons-{ doc } .html' )
482
468
pdf = os .path .join (build , 'PDF' , f'scons-{ doc } .pdf' )
483
469
epub = os .path .join (build , 'EPUB' , f'scons-{ doc } .epub' )
484
470
text = os .path .join (build , 'TEXT' , f'scons-{ doc } .txt' )
485
- if 'chunked' in docs [ doc ][ DOCTARGETS ] :
471
+ if 'chunked' in targets :
486
472
installed_chtml = env .ChunkedInstall (
487
473
env .Dir (htmldir ),
488
474
os .path .join (build , doc , f'scons-{ doc } ' , 'index.html' ),
489
475
)
490
476
installed_chtml_css = env .Install (
491
477
env .Dir (htmldir ), os .path .join (build , doc , 'scons.css' )
492
478
)
493
- env .Depends (installed_chtml , docs [ doc ][ DOCNODES ] )
494
- env .Depends (installed_chtml_css , docs [ doc ][ DOCNODES ] )
479
+ env .Depends (installed_chtml , nodes )
480
+ env .Depends (installed_chtml_css , nodes )
495
481
496
482
tar_deps .extend ([htmlindex , installed_chtml_css ])
497
483
tar_list .extend ([htmldir ])
498
484
Local (htmlindex )
499
485
env .Ignore (htmlindex , version_xml )
500
486
501
- if 'html' in docs [ doc ][ DOCTARGETS ] :
487
+ if 'html' in targets :
502
488
env .InstallAs (
503
489
target = env .File (html ),
504
490
source = env .File (os .path .join (build , doc , 'index.html' )),
@@ -509,7 +495,7 @@ else:
509
495
env .Ignore (html , version_xml )
510
496
install_css = True
511
497
512
- if 'pdf' in docs [ doc ][ DOCTARGETS ] :
498
+ if 'pdf' in targets :
513
499
env .InstallAs (
514
500
target = env .File (pdf ),
515
501
source = env .File (os .path .join (build , doc , f'scons-{ doc } .pdf' )),
@@ -520,7 +506,7 @@ else:
520
506
tar_deps .append (pdf )
521
507
tar_list .append (pdf )
522
508
523
- if 'epub' in docs [ doc ][ DOCTARGETS ] and gs :
509
+ if 'epub' in targets and gs :
524
510
env .InstallAs (
525
511
target = env .File (epub ),
526
512
source = env .File (os .path .join (build , doc , f'scons-{ doc } .epub' )),
@@ -532,9 +518,9 @@ else:
532
518
tar_list .append (epub )
533
519
534
520
if (
535
- 'text' in docs [ doc ][ DOCTARGETS ]
521
+ 'text' in targets
536
522
and lynx
537
- and (( 'html' in docs [ doc ][ DOCTARGETS ]) or ( doc == 'man' ) )
523
+ and ('html' in targets or doc == 'man' )
538
524
):
539
525
texthtml = os .path .join (build , doc , 'index.html' )
540
526
if doc == 'man' :
@@ -553,7 +539,7 @@ else:
553
539
tar_deps .append (text )
554
540
tar_list .append (text )
555
541
556
- if 'man' in docs [ doc ][ DOCTARGETS ] :
542
+ if 'man' in targets :
557
543
for m in man_page_list :
558
544
man , _1 = os .path .splitext (m )
559
545
0 commit comments