Login | Register
My pages Projects Community openCollabNet

2.2.  Plugins

[ fromfile: userguide.xml id: plugins ]

If a file called plugin.py is found in the plugins.dir (which defaults to ../bin), it will be loaded as a plugin and its mapText() function will be called if the extension() is provided as a command line switch to slacker's docbook. Example 3 shows an example plugin that could be used to process the document a final time.

Example 3. ../bin/example-plugin.py

# This is an example plugin for slacker's docbook. 
# See http://slackerdoc.tigris.org for details.

import os
from classnamemapper import ClassNameMapper
from tagwrapper import toxml
import application
from stringhelpers import isStringType

# Here is a list of all Qt classes we use in our documentation:

qtclasses = """ QButtonGroup, QDataWidgetMapper, QPaintDevice, QPointer, QPoint, QSize,
QDimension, QChar, QStringList, QStringListModel, QSet, QCache, QString, QMetaObject,
QMetaType, qRegisterMetaType, Q_DECLARE_METATYPE, Q_INTERFACES, QPair, QMetaProperty,
QDate, QDateTime, QDateEdit, QSlider, QLCDNumber, QHelpContentItem, QResource,
QDirIterator, QKeySequence, QSortFilterProxyModel, QTreeWidgetItemIterator,
QDomNodeList """

#excludeclasses = """ QFileInfoListIterator, QFileInfoList """

#qtbaseurl = "http://doc.trolltech.com/%s.html"
qtbaseurl = application.getProperty("qtdocs", "/qtdocs") + "/%s.html"
qtmapper = ClassNameMapper(qtclasses, qtbaseurl, 0)

apiclasses = """ QObjectBrowser, QObjectBrowserAction, ModelTest, DataObject,
DataObjectTableModel, ActionTableEditor, ActionTableModel, QObjectReader,
QObjectWriter, ObjectFactory, AbstractFactory, AudioMetaData, MetaDataObject,
ArgumentList """

apibaseurl = application.getProperty("oopapidoc", "/oopdocbook/api/html") + "/class%s.html"
apimapper = ClassNameMapper(apiclasses, apibaseurl, 0)


docbookelements = """ para, question, section, chapter, book, article, appendix,
    itemizedlist, unorderedlist, listitem, formalpara, tip, note, important,
    warning, caution """

docbookbaseurl = application.getProperty("docbook.doc.url", "") + "/%s.html"

# plugin interface:
def extension() :
    """ return the switch used by slacker's docbook to
        select this plugin """
    return 'oop'

def mapText(doc) :
    """ doc - an XML document 
        return the transformed document
    retval = qtmapper.xlat(doc)
    return apimapper.xlat(retval)