Skip to content

Commit 61289d4

Browse files
python273taleinat
authored andcommitted
bpo-38786: Add parsing of https links to pydoc (GH-17143)
1 parent d89cea1 commit 61289d4

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

Lib/pydoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
585585
escape = escape or self.escape
586586
results = []
587587
here = 0
588-
pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
588+
pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|'
589589
r'RFC[- ]?(\d+)|'
590590
r'PEP[- ]?(\d+)|'
591591
r'(self\.)?(\w+))')

Lib/test/test_pydoc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,17 @@ async def an_async_generator():
13111311
'async <a name="-an_async_generator"><strong>an_async_generator',
13121312
html)
13131313

1314+
def test_html_for_https_links(self):
1315+
def a_fn_with_https_link():
1316+
"""a link https://localhost/"""
1317+
pass
1318+
1319+
html = pydoc.HTMLDoc().document(a_fn_with_https_link)
1320+
self.assertIn(
1321+
'<a href="https://localhost/">https://localhost/</a>',
1322+
html
1323+
)
1324+
13141325
class PydocServerTest(unittest.TestCase):
13151326
"""Tests for pydoc._start_server"""
13161327

Lib/xmlrpc/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
732732
# hyperlinking of arbitrary strings being used as method
733733
# names. Only methods with names consisting of word characters
734734
# and '.'s are hyperlinked.
735-
pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
735+
pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|'
736736
r'RFC[- ]?(\d+)|'
737737
r'PEP[- ]?(\d+)|'
738738
r'(self\.)?((?:\w|\.)+))\b')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pydoc now recognizes and parses HTTPS URLs. Patch by python273.

0 commit comments

Comments
 (0)