From ee29a6129d67e458f45a6be456e64eb3d0fd8759 Mon Sep 17 00:00:00 2001
From: Shamus Hammons
Date: Wed, 1 Feb 2017 13:13:36 -0600
Subject: [PATCH] Should be final version of Python build script.
---
build.py | 83 ++++++++++++++++++++++------
explode.py | 22 ++++----
implode.py | 1 +
include/favorite-plugins-window.html | 4 +-
master-doc.txt | 2 +
5 files changed, 82 insertions(+), 30 deletions(-)
diff --git a/build.py b/build.py
index e3eeef3..ec09ad6 100755
--- a/build.py
+++ b/build.py
@@ -15,6 +15,7 @@
import os
import re
import shutil
+import argparse
#
@@ -183,13 +184,32 @@ def FindTopLevelNodes(fs):
#
-# Internal links are of the form '@link-name', which are references to the
+# Find all header links and create a dictionary out of them
+#
+def FindInternalLinks(fs):
+ linkDict = {}
+
+ for hdr in fs:
+ if 'link' in hdr:
+ linkDict['@@' + hdr['link']] = '/' + hdr['filename'] + '/'
+
+ return linkDict
+
+
+#
+# Internal links are of the form '@@link-name', which are references to the
# 'link:' field in the part header. We have to find all occurances and replace
# them with the appropriate link.
#
-def FixInternalLinks(content):
-#make a dictionary ahead of time of pairs
- return content
+def FixInternalLinks(links, content):
+
+ # Make key1|key2|key3|... out of our links keys
+ pattern = re.compile('|'.join(links.keys()))
+
+ # Use a lambda callback to substitute each occurance found
+ result = pattern.sub(lambda x: links[x.group()], content)
+
+ return result
#
@@ -237,11 +257,23 @@ def CreateLinkSidebar(fs, pos, childList):
# Preliminaries
+# We have command line arguments now, so deal with them
+parser = argparse.ArgumentParser(description='A build script for the Ardour Manual')
+parser.add_argument('-v', '--verbose', action='store_true', help='Display the high-level structure of the manual')
+parser.add_argument('-q', '--quiet', action='store_true', help='Suppress all output (overrides -v)')
+args = parser.parse_args()
+verbose = args.verbose
+quiet = args.quiet
+
+if quiet:
+ verbose = False
+
+
roman = [ '0', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X',
'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX',
'XXI', 'XXII', 'XXIII', 'XXIV', 'XXV', 'XXVI', 'XXVII', 'XXVIII', 'XXIX', 'XXX' ]
-verbose = True
+#verbose = False
level = 0
fileCount = 0
levelNums = [0]*6
@@ -253,7 +285,9 @@ pageNumber = 0
siteDir = './website/'
if os.access(siteDir, os.F_OK):
- print('Removing stale HTML data...')
+ if not quiet:
+ print('Removing stale HTML data...')
+
shutil.rmtree(siteDir)
shutil.copytree('./source', siteDir)
@@ -275,20 +309,30 @@ template = template.replace('{{page.page_title}}', 'The Ardour Manual')
# Parse out the master docuemnt's structure into a dictionary list
fileStruct = GetFileStructure()
+
+# Build a quasi-tree structure listing children at level + 1 for each node
nodeChildren = FindChildren(fileStruct)
-# Here we go!
+# Create a dictionary for translation of internal links to real links
+links = FindInternalLinks(fileStruct)
-master = open('master-doc.txt')
-firstLine = master.readline().rstrip('\r\n')
-master.close()
+if not quiet:
+ print('Found ' + str(len(links)) + ' internal link target', end='')
+ print('.') if len(links) == 1 else print('s.')
-if firstLine == '':
- print('Parsing exploded file...')
-elif firstLine == '':
- print('Parsing imploded file...')
-else:
- print('Parsing unknown type...')
+if not quiet:
+ master = open('master-doc.txt')
+ firstLine = master.readline().rstrip('\r\n')
+ master.close()
+
+ if firstLine == '':
+ print('Parsing exploded file...')
+ elif firstLine == '':
+ print('Parsing imploded file...')
+ else:
+ print('Parsing unknown type...')
+
+# Here we go!
for header in fileStruct:
fileCount = fileCount + 1
@@ -312,7 +356,6 @@ for header in fileStruct:
# This is totally unnecessary, but nice; besides which, you can capture
# the output to a file to look at later if you like :-)
- # [TODO: add command line switch, default to False]
if verbose:
for i in range(level):
print('\t', end='')
@@ -382,6 +425,9 @@ for header in fileStruct:
else:
content = '[something went wrong]'
+ # Fix up any internal links
+ content = FixInternalLinks(links, content)
+
# Set up the actual page from the template
if 'style' not in header:
page = re.sub("{% if page.style %}.*\n.*\n{% endif %}.*\n", "", template)
@@ -421,5 +467,6 @@ tocFile = open(siteDir + 'toc/index.html', 'w')
tocFile.write(page)
tocFile.close()
-print('Processed ' + str(fileCount) + ' files.')
+if not quiet:
+ print('Processed ' + str(fileCount) + ' files.')
diff --git a/explode.py b/explode.py
index 85eb250..13fa677 100755
--- a/explode.py
+++ b/explode.py
@@ -86,7 +86,8 @@ for line in master:
suffix = suffix + 1
inclFile = MakeFilename(header['title']) + str(suffix) + '.html'
- # Pull in files and write the result to the master file
+ # Find all files in the master file and write them out to include/,
+ # while removing it from the master file.
explode.write('\n---\n' + 'title: ' + header['title'] + '\n')
if header['part'] != 'part':
@@ -119,15 +120,16 @@ for line in master:
toFile = open('include/' + inclFile, 'w')
writingFile = True
- toFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
- if 'menu_title' in header:
- toFile.write('menu_title: ' + header['menu_title'] + '\n')
-
- if 'style' in header:
- toFile.write('style: ' + header['style'] + '\n')
-
- toFile.write('---\n')
+#no more headers in separate files ffs...
+# toFile.write('---\n' + 'title: ' + header['title'] + '\n')
+#
+# if 'menu_title' in header:
+# toFile.write('menu_title: ' + header['menu_title'] + '\n')
+#
+# if 'style' in header:
+# toFile.write('style: ' + header['style'] + '\n')
+#
+# toFile.write('---\n')
else:
if writingFile:
toFile.write(line)
diff --git a/implode.py b/implode.py
index 46c26e5..8906a1d 100755
--- a/implode.py
+++ b/implode.py
@@ -102,6 +102,7 @@ for line in master:
os.rename('master-doc.bak', 'master-doc.txt')
exit(-1)
+#eventually this will go away, as this will never happen again...
if CheckForHeader(inclFile) == True:
# Skip the header
diff --git a/include/favorite-plugins-window.html b/include/favorite-plugins-window.html
index eec0f8e..6e83d38 100644
--- a/include/favorite-plugins-window.html
+++ b/include/favorite-plugins-window.html
@@ -21,7 +21,7 @@ ow">
- - Plugins can be dragged from the window to any track or bus processor box, which will add the plugin to that track or bus at the given position.
+ - Plugins can be dragged from the window to any track or bus processor box, which will add the plugin to that track or bus at the given position.
- The list includes user-presets for the plugins. Dragging a preset to a given track or bus will load that preset after adding the plugin.
- Double-clicking on a plugin or preset adds the given plugin to all selected tracks/busses pre-fader. Other insert positions are available from the context menu (right click).
- Dragging a plugin from a track into the window will add it to the list and optionally create a new preset from the current settings. The horizontal line in the list shows the spot where the plugin will land.
@@ -30,6 +30,6 @@ ow">
- When favorites are added with the Plugin Manager, they are appended to the bottom of the list.
+ When favorites are added with the Plugin Manager, they are appended to the bottom of the list.
diff --git a/master-doc.txt b/master-doc.txt
index 9991497..bf8813f 100644
--- a/master-doc.txt
+++ b/master-doc.txt
@@ -1519,12 +1519,14 @@ part: subchapter
---
title: Processor Box
+link: processor-box
include: _manual/13_working-with-plugins/03_processor-box.html
part: subchapter
---
---
title: Plugin Manager
+link: plugin-manager
include: _manual/13_working-with-plugins/02_plugin-manager.html
part: subchapter
---
--
2.37.2