Template:Documentation
Jump to navigation
Jump to search
This template has no visible appearance. View the source to see what it does.
Documentation
From Template:Documentation/doc:
This template provides an easy, non-messy way to document a template. The method is borrowed from Wikipedia. This works properly only for templates, not for regular wiki articles. The benefits include:
- Keeps the docs separate from the template functionality
- Typesets all template documentation in a consistent manner
- Automatically detects when a template is not documented and provides a link to create the docs
The method
Put your documentation in a subpage of your template, called "doc".
- Edit your template, say,
Template:Foobar
. - Write your template code: Here is my fancy template definition. La la la la.
- End the template with
<noinclude>{{documentation}}</noinclude>
with no intervening whitespace:
<noinclude>
Here is my fancy template definition.
La la la la.<noinclude>{{documentation}}</noinclude>
- (Optional.) If the template has no visible content, put this heading at the top: <noinclude>{{template without visible content}}</noinclude> with no intervening whitespace, like this: <noinclude>{{template without visible content}}</noinclude>Here is my fancy template definition. La la la la.<noinclude>{{documentation}}</noinclude>
- Save the template. It should work fine when transcluded on other pages.
- Write your documentation in the article
Template:Foobar/doc
. It will automatically get transcluded into the template to document it. If no documentation exists, your template will display a message to this effect.
Care with whitespace
When inserting the documentation template, be careful not to add whitespace unnecessarily. MediaWiki is picky about whitespace when transcluding a template.
Tips
In your documentation article, refer to the parent article as {{BASEPAGENAME}}
for portability, in case the template name ever changes. This is particularly useful for demonstrating the template:
{{Documentation}}
by writing:
<nowiki>{{</nowiki>{{BASEPAGENAME}}}}