wiki:BoilerplatePlugin

Auto-Generate Parameterized Wiki Pages

Description

Automatically generates Wiki pages based on boilerplate Wiki markup with parameter placeholders and tables describing pages to create with argument lists on special 'boilerplate' Wiki pages.

Boilerplate Wiki markup is defined by placing it between special [[BoilerplateStart]] and [[BoilerplateEnd]] macros. Within such a boilerplate section, placeholders for parameter replacement can be described by {{n}}, where n is an integer greater than or equal to zero.

Boilerplate Wiki markup is hidden when the boilerplate page is rendered.

The pages to generate are defined by declaring how they should be generated in a Wiki table on the same page as the boilerplate Wiki markup. The first column must contain either the name of, or a MoinMoin-style free link to, the page to be generated. Subsequent columns contain text to be inserted into the Wiki page as described by the placeholders for parameter replacement in the boilerplate Wiki markup. {{1}} will be replaced by the contents of the first column after the target page column, {{2}} will be replaced by the contents of the second column after the target page column, etc. {{0}} will be replaced by the name of the page extracted from the first column without the link markup if present. Table rows whose contents are bold are ignored, to allow headers.

When a Wiki page with boilerplate Wiki markup is created or its content is changed, the plugin searches the page for table rows. It takes the boilerplate Wiki markup, performs parameter replacements as described above, and saves the resulting text into a new or existing Wiki page whose name is extracted from the first column. If the page already exists and the desired text is identical to the current page contents, the page is not saved.

Aside from the boilerplate markup and the descriptive table, the boilerplate page itself can have any other arbitrary Wiki markup, which allows the boilerplate page to itself have documentary value. This is also the reason the boilerplate markup is not shown when the boilerplate page is rendered.

I have not tested it with 0.11 but it will probably work there too.

Many thanks to Alec Thomas, whose AcronymsPlugin provided the instruction I needed to author this plugin.

Installation

Copy the BoilerplatePlugin.py file to your trac plugins directory (/usr/share/trac/plugins on my machine). No other configuration is neccessary.

Bugs/Feature Requests

Existing bugs and feature requests for BoilerplatePlugin are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out BoilerplatePlugin from here using Subversion, or browse the source with Trac.

Example

= Noble Gases =

This table describes the attributes of the noble, or inert, gases.

||'''Element Symbol''' ||'''Element Name''' ||'''Atomic Number''' ||
||["He"]               ||Helium             ||2                   ||
||["Ne"]               ||Neon               ||10                  ||
||["Ar"]               ||Argon              ||18                  ||
||["Kr"]               ||Krypton            ||36                  ||
||["Xe"]               ||Xenon              ||54                  ||
||["Rn"]               ||Radon              ||86                  ||
||["Uuo"]              ||Ununoctium         ||118                 ||

[[BoilerplateStart]]
= {{0}} =

The element {{1}} is a noble gas with an atomic number of {{2}}.  Like all
noble gases, it has a full complement of electrons in its outer valence.
[[BoilerplateEnd]]

This would result in seven pages being generated, the first of which would look like this:

= He =

The element Helium is a noble gas with an atomic number of 2.  Like all
noble gases, it has a full complement of electrons in its outer valence.

Recent Changes

[3528] by flowers on 2008-04-19 21:35:10
Add installation instructions to plugin py file.

Addresses #1865.

[2142] by flowers on 2007-03-31 19:35:25
BoilerplatePlugin:

First version of BoilerplatePlugin.

[2141] by flowers on 2007-03-31 19:30:44
New hack BoilerplatePlugin, created by flowers

Author/Contributors

Author: flowers
Maintainer: flowers
Contributors:

Last modified 2 years ago Last modified on Jul 31, 2012, 11:20:34 PM