Commits

Jason McKesson committed 052415d

Added Kindle and Print-based PDF generation. Also made the distribution building work with the new build tools.

Comments (0)

Files changed (8)

 -------------------------------------------
 -- Use the other Lua script to copy the HTML to the destination.
 local CopyWebsite = assert(loadfile("CopyWebsite.lua"));
-CopyWebsite(destDir .. "html\\");
+CopyWebsite(destDir .. "\\html\\");
 
+--Generate the PDF files.
+lfs.mkdir("pdfs");
+
+local cwd = lfs.currentdir();
+lfs.chdir("Documents\\Build");
+local BuildPrintBW = assert(loadfile("BuildPrintBWFO.lua"));
+BuildPrintBW(cwd .. "\\pdfs\\");
+local BuildKindleFO = assert(loadfile("BuildKindleFO.lua"));
+BuildKindleFO(cwd .. "\\pdfs\\");
+local BuildComputerFO = assert(loadfile("BuildComputerFO.lua"));
+BuildComputerFO(cwd .. "\\pdfs\\");
+lfs.chdir(cwd);
 
 --------------------------------------------
 -- Copy other files.
-os.execute(string.format([[copy "documents\TutorialsPrint.pdf" "%s\"]], destDir));
-os.execute(string.format([[copy "documents\TutorialsKindle.pdf" "%s\"]], destDir));
-os.execute(string.format([[copy "documents\TutorialsComp.pdf" "%s\"]], destDir));
+os.execute(string.format([[copy "pdfs\TutorialsPrintBW.pdf" "%s\"]], destDir));
+os.execute(string.format([[copy "pdfs\TutorialsKindle.pdf" "%s\"]], destDir));
+os.execute(string.format([[copy "pdfs\TutorialsComp.pdf" "%s\"]], destDir));
 
 ------------------------------------------
 -- Use Mercurial to get a version in the destination directory.
-local clone = [[hg archive -r "%s" "%s\"]];
+local clone = [[hg archive -r "%s" "%s"]];
 clone = clone:format(hgChangelist, destDir);
 
 print(clone);
 -- Generate the ancillary files
 
 --Readme.txt
-local readme = io.open(destDir .. "readme.txt", "wt");
+local readme = io.open(destDir .. "\\readme.txt", "wt");
 readme:write(string.format(
 [===[
 OpenGL Tutorials, version %s
 alone is not enough information to understand what is going on. The actual
 documentation is available in several forms.
 
-The HTML form of the documentation can be found by openning the "index.html"
+The HTML form of the documentation can be found by opening the "index.html"
 file. There are 3 PDF forms of the documentation. TutorialsComp.pdf is a PDF
 that uses very thin margins; it is useful for display on computers (or
-tablets). TutorialsPrint.pdf is a PDF designed for printing.
-TutorialsKindle.pdf is a PDF that is sized specifically for the screen of the
-Kindle 2.
+tablets). TutorialsPrintBW.pdf is a PDF designed for printing on a black-and-white
+printer. TutorialsKindle.pdf is a PDF that is sized specifically for the screen
+of the Kindle 2.
 
 The source of the documentation is found in the Documents directory. This
 source documentation is in the DocBook 5 format. All other formats were
 readme:close()
 
 --Version.txt
-local version = io.open(destDir .. "version.txt", "wt");
+local version = io.open(destDir .. "\\version.txt", "wt");
 version:write(string.format(
 [===[
 OpenGL Tutorials.
 version:close();
 
 --Index.html
-local index_html = io.open(destDir .. "index.html", "wt");
+local index_html = io.open(destDir .. "\\index.html", "wt");
 index_html:write(
 [===[
 <html>

Documents/Build/BuildComputerFO.lua

 
 require "lfs"
-
-local function ToUnix(convString)
-	return string.gsub(convString, "%\\", "/");
-end
+require "_util"
 
 local data = dofile("_buildConfig.lua");
 
 outputDir = outputDir or "..\\fo\\";
 local foFilename = "..\\computerfo.fo";
 
+--Parameters
+local params = {}
+params["body.start.indent"] = "2pc";
+params["page.margin.top"] = "0.25in";
+params["page.margin.bottom"] = "0.25in";
+params["page.margin.inner"] = "0.25in";
+params["page.margin.outer"] = "0.25in";
+params["paper.type"] = "USLetter";
+params["body.start.indent"] = "0pt";
+--params["highlight.source"] = "1";
+--params["highlight.xslthl.config"] = "file:highlighting/xslthl-config.xml";
+
+
 --Auto-generate the main specialization file.
 local filename = "fo.xsl";
 
 
 hFile:write([[    <xsl:import href="colorfo-highlights.xsl"/>]], "\n");
 
+WriteParamsToFile(hFile, dofile("_commonParams.lua"));
+WriteParamsToFile(hFile, dofile("_commonFOParams.lua"));
+WriteParamsToFile(hFile, params);
+
 hFile:write([[</xsl:stylesheet> 
 ]]);
 
 command[#command + 1] = "\"" .. foFilename .. "\""
 command[#command + 1] = "\"..\\Tutorials.xml\""
 command[#command + 1] = filename
-command[#command + 1] = "toc.max.depth=2"
-command[#command + 1] = "toc.section.depth=1"
-command[#command + 1] = "funcsynopsis.style=ansi"
-command[#command + 1] = "body.start.indent=2pc"
-command[#command + 1] = "draft.mode=no"
-command[#command + 1] = "fop1.extensions=1"
-command[#command + 1] = "page.margin.bottom=0.25in"
-command[#command + 1] = "page.margin.inner=0.25in"
-command[#command + 1] = "page.margin.outer=0.25in"
-command[#command + 1] = "page.margin.top=0.25in"
-command[#command + 1] = "paper.type=USLetter"
-command[#command + 1] = "body.start.indent=0pt"
---command[#command + 1] = "highlight.source=1"
---command[#command + 1] = "\"highlight.xslthl.config=file:highlighting/xslthl-config.xml\""
 
 local finalCmd = table.concat(command, " ");
 print(finalCmd);
 command[#command + 1] = "-fo"
 command[#command + 1] = "\"" .. foFilename .. "\""
 command[#command + 1] = "-pdf"
-command[#command + 1] = "\"" .. outputDir .. "computerfo.pdf\""
+command[#command + 1] = "\"" .. outputDir .. "TutorialsComp.pdf\""
 
 finalCmd = table.concat(command, " ");
 print(finalCmd);

Documents/Build/BuildKindleFO.lua

+
+require "lfs"
+require "_util"
+
+local data = dofile("_buildConfig.lua");
+
+local outputDir = ...;
+outputDir = outputDir or "..\\fo\\";
+local foFilename = "..\\kindle.fo";
+
+--Parameters
+local params = {}
+params["body.font.master"] = "10";
+params["body.start.indent"] = "0pt";
+params["page.height"] = "4.79in";
+params["page.height.portrait"] = "4.79in";
+params["page.width"] = "3.59in";
+params["page.width.portrait"] = "3.59in";
+params["page.margin.top"] = "0in";
+params["page.margin.bottom"] = "0in";
+params["page.margin.inner"] = "0in";
+params["page.margin.outer"] = "0in";
+params["title.margin.left"] = "0pt";
+--params["highlight.source"] = "1";
+--params["highlight.xslthl.config"] = "file:highlighting/xslthl-config.xml";
+
+
+--Auto-generate the main specialization file.
+local filename = "fo.xsl";
+
+local hFile = io.open(filename, "wt");
+hFile:write(
+[[<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet  
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+    xmlns:s6hl="java:net.sf.xslthl.ConnectorSaxon6"
+    xmlns:xslthl="http://xslthl.sf.net"
+    extension-element-prefixes="s6hl xslthl">
+]]);
+
+hFile:write([[    <xsl:import href="]], ToUnix(data.docbookXSLBasepath .. "fo\\docbook.xsl"), "\"/>\n");
+
+hFile:write([[    <xsl:import href="colorfo-highlights.xsl"/>]], "\n");
+
+WriteParamsToFile(hFile, dofile("_commonParams.lua"));
+WriteParamsToFile(hFile, dofile("_commonFOParams.lua"));
+WriteParamsToFile(hFile, params);
+
+hFile:write([[</xsl:stylesheet> 
+]]);
+
+hFile:close();
+
+--Create the command line.
+local command = {};
+command[#command + 1] = "java"
+command[#command + 1] = "-cp"
+command[#command + 1] = "\"" .. table.concat({data.saxonFilepath, data.xercesJars, data.xslthlFilepath}, ";") .. "\""
+command[#command + 1] = "-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"
+command[#command + 1] = "-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl"
+command[#command + 1] = "-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration"
+command[#command + 1] = "com.icl.saxon.StyleSheet"
+command[#command + 1] = "-o"
+command[#command + 1] = "\"" .. foFilename .. "\""
+command[#command + 1] = "\"..\\Tutorials.xml\""
+command[#command + 1] = filename
+
+local finalCmd = table.concat(command, " ");
+print(finalCmd);
+print("");
+
+os.execute(finalCmd);
+
+
+command = {};
+command[#command + 1] = data.fopBatch
+command[#command + 1] = "-fo"
+command[#command + 1] = "\"" .. foFilename .. "\""
+command[#command + 1] = "-pdf"
+command[#command + 1] = "\"" .. outputDir .. "TutorialsKindle.pdf\""
+
+finalCmd = table.concat(command, " ");
+print(finalCmd);
+print("");
+
+os.execute(finalCmd);
+
+
+
+

Documents/Build/BuildPrintBWFO.lua

+
+require "lfs"
+require "_util"
+
+local data = dofile("_buildConfig.lua");
+
+local outputDir = ...;
+outputDir = outputDir or "..\\fo\\";
+local foFilename = "..\\printbw.fo";
+
+--Parameters
+local params = {}
+--params["body.start.indent"] = "2pc";
+params["paper.type"] = "USLetter";
+params["body.start.indent"] = "0pt";
+--params["highlight.source"] = "1";
+--params["highlight.xslthl.config"] = "file:highlighting/xslthl-config.xml";
+
+
+--Auto-generate the main specialization file.
+local filename = "fo.xsl";
+
+local hFile = io.open(filename, "wt");
+hFile:write(
+[[<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet  
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+    xmlns:s6hl="java:net.sf.xslthl.ConnectorSaxon6"
+    xmlns:xslthl="http://xslthl.sf.net"
+    extension-element-prefixes="s6hl xslthl">
+]]);
+
+hFile:write([[    <xsl:import href="]], ToUnix(data.docbookXSLBasepath .. "fo\\docbook.xsl"), "\"/>\n");
+
+hFile:write([[    <xsl:import href="colorfo-highlights.xsl"/>]], "\n");
+
+WriteParamsToFile(hFile, dofile("_commonParams.lua"));
+WriteParamsToFile(hFile, dofile("_commonFOParams.lua"));
+WriteParamsToFile(hFile, params);
+
+hFile:write([[</xsl:stylesheet> 
+]]);
+
+hFile:close();
+
+--Create the command line.
+local command = {};
+command[#command + 1] = "java"
+command[#command + 1] = "-cp"
+command[#command + 1] = "\"" .. table.concat({data.saxonFilepath, data.xercesJars, data.xslthlFilepath}, ";") .. "\""
+command[#command + 1] = "-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"
+command[#command + 1] = "-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl"
+command[#command + 1] = "-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration"
+command[#command + 1] = "com.icl.saxon.StyleSheet"
+command[#command + 1] = "-o"
+command[#command + 1] = "\"" .. foFilename .. "\""
+command[#command + 1] = "\"..\\Tutorials.xml\""
+command[#command + 1] = filename
+
+local finalCmd = table.concat(command, " ");
+print(finalCmd);
+print("");
+
+os.execute(finalCmd);
+
+
+command = {};
+command[#command + 1] = data.fopBatch
+command[#command + 1] = "-fo"
+command[#command + 1] = "\"" .. foFilename .. "\""
+command[#command + 1] = "-pdf"
+command[#command + 1] = "\"" .. outputDir .. "TutorialsPrintBW.pdf\""
+
+finalCmd = table.concat(command, " ");
+print(finalCmd);
+print("");
+
+os.execute(finalCmd);
+
+
+
+

Documents/Build/BuildWebsite.lua

 
 require "lfs"
-
-local function ToUnix(convString)
-	return string.gsub(convString, "%\\", "/");
-end
+require "_util"
 
 local data = dofile("_buildConfig.lua");
 
 local outputDir = ...;
 outputDir = outputDir or "..\\web\\";
 
+--Parameters
+local params = {}
+params["base.dir"] = ToUnix(outputDir);
+params["chunk.quietly"] = "1";
+params["html.stylesheet"] = "chunked.css";
+params["ignore.image.scaling"] = "1";
+params["highlight.source"] = "1";
+params["highlight.xslthl.config"] = "file:highlighting/xslthl-config.xml";
+
+
 --Auto-generate the main specialization file.
 local filename = "website.xsl";
 
 
 hFile:write([[    <xsl:import href="html-highlights.xsl"/>]], "\n");
 
+WriteParamsToFile(hFile, dofile("_commonParams.lua"));
+WriteParamsToFile(hFile, params);
+
 hFile:write([[</xsl:stylesheet> 
 ]]);
 
 command[#command + 1] = "\"" .. outputDir .. "nothing.html\""
 command[#command + 1] = "\"..\\Tutorials.xml\""
 command[#command + 1] = filename
---command[#command + 1] = "\"" .. data.docbookXSLBasepath .. "html\\chunkfast.xsl\""
-command[#command + 1] = "\"base.dir=" .. ToUnix(outputDir) .. "\""
-command[#command + 1] = "\"chunk.quietly=1\""
-command[#command + 1] = "html.stylesheet=chunked.css"
-command[#command + 1] = "ignore.image.scaling=1"
-command[#command + 1] = "toc.max.depth=2"
-command[#command + 1] = "toc.section.depth=1"
-command[#command + 1] = "funcsynopsis.style=ansi"
-command[#command + 1] = "highlight.source=1"
-command[#command + 1] = "\"highlight.xslthl.config=file:highlighting/xslthl-config.xml\""
 
 finalCmd = table.concat(command, " ");
 print(finalCmd);

Documents/Build/_commonFOParams.lua

+local params = ...;
+params = params or {};
+
+params["fop1.extensions"] = "1";
+params["generate.toc"] = "appendix  toc,title article/appendix  nop article   toc,title book      toc,title chapter   toc,title part      toc,title preface   toc,title qandadiv  toc qandaset  toc reference toc,title sect1     toc sect2     toc sect3     toc sect4     toc sect5     toc section   toc set       toc,title"
+
+return params;

Documents/Build/_commonParams.lua

+local params = ...;
+params = params or {};
+
+params["funcsynopsis.style"] = "ansi";
+params["draft.mode"] = "no";
+params["toc.max.depth"] = "2";
+params["toc.section.depth"] = "1";
+
+return params;

Documents/Build/_util.lua

+
+function WriteParamsToFile(hFile, params)
+	for param, value in pairs(params) do
+		hFile:write([[    <xsl:param name="]],
+			param,
+			[[">]],
+			value,
+			[[</xsl:param>]],
+			"\n");
+	end
+end
+
+function ToUnix(convString)
+	return string.gsub(convString, "%\\", "/");
+end
+
+