annotate MoinMoin/macro/WikiConfigHelp.py @ 5952:f6a74810da73

updated CHANGES
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 10 Mar 2013 15:28:04 +0100
parents 516d165c4bbf
children
rev   line source
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
2 """
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
3 MoinMoin - Wiki Configuration Help
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
4 """
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
5 from MoinMoin.config import multiconfig
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
6
4464
5ee5b69eefdc fix Dependencies of WikiConfig/WikiConfigHelp macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3791
diff changeset
7 Dependencies = ['user'] # table headings are translated to user language
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
8 generates_headings = True
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
9
5657
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
10 def macro_WikiConfigHelp(macro, section=None, show_heading=True, show_descriptions=True, heading_level=2):
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
11 request = macro.request
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
12 _ = request.getText
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
13 f = macro.request.formatter
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
14 ret = []
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
15
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
16 groups = []
5263
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
17 if section and section in multiconfig.options:
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
18 groups.append((section, True, multiconfig.options))
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
19 else:
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
20 for groupname in multiconfig.options:
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
21 groups.append((groupname, True, multiconfig.options))
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
22 for groupname in multiconfig.options_no_group_name:
5155ed62a9c5 macro WikiConfigHelp: added section keyword for selecting a subset of the description, e.g. <<WikiConfigHelp(section="xapian")>>
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4464
diff changeset
23 groups.append((groupname, False, multiconfig.options_no_group_name))
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
24 groups.sort()
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
25
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
26 for groupname, addgroup, optsdict in groups:
3744
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
27 heading, desc, opts = optsdict[groupname]
5657
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
28 if show_heading:
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
29 ret.extend([
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
30 f.heading(1, heading_level, id=groupname),
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
31 ## XXX: translate description?
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
32 f.text(heading),
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
33 f.heading(0, heading_level),
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
34 ])
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
35
516d165c4bbf WikiConfigHelp macro: make heading and description display optional, heading level as a parameter (default 2)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5269
diff changeset
36 if desc and show_descriptions:
3744
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
37 ret.extend([
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
38 f.paragraph(1),
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
39 f.text(desc),
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
40 f.paragraph(0)
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
41 ])
1eabe89b773b add longer group help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3743
diff changeset
42 ret.extend([
3743
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
43 f.table(1),
5269
cc2a7623d40a defined background color for column header
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5263
diff changeset
44 f.table_row(1, style="background-color: #ffffcc"),
3743
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
45 f.table_cell(1), f.strong(1), f.text(_('Variable name')), f.strong(0), f.table_cell(0),
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
46 f.table_cell(1), f.strong(1), f.text(_('Default')), f.strong(0), f.table_cell(0),
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
47 f.table_cell(1), f.strong(1), f.text(_('Description')), f.strong(0), f.table_cell(0),
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
48 f.table_row(0),
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
49 ])
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
50 opts = list(opts)
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
51 opts.sort()
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
52 for name, default, description in opts:
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
53 if addgroup:
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
54 name = groupname + '_' + name
3748
dc917a577d38 add multiconfig.DefaultExpression for documentation
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3745
diff changeset
55 if isinstance(default, multiconfig.DefaultExpression):
dc917a577d38 add multiconfig.DefaultExpression for documentation
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3745
diff changeset
56 default_txt = default.text
dc917a577d38 add multiconfig.DefaultExpression for documentation
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3745
diff changeset
57 else:
dc917a577d38 add multiconfig.DefaultExpression for documentation
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3745
diff changeset
58 default_txt = '%r' % (default, )
3791
7f43f5c38310 WikiConfigHelp macro: hide default already at 30 characters, use span to show on mouse hover
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3788
diff changeset
59 if len(default_txt) <= 30:
7f43f5c38310 WikiConfigHelp macro: hide default already at 30 characters, use span to show on mouse hover
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3788
diff changeset
60 default_txt = f.text(default_txt)
7f43f5c38310 WikiConfigHelp macro: hide default already at 30 characters, use span to show on mouse hover
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3788
diff changeset
61 else:
7f43f5c38310 WikiConfigHelp macro: hide default already at 30 characters, use span to show on mouse hover
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3788
diff changeset
62 default_txt = f.span(1, title=default_txt) + f.text('...') + f.span(0)
3788
8ddd2b1c49b4 WikiConfigHelp: translate and mark up descriptions
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3765
diff changeset
63 description = _(description or '', wiki=True)
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64 ret.extend([
3743
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
65 f.table_row(1),
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
66 f.table_cell(1), f.text(name), f.table_cell(0),
3791
7f43f5c38310 WikiConfigHelp macro: hide default already at 30 characters, use span to show on mouse hover
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3788
diff changeset
67 f.table_cell(1), f.code(1, css="backtick"), default_txt, f.code(0), f.table_cell(0),
3788
8ddd2b1c49b4 WikiConfigHelp: translate and mark up descriptions
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3765
diff changeset
68 f.table_cell(1), description, f.table_cell(0),
3743
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
69 f.table_row(0),
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
70 ])
3743
49144c908411 wiki config help: table-view like HelpOnConfiguration has
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3742
diff changeset
71 ret.append(f.table(0))
3742
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
72
9f60d7f5487a add example macro to print out all settings + help text
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
73 return ''.join(ret)