python-tldp/tldp/doctypes/asciidoc.py

74 lines
2.2 KiB
Python
Raw Normal View History

2016-02-12 21:25:19 +00:00
#! /usr/bin/python
2016-02-18 21:25:02 +00:00
# -*- coding: utf8 -*-
2016-02-12 21:25:19 +00:00
2016-03-05 01:10:30 +00:00
from __future__ import absolute_import, division, print_function
import logging
2016-02-12 21:25:19 +00:00
2016-03-05 01:10:30 +00:00
from tldp.utils import which
from tldp.utils import arg_isexecutable, isexecutable
from tldp.doctypes.common import BaseDoctype, depends
2016-02-12 21:25:19 +00:00
2016-02-26 19:56:28 +00:00
logger = logging.getLogger(__name__)
class Asciidoc(BaseDoctype):
2016-02-12 21:25:19 +00:00
formatname = 'AsciiDoc'
extensions = ['.txt']
signatures = []
required = {'asciidoc_sgml2html': isexecutable,
'asciidoc_html2text': isexecutable,
'asciidoc_htmldoc': isexecutable,
'asciidoc_a2x': isexecutable,
2016-03-05 01:10:30 +00:00
}
def make_name_pdf(self):
s = '''"{config.asciidoc_a2x}" \\
--verbose \\
--format pdf \\
--destination-dir . \\
"{source.filename}"'''
return self.shellscript(s)
def make_name_txt(self):
s = 'cp --verbose --target-directory . -- "{source.filename}"'
return self.shellscript(s)
def make_name_htmls(self):
s = '''"{config.asciidoc_a2x}" \\
--verbose \\
--format xhtml \\
--destination-dir . \\
"{source.filename}"'''
return self.shellscript(s)
def make_chunked_html(self):
s = '''"{config.asciidoc_a2x}" \\
--verbose \\
--format chunked \\
--destination-dir . \\
"{source.filename}"'''
return self.shellscript(s)
2016-02-12 21:25:19 +00:00
@depends(make_chunked_html)
2016-03-05 01:10:30 +00:00
def move_chunked_html(self):
2016-03-05 05:34:44 +00:00
s = 'mv --no-clobber -v -- "{output.stem}.chunked" html'
2016-03-05 01:10:30 +00:00
return self.shellscript(s)
2016-02-12 21:25:19 +00:00
@depends(move_chunked_html)
2016-03-05 01:10:30 +00:00
def make_name_html(self):
s = 'ln -sv --relative -- html/index.html {output.name_indexhtml}'
return self.shellscript(s)
2016-02-12 21:25:19 +00:00
2016-03-05 01:10:30 +00:00
@classmethod
def argparse(cls, p):
descrip = 'executables and data files for %s' % (cls.formatname,)
g = p.add_argument_group(title=cls.__name__, description=descrip)
g.add_argument('--asciidoc-a2x', type=arg_isexecutable,
default=which('a2x'),
help='full path to a2x [%(default)s]')
2016-02-12 21:25:19 +00:00
#
# -- end of file