[PATCH 1 of 2] templatefilters: add doctests for person

Martin Geisler mg at lazybytes.net
Mon Apr 18 04:49:25 CDT 2011


Adrian Buehlmann <adrian at cadifra.com> writes:

> On 2011-04-17 22:32, Adrian Buehlmann wrote:
>> # HG changeset patch
>> # User Adrian Buehlmann <adrian at cadifra.com>
>> # Date 1303068865 -7200
>> # Node ID 989a7f3abceb143a547f17e7520863d8124052f1
>> # Parent  d66272d05c8ab8dd4dd6f392d2e5820d7c417db8
>> templatefilters: add doctests for person
>> 
>> diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
>> --- a/mercurial/templatefilters.py
>> +++ b/mercurial/templatefilters.py
>> @@ -241,7 +241,12 @@
>>      return "-rw-r--r--"
>>  
>>  def person(author):
>> -    """:person: Any text. Returns the text before an email address."""
>> +    """:person: Any text. Returns the text before an email address.
>> +    >>> person('John Doe <john at example.com>')
>> +    'John Doe'
>> +    >>> person('john.doe at example.com')
>> +    'john'
>> +    """
>
> $ hg help templates
> ...
>     person      Any text. Returns the text before an email address. >>>
>                 person('John Doe <john at example.com>') 'John Doe' >>>
>                 person('john.doe at example.com') 'john doe'
>
> seems not pleased about doctests there. I need to figure out how to fix
> that.
>
> <joking>But in some ways, it's funny. Like that, we would have tested
> examples in the help text (ping parren :-).

Yeah, that could be neat. However, here the right way to fix this is not
to let help.py remove the doctests but instead teach minirst about them.

Also, I think that we should find a better way to show the output of the
template filters -- they are not really functions from a user's
perspective, so showing

  >>> person('John Doe <john at example.com>')
  'John Doe'

might be confusing. We should instead do something that shows that
'{author|person}' gives 'John Doe'. I'm unfortunately not really sure
how to do this in a nice way.

-- 
Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110418/16ab27fc/attachment.pgp>


More information about the Mercurial-devel mailing list