Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
db15ce96
Commit
db15ce96
authored
Jan 10, 2001
by
Shane Hathaway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the capability to create an API help topic from a module that
declares scarecrow interfaces.
parent
9bceb284
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
6 deletions
+71
-6
lib/python/HelpSys/APIHelpTopic.py
lib/python/HelpSys/APIHelpTopic.py
+71
-6
No files found.
lib/python/HelpSys/APIHelpTopic.py
View file @
db15ce96
...
@@ -91,6 +91,14 @@ import string
...
@@ -91,6 +91,14 @@ import string
import
HelpTopic
import
HelpTopic
from
Globals
import
HTMLFile
,
Persistent
from
Globals
import
HTMLFile
,
Persistent
_ignore_objects
=
{}
try
:
import
Interface
_ignore_objects
.
update
(
Interface
.
__dict__
)
except
ImportError
:
pass
class
APIHelpTopic
(
HelpTopic
.
HelpTopic
):
class
APIHelpTopic
(
HelpTopic
.
HelpTopic
):
"""
"""
Provides API documentation.
Provides API documentation.
...
@@ -106,9 +114,15 @@ class APIHelpTopic(HelpTopic.HelpTopic):
...
@@ -106,9 +114,15 @@ class APIHelpTopic(HelpTopic.HelpTopic):
self
.
doc
=
dict
.
get
(
'__doc__'
,
''
)
self
.
doc
=
dict
.
get
(
'__doc__'
,
''
)
self
.
apis
=
[]
self
.
apis
=
[]
for
v
in
dict
.
values
():
for
k
,
v
in
dict
.
items
():
if
type
(
v
)
==
types
.
ClassType
:
if
(
not
_ignore_objects
.
has_key
(
k
)
or
self
.
apis
.
append
(
APIDoc
(
v
))
_ignore_objects
[
k
]
is
not
v
):
if
type
(
v
)
==
types
.
ClassType
:
# A class.
self
.
apis
.
append
(
APIDoc
(
v
,
0
))
elif
(
hasattr
(
v
,
'isImplementedByInstancesOf'
)):
# A scarecrow interface.
self
.
apis
.
append
(
APIDoc
(
v
,
1
))
# try to get title from first non-blank line
# try to get title from first non-blank line
# of module docstring
# of module docstring
...
@@ -143,7 +157,39 @@ class APIDoc(Persistent):
...
@@ -143,7 +157,39 @@ class APIDoc(Persistent):
extends
=
()
extends
=
()
def
__init__
(
self
,
klass
):
def
__init__
(
self
,
klass
,
isInterface
=
0
):
if
isInterface
:
self
.
_createFromInterface
(
klass
)
else
:
self
.
_createFromClass
(
klass
)
def
_createFromInterface
(
self
,
klass
):
# Creates an APIDoc instance given an interface object.
self
.
name
=
klass
.
__name__
self
.
doc
=
trim_doc_string
(
klass
.
__doc__
)
# inheritence information
self
.
extends
=
[]
## for base in klass.getBases():
## names = string.split(base.__name__, '.')
## url="%s/Help/%s.py#%s" % (names[0], names[1], names[2])
## self.extends.append((names[2], url))
# constructor information
## if hasattr(klass, '__constructor__'):
## self.constructor=MethodDoc(klass.__constructor__)
# Get info on methods and attributes, ignore special items
self
.
attributes
=
[]
self
.
methods
=
[]
from
Interface.Method
import
Method
for
k
,
v
in
klass
.
namesAndDescriptions
():
if
hasattr
(
v
,
'getSignatureInfo'
):
self
.
methods
.
append
(
MethodDoc
(
v
,
1
))
else
:
self
.
attributes
.
append
(
AttributeDoc
(
k
,
v
.
__doc__
))
def
_createFromClass
(
self
,
klass
):
# Creates an APIDoc instance given a python class.
# Creates an APIDoc instance given a python class.
# the class describes the API; it contains
# the class describes the API; it contains
# methods, arguments and doc strings.
# methods, arguments and doc strings.
...
@@ -175,7 +221,7 @@ class APIDoc(Persistent):
...
@@ -175,7 +221,7 @@ class APIDoc(Persistent):
for
k
,
v
in
klass
.
__dict__
.
items
():
for
k
,
v
in
klass
.
__dict__
.
items
():
if
k
not
in
(
'__extends__'
,
'__doc__'
,
'__constructor__'
):
if
k
not
in
(
'__extends__'
,
'__doc__'
,
'__constructor__'
):
if
type
(
v
)
==
types
.
FunctionType
:
if
type
(
v
)
==
types
.
FunctionType
:
self
.
methods
.
append
(
MethodDoc
(
v
))
self
.
methods
.
append
(
MethodDoc
(
v
,
0
))
else
:
else
:
self
.
attributes
.
append
(
AttributeDoc
(
k
,
v
))
self
.
attributes
.
append
(
AttributeDoc
(
k
,
v
))
...
@@ -218,7 +264,26 @@ class MethodDoc(Persistent):
...
@@ -218,7 +264,26 @@ class MethodDoc(Persistent):
varargs
=
None
varargs
=
None
kwargs
=
None
kwargs
=
None
def
__init__
(
self
,
func
):
def
__init__
(
self
,
func
,
isInterface
=
0
):
if
isInterface
:
self
.
_createFromInterfaceMethod
(
func
)
else
:
self
.
_createFromFunc
(
func
)
def
_createFromInterfaceMethod
(
self
,
func
):
self
.
name
=
func
.
__name__
self
.
doc
=
trim_doc_string
(
func
.
__doc__
)
self
.
required
=
func
.
required
opt
=
[]
for
p
in
func
.
positional
[
len
(
func
.
required
):]:
opt
.
append
((
p
,
func
.
optional
[
p
]))
self
.
optional
=
tuple
(
opt
)
if
func
.
varargs
:
self
.
varargs
=
func
.
varargs
if
func
.
kwargs
:
self
.
kwargs
=
func
.
kwargs
def
_createFromFunc
(
self
,
func
):
if
hasattr
(
func
,
'im_func'
):
if
hasattr
(
func
,
'im_func'
):
func
=
func
.
im_func
func
=
func
.
im_func
...
...
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