rework the build sequence

adapt all of the methods to the new topological-sort driven technique
This commit is contained in:
Martin A. Brown 2016-02-26 01:02:16 -08:00
parent 74bdfcd44f
commit 4e76494cce
1 changed files with 47 additions and 45 deletions

View File

@ -5,11 +5,13 @@ from __future__ import absolute_import, division, print_function
import os import os
import logging import logging
logger = logging.getLogger(__name__) import networkx as nx
from tldp.utils import which, execute from tldp.utils import which
from tldp.utils import arg_isexecutable, isexecutable from tldp.utils import arg_isexecutable, isexecutable
from tldp.doctypes.common import BaseDoctype, SignatureChecker from tldp.doctypes.common import BaseDoctype, SignatureChecker, depends
logger = logging.getLogger(__name__)
class Linuxdoc(BaseDoctype, SignatureChecker): class Linuxdoc(BaseDoctype, SignatureChecker):
@ -22,54 +24,56 @@ class Linuxdoc(BaseDoctype, SignatureChecker):
'linuxdoc_htmldoc': isexecutable, 'linuxdoc_htmldoc': isexecutable,
} }
graph = nx.DiGraph()
buildorder = ['buildall'] buildorder = ['buildall']
buildscript = '''#! /bin/bash
#
# -- generate LDP outputs from DocBook XML 4.x
set -x def chdir_output(self):
set -e os.chdir(self.output.dirname)
set -o pipefail return True
cd "{output.dirname}" @depends(graph, chdir_output)
def make_htmls(self):
'''create a single page HTML output (with incorrect name)'''
s = '"{config.linuxdoc_sgml2html}" --split=0 "{source.filename}"'
return self.shellscript(s)
# -- implicitly creates {output.name_html} @depends(graph, make_htmls)
"{config.linuxdoc_sgml2html}" \\ def make_name_htmls(self):
--split=0 \\ '''correct the single page HTML output name'''
"{source.filename}" s = 'mv -v --no-clobber -- "{output.name_html}" "{output.name_htmls}"'
return self.shellscript(s)
# -- .... so, it must be rename to {output.name_htmls} @depends(graph, make_name_htmls)
mv \\ def make_name_txt(self):
--no-clobber \\ '''create text output (from single-page HTML)'''
--verbose \\ s = '''"{config.linuxdoc_html2text}" > "{output.name_txt}" \\
-- "{output.name_html}" "{output.name_htmls}" -style pretty \\
-nobs \\
"{output.name_htmls}"'''
return self.shellscript(s)
"{config.linuxdoc_html2text}" > "{output.name_txt}" \\ @depends(graph, make_name_htmls)
-style pretty \\ def make_name_pdf(self):
-nobs \\ s = '''"{config.linuxdoc_htmldoc}" \\
"{output.name_htmls}" --size universal \\
-t pdf \\
--firstpage p1 \\
--outfile "{output.name_pdf}" \\
"{output.name_htmls}"'''
return self.shellscript(s)
"{config.linuxdoc_htmldoc}" \\ @depends(graph, make_name_htmls)
--size universal \\ def make_name_html(self):
-t pdf \\ '''create final index.html symlink'''
--firstpage p1 \\ s = '"{config.linuxdoc_sgml2html}" "{source.filename}"'
--outfile "{output.name_pdf}" \\ return self.shellscript(s)
"{output.name_htmls}"
# -- implicitly creates {output.name_html} @depends(graph, make_name_html)
"{config.linuxdoc_sgml2html}" \\ def make_name_indexhtml(self):
"{source.filename}" '''create final index.html symlink'''
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
ln \ return self.shellscript(s)
--symbolic \
--relative \
--verbose \
-- "{output.name_html}" "{output.name_indexhtml}"
# -- end of file'''
def buildall(self):
return self.shellscript(self.buildscript)
@staticmethod @staticmethod
def argparse(p): def argparse(p):
@ -83,7 +87,5 @@ ln \
default=which('htmldoc'), default=which('htmldoc'),
help='full path to htmldoc [%(default)s]') help='full path to htmldoc [%(default)s]')
# #
# -- end of file # -- end of file