Back to index

moin  1.9.0~rc2
WikiConfigHelp.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - Wiki Configuration Help
00004 """
00005 from MoinMoin.config import multiconfig
00006 
00007 Dependencies = ['user'] # table headings are translated to user language
00008 generates_headings = True
00009 
00010 def macro_WikiConfigHelp(macro, section=None):
00011     request = macro.request
00012     _ = request.getText
00013     f = macro.request.formatter
00014     ret = []
00015 
00016     groups = []
00017     if section and section in multiconfig.options:
00018         groups.append((section, True, multiconfig.options))
00019     else:
00020         for groupname in multiconfig.options:
00021             groups.append((groupname, True, multiconfig.options))
00022         for groupname in multiconfig.options_no_group_name:
00023             groups.append((groupname, False, multiconfig.options_no_group_name))
00024     groups.sort()
00025 
00026     for groupname, addgroup, optsdict in groups:
00027         heading, desc, opts = optsdict[groupname]
00028         ret.extend([
00029             f.heading(1, 1, id=groupname),
00030             ## XXX: translate description?
00031             f.text(heading),
00032             f.heading(0, 1),
00033         ])
00034         if desc:
00035             ret.extend([
00036                 f.paragraph(1),
00037                 f.text(desc),
00038                 f.paragraph(0)
00039             ])
00040         ret.extend([
00041             f.table(1),
00042             f.table_row(1, style="background-color: #ffffcc"),
00043             f.table_cell(1), f.strong(1), f.text(_('Variable name')), f.strong(0), f.table_cell(0),
00044             f.table_cell(1), f.strong(1), f.text(_('Default')), f.strong(0), f.table_cell(0),
00045             f.table_cell(1), f.strong(1), f.text(_('Description')), f.strong(0), f.table_cell(0),
00046             f.table_row(0),
00047         ])
00048         opts = list(opts)
00049         opts.sort()
00050         for name, default, description in opts:
00051             if addgroup:
00052                 name = groupname + '_' + name
00053             if isinstance(default, multiconfig.DefaultExpression):
00054                 default_txt = default.text
00055             else:
00056                 default_txt = '%r' % (default, )
00057                 if len(default_txt) <= 30:
00058                     default_txt = f.text(default_txt)
00059                 else:
00060                     default_txt = f.span(1, title=default_txt) + f.text('...') + f.span(0)
00061                 description = _(description or '', wiki=True)
00062             ret.extend([
00063                 f.table_row(1),
00064                 f.table_cell(1), f.text(name), f.table_cell(0),
00065                 f.table_cell(1), f.code(1, css="backtick"), default_txt, f.code(0), f.table_cell(0),
00066                 f.table_cell(1), description, f.table_cell(0),
00067                 f.table_row(0),
00068             ])
00069         ret.append(f.table(0))
00070 
00071     return ''.join(ret)