From c3b626c960e2a2310685b7425b028e0f1f57178c Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Fri, 7 Oct 2005 07:14:09 +0000 Subject: [PATCH] * doc/gramps-manual/C/cmdplug.xml: Add new section documenting plugin options (Reports and Tools). * src/build_cmdplug: Add script to refresh the new doc section. * doc/gramps-manual/C/Makefile.am: Ship new file. * doc/gramps-manual/C/gramps-manual.xml: Define new entity. * doc/gramps-manual/C/cmdline.xml: Include new section. * src/Makefile.am: Define new make target (cmdplug). * src/PluginMgr.py: Include human-readable names in CLI plugins registration. * src/Report.py: Allow instantiation of command-line report without adding item-specific options. * src/Tool.py: Allow instantiation of command-line tool without adding item-specific options. * src/plugins/CmdRef.py: Add options for inclusion into the manual and the target filename; Use human-readable names for titles; Add section with common options; Add name option. svn: r5288 --- gramps2/ChangeLog | 18 + gramps2/doc/gramps-manual/C/Makefile.am | 1 + gramps2/doc/gramps-manual/C/cmdline.xml | 1 + gramps2/doc/gramps-manual/C/cmdplug.xml | 1815 +++++++++++++++++ gramps2/doc/gramps-manual/C/gramps-manual.xml | 1 + gramps2/src/ArgHandler.py | 3 +- gramps2/src/Makefile.am | 3 + gramps2/src/PluginMgr.py | 18 +- gramps2/src/Report.py | 10 +- gramps2/src/Tool.py | 12 +- gramps2/src/build_cmdplug | 10 + gramps2/src/plugins/CmdRef.py | 189 +- 12 files changed, 2019 insertions(+), 62 deletions(-) create mode 100644 gramps2/doc/gramps-manual/C/cmdplug.xml create mode 100755 gramps2/src/build_cmdplug diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index a85d82a6e..41635eb0c 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,21 @@ +2005-10-07 Alex Roitman + * doc/gramps-manual/C/cmdplug.xml: Add new section documenting + plugin options (Reports and Tools). + * src/build_cmdplug: Add script to refresh the new doc section. + * doc/gramps-manual/C/Makefile.am: Ship new file. + * doc/gramps-manual/C/gramps-manual.xml: Define new entity. + * doc/gramps-manual/C/cmdline.xml: Include new section. + * src/Makefile.am: Define new make target (cmdplug). + * src/PluginMgr.py: Include human-readable names in CLI plugins + registration. + * src/Report.py: Allow instantiation of command-line report + without adding item-specific options. + * src/Tool.py: Allow instantiation of command-line tool + without adding item-specific options. + * src/plugins/CmdRef.py: Add options for inclusion into the manual + and the target filename; Use human-readable names for titles; Add + section with common options; Add name option. + 2005-10-06 Don Allingham * src/plugins/DetAncestralReport.py: fix margin on note paragraph * src/DateEdit.py: try using standard icons diff --git a/gramps2/doc/gramps-manual/C/Makefile.am b/gramps2/doc/gramps-manual/C/Makefile.am index b50c756a9..9a946a12e 100644 --- a/gramps2/doc/gramps-manual/C/Makefile.am +++ b/gramps2/doc/gramps-manual/C/Makefile.am @@ -12,6 +12,7 @@ entities = legal.xml\ keybind.xml\ filtref.xml\ cmdline.xml\ + cmdplug.xml\ bugs.xml\ authors.xml include $(top_srcdir)/doc/xmldocs.make diff --git a/gramps2/doc/gramps-manual/C/cmdline.xml b/gramps2/doc/gramps-manual/C/cmdline.xml index c18dd3944..d81ab514e 100644 --- a/gramps2/doc/gramps-manual/C/cmdline.xml +++ b/gramps2/doc/gramps-manual/C/cmdline.xml @@ -319,6 +319,7 @@ + &cmdplug; Operation diff --git a/gramps2/doc/gramps-manual/C/cmdplug.xml b/gramps2/doc/gramps-manual/C/cmdplug.xml new file mode 100644 index 000000000..285f66a46 --- /dev/null +++ b/gramps2/doc/gramps-manual/C/cmdplug.xml @@ -0,0 +1,1815 @@ + + Detailed plugin option reference + + Reports + + Common Options + + + style: =name + + Style name. + + default + + + + + pagebbg: =0/1 + + Page break between generations. + + + + off: =format + + Output file format. + + print + sxw + ps + pdf + svg + + + + + of: =filename + + Output file name. MANDATORY + Value: /home/shura/whatever_name + + + + papero: =num + + Paper orientation number. + + 0 Portrait + 1 Landscape + + + + + gen: =num + + Number of generations to follow. + + + + filter: =num + + Filter number. + + + + template: =name + + Template name (HTML only). + Value: /home/shura/whatever_name + + + + papers: =name + + Paper size name. + + Letter + Legal + A0 + A1 + A2 + A3 + A4 + A5 + B0 + B1 + B2 + B3 + B4 + B5 + B6 + B + C + D + E + + + + + dispf: =str + + Display format for the outputbox. + + + + id: =ID + + Gramps ID of a central person. MANDATORY + + + + + + + + Ancestor Chart + + + name: + + ancestor_chart + + + + + + Ancestor Chart (Wall Chart) + + + name: + + ancestor_chart2 + + + + singlep: =0/1 + + Whether to scale to fit on a single page. + + Do not scale to fit + Scale to fit + + + + + compress: =0/1 + + Whether to compress chart. + + Do not compress chart + Compress chart + + + + + title: =str + + Title string for the report + Value: Whatever String You Wish + + + + + + Ahnentafel Report + + + name: + + ancestor_report + + + + + + Comprehensive Ancestors Report + + + name: + + ancestors_report + + + + cites: =0/1 + + Whether to cite sources. + + Do not cite sources + Cite sources + + + + + + + Descendant Graph + + + name: + + descendant_graph + + + + + + Descendant Report + + + name: + + descend_report + + + + + + Detailed Ancestral Report + + + name: + + det_ancestor_report + + + + repdate: =0/1 + + Whether to replace missing Dates with blanks. + + Do not replace missing Dates + Replace missing Dates + + + + + listc: =0/1 + + Whether to list children. + + Do not list children + List children + + + + + incsources: =0/1 + + Whether to include source references. + + Do not include sources + Include sources + + + + + incphotos: =0/1 + + Whether to include images. + + Do not include images + Include images + + + + + desref: =0/1 + + Whether to add descendant references in child list. + + Do not add references + Add references + + + + + computeage: =0/1 + + Whether to compute age. + + Do not compute age + Compute age + + + + + fulldates: =0/1 + + Whether to use full dates instead of just year. + + Do not use full dates + Use full dates + + + + + incnames: =0/1 + + Whether to include other names. + + Do not include other names + Include other names + + + + + firstnameiop: =0/1 + + Whether to use first names instead of pronouns + + Do not use first names + Use first names + + + + + incevents: =0/1 + + Whether to include events. + + Do not include events + Include events + + + + + incnotes: =0/1 + + Whether to include notes. + + Do not include notes + Include notes + + + + + omitda: =0/1 + + Whether to omit duplicate ancestors. + + Do not omit duplicates + Omit duplicates + + + + + repplace: =0/1 + + Whether to replace missing Places with blanks. + + Do not replace missing Places + Replace missing Places + + + + + + + Detailed Descendant Report + + + name: + + det_descendant_report + + + + repdate: =0/1 + + Whether to replace missing Dates with blanks. + + Do not replace missing Dates + Replace missing Dates + + + + + listc: =0/1 + + Whether to list children. + + Do not list children + List children + + + + + incsources: =0/1 + + Whether to include source references. + + Do not include sources + Include sources + + + + + incphotos: =0/1 + + Whether to include images. + + Do not include images + Include images + + + + + desref: =0/1 + + Whether to add descendant references in child list. + + Do not add references + Add references + + + + + computeage: =0/1 + + Whether to compute age. + + Do not compute age + Compute age + + + + + fulldates: =0/1 + + Whether to use full dates instead of just year. + + Do not use full dates + Use full dates + + + + + incnames: =0/1 + + Whether to include other names. + + Do not include other names + Include other names + + + + + firstnameiop: =0/1 + + Whether to use first names instead of pronouns + + Do not use first names + Use first names + + + + + incevents: =0/1 + + Whether to include events. + + Do not include events + Include events + + + + + incnotes: =0/1 + + Whether to include notes. + + Do not include notes + Include notes + + + + + omitda: =0/1 + + Whether to omit duplicate ancestors. + + Do not omit duplicates + Omit duplicates + + + + + repplace: =0/1 + + Whether to replace missing Places with blanks. + + Do not replace missing Places + Replace missing Places + + + + + + + Family Group Report + + + name: + + family_group + + + + spouse_id: =ID + + Gramps ID of the person's spouse. + Value: Use show=id to get ID list. + + + + + + Fan Chart + + + name: + + fan_chart + + + + + + FTM Style Ancestor Report + + + name: + + ftm_ancestor_report + + + + + + FTM Style Descendant Report + + + name: + + ftm_descendant_report + + + + + + Relationship Graph + + + name: + + rel_graph + + + + rankdir: =str + + Graph direction. + + LR Horizontal + RL Vertical + + + + + justyears: =0/1 + + Whether to use years only. + + Do not use years only + Use years only + + + + + latin: =0/1 + + Needs to be set if font doesn't support unicode. + + Supports unicode + Supports only Latin1 + + + + + arrow: =str + + Arrow styles for heads and tails. + + d Descendants <- Ancestors + a Descendants -> Ancestors + da Descendants <-> Ancestors + Descendants - Ancestors + + + + + dashedl: =0/1 + + Whether to use dotted lines for non-birth relationships. + + Do not use dotted lines + Use dotted lines + + + + + url: =0/1 + + Whether to include URLs. + + Do not include URLs + Include URLs + + + + + pagesh: =num + + Number of pages in horizontal direction. + Value: Integer values + + + + placecause: =0/1 + + Whether to replace missing dates with place/cause. + + Do not replace blank dates + Replace blank dates + + + + + gvof: =str + + Output format to convert dot file into. + + ps Postscript + svg Structured Vector Graphics (SVG) + svgz Compressed Structured Vector Graphics (SVG) + png PNG image + jpg JPEG image + gif GIF image + + + + + color: =str + + Whether and how to colorize graph. + + outline B&W Outline + colored Colored outline + filled Color fill + + + + + incid: =0/1 + + Whether to include IDs. + + Do not include IDs + Include IDs + + + + + incdate: =0/1 + + Whether to include dates. + + Do not include dates + Include dates + + + + + pagesv: =num + + Number of pages in vertical direction. + Value: Integer values + + + + font: =str + + Font to use in the report. + + Default + Helvetica Postscript / Helvetica + FreeSans Truetype / FreeSans + + + + + margin: =num + + Margin size. + Value: Floating point value, in cm + + + + showfamily: =0/1 + + Whether to show family nodes. + + Do not show family nodes + Show family nodes + + + + + + + Relationship Graph + + + name: + + rel_graph2 + + + + rankdir: =str + + Graph direction. + + LR Horizontal + RL Vertical + + + + + justyears: =0/1 + + Whether to use years only. + + Do not use years only + Use years only + + + + + latin: =0/1 + + Needs to be set if font doesn't support unicode. + + Supports unicode + Supports only Latin1 + + + + + arrow: =str + + Arrow styles for heads and tails. + + d Descendants <- Ancestors + a Descendants -> Ancestors + da Descendants <-> Ancestors + Descendants - Ancestors + + + + + dashedl: =0/1 + + Whether to use dotted lines for non-birth relationships. + + Do not use dotted lines + Use dotted lines + + + + + url: =0/1 + + Whether to include URLs. + + Do not include URLs + Include URLs + + + + + pagesh: =num + + Number of pages in horizontal direction. + Value: Integer values + + + + placecause: =0/1 + + Whether to replace missing dates with place/cause. + + Do not replace blank dates + Replace blank dates + + + + + gvof: =str + + Output format to convert dot file into. + + ps Postscript + svg Structured Vector Graphics (SVG) + svgz Compressed Structured Vector Graphics (SVG) + png PNG image + jpg JPEG image + gif GIF image + + + + + color: =str + + Whether and how to colorize graph. + + outline B&W Outline + colored Colored outline + filled Color fill + + + + + incid: =0/1 + + Whether to include IDs. + + Do not include IDs + Include IDs + + + + + incdate: =0/1 + + Whether to include dates. + + Do not include dates + Include dates + + + + + pagesv: =num + + Number of pages in vertical direction. + Value: Integer values + + + + font: =str + + Font to use in the report. + + Default + Helvetica Postscript / Helvetica + FreeSans Truetype / FreeSans + + + + + margin: =num + + Margin size. + Value: Floating point value, in cm + + + + showfamily: =0/1 + + Whether to show family nodes. + + Do not show family nodes + Show family nodes + + + + + + + Complete Individual Report + + + name: + + indiv_complete + + + + cites: =0/1 + + Whether to cite sources. + + Do not cite sources + Cite sources + + + + + + + Individual Summary + + + name: + + individual_summary + + + + + + Timeline Graph + + + name: + + timeline + + + + sortby: =num + + Number of a sorting function + + Birth Date + Name + + + + + title: =str + + Title string for the report + Value: Whatever String You Wish + + + + + + Generate Web Site (deprecated) + + + name: + + webpage + + + + HTMLidurl: =str + + URL for links from GRAMPS IDs + Value: the_url_value + + + + HTMLext: =str + + Extension for generated files + Value: Any extension you like: html, htm, php, asp, etc. + + + + HTMLimagedir: =str + + Image subdirectory + Value: image_subdir_name + + + + HTMLsplita: =0/1 + + Split alphabetical sections to different pages + + Do not split sections + Split sections + + + + + HTMLincpriv: =0/1 + + Inclusion of people marked private + + Do not include + Include + + + + + HTMLincid: =0/1 + + Include GRAMPS ID in the report + + Do not include + Include + + + + + HTMLidxcol: =num + + Number of columns in the index page + Value: Any integer number + + + + HTMLcmtxtsi: =0/1 + + Inclusion of comments and text in source information + + Do not include + Include + + + + + HTMLlnktoalphabet: =0/1 + + Include links to alphabetical sections in index page + + Do not include + Include + + + + + HTMLgendex: =0/1 + + Create a GENDEX index + + Do not create + Create + + + + + HTMLtreed: =num + + Depth of ancestor tree + Value: Any integer number + + + + HTMLidxt: =str + + Template name for the index page + Value: /full/path/to/the/tpkg + + + + HTMLlinktidx: =0/1 + + Include links to the index page + + Do not include + Include + + + + + HTMLrestrictinfo: =0/1 + + Restrict information on living people + + Do not restrict + Restrict + + + + + HTMLyearso: =0/1 + + Use only birth year on the index page + + Use full date + Use just year + + + + + HTMLidxbirth: =0/1 + + Append birth dates to the names on the index page + + Do not append + Append + + + + + HTMLshorttree: =0/1 + + Include short ancestor tree + + Do not include + Include + + + + + HTMLimg: =num + + Inclusion of images + + No images at all + No images for living people + Images for all people + + + + + HTMLod: =str + + Output directory for the web site + Value: /full/name/of/the/dir + + + + HTMLplaceidx: =0/1 + + Create an index of all Places + + Do not create + Create + + + + + + + Book Report + + + name: + + book + + + + bookname: =name + + Name of the book. MANDATORY + + + + + + + + Statistics Chart + + + name: + + statistics_chart + + + + data_sname: =0/1 + + Surname + + Leave chart with this data out + Include chart with this data + + + + + data_age: =0/1 + + Age + + Leave chart with this data out + Include chart with this data + + + + + data_ccount: =0/1 + + Number of children + + Leave chart with this data out + Include chart with this data + + + + + bar_items: =num + + Use barchart instead of piechart with this many or more items + Value: Number of items with which piecharts still look good... + + + + data_byear: =0/1 + + Birth year + + Leave chart with this data out + Include chart with this data + + + + + data_dmonth: =0/1 + + Death month + + Leave chart with this data out + Include chart with this data + + + + + data_mage: =0/1 + + Age at marriage + + Leave chart with this data out + Include chart with this data + + + + + year_from: =num + + Birth year from which to include people + Value: Earlier than 'year_to' value + + + + data_mcount: =0/1 + + Number of relationships + + Leave chart with this data out + Include chart with this data + + + + + data_bmonth: =0/1 + + Birth month + + Leave chart with this data out + Include chart with this data + + + + + data_fname: =0/1 + + Forename + + Leave chart with this data out + Include chart with this data + + + + + data_dplace: =0/1 + + Death place + + Leave chart with this data out + Include chart with this data + + + + + data_fchild: =0/1 + + Age when first child born + + Leave chart with this data out + Include chart with this data + + + + + data_title: =0/1 + + Title + + Leave chart with this data out + Include chart with this data + + + + + data_lchild: =0/1 + + Age when last child born + + Leave chart with this data out + Include chart with this data + + + + + data_dage: =0/1 + + Age at death + + Leave chart with this data out + Include chart with this data + + + + + data_mplace: =0/1 + + Marriage place + + Leave chart with this data out + Include chart with this data + + + + + data_dyear: =0/1 + + Death year + + Leave chart with this data out + Include chart with this data + + + + + data_bplace: =0/1 + + Birth place + + Leave chart with this data out + Include chart with this data + + + + + reverse: =0/1 + + Whether to sort in reverse order + + Do not sort in reverse + Sort in reverse + + + + + gender: =num + + Genders included + + 2 Both + 1 Men + 0 Women + + + + + data_etypes: =0/1 + + Event type + + Leave chart with this data out + Include chart with this data + + + + + no_years: =0/1 + + Whether to include people without known birth years + + Do not include + Include + + + + + sortby: =num + + Sort chart items by + + 0 Item count + 1 Item name + + + + + year_to: =num + + Birth year until which to include people + Value: Smaller than 2005 + + + + data_gender: =0/1 + + Gender + + Leave chart with this data out + Include chart with this data + + + + + data_dcause: =0/1 + + Cause of death + + Leave chart with this data out + Include chart with this data + + + + + + + Descendant Wall Chart + + + name: + + descend_chart2 + + + + singlep: =0/1 + + Whether to scale to fit on a single page. + + Do not scale to fit + Scale to fit + + + + + title: =str + + Title string for the report + Value: Whatever String You Wish + + + + + + + Tools + + Common Options + + + filter: =num + + Filter number. + + + + id: =ID + + Gramps ID of a central person. + + + + + + + + Rename personal event types + + + name: + + chtype + + + + fromtype: =str + + Type of events to replace + Value: Event type string + + + + totype: =str + + New type replacing the old one + Value: Event type string + + + + + + Check and repair database + + + name: + + check + + + + + + Reorder GRAMPS IDs + + + name: + + reorder_ids + + + + + + Verify the database + + + name: + + verify + + + + lngwdw: =num + + Maximum number of consecutive years of widowhood + Value: Number of years + + + + mxchildmom: =num + + Maximum number of children for a woman + Value: Number of children + + + + wedder: =num + + Maximum number of spouses for a person + Value: Number of spouses + + + + mxchilddad: =num + + Maximum number of children for a man + Value: Number of chidlren + + + + estimate_age: =0/1 + + Whether to estimate missing dates + + Do not estimate + Estimate dates + + + + + yngmar: =num + + Minimum age to marry + Value: Age in years + + + + oldmar: =num + + Maximum age to marry + Value: Age in years + + + + cbspan: =num + + Maximum span of years for all children + Value: Span in years + + + + oldage: =num + + Maximum age + Value: Age in years + + + + olddad: =num + + Maximum age to father a child + Value: Age in years + + + + hwdif: =num + + Maximum husband-wife age difference + Value: Age difference in years + + + + yngmom: =num + + Minimum age to bear a child + Value: Age in years + + + + yngdad: =num + + Minimum age to father a child + Value: Age in years + + + + oldmom: =num + + Maximum age to bear a child + Value: Age in years + + + + cspace: =num + + Maximum number of years between children + Value: Number of years + + + + + + Generate Testcases for persons and families + + + name: + + testcasegenerator + + + + dates: =0/1 + + Whether to create test for date handling. + + Skip test + Create date tests + + + + + person_count: =int + + Number of dummy persons to generate + Value: Number of persons + + + + no_trans: =0/1 + + Wheter to use one transaction or multiple small ones + + One transaction + Multiple transactions + + + + + long_names: =0/1 + + Wheter to create short or long names + + Short names + Long names + + + + + bugs: =0/1 + + Whether to create invalid database references. + + Skip test + Create invalid Database references + + + + + persons: =0/1 + + Whether to create a bunch of dummy persons + + Dont create persons + Create dummy persons + + + + + + + Checkpoint the database + + + name: + + chkpoint + + + + crcmd: =str + + Custom command line for retrieval + Value: Custom command string + + + + cacmd: =str + + Custom command line for archiving + Value: Custom command string + + + + archive: =0/1 + + Whether to archive or retrieve. + + Retrieve + Archive + + + + + rcs: =0/1 + + Whether to use RCS (ignores custom commands). + + Do not use RCS + Use RCS + + + + + + + Rebuild secondary indices + + + name: + + rebuild + + + + + + Dumps gender statistics + + + name: + + dgenstats + + + + + + Generate Commandline Reference for Reports and Tools + + + name: + + cmdref + + + + include: =0/1 + + Whether to include into the manual + + Do not include + Include + + + + + target: =str + + Pathname to the target file + Value: Any valid pathname + + + + + + + diff --git a/gramps2/doc/gramps-manual/C/gramps-manual.xml b/gramps2/doc/gramps-manual/C/gramps-manual.xml index 94a24bbd4..4ba08bf78 100644 --- a/gramps2/doc/gramps-manual/C/gramps-manual.xml +++ b/gramps2/doc/gramps-manual/C/gramps-manual.xml @@ -50,6 +50,7 @@ + ]> diff --git a/gramps2/src/ArgHandler.py b/gramps2/src/ArgHandler.py index 0699f273a..fa753aa3f 100644 --- a/gramps2/src/ArgHandler.py +++ b/gramps2/src/ArgHandler.py @@ -614,7 +614,8 @@ class ArgHandler: category,options_str_dict) else: Report.cl_report(self.parent.db,name,category, - report_class,options_class,options_str_dict) + report_class,options_class, + options_str_dict) return print "Unknown report name. Available names are:" diff --git a/gramps2/src/Makefile.am b/gramps2/src/Makefile.am index 9778dd54a..dae12349e 100644 --- a/gramps2/src/Makefile.am +++ b/gramps2/src/Makefile.am @@ -176,3 +176,6 @@ pycheck: docs: epydoc -o doc --url http://gramps.sourceforge.net --name GRAMPS --html $(docfiles) epydoc --pdf $(docfiles) + +cmdplug: + ./build_cmdplug diff --git a/gramps2/src/PluginMgr.py b/gramps2/src/PluginMgr.py index a617934e7..7d5b22702 100644 --- a/gramps2/src/PluginMgr.py +++ b/gramps2/src/PluginMgr.py @@ -190,7 +190,8 @@ def register_tool( (junk,cli_task) = divmod(modes-gui_task,2**Tool.MODE_CLI) if cli_task: - _register_cli_tool(name,category,tool_class,options_class) + _register_cli_tool(name,category,tool_class,options_class, + translated_name) def _register_gui_tool(tool_class,options_class,translated_name, name,category, @@ -209,11 +210,13 @@ def _register_gui_tool(tool_class,options_class,translated_name, category,name,description,status, author_name,author_email)) -def _register_cli_tool(name,category,tool_class,options_class): +def _register_cli_tool(name,category,tool_class,options_class, + translated_name): for n in cli_tool_list: if n[0] == name: return - cli_tool_list.append((name,category,tool_class,options_class)) + cli_tool_list.append((name,category,tool_class,options_class, + translated_name)) #------------------------------------------------------------------------- # @@ -257,7 +260,8 @@ def register_report( (junk,command_line_task) = divmod(modes-standalone_task-book_item_task, 2**Report.MODE_CLI) if command_line_task: - _register_cl_report(name,category,report_class,options_class) + _register_cl_report(name,category,report_class,options_class, + translated_name) def _register_standalone(report_class, options_class, translated_name, name, category, @@ -290,11 +294,13 @@ def register_book_item(translated_name, category, report_class, bkitems_list.append((translated_name, category, report_class, option_class, name)) -def _register_cl_report(name,category,report_class,options_class): +def _register_cl_report(name,category,report_class,options_class, + translated_name): for n in cl_list: if n[0] == name: return - cl_list.append((name,category,report_class,options_class)) + cl_list.append((name,category,report_class,options_class, + translated_name)) #------------------------------------------------------------------------- # diff --git a/gramps2/src/Report.py b/gramps2/src/Report.py index d3bf5f0eb..453026bc9 100644 --- a/gramps2/src/Report.py +++ b/gramps2/src/Report.py @@ -1584,17 +1584,18 @@ class CommandLineReport: """ - def __init__(self,database,name,category,option_class,options_str_dict): + def __init__(self,database,name,category,option_class,options_str_dict, + noopt=False): self.database = database self.category = category self.option_class = option_class(name) self.show = options_str_dict.pop('show',None) self.options_str_dict = options_str_dict - self.init_options() + self.init_options(noopt) self.parse_option_str() self.show_options() - def init_options(self): + def init_options(self,noopt): self.options_dict = { 'of' : self.option_class.handler.module_name, 'off' : self.option_class.handler.get_format_name(), @@ -1619,6 +1620,9 @@ class CommandLineReport: 'dispf' : ["=str","Display format for the outputbox."], } + if noopt: + return + # Add report-specific options for key in self.option_class.handler.options_dict.keys(): if key not in self.options_dict.keys(): diff --git a/gramps2/src/Tool.py b/gramps2/src/Tool.py index d64b2eaea..dc92ad41b 100644 --- a/gramps2/src/Tool.py +++ b/gramps2/src/Tool.py @@ -105,26 +105,30 @@ class CommandLineTool: """ - def __init__(self,database,name,category,option_class,options_str_dict): + def __init__(self,database,name,category,option_class,options_str_dict, + noopt=False): self.database = database self.category = category self.option_class = option_class(name) self.show = options_str_dict.pop('show',None) self.options_str_dict = options_str_dict - self.init_options() + self.init_options(noopt) self.parse_option_str() self.show_options() - def init_options(self): + def init_options(self,noopt): self.options_dict = { 'id' : '' } self.options_help = { - 'id' : ["=ID","Gramps ID of a central person. MANDATORY"], + 'id' : ["=ID","Gramps ID of a central person."], 'filter' : ["=num","Filter number."], } + if noopt: + return + # Add tool-specific options for key in self.option_class.handler.options_dict.keys(): if key not in self.options_dict.keys(): diff --git a/gramps2/src/build_cmdplug b/gramps2/src/build_cmdplug new file mode 100755 index 000000000..d9f7aab01 --- /dev/null +++ b/gramps2/src/build_cmdplug @@ -0,0 +1,10 @@ +#! /bin/sh + +TARGET=../doc/gramps-manual/C/cmdplug.xml + +touch ./junk.grdb +python gramps.py -O ./junk.grdb -a tool -p name=cmdref,include=1,target=$TARGET +chmod +r $TARGET +rm ./junk.grdb + +exit 0 diff --git a/gramps2/src/plugins/CmdRef.py b/gramps2/src/plugins/CmdRef.py index dc4a87ae1..50c92d77b 100644 --- a/gramps2/src/plugins/CmdRef.py +++ b/gramps2/src/plugins/CmdRef.py @@ -44,56 +44,118 @@ import Report #------------------------------------------------------------------------- # -# runTool +# Constants +# +#------------------------------------------------------------------------- +_tags = [ + 'article', + 'sect1', + 'sect2', + 'sect3' + ] + +#------------------------------------------------------------------------- +# +# # #------------------------------------------------------------------------- class CmdRef(Tool.Tool): def __init__(self,db,person,options_class,name,callback=None,parent=None): Tool.Tool.__init__(self,db,person,options_class,name) + # retrieve options + include = self.options.handler.options_dict['include'] + target = self.options.handler.options_dict['target'] + + if include: + level = 1 + else: + level = 0 + cli = int(parent == None) f = tempfile.NamedTemporaryFile() fname = f.name - f.write('\n') - f.write('\n') - f.write('\n') - f.write('
\n') - f.write(' Reports and Tools parameter reference\n') - f.write(' \n') + id_counter = 0 + + if not include: + f.write('\n') + f.write('\n') + f.write('\n') + + # Top section and title + f.write('<%s id="cmdplug-id%d">\n' % (_tags[level],id_counter) ) + id_counter = id_counter + 1 + f.write(' Detailed plugin option reference\n') + + # Reports + f.write(' <%s id="cmdplug-reps">\n' % _tags[level+1]) f.write(' Reports\n') - counter=0 + + # Common report options + item = PluginMgr.cl_list[0] + clr = Report.CommandLineReport(db,item[0],item[1],item[3],{},True) + self.write_ref(f,clr,level+2,id_counter,True) + id_counter = id_counter + 1 + for item in PluginMgr.cl_list: category = item[1] if category in (Report.CATEGORY_BOOK, Report.CATEGORY_CODE, Report.CATEGORY_WEB): - self.write_ref(f,item,counter,category) + self.write_ref(f,item,level+2,id_counter,category) else: - self.write_ref( f, item, counter, None) - counter = counter + 1 - f.write(' \n') - f.write(' \n') + self.write_ref(f,item,level+2,id_counter,None) + id_counter = id_counter + 1 + f.write(' \n' % _tags[level+1] ) + + # Tools + f.write(' <%s id="cmdplug-tools">\n ' % _tags[level+1] ) f.write(' Tools\n') + + # Common tool options + item = PluginMgr.cli_tool_list[0] + clr = Tool.CommandLineTool(db,item[0],item[1],item[3],{},True) + self.write_ref(f,clr,level+2,id_counter,True) + id_counter = id_counter + 1 + for item in PluginMgr.cli_tool_list: - self.write_ref( f, item, counter) - counter = counter + 1 - f.write(' \n') + self.write_ref(f,item,level+2,id_counter) + id_counter = id_counter + 1 + f.write(' \n' % _tags[level+1] ) f.write(' \n') - f.write(' \n') - f.write(' \n') - f.write('
\n') + f.write('\n' %_tags[level]) f.flush() - os.spawnlp( os.P_WAIT, "yelp", "yelp", fname) + if include: + os.spawnlp( os.P_WAIT, "cp", "cp", fname, target) + else: + os.spawnlp( os.P_WAIT, "yelp", "yelp", fname) f.close() - def write_ref( self, f, item,counter,category=None): - f.write('\n' % counter) - f.write(' %s\n' % item[0]) - f.write(' \n') - f.write(' Options\n') + def write_ref(self,f,item,level,id_counter,category=None): + # Section and title + f.write('<%s id="cmdplug-id%d">\n' % (_tags[level],id_counter) ) + if category == True: + title = 'Common Options' + else: + title = item[4] + f.write(' %s\n' % title) + + # Show command-line name f.write(' \n') + + if category != True: + f.write(' \n') + f.write(' name:\n') + f.write(' \n') + f.write(' %s\n' % item[0]) + f.write(' \n') + f.write(' \n') + + # Instantiate options class if category == None: oclass = item[3]( item[0]) elif category == Report.CATEGORY_BOOK: @@ -109,39 +171,71 @@ class CmdRef(Tool.Tool): elif item[0] == "navwebpage": import NavWebPage oclass = NavWebPage.WebReportOptions(item[0]) + elif category == True: + # This is the common options case + # so class is already instantiated + oclass = item + # Spit out all options for arg in oclass.options_help.keys(): - f.write(' \n') f.write(' \n') f.write(' %s: %s\n' % (escape(arg), escape(oclass.options_help[arg][0]))) f.write(' \n') f.write(' %s\n' % escape(oclass.options_help[arg][1])) - if type(oclass.options_help[arg][2]) in [list,tuple]: - if oclass.options_help[arg][3]: - f.write(' \n') - for val in oclass.options_help[arg][2]: - f.write( " %s\n" - % escape(val)) - f.write(' \n') + + if len(oclass.options_help[arg])>2: + if type(oclass.options_help[arg][2]) in [list,tuple]: + if oclass.options_help[arg][3]: + f.write(' \n') + for val in oclass.options_help[arg][2]: + f.write( " %s\n" + % escape(val)) + f.write(' \n') + else: + f.write(' \n') + for val in oclass.options_help[arg][2]: + f.write( " %s\n" + % escape(val)) + f.write(' \n') else: - f.write(' \n') - for val in oclass.options_help[arg][2]: - f.write( " %s\n" - % escape(val)) - f.write(' \n') - else: - f.write(' Value: %s\n' - % escape(oclass.options_help[arg][2])) + f.write(' ' + 'Value: %s\n' + % escape(oclass.options_help[arg][2])) f.write(' \n') f.write(' \n') - f.write(' \n') f.write(' \n') - f.write(' \n') - f.write('\n') + f.write('\n' % _tags[level]) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +class CmdRefOptions(Tool.ToolOptions): + """ + Defines options and provides handling interface. + """ + + def __init__(self,name,person_id=None): + Tool.ToolOptions.__init__(self,name,person_id) + + def set_new_options(self): + # Options specific for this report + self.options_dict = { + 'include' : 0, + 'target' : '../doc/gramps-manual/C/cmdplug.xml', + } + self.options_help = { + 'include' : ("=0/1","Whether to include into the manual", + ["Do not include","Include"], + True), + 'target' : ("=str","Pathname to the target file", + "Any valid pathname") + } + #------------------------------------------------------------------------ # # @@ -153,10 +247,9 @@ register_tool( name = 'cmdref', category = Tool.TOOL_DEBUG, tool_class = CmdRef, - options_class = Tool.ToolOptions, + options_class = CmdRefOptions, modes = Tool.MODE_GUI | Tool.MODE_CLI, - translated_name = _("Generate Commandline Reference " - "for Reports and Tools"), + translated_name = _("Generate Commandline Plugin Reference"), author_name = "Martin Hawlisch", author_email = "martin@hawlisch.de", description=_("Generates a DocBook XML file that contains "