chiark / gitweb /
plugins: avoid dependency on __init__.py for simple link plugins.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 4 Jun 2018 07:04:47 +0000 (09:04 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 4 Jun 2018 07:04:47 +0000 (09:04 +0200)
Duplicated the common code over. It's fully covered, so it's okay.

pelican-plugins/m/__init__.py
pelican-plugins/m/abbr.py
pelican-plugins/m/dox.py
pelican-plugins/m/gh.py
pelican-plugins/m/gl.py

index 131dcd4d1b2de4d8386dc7ed3b1ba74c94a810e6..29b1c1ddf55b0f344831c7117ef1b2d3779ec71d 100644 (file)
 #   DEALINGS IN THE SOFTWARE.
 #
 
-from docutils import utils
-import re
-
-link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
-
-def parse_link(text):
-    link = utils.unescape(text)
-    m = link_regexp.match(link)
-    if m: return m.group('title', 'link')
-    return None, link
+# This file is here only to make python unittest work, it's not needed
+# otherwise
index 33841145f990ff1a1882d1a529f8a873c9f23ade..4eb705e1bf27ccf41faddff69c977daa9ae8cda1 100644 (file)
 #   DEALINGS IN THE SOFTWARE.
 #
 
-from . import parse_link
-from docutils import nodes
+import re
+from docutils import nodes, utils
 from docutils.parsers import rst
 
+# to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
+# m.gh and m.gl
+
+link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
+
+def parse_link(text):
+    link = utils.unescape(text)
+    m = link_regexp.match(link)
+    if m: return m.group('title', 'link')
+    return None, link
+
 def abbr(name, rawtext, text, lineno, inliner, options={}, content=[]):
     abbr, title = parse_link(text)
     if not abbr:
index ccf1f0138129fa844579f856fb1124797d14230c..4063841be1411dd677654144fee9ea68d71ef201 100644 (file)
@@ -22,7 +22,6 @@
 #   DEALINGS IN THE SOFTWARE.
 #
 
-from . import parse_link
 from docutils.parsers.rst.states import Inliner
 from docutils import nodes, utils
 from docutils.parsers import rst
index 858d641cb17e0f7dad0fd224b1f96e996278fce5..422d12de0f5edd31a5e7043e60f4009b2ae52297 100644 (file)
 #   DEALINGS IN THE SOFTWARE.
 #
 
-from . import parse_link
-from docutils import nodes
+import re
+from docutils import nodes, utils
 from docutils.parsers import rst
 
+# to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
+# m.gh and m.gl
+
+link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
+
+def parse_link(text):
+    link = utils.unescape(text)
+    m = link_regexp.match(link)
+    if m: return m.group('title', 'link')
+    return None, link
+
 def gh_internal(account, ref, title, link):
     base_url = "https://github.com/{}/{}/{}/{}"
     if '#' in ref:
index 7ef8071a61f6995e352bc5642292cb95e7a94ef9..ae61867d85faa8a452db74e2649227cf1ed2b8c2 100644 (file)
 #   DEALINGS IN THE SOFTWARE.
 #
 
-from . import parse_link
+import re
 from docutils import nodes, utils
 from docutils.parsers import rst
 
+# to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
+# m.gh and m.gl
+
+link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
+
+def parse_link(text):
+    link = utils.unescape(text)
+    m = link_regexp.match(link)
+    if m: return m.group('title', 'link')
+    return None, link
+
 def glext(name, rawtext, text, lineno, inliner, options={}, content=[]):
     title, extension = parse_link(text)
     if not title: title = extension