Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
89249205
Commit
89249205
authored
Jun 03, 2016
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#16484: Fix pydoc doc links to modules whose names are mixed case.
Patch by Sean Rodman, test by Kaushik N.
parent
27f177ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
Lib/pydoc.py
Lib/pydoc.py
+6
-6
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+14
-0
Misc/ACKS
Misc/ACKS
+1
-0
No files found.
Lib/pydoc.py
View file @
89249205
...
@@ -354,7 +354,7 @@ def safeimport(path, forceload=0, cache={}):
...
@@ -354,7 +354,7 @@ def safeimport(path, forceload=0, cache={}):
class
Doc
:
class
Doc
:
PYTHONDOCS
=
os
.
environ
.
get
(
"PYTHONDOCS"
,
PYTHONDOCS
=
os
.
environ
.
get
(
"PYTHONDOCS"
,
"http://docs.python.org/%d.%d/library"
"http
s
://docs.python.org/%d.%d/library"
%
sys
.
version_info
[:
2
])
%
sys
.
version_info
[:
2
])
def
document
(
self
,
object
,
name
=
None
,
*
args
):
def
document
(
self
,
object
,
name
=
None
,
*
args
):
...
@@ -383,7 +383,9 @@ class Doc:
...
@@ -383,7 +383,9 @@ class Doc:
docmodule
=
docclass
=
docroutine
=
docother
=
docproperty
=
docdata
=
fail
docmodule
=
docclass
=
docroutine
=
docother
=
docproperty
=
docdata
=
fail
def
getdocloc
(
self
,
object
):
def
getdocloc
(
self
,
object
,
basedir
=
os
.
path
.
join
(
sys
.
base_exec_prefix
,
"lib"
,
"python%d.%d"
%
sys
.
version_info
[:
2
])):
"""Return the location of module docs or None"""
"""Return the location of module docs or None"""
try
:
try
:
...
@@ -393,8 +395,6 @@ class Doc:
...
@@ -393,8 +395,6 @@ class Doc:
docloc
=
os
.
environ
.
get
(
"PYTHONDOCS"
,
self
.
PYTHONDOCS
)
docloc
=
os
.
environ
.
get
(
"PYTHONDOCS"
,
self
.
PYTHONDOCS
)
basedir
=
os
.
path
.
join
(
sys
.
base_exec_prefix
,
"lib"
,
"python%d.%d"
%
sys
.
version_info
[:
2
])
if
(
isinstance
(
object
,
type
(
os
))
and
if
(
isinstance
(
object
,
type
(
os
))
and
(
object
.
__name__
in
(
'errno'
,
'exceptions'
,
'gc'
,
'imp'
,
(
object
.
__name__
in
(
'errno'
,
'exceptions'
,
'gc'
,
'imp'
,
'marshal'
,
'posix'
,
'signal'
,
'sys'
,
'marshal'
,
'posix'
,
'signal'
,
'sys'
,
...
@@ -403,9 +403,9 @@ class Doc:
...
@@ -403,9 +403,9 @@ class Doc:
not
file
.
startswith
(
os
.
path
.
join
(
basedir
,
'site-packages'
))))
and
not
file
.
startswith
(
os
.
path
.
join
(
basedir
,
'site-packages'
))))
and
object
.
__name__
not
in
(
'xml.etree'
,
'test.pydoc_mod'
)):
object
.
__name__
not
in
(
'xml.etree'
,
'test.pydoc_mod'
)):
if
docloc
.
startswith
(
"http://"
):
if
docloc
.
startswith
(
"http://"
):
docloc
=
"%s/%s"
%
(
docloc
.
rstrip
(
"/"
),
object
.
__name__
)
docloc
=
"%s/%s"
%
(
docloc
.
rstrip
(
"/"
),
object
.
__name__
.
lower
()
)
else
:
else
:
docloc
=
os
.
path
.
join
(
docloc
,
object
.
__name__
+
".html"
)
docloc
=
os
.
path
.
join
(
docloc
,
object
.
__name__
.
lower
()
+
".html"
)
else
:
else
:
docloc
=
None
docloc
=
None
return
docloc
return
docloc
...
...
Lib/test/test_pydoc.py
View file @
89249205
...
@@ -18,6 +18,7 @@ import types
...
@@ -18,6 +18,7 @@ import types
import
unittest
import
unittest
import
urllib.parse
import
urllib.parse
import
xml.etree
import
xml.etree
import
xml.etree.ElementTree
import
textwrap
import
textwrap
from
io
import
StringIO
from
io
import
StringIO
from
collections
import
namedtuple
from
collections
import
namedtuple
...
@@ -352,6 +353,14 @@ def get_pydoc_html(module):
...
@@ -352,6 +353,14 @@ def get_pydoc_html(module):
loc
=
"<br><a href=
\
"
"
+
loc
+
"
\
"
>Module Docs</a>"
loc
=
"<br><a href=
\
"
"
+
loc
+
"
\
"
>Module Docs</a>"
return
output
.
strip
(),
loc
return
output
.
strip
(),
loc
def
get_pydoc_link
(
module
):
"Returns a documentation web link of a module"
dirname
=
os
.
path
.
dirname
basedir
=
os
.
path
.
join
(
dirname
(
dirname
(
__file__
)))
doc
=
pydoc
.
TextDoc
()
loc
=
doc
.
getdocloc
(
module
,
basedir
=
basedir
)
return
loc
def
get_pydoc_text
(
module
):
def
get_pydoc_text
(
module
):
"Returns pydoc generated output as text"
"Returns pydoc generated output as text"
doc
=
pydoc
.
TextDoc
()
doc
=
pydoc
.
TextDoc
()
...
@@ -443,6 +452,11 @@ class PydocDocTest(unittest.TestCase):
...
@@ -443,6 +452,11 @@ class PydocDocTest(unittest.TestCase):
doc
=
pydoc
.
render_doc
(
BinaryInteger
)
doc
=
pydoc
.
render_doc
(
BinaryInteger
)
self
.
assertIn
(
'<BinaryInteger.zero: 0>'
,
doc
)
self
.
assertIn
(
'<BinaryInteger.zero: 0>'
,
doc
)
def
test_mixed_case_module_names_are_lower_cased
(
self
):
# issue16484
doc_link
=
get_pydoc_link
(
xml
.
etree
.
ElementTree
)
self
.
assertIn
(
'xml.etree.elementtree'
,
doc_link
)
def
test_issue8225
(
self
):
def
test_issue8225
(
self
):
# Test issue8225 to ensure no doc link appears for xml.etree
# Test issue8225 to ensure no doc link appears for xml.etree
result
,
doc_loc
=
get_pydoc_text
(
xml
.
etree
)
result
,
doc_loc
=
get_pydoc_text
(
xml
.
etree
)
...
...
Misc/ACKS
View file @
89249205
...
@@ -1018,6 +1018,7 @@ Louis Munro
...
@@ -1018,6 +1018,7 @@ Louis Munro
R. David Murray
R. David Murray
Matti Mäki
Matti Mäki
Jörg Müller
Jörg Müller
Kaushik N
Dale Nagata
Dale Nagata
John Nagle
John Nagle
Takahiro Nakayama
Takahiro Nakayama
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment