blob: 0dedb9e5d2fe5b95697ff589948580faf6dbadc8 [file] [log] [blame]
Fred Drake6b103f11999-02-18 21:06:50 +00001\section{\module{pyclbr} ---
Fred Drake7ceb5771999-04-20 18:18:53 +00002 Python class browser support}
Fred Drake6b103f11999-02-18 21:06:50 +00003
4\declaremodule{standard}{pyclbr}
5\modulesynopsis{Supports information extraction for a Python class
Fred Drake7ceb5771999-04-20 18:18:53 +00006 browser.}
Fred Drake6b103f11999-02-18 21:06:50 +00007\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
8
9
10The \module{pyclbr} can be used to determine some limited information
Alex Martelli37dc3342003-11-09 16:32:54 +000011about the classes, methods and top-level functions
12defined in a module. The information
Fred Drake6b103f11999-02-18 21:06:50 +000013provided is sufficient to implement a traditional three-pane class
14browser. The information is extracted from the source code rather
Alex Martelli37dc3342003-11-09 16:32:54 +000015than by importing the module, so this module is safe to use with
Fred Drakeef1a0291999-06-29 15:43:02 +000016untrusted source code. This restriction makes it impossible to use
17this module with modules not implemented in Python, including many
18standard and optional extension modules.
Fred Drake6b103f11999-02-18 21:06:50 +000019
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
Alex Martelli37dc3342003-11-09 16:32:54 +000031\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
Fred Drake6b103f11999-02-18 21:06:50 +000041
42\subsection{Class Descriptor Objects \label{pyclbr-class-objects}}
43
44The class descriptor objects used as values in the dictionary returned
Alex Martelli37dc3342003-11-09 16:32:54 +000045by \function{readmodule()} and \function{readmodule_ex()}
46provide the following data members:
Fred Drake6b103f11999-02-18 21:06:50 +000047
48
Fred Drake7ceb5771999-04-20 18:18:53 +000049\begin{memberdesc}[class descriptor]{module}
50 The name of the module defining the class described by the class
51 descriptor.
52\end{memberdesc}
53
Fred Drake6b103f11999-02-18 21:06:50 +000054\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}
Fred Draked85ed1b2003-11-10 14:50:54 +000071 Name of the file containing the \code{class} statement defining the class.
Fred Drake6b103f11999-02-18 21:06:50 +000072\end{memberdesc}
73
74\begin{memberdesc}[class descriptor]{lineno}
Alex Martelli37dc3342003-11-09 16:32:54 +000075 The line number of the \code{class} statement within the file named by
Fred Drake6b103f11999-02-18 21:06:50 +000076 \member{file}.
77\end{memberdesc}
Alex Martelli37dc3342003-11-09 16:32:54 +000078
79\subsection{Function Descriptor Objects \label{pyclbr-function-objects}}
80
81The function descriptor objects used as values in the dictionary returned
82by \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