@@ -38,11 +38,28 @@ class MatcherRegistry(SkipDefaultFieldsReprMixin):
3838
3939 def register (self , cls : Matcher ) -> None :
4040 """
41- >>> from libvcs.parse.git import GitURL
41+
42+ .. currentmodule:: libvcs.parse.git
43+
44+ >>> from libvcs.parse.git import GitURL, GitBaseURL
45+
46+ :class:`GitBaseURL` - the ``git(1)`` compliant parser - won't accept a pip-style URL:
47+
48+ >>> GitBaseURL.is_valid(url="git+ssh://git@github.com/tony/AlgoXY.git")
49+ False
50+
51+ :class:`GitURL` - the "batteries-included" parser - can do it:
4252
4353 >>> GitURL.is_valid(url="git+ssh://git@github.com/tony/AlgoXY.git")
54+ True
55+
56+ But what if you wanted to do ``github:org/repo``?
57+
58+ >>> GitURL.is_valid(url="github:org/repo")
4459 False
4560
61+ **Extending matching capability:**
62+
4663 >>> class GitHubPrefix(Matcher):
4764 ... label = 'gh-prefix'
4865 ... description ='Matches prefixes like github:org/repo'
@@ -95,9 +112,15 @@ def register(self, cls: Matcher) -> None:
95112
96113 git URLs + pip-style git URLs:
97114
115+ This is already in :class:`GitURL` via :data:`PIP_DEFAULT_MATCHERS`. For the
116+ sake of showing how extensibility works, here is a recreation based on
117+ :class:`GitBaseURL`:
118+
119+ >>> from libvcs.parse.git import GitBaseURL
120+
98121 >>> from libvcs.parse.git import DEFAULT_MATCHERS, PIP_DEFAULT_MATCHERS
99122
100- >>> class GitURLWithPip(GitURL ):
123+ >>> class GitURLWithPip(GitBaseURL ):
101124 ... matchers = MatcherRegistry = MatcherRegistry(
102125 ... _matchers={m.label: m for m in [*DEFAULT_MATCHERS, *PIP_DEFAULT_MATCHERS]}
103126 ... )
0 commit comments