1 | \section{\module{pyclbr} ---
|
---|
2 | Python class browser support}
|
---|
3 |
|
---|
4 | \declaremodule{standard}{pyclbr}
|
---|
5 | \modulesynopsis{Supports information extraction for a Python class
|
---|
6 | browser.}
|
---|
7 | \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
|
---|
8 |
|
---|
9 |
|
---|
10 | The \module{pyclbr} can be used to determine some limited information
|
---|
11 | about the classes, methods and top-level functions
|
---|
12 | defined in a module. The information
|
---|
13 | provided is sufficient to implement a traditional three-pane class
|
---|
14 | browser. The information is extracted from the source code rather
|
---|
15 | than by importing the module, so this module is safe to use with
|
---|
16 | untrusted source code. This restriction makes it impossible to use
|
---|
17 | this module with modules not implemented in Python, including many
|
---|
18 | standard and optional extension modules.
|
---|
19 |
|
---|
20 |
|
---|
21 | \begin{funcdesc}{readmodule}{module\optional{, path}}
|
---|
22 | % The 'inpackage' parameter appears to be for internal use only....
|
---|
23 | Read a module and return a dictionary mapping class names to class
|
---|
24 | descriptor objects. The parameter \var{module} should be the name
|
---|
25 | of a module as a string; it may be the name of a module within a
|
---|
26 | package. The \var{path} parameter should be a sequence, and is used
|
---|
27 | to augment the value of \code{sys.path}, which is used to locate
|
---|
28 | module source code.
|
---|
29 | \end{funcdesc}
|
---|
30 |
|
---|
31 | \begin{funcdesc}{readmodule_ex}{module\optional{, path}}
|
---|
32 | % The 'inpackage' parameter appears to be for internal use only....
|
---|
33 | Like \function{readmodule()}, but the returned dictionary, in addition
|
---|
34 | to mapping class names to class descriptor objects, also maps
|
---|
35 | top-level function names to function descriptor objects. Moreover, if
|
---|
36 | the module being read is a package, the key \code{'__path__'} in the
|
---|
37 | returned dictionary has as its value a list which contains the package
|
---|
38 | search path.
|
---|
39 | \end{funcdesc}
|
---|
40 |
|
---|
41 |
|
---|
42 | \subsection{Class Descriptor Objects \label{pyclbr-class-objects}}
|
---|
43 |
|
---|
44 | The class descriptor objects used as values in the dictionary returned
|
---|
45 | by \function{readmodule()} and \function{readmodule_ex()}
|
---|
46 | provide the following data members:
|
---|
47 |
|
---|
48 |
|
---|
49 | \begin{memberdesc}[class descriptor]{module}
|
---|
50 | The name of the module defining the class described by the class
|
---|
51 | descriptor.
|
---|
52 | \end{memberdesc}
|
---|
53 |
|
---|
54 | \begin{memberdesc}[class descriptor]{name}
|
---|
55 | The name of the class.
|
---|
56 | \end{memberdesc}
|
---|
57 |
|
---|
58 | \begin{memberdesc}[class descriptor]{super}
|
---|
59 | A list of class descriptors which describe the immediate base
|
---|
60 | classes of the class being described. Classes which are named as
|
---|
61 | superclasses but which are not discoverable by
|
---|
62 | \function{readmodule()} are listed as a string with the class name
|
---|
63 | instead of class descriptors.
|
---|
64 | \end{memberdesc}
|
---|
65 |
|
---|
66 | \begin{memberdesc}[class descriptor]{methods}
|
---|
67 | A dictionary mapping method names to line numbers.
|
---|
68 | \end{memberdesc}
|
---|
69 |
|
---|
70 | \begin{memberdesc}[class descriptor]{file}
|
---|
71 | Name of the file containing the \code{class} statement defining the class.
|
---|
72 | \end{memberdesc}
|
---|
73 |
|
---|
74 | \begin{memberdesc}[class descriptor]{lineno}
|
---|
75 | The line number of the \code{class} statement within the file named by
|
---|
76 | \member{file}.
|
---|
77 | \end{memberdesc}
|
---|
78 |
|
---|
79 | \subsection{Function Descriptor Objects \label{pyclbr-function-objects}}
|
---|
80 |
|
---|
81 | The function descriptor objects used as values in the dictionary returned
|
---|
82 | by \function{readmodule_ex()} provide the following data members:
|
---|
83 |
|
---|
84 |
|
---|
85 | \begin{memberdesc}[function descriptor]{module}
|
---|
86 | The name of the module defining the function described by the function
|
---|
87 | descriptor.
|
---|
88 | \end{memberdesc}
|
---|
89 |
|
---|
90 | \begin{memberdesc}[function descriptor]{name}
|
---|
91 | The name of the function.
|
---|
92 | \end{memberdesc}
|
---|
93 |
|
---|
94 | \begin{memberdesc}[function descriptor]{file}
|
---|
95 | Name of the file containing the \code{def} statement defining the function.
|
---|
96 | \end{memberdesc}
|
---|
97 |
|
---|
98 | \begin{memberdesc}[function descriptor]{lineno}
|
---|
99 | The line number of the \code{def} statement within the file named by
|
---|
100 | \member{file}.
|
---|
101 | \end{memberdesc}
|
---|
102 |
|
---|