Extension:TemplateData

The TemplateData extension introduces a  tag and an API which together allow editors to specify how templates should be invoked. This information is available as a nicely-formatted table for end-users, and as a JSON API, which enables other systems (e.g. VisualEditor) to build interfaces for working with templates and their parameters.

Defining a TemplateData block
The TemplateData extension works through having a  tag defined in the wikitext of a template page (optionally it can be transcluded into the template page as well). This is designed to be compatible with the common layout many wikis have of transcluding template documentation from a separate page (but is not required). This content of the  tag is parsed as JSON using the format described below; note that all descriptions must be in plain text (no wikitext is accepted inside the JSON).

The below is a visualised version of the formal specification in the TemplateData repository. Please refer to spec.templatedata.json for the latest version.


 * InterfaceText value (string or Object): A free-form string (no wikitext) in the content-language of the wiki, or, an object containing those strings keyed by language code.

Tools

 * TemplateDataEditor A user script that makes the process of adding TemplateData easier.
 * Yet another template data editor
 * Jsonlint a JSON validator to help spot errors in the template data syntax.

Example use
{	"description": "Label unsigned comments in a conversation.", "params": { "user": { "label": "Username", "type": "string/wiki-user-name", "required": true, "description": "User name of person who forgot to sign their comment.", "aliases": ["1"] },		"date": { "label": "Date", "description": { "en": "Timestamp of when the comment was posted, in YYYY-MM-DD format." },			"aliases": ["2"] },		"year": { "label": "Year", "type": "number" },		"month": { "label": "Month", "inherits": "year" },		"day": { "label": "Day", "inherits": "year" },		"comment": { "required": false }	},	"sets": [ {			"label": "Date", "params": ["year", "month", "day"] }	] }

Using the TemplateData API
More to come.

See the automatically formatted help at https://en.wikipedia.org/w/api.php?action=help&modules=templatedata. An example of a working call is https://en.wikipedia.org/w/api.php?action=templatedata&titles=Template:Italic%20title (for Template:Italic title). You can also see a formatted version to better understand the structure.