Package gavo :: Package utils :: Module misctricks :: Class RSTExtensions
[frames] | no frames]

Class RSTExtensions

source code

object --+
         |
        RSTExtensions

a register for local RST extensions.

This is for both directives and interpreted text roles.

We need these as additional markup in examples; these always introduce local rst interpreted text roles, which always add some class to the node in question (modifications are possible).

These classes are then changed to properties as the HTML fragments from RST translation are processed by the _Example nevow data factory.

To add a new text role, say:

       RSTExtensions.addRole(roleName, roleFunc=None)

You can pass in a full role function as discussed in /usr/share/doc/python-docutils/docs/howto/rst-roles.html (Debian systems). It must, however, add a dachs-ex-<roleName> class to the node. The default funtion produces a nodes.emphasis item with the proper class.

In a pinch, you can pass a propertyName argument to addRole if the desired property name is distinct from the role name in the RST. This is used by tapquery and taprole since we didn't want to change our examples when the standard changed.

To add a directive, say:

       RSTExtensions.addDirective(dirName, dirClass)

In HTML, these classes become properties named like the role name (except you can again use propertyName in a pinch).

Instance Methods

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
addDirective(cls, name, implementingClass, propertyName=None) source code
 
makeTextRole(cls, roleName, roleFunc=None, propertyName=None)
creates a new text role for roleName.
source code
Class Variables
  classToProperty = {'dachs-ex-bibcode': 'bibcode', 'dachs-ex-da...
Properties

Inherited from object: __class__

Method Details

makeTextRole(cls, roleName, roleFunc=None, propertyName=None)
Class Method

source code 

creates a new text role for roleName.

See class docstring.


Class Variable Details

classToProperty

Value:
{'dachs-ex-bibcode': 'bibcode',
 'dachs-ex-dachsdoc': 'dachsdoc',
 'dachs-ex-dachsref': 'dachsref',
 'dachs-ex-dl-id': 'dl-id',
 'dachs-ex-genparam': 'genparam',
 'dachs-ex-samplerd': 'samplerd',
 'dachs-ex-tapquery': 'query',
 'dachs-ex-taptable': 'table'}