bpo-38786: Add parsing of https links to pydoc (GH-17143)
This commit is contained in:
parent
d89cea15ad
commit
61289d4366
|
@ -585,7 +585,7 @@ class HTMLDoc(Doc):
|
||||||
escape = escape or self.escape
|
escape = escape or self.escape
|
||||||
results = []
|
results = []
|
||||||
here = 0
|
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'RFC[- ]?(\d+)|'
|
||||||
r'PEP[- ]?(\d+)|'
|
r'PEP[- ]?(\d+)|'
|
||||||
r'(self\.)?(\w+))')
|
r'(self\.)?(\w+))')
|
||||||
|
|
|
@ -1311,6 +1311,17 @@ foo
|
||||||
'async <a name="-an_async_generator"><strong>an_async_generator',
|
'async <a name="-an_async_generator"><strong>an_async_generator',
|
||||||
html)
|
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):
|
class PydocServerTest(unittest.TestCase):
|
||||||
"""Tests for pydoc._start_server"""
|
"""Tests for pydoc._start_server"""
|
||||||
|
|
||||||
|
|
|
@ -732,7 +732,7 @@ class ServerHTMLDoc(pydoc.HTMLDoc):
|
||||||
# hyperlinking of arbitrary strings being used as method
|
# hyperlinking of arbitrary strings being used as method
|
||||||
# names. Only methods with names consisting of word characters
|
# names. Only methods with names consisting of word characters
|
||||||
# and '.'s are hyperlinked.
|
# 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'RFC[- ]?(\d+)|'
|
||||||
r'PEP[- ]?(\d+)|'
|
r'PEP[- ]?(\d+)|'
|
||||||
r'(self\.)?((?:\w|\.)+))\b')
|
r'(self\.)?((?:\w|\.)+))\b')
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pydoc now recognizes and parses HTTPS URLs. Patch by python273.
|
Loading…
Reference in New Issue