Fred Drake | 6b103f1 | 1999-02-18 21:06:50 +0000 | [diff] [blame] | 1 | \section{\module{pyclbr} --- |
Fred Drake | 7ceb577 | 1999-04-20 18:18:53 +0000 | [diff] [blame] | 2 | Python class browser support} |
Fred Drake | 6b103f1 | 1999-02-18 21:06:50 +0000 | [diff] [blame] | 3 | |
| 4 | \declaremodule{standard}{pyclbr} |
| 5 | \modulesynopsis{Supports information extraction for a Python class |
Fred Drake | 7ceb577 | 1999-04-20 18:18:53 +0000 | [diff] [blame] | 6 | browser.} |
Fred Drake | 6b103f1 | 1999-02-18 21:06:50 +0000 | [diff] [blame] | 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 and methods defined in a module. The information |
| 12 | provided is sufficient to implement a traditional three-pane class |
| 13 | browser. The information is extracted from the source code rather |
| 14 | than from an imported module, so this module is safe to use with |
Fred Drake | ef1a029 | 1999-06-29 15:43:02 +0000 | [diff] [blame] | 15 | untrusted source code. This restriction makes it impossible to use |
| 16 | this module with modules not implemented in Python, including many |
| 17 | standard and optional extension modules. |
Fred Drake | 6b103f1 | 1999-02-18 21:06:50 +0000 | [diff] [blame] | 18 | |
| 19 | |
| 20 | \begin{funcdesc}{readmodule}{module\optional{, path}} |
| 21 | % The 'inpackage' parameter appears to be for internal use only.... |
| 22 | Read a module and return a dictionary mapping class names to class |
| 23 | descriptor objects. The parameter \var{module} should be the name |
| 24 | of a module as a string; it may be the name of a module within a |
| 25 | package. The \var{path} parameter should be a sequence, and is used |
| 26 | to augment the value of \code{sys.path}, which is used to locate |
| 27 | module source code. |
| 28 | \end{funcdesc} |
| 29 | |
| 30 | |
| 31 | \subsection{Class Descriptor Objects \label{pyclbr-class-objects}} |
| 32 | |
| 33 | The class descriptor objects used as values in the dictionary returned |
| 34 | by \function{readmodule()} provide the following data members: |
| 35 | |
| 36 | |
Fred Drake | 7ceb577 | 1999-04-20 18:18:53 +0000 | [diff] [blame] | 37 | \begin{memberdesc}[class descriptor]{module} |
| 38 | The name of the module defining the class described by the class |
| 39 | descriptor. |
| 40 | \end{memberdesc} |
| 41 | |
Fred Drake | 6b103f1 | 1999-02-18 21:06:50 +0000 | [diff] [blame] | 42 | \begin{memberdesc}[class descriptor]{name} |
| 43 | The name of the class. |
| 44 | \end{memberdesc} |
| 45 | |
| 46 | \begin{memberdesc}[class descriptor]{super} |
| 47 | A list of class descriptors which describe the immediate base |
| 48 | classes of the class being described. Classes which are named as |
| 49 | superclasses but which are not discoverable by |
| 50 | \function{readmodule()} are listed as a string with the class name |
| 51 | instead of class descriptors. |
| 52 | \end{memberdesc} |
| 53 | |
| 54 | \begin{memberdesc}[class descriptor]{methods} |
| 55 | A dictionary mapping method names to line numbers. |
| 56 | \end{memberdesc} |
| 57 | |
| 58 | \begin{memberdesc}[class descriptor]{file} |
| 59 | Name of the file containing the class statement defining the class. |
| 60 | \end{memberdesc} |
| 61 | |
| 62 | \begin{memberdesc}[class descriptor]{lineno} |
| 63 | The line number of the class statement within the file named by |
| 64 | \member{file}. |
| 65 | \end{memberdesc} |