Changes between Initial Version and Version 1 of CreatePluginScript


Ignore:
Timestamp:
Jul 3, 2008, 8:38:35 PM (16 years ago)
Author:
Jeff Hammel
Comment:

New hack CreatePluginScript, created by k0s

Legend:

Unmodified
Added
Removed
Modified
  • CreatePluginScript

    v1 v1  
     1= create a trac plugin skeleton given a list of interfaces =
     2
     3== Description ==
     4
     5This python package will create a plugin skeleton given its name and a list of interfaces.  The console script, create-trac-plugin, front-ends TracPluginTemplateScript and creates the basic layout of the plugin using [http://pythonpaste.org/script/ PasteScript].  Then the basic contents of the [http://trac.edgewall.org/wiki/TracDev/ComponentArchitecture component] are generated by looking through the chosen interfaces and filling out the imports needed and signatures for the methods used.
     6
     7The create-component script front-ends create_component.py, which can be used as as standalone piece without the rest of the software.
     8
     9== Bugs/Feature Requests ==
     10
     11Existing bugs and feature requests for CreatePluginScript are
     12[report:9?COMPONENT=CreatePluginScript here].
     13
     14If you have any issues, create a
     15[http://trac-hacks.org/newticket?component=CreatePluginScript&owner=k0s new ticket].
     16
     17== Download ==
     18
     19Download the zipped source from [download:createpluginscript here].
     20
     21== Source ==
     22
     23You can check out CreatePluginScript from [http://trac-hacks.org/svn/createpluginscript here] using Subversion, or [source:createpluginscript browse the source] with Trac.
     24
     25== Example ==
     26
     27To list the interfaces available, simply run either of the console scripts without arguments:
     28
     29{{{
     30$ create-trac-plugin
     31Usage:
     32 create-trac-plugin <name> [interface1] [interface2] [...] # to create a component with name
     33 create-trac-plugin # for usage and component list
     34
     35Interfaces available:
     36
     37IAdminPanelProvider
     38IAttachmentChangeListener
     39IAttachmentManipulator
     40IAuthenticator
     41IContentConverter
     42IDatabaseConnector
     43IEnvironmentSetupParticipant
     44IHTMLPreviewAnnotator
     45IHTMLPreviewRenderer
     46ILegacyAttachmentPolicyDelegate
     47INavigationContributor
     48IPermissionGroupProvider
     49IPermissionPolicy
     50IPermissionRequestor
     51IPermissionStore
     52IPreferencePanelProvider
     53IPropertyDiffRenderer
     54IPropertyRenderer
     55IRepositoryConnector
     56IRequestFilter
     57IRequestHandler
     58IResourceManager
     59ISearchSource
     60ITemplateProvider
     61ITemplateStreamFilter
     62ITicketActionController
     63ITicketChangeListener
     64ITicketManipulator
     65ITimelineEventProvider
     66IWikiChangeListener
     67IWikiMacroProvider
     68IWikiPageManipulator
     69IWikiSyntaxProvider
     70}}}
     71
     72To make a plugin named NewPlugin that implements the ITemplateStreamFilter and IWikiSyntaxProvider interfaces, run:
     73
     74{{{
     75$ create-trac-plugin NewPlugin ITemplateStreamFilter IWikiSyntaxProvider
     76}}}
     77
     78This will setup a directory structure using TracPluginTemplateScript:
     79
     80{{{
     81NewPlugin/
     82|-- NewPlugin.egg-info
     83|-- newplugin
     84|   |-- __init__.py
     85|   `-- newplugin.py
     86`-- setup.py
     87}}}
     88
     89{{{newplugin.py}}} will be populated with markers for the appropriate interfaces and the correct imports:
     90
     91{{{
     92"""
     93NewPlugin:
     94a plugin for Trac
     95http://trac.edgewall.org
     96"""
     97
     98from trac.core import *
     99
     100from trac.web.api import ITemplateStreamFilter
     101from trac.wiki.api import IWikiSyntaxProvider
     102
     103class NewPlugin(Component):
     104
     105    implements(ITemplateStreamFilter, IWikiSyntaxProvider)
     106
     107    ### methods for ITemplateStreamFilter
     108
     109    """Filter a Genshi event stream prior to rendering."""
     110
     111    def filter_stream(self, req, method, filename, stream, data):
     112        """Return a filtered Genshi event stream, or the original unfiltered
     113        stream if no match.
     114
     115        `req` is the current request object, `method` is the Genshi render
     116        method (xml, xhtml or text), `filename` is the filename of the template
     117        to be rendered, `stream` is the event stream and `data` is the data for
     118        the current template.
     119
     120        See the Genshi documentation for more information.
     121        """
     122
     123    ### methods for IWikiSyntaxProvider
     124
     125    def get_link_resolvers(self):
     126        """Return an iterable over (namespace, formatter) tuples.
     127
     128        Each formatter should be a function of the form
     129        fmt(formatter, ns, target, label), and should
     130        return some HTML fragment.
     131        The `label` is already HTML escaped, whereas the `target` is not.
     132        """
     133
     134    def get_wiki_syntax(self):
     135        """Return an iterable that provides additional wiki syntax.
     136
     137        Additional wiki syntax correspond to a pair of (regexp, cb),
     138        the `regexp` for the additional syntax and the callback `cb`
     139        which will be called if there's a match.
     140        That function is of the form cb(formatter, ns, match).
     141        """
     142}}}
     143
     144To just generate the file (to stdout), use {{{create-trac-component}}} (or {{{python create_component.py}}}):
     145
     146{{{
     147$ create-trac-component NewPlugin ITemplateStreamFilter IWikiSyntaxProvider
     148}}}
     149
     150== Recent Changes ==
     151
     152[[ChangeLog(createpluginscript, 3)]]
     153
     154== Author/Contributors ==
     155
     156'''Author:''' [wiki:k0s] [[BR]]
     157'''Contributors:'''