Changes between Version 16 and Version 17 of DevGuide
- Timestamp:
- May 2, 2015, 11:48:13 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevGuide
v16 v17 1 1 [[PageOutline(2-5,Contents,pullout)]] 2 2 3 = Plugin Development Guide 3 4 4 5 This document captures some best practices and guidelines for plugin development. It is a community driven document, and everyone is encouraged to contribute to it. If you have questions or comments, please raise them on the [trac:MailingList Trac-dev MailingList]. 5 6 6 == Licens e7 == Licensing 7 8 8 9 Plugin authors are encouraged to clearly indicate how the contribution is licensed. This is important for both users and future developers of your plugin. Having a clearly defined license allows someone else to adopt and carry on development of the plugin if you choose to no longer support it. It is also important for users and administrators who need to understand the terms and conditions under which they can use or modify the code. 9 10 10 Trac-Hacks is an open source community driven by voluntary contributions and made successful by collaboration. Therefore we encourage the use of licenses that foster collaboration and minim al restrictions on future use of the code. Trac has adopted the [trac:TracLicense BSD 3-Clause license], and use of the same license in any plugin code is encouraged. One of the many benefits to adopting this license is that any plugin code can potentiallybe integrated into the Trac core down the road.11 Trac-Hacks is an open source community driven by voluntary contributions and made successful by collaboration. Therefore we encourage the use of licenses that foster collaboration and minimise restrictions on future use of the code. Trac has adopted the [trac:TracLicense BSD 3-Clause license], and use of the same license in any plugin code is encouraged. One of the many benefits to adopting this license is that any plugin code can be integrated into the Trac core down the road. 11 12 12 13 The following steps are suggested: … … 22 23 # you should have received as part of this distribution. 23 24 }}} 24 1. Add a license header to every RSS and XHTML Genshi template (example: TBD).25 1. Add a license header to every RSS and XHTML Genshi template (example: '''todo'''). 25 26 {{{#!text/html 26 27 <!--! … … 32 33 --> 33 34 }}} 34 The use of the XML comment marker as shown is important so that the text does not get rendered to the output. Make sure not to use the alternate form, which is rendered to the output as a hidden comment: `<!-- This is also a comment -->`35 The use of the XML comment marker as shown is important, so that the text does not get rendered to the output. Make sure not to use the alternate form, which is rendered to the output as a hidden comment: `<!-- This is also a comment -->` 35 36 1. Add a `COPYING` file with the license text in the top-level directory of the project ([browser:/plantumlmacro/trunk/COPYING example]). 36 37 1. Add an appropriate tag to the wiki page: [[ListTagged(realm:wiki license, format=compact)]] … … 42 43 == Metadata for Single-File Plugins 43 44 44 Plugins are typically packaged using setuptools egg format, but Trac also supports single-file plugins. A single-file plugins is a single `.py` file that is placed in the project or shared `plugins` directory. While the metadata for a packaged plugin is stored in its `setup.py` file, the metadata for a single-file plugin can added using file-scope attributes. The supported attributes and their aliases are: `author`, `author_email`, `home_page` (`url`), `license`, `trac` and `version` (`revision`).45 Plugins are typically packaged using setuptools egg format, but Trac also supports single-file plugins. A single-file plugin is a single `.py` file that is placed in the project or shared `plugins` directory. While the metadata for a packaged plugin is stored in its `setup.py` file, the metadata for a single-file plugin can added using file-scope attributes. The supported attributes and their aliases are: `author`, `author_email`, `home_page` (`url`), `license`, `trac` and `version` (`revision`): 45 46 46 47 {{{#!python 47 48 revision = "$Rev$" 48 homepage = "http://trac-hacks.org/wiki/MyAmazing Macro"49 homepage = "http://trac-hacks.org/wiki/MyAmazingPlugin" 49 50 license = "3-Clause BSD" 50 author = " Guido van Rossum"51 author = "Joe Bloggs" 51 52 author_email = "trac@python.org" 52 53 }}} … … 66 67 }}} 67 68 68 The file's `svn:keywords` property must be edited to append `Rev` and/or `URL`. 69 The file's `svn:keywords` property must be edited to append `Rev` and/or `URL`. Note that the aliases `Revision`, `LastChangedRevision` and `HeadURL` are not supported. 69 70 {{{#!sh 70 71 svn propedit svn:keywords MyAmazingMacro.py … … 78 79 79 80 There are numerous other recommendations, and while some are mainly a matter of personal esthetic and preference, others are suggested for review and adoption: 80 * [http://en.wikipedia.org/wiki/Yoda_conditions Yoda conditions] as [comment:ticket:11622:24 suggested by lkraav][[BR]] 81 PROs: 81 * [http://en.wikipedia.org/wiki/Yoda_conditions Yoda conditions] as [comment:ticket:11622:24 suggested by lkraav]: 82 82 * makes comparisons more obvious by putting the constant up-front 83 83 * erroneous assignment ('=' instead of '==') can't slip though unnoticed … … 86 86 not req.authname or req.authname == 'anonymous' 87 87 }}} 88 same in 'Yoda condition' style88 The same example in 'Yoda condition' style: 89 89 {{{ 90 90 not req.authname or 'anonymous' == req.authname