Commits

dirkbaechle committed 8414724

- added EPUB as output format for documentation ("user" and "man" targets)

Comments (0)

Files changed (18)

 fop = whereis('fop')
 xep = whereis('xep')
 epydoc_cli = whereis('epydoc')
+gs = whereis('gs')
 
 #
 #
         env.Execute(Mkdir(os.path.join(build_dir, *(dbpath + ['html']))))
         env.Execute(Mkdir(os.path.join(build_dir, *(dbpath + ['fo']))))
         env.Execute(Mkdir(os.path.join(build_dir, *(dbpath + ['manpages']))))
+        env.Execute(Mkdir(os.path.join(build_dir, *(dbpath + ['epub']))))
+        env.Execute(Mkdir(os.path.join(build_dir, *(dbpath + ['xhtml-1_1']))))
         env.Execute(Copy(os.path.join(build_dir, *dbpath),
                          os.path.join('..', *(dbpath + ['VERSION']))))
         for g in glob.glob(os.path.join('..', *(dbpath + ['common', '*.*']))):
             env.Execute(Copy(os.path.join(build_dir, *(dbpath + ['fo'])), g))
         for g in glob.glob(os.path.join('..', *(dbpath + ['manpages', '*.*']))):
             env.Execute(Copy(os.path.join(build_dir, *(dbpath + ['manpages'])), g))
+        for g in glob.glob(os.path.join('..', *(dbpath + ['epub', '*.xsl']))):
+            env.Execute(Copy(os.path.join(build_dir, *(dbpath + ['epub'])), g))
+        for g in glob.glob(os.path.join('..', *(dbpath + ['xhtml-1_1', '*.*']))):
+            env.Execute(Copy(os.path.join(build_dir, *(dbpath + ['xhtml-1_1'])), g))
+
+        #
+        # Copy additional Tools (gs, zip)
+        #
+        toolpath = ['src', 'engine', 'SCons', 'Tool']
+        env.Execute(Copy(os.path.join(build_dir, *toolpath),
+                         os.path.join('..', *(toolpath + ['gs.py']))))
+        env.Execute(Copy(os.path.join(build_dir, *toolpath),
+                         os.path.join('..', *(toolpath + ['zip.py']))))
+
 
     #
     # Each document will live in its own subdirectory.  List them here
             #'python10' : ['chtml','html','pdf'],
             'reference' : ['chtml','html','pdf'],
             #'developer' : ['chtml','html','pdf'],
-            'user' : ['chtml','html','pdf'],
-            'man' : ['man']
+            'user' : ['chtml','html','pdf','epub'],
+            'man' : ['man','epub']
            }
     # The names of the target files for the MAN pages
     man_page_list = ['scons.1','scons-time.1','sconsign.1']
         htmlindex = os.path.join(htmldir, 'index.html')
         html = os.path.join(build, 'HTML', 'scons-%s.html' % doc)
         pdf = os.path.join(build, 'PDF', 'scons-%s.pdf' % doc)
+        epub = os.path.join(build, 'EPUB', 'scons-%s.epub' % doc)
         if 'chtml' in docs[doc]:
             env.Install(htmldir, Glob(os.path.join(build, doc,'scons-%s' % doc, '*.html')))
             tar_deps.extend([htmlindex])
 
             tar_deps.append(pdf)
             tar_list.append(pdf)
+
+        if 'epub' in docs[doc] and gs:
+            env.InstallAs(epub, os.path.join(build, doc,'scons-%s.epub' % doc))
+            Local(epub)
+            env.Ignore(epub, version_xml)
+
+            tar_deps.append(epub)
+            tar_list.append(epub)
             
         if 'man' in docs[doc]:
             #
 sconsign.xml
 scons-time.xml
 *.xsl
-scons.css
+*.css
 SConstruct
+cover.jpg
 titlepage/bricks.jpg
 titlepage/mapnik_final_colors.svg
 titlepage/SCons_path.svg

doc/man/SConstruct

 import os
 
 env = Environment(ENV={'PATH' : os.environ['PATH']},
-                  tools=['docbook'],
+                  tools=['docbook','gs','zip'],
                   toolpath=['../../src/engine/SCons/Tool'],
                   DOCBOOK_DEFAULT_XSL_HTML='html.xsl',
                   DOCBOOK_DEFAULT_XSL_PDF='pdf.xsl')
 createManPages(env, "scons")
 createManPages(env, "sconsign")
 createManPages(env, "scons-time")
+
+has_gs = False
+if env.WhereIs('gs'):
+    has_gs = True
+
+#
+# Create the EPUB format
+#
+if has_gs and has_pdf:
+    metainf = env.Command('META-INF','',[Mkdir('META-INF'), Mkdir('OEBPS')])
+    css = env.Command('OEBPS/epub.css','epub.css',[Copy('OEBPS/epub.css','epub.css')])
+    env.Depends(css, metainf)
+    jpg = env.Gs('OEBPS/cover.jpg','scons-scons.pdf', 
+                 GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=100 -r72x72 -q')
+    env.Depends(jpg, metainf)
+    oebps = env.DocbookXslt('OEBPS/toc.ncx', 'scons_db.xml', xsl='epub.xsl')
+    env.Depends(oebps, jpg)
+    env.Zip('scons-man.epub', 'OEBPS', ZIPFLAGS='-Xr9D')
+    env.Clean(oebps, Glob('OEBPS/*.*'))
+    env.Clean(oebps, Glob('META-INF/*.*'))

doc/man/cover.jpg

Added
New image
+/* This defines styles and classes used in the book */
+body { }
+code { font-family: monospace; }
+h1, h2, h3, h4, h5, h6 { text-align: center; margin-bottom:2em;}
+h1.title { }
+h2.author { }
+p{
+	padding:0;
+	margin:0;
+	text-indent:2em;
+}
+blockquote{
+	margin-left:3em;
+	margin-right:3em;
+}
+.caption{
+	text-align:center;
+	font-style:italic;
+	margin-bottom:1em;
+	margin-top:.2em;
+	font-size:.8em;
+}
+blockquote > p{
+	text-indent:0;
+	margin-bottom:1em;
+}
+img{
+	display:block;
+	margin-left: auto;
+	margin-right: auto;
+	text-align:center;
+	margin-top:1em;
+}
+<?xml version='1.0'?>
+<!--
+
+  __COPYRIGHT__
+
+  Permission is hereby granted, free of charge, to any person obtaining
+  a copy of this software and associated documentation files (the
+  "Software"), to deal in the Software without restriction, including
+  without limitation the rights to use, copy, modify, merge, publish,
+  distribute, sublicense, and/or sell copies of the Software, and to
+  permit persons to whom the Software is furnished to do so, subject to
+  the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+  KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+  WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+-->
+<xsl:stylesheet
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
+	version="1.0"> 
+
+	<xsl:import href="../../src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/epub/docbook.xsl"/> 
+
+<xsl:param name="html.stylesheet" select="'epub.css'"/>
+
+</xsl:stylesheet> 
 set       toc,title
 </xsl:param>
 
+<!-- Prevent our EPUB cover image from getting included -->
+<xsl:template match="mediaobject[@role = 'cover']">
+</xsl:template>
+
 </xsl:stylesheet> 
 
   <xsl:apply-templates select="." mode="vl.as.blocks"/>
 </xsl:template>
 
+<!-- Prevent our EPUB cover image from getting printed to the PDF -->
+<xsl:template match="mediaobject[@role = 'cover']">
+</xsl:template>
+
 </xsl:stylesheet> 
-

doc/man/scons.xml

     </copyright>
 
     <releaseinfo>version &buildversion;</releaseinfo>
+    
+    <mediaobject role="cover"><imageobject><imagedata fileref="cover.jpg" format="JPG"/></imageobject></mediaobject>
+    
   </referenceinfo>
   
   <title>SCons &buildversion;</title>

doc/user/MANIFEST

 variables.xml
 *.jpg
 *.xsl
-scons.css
+*.css
 SConstruct
 titlepage/bricks.jpg
 titlepage/mapnik_final_colors.svg

doc/user/SConstruct

 import os
 
 env = Environment(ENV={'PATH' : os.environ['PATH']},
-                  tools=['docbook'], 
+                  tools=['docbook','gs','zip'], 
                   toolpath=['../../src/engine/SCons/Tool'],
                   DOCBOOK_DEFAULT_XSL_HTML='html.xsl',
                   DOCBOOK_DEFAULT_XSL_HTMLCHUNKED='chtml.xsl',
 env.DocbookHtmlChunked('index.html', 'scons_db.xml', base_dir='scons-user/')
 if has_pdf:
     env.DocbookPdf('scons-user.pdf','scons_db.xml')
+
+has_gs = False
+if env.WhereIs('gs'):
+    has_gs = True
+
+#
+# Create the EPUB format
+#
+if has_gs and has_pdf:
+    metainf = env.Command('META-INF','',[Mkdir('META-INF'), Mkdir('OEBPS')])
+    css = env.Command('OEBPS/epub.css','epub.css',[Copy('OEBPS/epub.css','epub.css')])
+    env.Depends(css, metainf)
+    jpg = env.Gs('OEBPS/cover.jpg','scons-user.pdf', 
+                 GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=100 -r72x72 -q')
+    env.Depends(jpg, metainf)
+    oebps = env.DocbookXslt('OEBPS/toc.ncx', 'scons_db.xml', xsl='epub.xsl')
+    env.Depends(oebps, jpg)
+    env.Zip('scons-user.epub', 'OEBPS', ZIPFLAGS='-Xr9D')
+    env.Clean(oebps, Glob('OEBPS/*.*'))
+    env.Clean(oebps, Glob('META-INF/*.*'))

doc/user/chtml.xsl

 set       toc,title
 </xsl:param>
 
+<!-- Prevent our EPUB cover image from getting included -->
+<xsl:template match="mediaobject[@role = 'cover']">
+</xsl:template>
+
 </xsl:stylesheet> 
 

doc/user/cover.jpg

Added
New image

doc/user/epub.css

+/* This defines styles and classes used in the book */
+body { }
+code { font-family: monospace; }
+h1, h2, h3, h4, h5, h6 { text-align: center; margin-bottom:2em;}
+h1.title { }
+h2.author { }
+p{
+	padding:0;
+	margin:0;
+	text-indent:2em;
+}
+blockquote{
+	margin-left:3em;
+	margin-right:3em;
+}
+.caption{
+	text-align:center;
+	font-style:italic;
+	margin-bottom:1em;
+	margin-top:.2em;
+	font-size:.8em;
+}
+blockquote > p{
+	text-indent:0;
+	margin-bottom:1em;
+}
+img{
+	display:block;
+	margin-left: auto;
+	margin-right: auto;
+	text-align:center;
+	margin-top:1em;
+}

doc/user/epub.xsl

+<?xml version='1.0'?>
+<!--
+
+  __COPYRIGHT__
+
+  Permission is hereby granted, free of charge, to any person obtaining
+  a copy of this software and associated documentation files (the
+  "Software"), to deal in the Software without restriction, including
+  without limitation the rights to use, copy, modify, merge, publish,
+  distribute, sublicense, and/or sell copies of the Software, and to
+  permit persons to whom the Software is furnished to do so, subject to
+  the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+  KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+  WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+-->
+<xsl:stylesheet
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
+	version="1.0"> 
+
+	<xsl:import href="../../src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/epub/docbook.xsl"/> 
+
+<xsl:param name="html.stylesheet" select="'epub.css'"/>
+
+</xsl:stylesheet> 
+

doc/user/html.xsl

 set       toc,title
 </xsl:param>
 
+<!-- Prevent our EPUB cover image from getting included -->
+<xsl:template match="mediaobject[@role = 'cover']">
+</xsl:template>
+
 </xsl:stylesheet> 
 

doc/user/main.xml

     
     <releaseinfo>version &buildversion;</releaseinfo>
 
+    <mediaobject role="cover"><imageobject><imagedata fileref="cover.jpg" format="JPG"/></imageobject></mediaobject>
   </bookinfo>
 
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="preface.xml"/>
   <xsl:apply-templates select="." mode="vl.as.blocks"/>
 </xsl:template>
 
+<!-- Prevent our EPUB cover image from getting printed to the PDF -->
+<xsl:template match="mediaobject[@role = 'cover']">
+</xsl:template>
+
 </xsl:stylesheet>