* src/plugins/CmdRef.py: Work out Report docs.

* src/Report.py: Typo.


svn: r5285
This commit is contained in:
Alex Roitman 2005-10-06 21:53:49 +00:00
parent 038cbfa9bb
commit 4f86f7d28b
3 changed files with 80 additions and 58 deletions

View File

@ -1,3 +1,7 @@
2005-10-06 Alex Roitman <shura@gramps-project.org>
* src/plugins/CmdRef.py: Work out Report docs.
* src/Report.py: Typo.
2005-10-06 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-10-06 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/CmdRef.py: New file. * src/plugins/CmdRef.py: New file.

View File

@ -1596,7 +1596,7 @@ class CommandLineReport:
def init_options(self): def init_options(self):
self.options_dict = { self.options_dict = {
'of' : self.option_class.handler.report_name, 'of' : self.option_class.handler.module_name,
'off' : self.option_class.handler.get_format_name(), 'off' : self.option_class.handler.get_format_name(),
'style' : self.option_class.handler.get_default_stylesheet_name(), 'style' : self.option_class.handler.get_default_stylesheet_name(),
'papers' : self.option_class.handler.get_paper_name(), 'papers' : self.option_class.handler.get_paper_name(),

View File

@ -22,14 +22,14 @@
"Export Report and Tools commandline parameters to DocBook XML" "Export Report and Tools commandline parameters to DocBook XML"
import os
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# python modules # python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os
import tempfile import tempfile
from cgi import escape
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -40,6 +40,7 @@ from gettext import gettext as _
import Tool import Tool
import Utils import Utils
import PluginMgr import PluginMgr
import Report
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -55,75 +56,90 @@ class CmdRef(Tool.Tool):
f = tempfile.NamedTemporaryFile() f = tempfile.NamedTemporaryFile()
fname = f.name fname = f.name
f.write('<?xml version="1.0" encoding="UTF-8"?>\n') f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
f.write('<?yelp:chunk-depth 2?>\n')
f.write('<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" ') f.write('<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" ')
f.write(' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">\n') f.write(' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">\n')
f.write('<appendix id="plugin_ref" lang="en">\n') f.write('<article id="index" lang="en">\n')
f.write(' <title>Reports and Tools parameter reference</title>\n') f.write(' <title>Reports and Tools parameter reference</title>\n')
f.write(' <sect1 id="reps">\n') f.write(' <sect1 id="reps">\n')
f.write(' <title>Reports</title>\n') f.write(' <title>Reports</title>\n')
counter=0
for item in PluginMgr.cl_list: for item in PluginMgr.cl_list:
self.write_ref( f, item) category = item[1]
if category in (Report.CATEGORY_BOOK,
Report.CATEGORY_CODE,
Report.CATEGORY_WEB):
self.write_ref(f,item,counter,category)
else:
self.write_ref( f, item, counter, None)
counter = counter + 1
f.write(' </sect1>\n') f.write(' </sect1>\n')
f.write(' <sect1 id="plugin_ref_tools">\n') f.write(' <sect1 id="tools">\n')
f.write(' <title>Tools</title>\n') f.write(' <title>Tools</title>\n')
for item in PluginMgr.cli_tool_list: for item in PluginMgr.cli_tool_list:
self.write_ref( f, item) self.write_ref( f, item, counter)
f.write(' </sect1>') counter = counter + 1
f.write(' ') f.write(' </sect1>\n')
f.write(' ') f.write(' \n')
f.write(' ') f.write(' \n')
f.write('</appendix>') f.write(' \n')
f.write('</article>\n')
f.flush() f.flush()
os.spawnlp( os.P_WAIT, "yelp", "yelp", fname) os.spawnlp( os.P_WAIT, "yelp", "yelp", fname)
f.close() f.close()
def fix(self,line): def write_ref( self, f, item,counter,category=None):
l = line.strip() f.write('<sect2 id="sect2id%d">\n' % counter)
l = l.replace('&','&amp;') f.write(' <title>%s</title>\n' % item[0])
l = l.replace('>','&gt;') f.write(' <simplesect>\n')
l = l.replace('<','&lt;') f.write(' <title>Options</title>\n')
return l.replace('"','&quot;') f.write(' <variablelist>\n')
if category == None:
def write_ref( self, f, item):
f.write('<sect2 id="tool_opt_%s">\n' % item[0])
f.write(' <title>%s</title>\n' % self.fix(item[0]))
try: # For Tools
oclass = item[3]( item[0]) oclass = item[3]( item[0])
except: # For Reports elif category == Report.CATEGORY_BOOK:
oclass = item[3] import BookReport
try: oclass = BookReport.BookOptions(item[0])
ohelp = oclass.options_help elif category == Report.CATEGORY_CODE:
except: import GraphViz
ohelp = None oclass = GraphViz.GraphVizOptions(item[0])
if ohelp: elif category == Report.CATEGORY_WEB:
f.write(' <simplesect>\n') if item[0] == "webpage":
f.write(' <title>Options</title>\n') import WebPage
f.write(' <variablelist>\n') oclass = WebPage.WebReportOptions(item[0])
for arg in ohelp.keys(): elif item[0] == "navwebpage":
f.write(' <variablelist>\n') import NavWebPage
f.write(' <varlistentry>\n') oclass = NavWebPage.WebReportOptions(item[0])
f.write(' <term><command>%s</command>: %s</term>\n' % (self.fix(arg), self.fix(ohelp[arg][0])))
f.write(' <listitem>\n') for arg in oclass.options_help.keys():
f.write(' <para>%s</para>\n' % self.fix(ohelp[arg][1])) f.write(' <variablelist>\n')
if type(ohelp[arg][2]) in [list,tuple]: f.write(' <varlistentry>\n')
if ohelp[arg][3]: f.write(' <term><command>%s</command>: %s</term>\n'
f.write(' <orderedlist>\n') % (escape(arg), escape(oclass.options_help[arg][0])))
for val in ohelp[arg][2]: f.write(' <listitem>\n')
f.write( " <listitem>%s</listitem>\n" % self.fix(val)) f.write(' <para>%s</para>\n'
f.write(' </orderedlist>\n') % escape(oclass.options_help[arg][1]))
else: if type(oclass.options_help[arg][2]) in [list,tuple]:
f.write(' <itemizedlist>\n') if oclass.options_help[arg][3]:
for val in ohelp[arg][2]: f.write(' <orderedlist>\n')
f.write( " <listitem>%s</listitem>\n" % self.fix(val)) for val in oclass.options_help[arg][2]:
f.write(' </itemizedlist>\n') f.write( " <listitem>%s</listitem>\n"
% escape(val))
f.write(' </orderedlist>\n')
else: else:
f.write(' <para>Value: <userinput>%s</userinput></para>\n' % self.fix(ohelp[arg][2])) f.write(' <itemizedlist>\n')
f.write(' </listitem>\n') for val in oclass.options_help[arg][2]:
f.write(' </varlistentry>\n') f.write( " <listitem>%s</listitem>\n"
f.write(' </variablelist>\n') % escape(val))
f.write(' </itemizedlist>\n')
else:
f.write(' <para>Value: <userinput>%s</userinput></para>\n'
% escape(oclass.options_help[arg][2]))
f.write(' </listitem>\n')
f.write(' </varlistentry>\n')
f.write(' </variablelist>\n')
f.write(' </variablelist>\n') f.write(' </variablelist>\n')
f.write(' </simplesect>\n') f.write(' </simplesect>\n')
f.write('</sect2>\n') f.write('</sect2>\n')
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -139,8 +155,10 @@ register_tool(
tool_class = CmdRef, tool_class = CmdRef,
options_class = Tool.ToolOptions, options_class = Tool.ToolOptions,
modes = Tool.MODE_GUI | Tool.MODE_CLI, modes = Tool.MODE_GUI | Tool.MODE_CLI,
translated_name = _("Generate Commandline Reference for Reports and Tools"), translated_name = _("Generate Commandline Reference "
"for Reports and Tools"),
author_name = "Martin Hawlisch", author_name = "Martin Hawlisch",
author_email = "martin@hawlisch.de", author_email = "martin@hawlisch.de",
description=_("Generates a DocBook XML file that contains a parameter reference of Reports and Tools.") description=_("Generates a DocBook XML file that contains "
"a parameter reference of Reports and Tools.")
) )