]> Shamusworld >> Repos - ardour-manual-diverged/blobdiff - build.py
Sync to master.
[ardour-manual-diverged] / build.py
index 021f6a0eadc888664aebe388587946dfd8db4dae..e6c6ebcc4675ee0b004d70f62272f7004ed38058 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -8,6 +8,7 @@
 # to handle.
 #
 # by James Hammons
+# (C) 2017 Underground Software
 #
 
 import os
@@ -133,7 +134,6 @@ for line in master:
 
                # Make a filename from the title...
                levelNames[level] = MakeFilename(header['title'])
-
                path = ''
 
                for i in range(level):
@@ -141,17 +141,27 @@ for line in master:
 
                path = path + str(levelNums[level]).zfill(2) + '_' + levelNames[level]
 
-               # Append the appropriate footer, if the current file is one level
-               # down from the previous...
+               # Append the appropriate footer to the last file, if the current file
+               # is one level down from the previous...
                if ((level > 0) and (level > lastLevel)):
                        nfile = open(buildDir + lastFile + '.html', 'a')
                        nfile.write('\n{% children %}\n\n')
                        nfile.close()
 
-               # Parts DO NOT have any content, they are ONLY an organizing construct!
-               if (level == 0):
+               # Handle TOC scriblings...
+               if level == 0:
                        toc.write('<h2>Part ' + roman[levelNums[level]] + ': ' + header['title'] + '</h2>\n');
+               elif level == 1:
+                       toc.write('  <p id=chapter>Ch. ' + str(levelNums[level]) + ':&nbsp;&nbsp;<a href="/' + levelNames[0] + '/' + levelNames[1] + '/">' + header['title'] + '</a></p>\n')
+               elif level == 2:
+                       toc.write('    <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/">' + header['title'] + '</a><br>\n')
+               elif level == 3:
+                       toc.write('      <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/">' + header['title'] + '</a><br>\n')
+               elif level == 4:
+                       toc.write('      <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/' + levelNames[4] + '/">' + header['title'] + '</a><br>\n')
 
+               # Parts DO NOT have any content, they are ONLY an organizing construct!
+               if (level == 0):
                        os.mkdir(buildDir + path, 0o774)
                        nfile = open(buildDir + path + '.html', 'w')
                        nfile.write('---\n' + 'title: ' + header['title'] + '\n')
@@ -165,69 +175,7 @@ for line in master:
                # Chapters, subchapters, sections & subsections all can have content.
                # But the basic fundamental organizing unit WRT content is still the
                # chapter.
-               elif (level == 1):
-                       toc.write('  <p id=chapter>Ch. ' + str(levelNums[level]) + ':&nbsp;&nbsp;<a href="/' + levelNames[0] + '/' + levelNames[1] + '/">' + header['title'] + '</a></p>\n')
-
-                       os.mkdir(buildDir + path, 0o774)
-
-                       if ('include' in header):
-                               shutil.copy('include/' + header['include'], buildDir + path + '.html')
-                       else:
-                               htmlFile = open(buildDir + path + '.html', 'w')
-                               writingToFile = True
-                               htmlFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
-                               if ('menu_title' in header):
-                                       htmlFile.write('menu_title: ' + header['menu_title'] + '\n')
-
-                               if ('style' in header):
-                                       htmlFile.write('style: ' + header['style'] + '\n')
-
-                               htmlFile.write('---\n\n')
-
-               elif (level == 2):
-                       toc.write('    <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/">' + header['title'] + '</a><br>\n')
-
-                       os.mkdir(buildDir + path, 0o774)
-
-                       if ('include' in header):
-                               shutil.copy('include/' + header['include'], buildDir + path + '.html')
-                       else:
-                               htmlFile = open(buildDir + path + '.html', 'w')
-                               writingToFile = True
-                               htmlFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
-                               if ('menu_title' in header):
-                                       htmlFile.write('menu_title: ' + header['menu_title'] + '\n')
-
-                               if ('style' in header):
-                                       htmlFile.write('style: ' + header['style'] + '\n')
-
-                               htmlFile.write('---\n\n')
-
-               elif (level == 3):
-                       toc.write('      <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/">' + header['title'] + '</a><br>\n')
-
-                       os.mkdir(buildDir + path, 0o774)
-
-                       if ('include' in header):
-                               shutil.copy('include/' + header['include'], buildDir + path + '.html')
-                       else:
-                               htmlFile = open(buildDir + path + '.html', 'w')
-                               writingToFile = True
-                               htmlFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
-                               if ('menu_title' in header):
-                                       htmlFile.write('menu_title: ' + header['menu_title'] + '\n')
-
-                               if ('style' in header):
-                                       htmlFile.write('style: ' + header['style'] + '\n')
-
-                               htmlFile.write('---\n\n')
-
-               elif (level == 4):
-                       toc.write('      <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/' + levelNames[4] + '/">' + header['title'] + '</a><br>\n')
-
+               else:
                        os.mkdir(buildDir + path, 0o774)
 
                        if ('include' in header):