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
060407d3
Commit
060407d3
authored
Sep 10, 2003
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display link to module docs when it looks like the object module is a core
module
parent
8d7f81f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
Lib/pydoc.py
Lib/pydoc.py
+47
-1
No files found.
Lib/pydoc.py
View file @
060407d3
...
@@ -24,6 +24,14 @@ and also pops up a little window for controlling it.
...
@@ -24,6 +24,14 @@ and also pops up a little window for controlling it.
Run "pydoc -w <name>" to write out the HTML documentation for a module
Run "pydoc -w <name>" to write out the HTML documentation for a module
to a file named "<name>.html".
to a file named "<name>.html".
Module docs for core modules are assumed to be in
http://www.python.org/doc/current/lib/
This can be overridden by setting the PYTHONDOCS environment variable
to a different URL or to a local directory containing the Library
Reference Manual pages.
"""
"""
__author__
=
"Ka-Ping Yee <ping@lfw.org>"
__author__
=
"Ka-Ping Yee <ping@lfw.org>"
...
@@ -295,6 +303,33 @@ class Doc:
...
@@ -295,6 +303,33 @@ class Doc:
docmodule
=
docclass
=
docroutine
=
docother
=
fail
docmodule
=
docclass
=
docroutine
=
docother
=
fail
def
getdocloc
(
self
,
object
):
"""Return the location of module docs or None"""
try
:
file
=
inspect
.
getabsfile
(
object
)
except
TypeError
:
file
=
'(built-in)'
docloc
=
os
.
environ
.
get
(
"PYTHONDOCS"
,
"http://www.python.org/doc/current/lib"
)
basedir
=
os
.
path
.
join
(
sys
.
exec_prefix
,
"lib"
,
"python"
+
sys
.
version
[
0
:
3
])
if
(
isinstance
(
object
,
type
(
os
))
and
(
object
.
__name__
in
(
'errno'
,
'exceptions'
,
'gc'
,
'imp'
,
'marshal'
,
'posix'
,
'signal'
,
'sys'
,
'thread'
,
'zipimport'
)
or
(
file
.
startswith
(
basedir
)
and
not
file
.
startswith
(
os
.
path
.
join
(
basedir
,
'site-packages'
))))):
if
docloc
.
startswith
(
"http://"
):
docloc
=
(
docloc
.
rstrip
(
"/"
)
+
"/module-%s.html"
%
object
.
__name__
)
else
:
docloc
=
os
.
path
.
join
(
docloc
,
"module-%s.html"
%
name
)
else
:
docloc
=
None
return
docloc
# -------------------------------------------- HTML documentation generator
# -------------------------------------------- HTML documentation generator
class
HTMLRepr
(
Repr
):
class
HTMLRepr
(
Repr
):
...
@@ -535,8 +570,14 @@ class HTMLDoc(Doc):
...
@@ -535,8 +570,14 @@ class HTMLDoc(Doc):
info
.
append
(
self
.
escape
(
str
(
object
.
__date__
)))
info
.
append
(
self
.
escape
(
str
(
object
.
__date__
)))
if
info
:
if
info
:
head
=
head
+
' (%s)'
%
join
(
info
,
', '
)
head
=
head
+
' (%s)'
%
join
(
info
,
', '
)
docloc
=
self
.
getdocloc
(
object
)
if
docloc
is
not
None
:
docloc
=
'<br><a href="%(docloc)s">Module Docs</a>'
%
locals
()
else
:
docloc
=
''
result
=
self
.
heading
(
result
=
self
.
heading
(
head
,
'#ffffff'
,
'#7799ee'
,
'<a href=".">index</a><br>'
+
filelink
)
head
,
'#ffffff'
,
'#7799ee'
,
'<a href=".">index</a><br>'
+
filelink
+
docloc
)
modules
=
inspect
.
getmembers
(
object
,
inspect
.
ismodule
)
modules
=
inspect
.
getmembers
(
object
,
inspect
.
ismodule
)
...
@@ -950,6 +991,11 @@ class TextDoc(Doc):
...
@@ -950,6 +991,11 @@ class TextDoc(Doc):
except
TypeError
:
except
TypeError
:
file
=
'(built-in)'
file
=
'(built-in)'
result
=
result
+
self
.
section
(
'FILE'
,
file
)
result
=
result
+
self
.
section
(
'FILE'
,
file
)
docloc
=
self
.
getdocloc
(
object
)
if
docloc
is
not
None
:
result
=
result
+
self
.
section
(
'MODULE DOCS'
,
docloc
)
if
desc
:
if
desc
:
result
=
result
+
self
.
section
(
'DESCRIPTION'
,
desc
)
result
=
result
+
self
.
section
(
'DESCRIPTION'
,
desc
)
...
...
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