python-tldp/tldp/doctypes/linuxdoc.py

88 lines
2.2 KiB
Python
Raw Normal View History

2016-02-11 03:22:23 +00:00
#! /usr/bin/python
2016-02-18 21:25:02 +00:00
# -*- coding: utf8 -*-
2016-02-11 03:22:23 +00:00
from __future__ import absolute_import, division, print_function
2016-02-11 17:15:50 +00:00
import os
from tldp.utils import logger, which, execute
from tldp.utils import arg_isexecutable, isexecutable
from tldp.doctypes.common import BaseDoctype, SignatureChecker
2016-02-11 03:22:23 +00:00
class Linuxdoc(BaseDoctype, SignatureChecker):
formatname = 'Linuxdoc'
2016-02-11 03:22:23 +00:00
extensions = ['.sgml']
signatures = ['<!doctype linuxdoc system', ]
required = {'linuxdoc_sgml2html': isexecutable,
'linuxdoc_html2text': isexecutable,
'linuxdoc_htmldoc': isexecutable,
}
buildorder = ['buildall']
buildscript = '''#! /bin/bash
#
# -- generate LDP outputs from DocBook XML 4.x
set -x
set -e
set -o pipefail
cd "{output.dirname}"
# -- implicitly creates {output.name_html}
"{config.linuxdoc_sgml2html}" \\
--split=0 \\
"{source.filename}"
# -- .... so, it must be rename to {output.name_htmls}
mv \\
--no-clobber \\
--verbose \\
-- "{output.name_html}" "{output.name_htmls}"
"{config.linuxdoc_html2text}" > "{output.name_txt}" \\
-style pretty \\
-nobs \\
"{output.name_htmls}"
"{config.linuxdoc_htmldoc}" \\
--size universal \\
-t pdf \\
--firstpage p1 \\
--outfile "{output.name_pdf}" \\
"{output.name_htmls}"
# -- implicitly creates {output.name_html}
"{config.linuxdoc_sgml2html}" \\
"{source.filename}"
ln \
--symbolic \
--relative \
--verbose \
-- "{output.name_html}" "{output.name_indexhtml}"
# -- end of file'''
def buildall(self):
return self.shellscript(self.buildscript)
2016-02-11 03:22:23 +00:00
@staticmethod
def argparse(p):
p.add_argument('--linuxdoc-sgml2html', type=arg_isexecutable,
default=which('sgml2html'),
help='full path to sgml2html [%(default)s]')
p.add_argument('--linuxdoc-html2text', type=arg_isexecutable,
default=which('html2text'),
help='full path to html2text [%(default)s]')
p.add_argument('--linuxdoc-htmldoc', type=arg_isexecutable,
default=which('htmldoc'),
help='full path to htmldoc [%(default)s]')
2016-02-11 03:22:23 +00:00
#
# -- end of file