From 55cc7d5775cb2a5b9a913d060b5c499f7257eb35 Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Sat, 27 Feb 2016 09:45:32 -0800 Subject: [PATCH] improve visual grouping of --help output use argparse's ArgumentGroups to separate the argparse options for each of the processors --- tldp/doctypes/docbook4xml.py | 20 +++++++++++--------- tldp/doctypes/docbook5xml.py | 14 ++++++++------ tldp/doctypes/docbooksgml.py | 22 ++++++++++++---------- tldp/doctypes/linuxdoc.py | 12 +++++++----- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/tldp/doctypes/docbook4xml.py b/tldp/doctypes/docbook4xml.py index 3c12021..b9cf440 100644 --- a/tldp/doctypes/docbook4xml.py +++ b/tldp/doctypes/docbook4xml.py @@ -159,27 +159,29 @@ class Docbook4XML(BaseDoctype, SignatureChecker): s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"' return self.shellscript(s) - @staticmethod - def argparse(p): - p.add_argument('--docbook4xml-xslchunk', type=arg_isreadablefile, + @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('--docbook4xml-xslchunk', type=arg_isreadablefile, default=xslchunk_finder(), help='full path to LDP HTML chunker XSL [%(default)s]') - p.add_argument('--docbook4xml-xslsingle', type=arg_isreadablefile, + g.add_argument('--docbook4xml-xslsingle', type=arg_isreadablefile, default=xslsingle_finder(), help='full path to LDP HTML single-page XSL [%(default)s]') - p.add_argument('--docbook4xml-xslprint', type=arg_isreadablefile, + g.add_argument('--docbook4xml-xslprint', type=arg_isreadablefile, default=xslprint_finder(), help='full path to LDP FO print XSL [%(default)s]') - p.add_argument('--docbook4xml-xsltproc', type=arg_isexecutable, + g.add_argument('--docbook4xml-xsltproc', type=arg_isexecutable, default=which('xsltproc'), help='full path to xsltproc [%(default)s]') - p.add_argument('--docbook4xml-html2text', type=arg_isexecutable, + g.add_argument('--docbook4xml-html2text', type=arg_isexecutable, default=which('html2text'), help='full path to html2text [%(default)s]') - p.add_argument('--docbook4xml-fop', type=arg_isexecutable, + g.add_argument('--docbook4xml-fop', type=arg_isexecutable, default=which('fop'), help='full path to fop [%(default)s]') - p.add_argument('--docbook4xml-dblatex', type=arg_isexecutable, + g.add_argument('--docbook4xml-dblatex', type=arg_isexecutable, default=which('dblatex'), help='full path to dblatex [%(default)s]') diff --git a/tldp/doctypes/docbook5xml.py b/tldp/doctypes/docbook5xml.py index 3da75f1..d28983a 100644 --- a/tldp/doctypes/docbook5xml.py +++ b/tldp/doctypes/docbook5xml.py @@ -30,18 +30,20 @@ class Docbook5XML(BaseDoctype, SignatureChecker): def create_htmls(self): logger.info("Creating single page HTML for %s", self.source.stem) - @staticmethod - def argparse(p): - p.add_argument('--docbook5xml-xsltproc', type=which, + @classmethod + def argparse(cls, p): + descrip = 'executables for %s' % (cls.formatname,) + g = p.add_argument_group(title=cls.__name__, description=descrip) + g.add_argument('--docbook5xml-xsltproc', type=which, default=which('xsltproc'), help='full path to xsltproc [%(default)s]') - p.add_argument('--docbook5xml-html2text', type=which, + g.add_argument('--docbook5xml-html2text', type=which, default=which('html2text'), help='full path to html2text [%(default)s]') - p.add_argument('--docbook5xml-fop', type=which, + g.add_argument('--docbook5xml-fop', type=which, default=which('fop'), help='full path to fop [%(default)s]') - p.add_argument('--docbook5xml-dblatex', type=which, + g.add_argument('--docbook5xml-dblatex', type=which, default=which('dblatex'), help='full path to dblatex [%(default)s]') diff --git a/tldp/doctypes/docbooksgml.py b/tldp/doctypes/docbooksgml.py index 6c6a98b..c9a0875 100644 --- a/tldp/doctypes/docbooksgml.py +++ b/tldp/doctypes/docbooksgml.py @@ -237,28 +237,30 @@ class DocbookSGML(BaseDoctype, SignatureChecker): s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"' return self.shellscript(s) - @staticmethod - def argparse(p): - p.add_argument('--docbooksgml-docbookdsl', type=arg_isreadablefile, + @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('--docbooksgml-docbookdsl', type=arg_isreadablefile, default=docbookdsl_finder(), help='full path to html/docbook.dsl [%(default)s]') - p.add_argument('--docbooksgml-ldpdsl', type=arg_isreadablefile, + g.add_argument('--docbooksgml-ldpdsl', type=arg_isreadablefile, default=ldpdsl_finder(), help='full path to ldp/ldp.dsl [%(default)s]') - p.add_argument('--docbooksgml-jw', type=arg_isexecutable, + g.add_argument('--docbooksgml-jw', type=arg_isexecutable, default=which('jw'), help='full path to jw [%(default)s]') - p.add_argument('--docbooksgml-html2text', type=arg_isexecutable, + g.add_argument('--docbooksgml-html2text', type=arg_isexecutable, default=which('html2text'), help='full path to html2text [%(default)s]') - p.add_argument('--docbooksgml-openjade', type=arg_isexecutable, + g.add_argument('--docbooksgml-openjade', type=arg_isexecutable, default=which('openjade'), help='full path to openjade [%(default)s]') - p.add_argument('--docbooksgml-dblatex', type=arg_isexecutable, + g.add_argument('--docbooksgml-dblatex', type=arg_isexecutable, default=which('dblatex'), help='full path to dblatex [%(default)s]') - p.add_argument('--docbooksgml-collateindex', type=arg_isexecutable, - default=which('collateindex'), + g.add_argument('--docbooksgml-collateindex', type=arg_isexecutable, + default=which('collateindex.pl'), help='full path to collateindex [%(default)s]') # diff --git a/tldp/doctypes/linuxdoc.py b/tldp/doctypes/linuxdoc.py index f79f1da..6b71f74 100644 --- a/tldp/doctypes/linuxdoc.py +++ b/tldp/doctypes/linuxdoc.py @@ -89,15 +89,17 @@ class Linuxdoc(BaseDoctype, SignatureChecker): s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"' return self.shellscript(s) - @staticmethod - def argparse(p): - p.add_argument('--linuxdoc-sgml2html', type=arg_isexecutable, + @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('--linuxdoc-sgml2html', type=arg_isexecutable, default=which('sgml2html'), help='full path to sgml2html [%(default)s]') - p.add_argument('--linuxdoc-html2text', type=arg_isexecutable, + g.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, + g.add_argument('--linuxdoc-htmldoc', type=arg_isexecutable, default=which('htmldoc'), help='full path to htmldoc [%(default)s]')