Sydebar: A browser sidebar generator for Python documentation

Project:Sydebar
Version:1.0 (2008-06-02)
Author:Remy Blank
License:GPLv2
URL:http://c-space.org/software/Sydebar.html
Download:http://c-space.org/download/Sydebar/Sydebar-1.0.tar.gz
RC repository:http://rc.c-space.org/hg/Sydebar

Description

Sydebar is a browser sidebar generator for Python documentation pages. It can generate Python documentation sidebars for all Python versions, with the documentation pages either local or on a remote web server.

Sydebar parses the documentation index of a specific version of Python, and generates a single, self-contained XHTML document with one panel per section for the following sections:

Additionally, a search panel allows performing searches on the following sources:

Sydebar is released under the GNU General Public License version 2.

Quick start

Sample sidebars for all documentation versions available on python.org, generated with default parameters, can be found at this location.

To generate your own sidebar, proceed as follows:

Installation

Sydebar requires Python 2.4 or later and probably runs on all platforms where Python runs. It has been tested on Linux and Windows. The latest version can be downloaded at this location. Installation is not really necessary, as the sydebar.py script in the bin folder can be run directly from an unpacked source archive. A system-wide installation can be performed anyway with the usual distutils command:

python setup.py install

Usage

Sydebar generates XHTML sidebars for specific versions of the Python documentation. The generated page must be bookmarked in the browser and set up to be displayed in the sidebar instead of the main browser pane.

Generating the sidebar document

This step takes a URL pointing to the index page of the documentation for a specific Python version and a few options as inputs, and outputs a self-contained XHTML file containing the sidebar data and code. It only has to be performed once per documentation URL.

Command line usage information for the program can be displayed with sydebar.py --help:

$ sydebar.py --help
Usage: sydebar.py [options]

Sydebar 1.0   A browser sidebar generator for Python documentation
Copyright (C) 2008 Remy Blank

Sydebar is a browser sidebar generator for Python documentation pages. It can
generate Python documentation sidebars for all Python versions. The
documentation pages can be either local or on a remote web server.

Options:
  --debug               Show a full traceback when exceptions are raised
                        during execution.
  -h, --help            Show this help message and exit.
  --version             Show the program version and exit.

  Input options:
    --image-clear=FILE  Read the 'clear' image from FILE. The default is
                        'clear.png'.
    --image-icon=FILE   Read the 'icon' image from FILE. The default is
                        'python.ico'.
    --image-minus=FILE  Read the 'minus' image from FILE. The default is
                        'minus.png'.
    --image-plus=FILE   Read the 'plus' image from FILE. The default is
                        'plus.png'.
    --image-search=FILE
                        Read the 'search' image from FILE. The default is
                        'search.png'.
    -t FILE, --template=FILE
                        Read the page template from FILE. The default is
                        'template.html'.
    -u URL, --url=URL   Generate the sidebar for the Python documentation
                        located at URL. The default is
                        'http://www.python.org/doc/2.4.4/'.

  Output options:
    -a, --all-versions  Generate sidebars for all documentation versions
                        available on python.org. The output file name must
                        contain a '%s' pattern that will be replaced by the
                        version string.
    -f N, --field-width=N
                        Set the width of text fields to N characters. The
                        default is 25.
    -n, --no-pack       Don't pack the resulting XHTML file (i.e. don't remove
                        non-significant white space). This will output nicely
                        indented and readable XHTML.
    -o FILE, --output=FILE
                        Write the output to FILE. If FILE is '-', the output
                        is written to standard output. The default is '-'.
    -p PANEL, --panel=PANEL
                        Show PANEL when loading the sidebar. PANEL can be one
                        of Tut, Ref, Lib, Api, Ext, Mod, Search. The default
                        is to show the module index if it is available, and
                        the tutorial otherwise.
    -s N, --font-size=N
                        Set the base font size to N pixels. The default is 11.

Input options

--image-clear=FILE, --image-icon=FILE, --image-minus=FILE, --image-plus=FILE, --image-search=FILE
Specify alternate image files for the clear button of the incremental search, the page icon, the minus and plus buttons for collapsing and expanding the trees, and the search tab and buttons, respectively. The images are embedded into the XHTML page as data: URIs.
-t FILE, --template=FILE
Specify an alternate page template for the sidebar. The template contains named string substitution references that are replaced by the relevant generated items using the string formatting operator %.
-u URL, --url=URL
Specify the base URL of the documentation for which the sidebar is to be generated. The URL can be either remote or local: The default is a remote URL to the documentation of the Python version running the program.

Output options

-a, --all-versions
Generate one sidebar for every documentation version available on python.org. The sidebars are written to separate files. The --output option becomes mandatory and it must contain a single %s pattern that will be replaced with the version string to construct the output file names.
-f N, --field-width=N
Specify the width of the search fields in characters.
-n, --no-pack
Don't pack the resulting XHTML file. The packing algorithm is very simple: it just removes any white space between > and < characters. Setting this option will make the program output nicely indented and readable XHTML.
-o FILE, --output=FILE
Write the generated XHTML to FILE. The default is to write to standard output, which can also be specified explicitly by passing '' as FILE.
-p PANEL, --panel=PANEL
Specify the panel to be shown initially when the sidebar is loaded.
-s N, --font-size=N
Set the base font size to N pixels.

Examples

Bookmarking the generated sidebar

The generated sidebar document can now be displayed in the main pane of a browser. To show it in the sidebar, it must be bookmarked specifically.

Using the sidebar

The sidebar is structured as a deck of panels containing links to various sections of the documentation. Clicking a link opens the corresponding section in the main browser pane. The main features of the sidebar are the following:

Load-time parameters

The appearance of the sidebar content is determined at generation time from the command line options. However, a few parameters can be changed at load-time through URL parameters:

fontSize=N
Set the base font size to N pixels. This parameter has the same effect as the --font-size command line option.
fieldWidth=N
Set the width of the search fields to N characters. This parameter has the same effect as the --field-width command line option.
panel=(Tut|Ref|Lib|Api|Ext|Mod|Search)
Specify the panel to be shown initially when the sidebar is loaded. This parameter has the same effect as the --panel command line option.

As an example, the following URL loads the sidebar with a font size of 15 pixels, a field width of 30 and initially shows the search panel:

file:///home/user/Sydebar-current.html?fontSize=15&fieldWidth=30&panel=Search

Known issues

Sydebar has been tested with Python 2.4.4 on Linux and Windows. Moreover, the generated pages have been tested in Firefox 2.0.0.14 and Opera 9.27. This section documents the issues that have appeared during testing, and for which I haven't found a solution yet.

Feedback

If you are using Sydebar, please let me know! I'm especially interested in bug reports, improvement ideas, and compatibility fixes.

Links