changeset 42082:413a75da98ce

match: add doctest examples for patkind()
author Denis Laxalde <denis@laxalde.org>
date Sat, 06 Apr 2019 17:54:13 +0200
parents bf777c1e78dd
children bee1647578b7
files mercurial/match.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Sat Apr 06 15:21:55 2019 +0200
+++ b/mercurial/match.py	Sat Apr 06 17:54:13 2019 +0200
@@ -1024,7 +1024,18 @@
         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):