From ef9d8a0031b3ca6faabb0746eeb2a7da519fb805 Mon Sep 17 00:00:00 2001 From: Dirk Baechle Date: Tue, 8 Oct 2013 15:45:37 +0200 Subject: - added EPUB as output format for documentation ("user" and "man" targets) --- doc/SConscript | 30 ++++++++++++++++++++++++++++-- doc/man/MANIFEST | 3 ++- doc/man/SConstruct | 22 +++++++++++++++++++++- doc/man/cover.jpg | Bin 0 -> 306 bytes doc/man/epub.css | 33 +++++++++++++++++++++++++++++++++ doc/man/epub.xsl | 35 +++++++++++++++++++++++++++++++++++ doc/man/html.xsl | 4 ++++ doc/man/pdf.xsl | 5 ++++- doc/man/scons.xml | 3 +++ doc/user/MANIFEST | 2 +- doc/user/SConstruct | 22 +++++++++++++++++++++- doc/user/chtml.xsl | 4 ++++ doc/user/cover.jpg | Bin 0 -> 306 bytes doc/user/epub.css | 33 +++++++++++++++++++++++++++++++++ doc/user/epub.xsl | 36 ++++++++++++++++++++++++++++++++++++ doc/user/html.xsl | 4 ++++ doc/user/main.xml | 1 + doc/user/pdf.xsl | 4 ++++ 18 files changed, 234 insertions(+), 7 deletions(-) create mode 100644 doc/man/cover.jpg create mode 100644 doc/man/epub.css create mode 100644 doc/man/epub.xsl create mode 100644 doc/user/cover.jpg create mode 100644 doc/user/epub.css create mode 100644 doc/user/epub.xsl diff --git a/doc/SConscript b/doc/SConscript index 8dcf697..c731dab 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -41,6 +41,7 @@ build = os.path.join(build_dir, 'doc') fop = whereis('fop') xep = whereis('xep') epydoc_cli = whereis('epydoc') +gs = whereis('gs') # # @@ -158,6 +159,8 @@ else: 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', '*.*']))): @@ -170,6 +173,20 @@ else: 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 @@ -182,8 +199,8 @@ else: #'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'] @@ -247,6 +264,7 @@ else: 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]) @@ -268,6 +286,14 @@ else: 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]: # diff --git a/doc/man/MANIFEST b/doc/man/MANIFEST index 7f0ad45..4b3ce9f 100644 --- a/doc/man/MANIFEST +++ b/doc/man/MANIFEST @@ -5,8 +5,9 @@ scons.xml sconsign.xml scons-time.xml *.xsl -scons.css +*.css SConstruct +cover.jpg titlepage/bricks.jpg titlepage/mapnik_final_colors.svg titlepage/SCons_path.svg diff --git a/doc/man/SConstruct b/doc/man/SConstruct index cd94021..cfdbb2d 100644 --- a/doc/man/SConstruct +++ b/doc/man/SConstruct @@ -27,7 +27,7 @@ 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') @@ -53,3 +53,23 @@ def createManPages(env, target): 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/*.*')) diff --git a/doc/man/cover.jpg b/doc/man/cover.jpg new file mode 100644 index 0000000..e2c2cb3 Binary files /dev/null and b/doc/man/cover.jpg differ diff --git a/doc/man/epub.css b/doc/man/epub.css new file mode 100644 index 0000000..31cebe5 --- /dev/null +++ b/doc/man/epub.css @@ -0,0 +1,33 @@ +/* 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; +} diff --git a/doc/man/epub.xsl b/doc/man/epub.xsl new file mode 100644 index 0000000..bc1d4b3 --- /dev/null +++ b/doc/man/epub.xsl @@ -0,0 +1,35 @@ + + + + + + + + + diff --git a/doc/man/html.xsl b/doc/man/html.xsl index 71a847a..864af88 100644 --- a/doc/man/html.xsl +++ b/doc/man/html.xsl @@ -51,5 +51,9 @@ reference title set toc,title + + + + diff --git a/doc/man/pdf.xsl b/doc/man/pdf.xsl index 652975f..f314103 100644 --- a/doc/man/pdf.xsl +++ b/doc/man/pdf.xsl @@ -67,5 +67,8 @@ set toc,title - + + + + diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 3f47b47..82c782d 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -60,6 +60,9 @@ version &buildversion; + + + SCons &buildversion; diff --git a/doc/user/MANIFEST b/doc/user/MANIFEST index e5f8988..62da288 100644 --- a/doc/user/MANIFEST +++ b/doc/user/MANIFEST @@ -51,7 +51,7 @@ variants.xml variables.xml *.jpg *.xsl -scons.css +*.css SConstruct titlepage/bricks.jpg titlepage/mapnik_final_colors.svg diff --git a/doc/user/SConstruct b/doc/user/SConstruct index 002aea4..5d36a5e 100644 --- a/doc/user/SConstruct +++ b/doc/user/SConstruct @@ -27,7 +27,7 @@ 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', @@ -51,3 +51,23 @@ env.DocbookHtml('index.html','scons_db.xml') 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/*.*')) diff --git a/doc/user/chtml.xsl b/doc/user/chtml.xsl index fa01b46..e292c88 100644 --- a/doc/user/chtml.xsl +++ b/doc/user/chtml.xsl @@ -52,5 +52,9 @@ reference toc,title set toc,title + + + + diff --git a/doc/user/cover.jpg b/doc/user/cover.jpg new file mode 100644 index 0000000..e2c2cb3 Binary files /dev/null and b/doc/user/cover.jpg differ diff --git a/doc/user/epub.css b/doc/user/epub.css new file mode 100644 index 0000000..31cebe5 --- /dev/null +++ b/doc/user/epub.css @@ -0,0 +1,33 @@ +/* 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; +} diff --git a/doc/user/epub.xsl b/doc/user/epub.xsl new file mode 100644 index 0000000..6ff435c --- /dev/null +++ b/doc/user/epub.xsl @@ -0,0 +1,36 @@ + + + + + + + + + + diff --git a/doc/user/html.xsl b/doc/user/html.xsl index 74ea529..c275c3d 100644 --- a/doc/user/html.xsl +++ b/doc/user/html.xsl @@ -51,5 +51,9 @@ reference toc,title set toc,title + + + + diff --git a/doc/user/main.xml b/doc/user/main.xml index cb516e1..60dd8c9 100644 --- a/doc/user/main.xml +++ b/doc/user/main.xml @@ -85,6 +85,7 @@ version &buildversion; + diff --git a/doc/user/pdf.xsl b/doc/user/pdf.xsl index 652975f..9c54592 100644 --- a/doc/user/pdf.xsl +++ b/doc/user/pdf.xsl @@ -67,5 +67,9 @@ set toc,title + + + + -- cgit v0.12