Patchwork [3,of,8] match: add doctest examples for patkind()

login
register
mail settings
Submitter Denis Laxalde
Date April 8, 2019, 8:23 a.m.
Message ID <a507b64705f6ce78c4ad.1554711827@steppe.logilab.fr>
Download mbox | patch
Permalink /patch/39530/
State Accepted
Headers show

Comments

Denis Laxalde - April 8, 2019, 8:23 a.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1554566053 -7200
#      Sat Apr 06 17:54:13 2019 +0200
# Node ID a507b64705f6ce78c4ad74b45a798668d8770cb7
# Parent  490dbf4f3e1668a186e14e95a119684dafcf496b
match: add doctest examples for patkind()

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -1024,7 +1024,18 @@  class unionmatcher(basematcher):
         return ('<unionmatcher matchers=%r>' % self._matchers)
 
 def patkind(pattern, default=None):
-    '''If pattern is 'kind:pat' with a known kind, return kind.'''
+    '''If pattern is 'kind:pat' with a known kind, return kind.
+
+    >>> patkind('re:.*\.c$')
+    're'
+    >>> patkind('glob:*.c')
+    'glob'
+    >>> patkind('relpath:test.py')
+    'relpath'
+    >>> patkind('main.py')
+    >>> patkind('main.py', default='re')
+    're'
+    '''
     return _patsplit(pattern, default)[0]
 
 def _patsplit(pattern, default):