|
This chapter describes the source code browser, which is available only in Wing IDE Standard and higher. The browser acts as an index to your source code, supporting inspection of collections of Python source code from either a module-oriented or class hierarchy-oriented standpoint.
The source code browser is divided into three panels: (1) a hierarchical list view, (2) a panel of display filter options, and (3) an embedded information display area. These panels can be resized by dragging on the seperator handles between them.
The source code browser offers three ways in which to look at your body of source code. These are selected using the radio buttons along the top edge of the class browser window.
Viewing by module shows all files that you have placed into your project file within the top major panel of the source code browser window. This module list is a hierarchical expandable tree view that shows all modules, directories, and packages at the top level in alphabetical order. These major units are defined as follows:
__init__.py
. This
file contains a special variable __all__
that lists the file-level
modules Python should automatically import when the package as a whole is
imported. See the Python documentation for additional information
on creating packages, or look at the Wing source code for examples.
__init__.py
file are listed as 'directory' rather than 'package'
in the source browser window.
Within each top-level package, directory, or module, the browser will display all sub-modules, sub-directories, modules, and any Python constructs. These are all labeled by generic type, including the following types:
When viewing by class hierachy, the browser replaces the hierarchical tree view with a list of all top-level classes found in analyzed code, in alphabetical order.
In this display mode, the structure on disk of your packages, directories, and modules is completely hidden from view. Instead, the hierarchy of your classes is displayed, starting at base classes and working downward to derived classes.
Within each class, in addition to a list of derived classes, the methods and attributes for the class are shown.
In order to find classes by name more easily, the browser can be asked to display a list that includes all found Python classes. In this case, all classes (and not just base classes) are displayed at the top-level of the hierarchical viewer.
This view is otherwise identical to the Class Hierarchy view.
Once it has the focus, the browser tree view is navigable with the keyboard, using the up/down arrow keys, page up and page down, home/end, and by using the right arrow key on a parent to expand it, or the left arrow key to collapse a parent. Holding down the shift key while pressing the right arrow will expand recursively below the expansion point. Recursive expansion is capped at five additional levels for each operation to avoid difficult-to-detect infinite recursions. Whenever a tree row is selected, pressing enter or return will open the source view for the selected symbol in a seperate window, selecting the point of definition for that symbol.
The source code analyzer will run in the background from the time that you open a project until all files have been analyzed. You may notice this overhead during the first 5 to 30 seconds after you have opened your project, depending on the size of your source base. Until analysis is complete, the class-oriented view within the browser window will only include those classes that have been analyzed. This list is updated as more code is analyzed.
|
A number of options are available for filtering the constructs that are presented by the source code browser. These filters are organized into two major groups: (1) construct scope and source, and (2) construct type.
The following distinctions are made. Constructs in each category can be shown or hidden as a group:
Print()
or kMaxListLength
.__ConstructNameList()
or __id_seed
. Python
enforces local-only access to these constructs in class methods
(see the Python documentation for details)._NotifyError()
or
_gMaxCount
. Python doesn't enforce usage of these constructs,
but they are helpful in writing clean, well-structured code and are
recommended in the Python language style guide.
Constructs in the source code browser window can also be shown or hidden on the basis of their basic type within the language:
In all the display views, the ordering of constructs within a module or class can be controlled by the radio buttons labeled 'Sort'.
Sorting doesn't affect the top-level of the hierarchical list view, which is alphabetic in all cases.
The tabbed area at the bottom of the source code browser can be used to view information about items selected in the hierarchical list view above.
When the Documentation tab is selected, the source code browser will display any available Python 'doc string' information for the construct selected in the hierarchical list view above.
This only contains information when a doc string is defined and only works for packages, modules, classes, functions, and methods (and never for variables or attributes).
When the Source tab is selected, the source code browser will display the source at point of definition of the selected construct.
The source view is a fully functional source code editor. If you make changes here, any additional view of that source will be updated.
You may be asked to save changes if you navigate to another source file after making an edit, since the source files are closed if there isn't another view to them open in another window.
|
You can disable tracking of your selection in the hierarchical list area by unchecking the 'Follow Selection' check box that is displayed under this tab. Otherwise, the source code view will scroll to position as you change your selection above.
A number of options are available for navigating around source from the browser window:
The following preferences are available for control source code analysis and the source browser:
WINGHOME
.
Default='src/pysource/builtin-pi-files'
true
__init__
method
or all methods in each class. Valid values are 'init-only'
and
'all-methods'
. Default='all-methods'
.50
. 10
.You need to quit and restart Wing before any changes in these preferences take effect.