]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38786: Add parsing of https links to pydoc (GH-17143)
authorKirill <iam@python273.pw>
Wed, 13 Nov 2019 16:13:53 +0000 (19:13 +0300)
committerTal Einat <taleinat+github@gmail.com>
Wed, 13 Nov 2019 16:13:52 +0000 (18:13 +0200)
Lib/pydoc.py
Lib/test/test_pydoc.py
Lib/xmlrpc/server.py
Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst [new file with mode: 0644]

index 9a22e56686f618822050da56867a07841fb12788..e32fdf76978e26ac895980497bb4bbb8eb8a9857 100755 (executable)
@@ -585,7 +585,7 @@ class HTMLDoc(Doc):
         escape = escape or self.escape
         results = []
         here = 0
-        pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
+        pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|'
                                 r'RFC[- ]?(\d+)|'
                                 r'PEP[- ]?(\d+)|'
                                 r'(self\.)?(\w+))')
index c80477c50f0980e3168475a10cb49a1f28ab0911..b803b8bff2f7f8f3fdd3a1923bc53d91853b5db3 100644 (file)
@@ -1311,6 +1311,17 @@ foo
             'async <a name="-an_async_generator"><strong>an_async_generator',
             html)
 
+    def test_html_for_https_links(self):
+        def a_fn_with_https_link():
+            """a link https://localhost/"""
+            pass
+
+        html = pydoc.HTMLDoc().document(a_fn_with_https_link)
+        self.assertIn(
+            '<a href="https://localhost/">https://localhost/</a>',
+            html
+        )
+
 class PydocServerTest(unittest.TestCase):
     """Tests for pydoc._start_server"""
 
index 32aba4df4c7eb5edc473b0a5cba6068ca3f61ee0..287e3243b10cc59d4453285466d5deda67c51f30 100644 (file)
@@ -732,7 +732,7 @@ class ServerHTMLDoc(pydoc.HTMLDoc):
         # hyperlinking of arbitrary strings being used as method
         # names. Only methods with names consisting of word characters
         # and '.'s are hyperlinked.
-        pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
+        pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|'
                                 r'RFC[- ]?(\d+)|'
                                 r'PEP[- ]?(\d+)|'
                                 r'(self\.)?((?:\w|\.)+))\b')
diff --git a/Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst b/Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst
new file mode 100644 (file)
index 0000000..f95d773
--- /dev/null
@@ -0,0 +1 @@
+pydoc now recognizes and parses HTTPS URLs. Patch by python273.