[PATCH 3 of 6] help: ReST tweaks
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sat Feb 9 13:57:48 UTC 2013
On Sat, Feb 09, 2013 at 01:00:37PM +0000, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
> # Date 1360414103 0
> # Node ID 03c9cfc461cce54da65f0ad0529a734181022b83
> # Parent aa74feb1f11d43453e6ef3797e6c4c24f950a9dc
> help: ReST tweaks
>
> Use a full header for topic titles; make the indent configurable by
> the caller
This patches is doing two stuff, you should probably split it.
The changes to header is a bit obscure to me. looks like you are adding a '==='
belong the header. But it must have been something there before. Why is that necessary ?
> diff --git a/mercurial/help.py b/mercurial/help.py
> --- a/mercurial/help.py
> +++ b/mercurial/help.py
> @@ -389,12 +389,17 @@ def help_(ui, name, unknowncmd=False, fu
> else:
> raise error.UnknownCommand(name)
>
> - rst = ["%s\n\n" % header]
> + headerstyleline = '=' * encoding.colwidth(header)
> + rst = ["%s\n%s\n%s\n\n" % (headerstyleline, header, headerstyleline)]
> +
> # description
> if not doc:
> - rst.append(" %s\n" % _("(no help text available)"))
> + doc = _("(no help text available)")
> if util.safehasattr(doc, '__call__'):
> - rst += [" %s\n" % l for l in doc().splitlines()]
> + doc = doc()
> +
> + indent = ' ' * int(opts.get('indent', 4))
> + rst += ["%s%s\n" % (indent, l) for l in doc.splitlines()]
The new `indent` argument should be documented. (note: having the default value
in the middle of the function is common but confusing)
--
Pierre-Yves
More information about the Mercurial-devel
mailing list