From bc4326c5a49d40ce8aa2f80aadaea428099b5f65 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Mon, 28 Jun 2021 13:37:26 -0700 Subject: [PATCH] Add ${ROOT} substitution Doesn't really affect the pages on the web, but it's easier to preview them in the filesystem when linked to "../main.css" rather than "/main.css". The common portion of the section is now in a separate "include" file. Added some indentation to masthead/topnav/sidenav so it looks nicer in the merged source listing. --- docs/block-repl.py | 22 ++++- docs/footer-incl.html | 18 ++-- docs/head-incl.html | 8 ++ docs/index.html | 67 +++++++------- docs/masthead-incl.html | 8 +- docs/sgtutorial/about-disasm.html | 117 +++++++++++++------------ docs/sgtutorial/address-tables.html | 117 +++++++++++++------------ docs/sgtutorial/advanced-topics.html | 117 +++++++++++++------------ docs/sgtutorial/digging-deeper.html | 117 +++++++++++++------------ docs/sgtutorial/editing-data.html | 117 +++++++++++++------------ docs/sgtutorial/extension-scripts.html | 117 +++++++++++++------------ docs/sgtutorial/generating-code.html | 117 +++++++++++++------------ docs/sgtutorial/index.html | 117 +++++++++++++------------ docs/sgtutorial/inline-data.html | 117 +++++++++++++------------ docs/sgtutorial/labels-symbols.html | 117 +++++++++++++------------ docs/sgtutorial/local-variables.html | 117 +++++++++++++------------ docs/sgtutorial/moving-around.html | 117 +++++++++++++------------ docs/sgtutorial/odds-ends.html | 117 +++++++++++++------------ docs/sgtutorial/sidenav-incl.html | 50 +++++------ docs/sgtutorial/simple-edits.html | 117 +++++++++++++------------ docs/sgtutorial/string-formatting.html | 117 +++++++++++++------------ docs/sgtutorial/using-sourcegen.html | 117 +++++++++++++------------ docs/sgtutorial/visualizations.html | 117 +++++++++++++------------ docs/topnav-incl.html | 36 ++++---- 24 files changed, 1140 insertions(+), 1058 deletions(-) create mode 100644 docs/head-incl.html diff --git a/docs/block-repl.py b/docs/block-repl.py index a171454..48d8341 100755 --- a/docs/block-repl.py +++ b/docs/block-repl.py @@ -15,7 +15,7 @@ # # # Run this from the top-level directory. Provide a list of all HTML files -# on the command line. +# on the command line, using relative paths. # # If the name of the file to include (specified on the START line) begins # with '/', the file will be loaded from the top-level directory, i.e. the @@ -113,12 +113,25 @@ def copyFromIncl(inFileName, tag, activeId, outFile): # file is in same directory as input file inclFileName = os.path.join(os.path.dirname(inFileName), tag) + print("== replacing section with " + inclFileName) + try: with open(inclFileName, "r") as inFile: fileData = inFile.read() except IOError as err: raise LocalError(err) + # Create a relative path for ${ROOT}, which is defined as the directory + # in which we're running. + # TODO: make this work correctly for absolute paths? + if inFileName[0] == '/': + raise LocalError("Not a relative path: " + inFileName) + tmpPair = os.path.split(inFileName) + rootRel = "" + while tmpPair[0]: + rootRel += "../" + tmpPair = os.path.split(tmpPair[0]) + if activeId: # Given an HTML block like
  • , insert # a class assignment: class="active". The ID to modify is @@ -131,6 +144,13 @@ def copyFromIncl(inFileName, tag, activeId, outFile): else: fileData = newData + # Replace ${ROOT} with relative path to root directory. + newData = re.sub("\${ROOT}\/", rootRel, fileData) + if newData != fileData: + #print("== ${ROOT}=" + rootRel + " in " + inclFileName) + fileData = newData + + # Copy data to output file. outFile.write(fileData) diff --git a/docs/footer-incl.html b/docs/footer-incl.html index e276c11..150d015 100644 --- a/docs/footer-incl.html +++ b/docs/footer-incl.html @@ -1,9 +1,9 @@ -
    -

    Copyright 2021 faddenSoft

    - +
    +

    Copyright 2021 faddenSoft

    + diff --git a/docs/head-incl.html b/docs/head-incl.html new file mode 100644 index 0000000..a8e7b76 --- /dev/null +++ b/docs/head-incl.html @@ -0,0 +1,8 @@ + + + + + + + diff --git a/docs/index.html b/docs/index.html index ad65e0b..df5e9ee 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,13 +1,16 @@ + + - + +