wiki:FlatTableMacro

Version 2 (modified by ashkulz, 6 years ago) (diff)

--

A Wiki Processor for displaying a table with the markup being entered in a flat form.

Description

This Wiki processor allows you to enter the data for a table in an alternative markup, which is very useful when there are a lot of columns and/or when some of the columns are optional. This markup also has the advantage of being much more readable and diff-friendly, at the expense of requiring more markup.

The column definition for the table has to be specified immediately after the macro directive, eg.

{{{
#!flat-table
#! Name: key, Relation: relation, Comment: comment notes
 [... table data ...]
}}}

Alternatively, one can also create a macro alias via configuration in trac.ini

[flat-table]
dbdoc = Name: key, Relation: relation, Comment: comment notes
dbdoc.description = macro description goes here

For the above example, one can then directly use

{{{
#!dbdoc
 [... table data ...]
}}}

Markup

The markup is loosely based on a very simplified YAML/JSON-like syntax. At least one column is always assumed to be mandatory per table, which is the key column. The order and name of the generated columns is controlled by the metadata line, as shown above. For each column, one can define one or more aliases which can be used in the markup to define the column data.

A line with no leading spaces and ending in a colon defines the start of a new row, with the line content representing the value of the key column. A line with some leading spaces followed by an @alias: defines the column within the row. Any other content on that line or any subsequent lines is assumed to be the content of that column (basic Wiki syntax can be used).

Bugs/Feature Requests

Existing bugs and feature requests for FlatTableMacro are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

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

Example

{{{
#!flat-table
#! Name: key, Relation: relation, Comment: comment notes

id:
  @relation: PK

desc:
  @comment: description

other_table_id:
  @relation: FK to other table
  @notes: 
    This is a reference to another table with a [WikiPedia:Wiki wiki] link.
    More than one line can be entered for a column.
}}}

will result in a display like this

Name Relation Comment
id PK
desc description
other_table_id FK to other table This is a reference to another table with a wiki link.
More than one line can be entered for a column.

Recent Changes

[12139] by rjollos on 2012-10-10 03:54:13
Fixed incorrect source code encoding (http://www.python.org/dev/peps/pep-0263/).
[7591] by ashkulz on 2010-02-14 16:48:01
add revision info (fixes #6573)
[5422] by ashkulz on 2009-03-28 15:17:29
fix typo in [5421]

Author/Contributors

Author: ashkulz
Contributors: