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

Adrian Buehlmann adrian at cadifra.com
Sun Apr 17 17:38:43 CDT 2011


On 2011-04-18 00:14, Adrian Buehlmann wrote:
> 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.

It looks like this might do the trick:

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -123,6 +123,9 @@
     entries = []
     for name in sorted(items):
         text = (items[name].__doc__ or '').rstrip()
+        f = text.find('    >>>') # remove doctests
+        if f != -1:
+            text = text[:f].rstrip()
         if not text:
             continue
         text = gettext(text)

I'll send an updated series tomorrow.


More information about the Mercurial-devel mailing list