Documentation
From W8MD weight loss and sleep centers
</nowiki>
}}</includeonly>
Documentation subpage for the W8MD Documentation template
Template:Documentation is a helper template used on W8MD.com to display documentation for templates from a separate documentation subpage, usually named /doc.
This template helps keep active template code separate from instructions, examples, parameter descriptions, and categories. It is especially useful for frequently used W8MD templates such as infoboxes, citation templates, navigation templates, medical topic templates, and service-area templates.
Purpose
The purpose of this template is to:
- Display template documentation in a clean documentation box.
- Keep template code separate from explanatory text.
- Allow examples and parameter notes to be edited without changing active template code.
- Encourage consistent W8MD template documentation.
- Place template categories on the documentation subpage instead of the main template page.
- Reduce the risk of accidental damage to working templates.
Basic usage
Place this at the bottom of a template page:
<noinclude>
{{Documentation}}
</noinclude>
A typical W8MD template page should use this structure:
<includeonly>
Template code goes here.
</includeonly><noinclude>
{{Documentation}}
</noinclude>
The documentation should then be placed on the matching documentation subpage:
Template:Example/doc
Custom documentation page
By default,
Template loop detected: Template:Documentation/doc
This documentation is transcluded from Template:Documentation/doc.
Editors can improve the documentation, examples, categories, and usage notes on the documentation subpage.
Documentation helper template for displaying template documentation subpages
Template:Documentation is a helper template used on template pages to display documentation from a separate documentation subpage, usually named /doc.
This follows the common MediaWiki pattern of keeping template code separate from explanatory documentation. MediaWiki templates are transcluded using double braces, and documentation subpages make it easier to protect or maintain template code while still allowing usage notes, examples, and categories to be edited separately.
Usage
Place this at the bottom of a template page, outside the active template code:
<noinclude>
{{Documentation}}
</noinclude>
A typical template page should look like this:
<includeonly>
Template code goes here.
</includeonly><noinclude>
{{Documentation}}
</noinclude>
Custom documentation page
By default, this template transcludes documentation from:
{{FULLPAGENAME}}/doc
You can also specify a custom documentation page:
{{Documentation|Template:Example/doc}}
Recommended /doc page structure
A good documentation subpage usually includes:
== Usage ==
== Parameters ==
== Examples ==
== See also ==
<includeonly>
[[Category:Templates]]
</includeonly>
Why use documentation subpages?
Documentation subpages are useful because they:
- Keep template code clean and easier to maintain.
- Allow categories to be placed on the documentation page instead of inside active template code.
- Allow usage examples and parameter explanations without affecting template output.
- Make protected templates easier to document.
- Reduce accidental edits to working template code.
Notes
- Add template categories to the
/doc page, not the main template page.
- Place categories inside
<includeonly>...</includeonly> on the documentation page.
- Use
<noinclude>{{Documentation}}</noinclude> at the bottom of templates.
- Use
<nowiki>...</nowiki> or <pre>...</pre> when showing template code examples.
See also
displays documentation from the current template's /doc subpage.
A custom documentation page can also be specified:
{{Documentation|Template:Example/doc}}
This may be useful when several related templates share the same documentation.
Recommended documentation page format
A good W8MD template documentation page should usually include:
{{Short description|Brief description of what the template does}}
{{DISPLAYTITLE:Template:Example/doc}}
'''Template:Example''' is used to...
== Usage ==
<pre>
{{Example
| name =
| image =
| caption =
}}
</pre>
== Parameters ==
{| class="wikitable"
! Parameter
! Description
! Required?
|-
| name
| Name displayed by the template
| Optional
|-
| image
| Image filename without File: prefix
| Optional
|}
== Examples ==
<pre>
{{Example
| name = Sample page
| image = Example.jpg
| caption = Example image
}}
</pre>
== See also ==
* [[Template:Infobox public health]]
* [[Template:Cite web]]
* [[Template:Cite journal]]
<includeonly>
[[Category:Template documentation]]
[[Category:W8MD templates]]
</includeonly>
Parameters
| Parameter | Description | Required? | Example |
|---|---|---|---|
1
|
Optional custom documentation page to transclude instead of the default /doc page
|
No | Template:Infobox public health/doc
|
Examples
Standard example
Use on a template page:
<includeonly>
{{#invoke:Infobox|infobox
| above = {{{name|{{PAGENAME}}}}}
| label1 = Field
| data1 = {{{field|}}}
}}
</includeonly><noinclude>
{{Documentation}}
</noinclude>
This will display documentation from:
Template:Template name/doc
Custom documentation example
Use a custom documentation page:
<noinclude>
{{Documentation|Template:Shared infobox documentation}}
</noinclude>
Where to place categories
Template categories should normally be placed on the /doc page, not directly on the main template page.
Use this format on the documentation subpage:
<includeonly> [[Category:W8MD templates]] [[Category:Template documentation]] </includeonly>
This prevents categories from being accidentally transcluded onto pages that use the template.
Where to place interwiki links
If interwiki links are used, they should usually be placed on the documentation subpage rather than inside the active template code.
W8MD best practices
For W8MD.com, documentation pages should be written clearly enough for editors, physicians, content writers, and technical maintainers to understand.
Recommended W8MD documentation practices:
- Begin with
{{Short description|...}}. - Use
{{DISPLAYTITLE:...}}when helpful. - Clearly explain what the template does.
- Include a copy-and-paste usage example.
- Document each parameter in a table.
- Mark parameters as required or optional.
- Include at least one working example.
- Add related templates under
== See also ==. - Place categories inside
<includeonly>...</includeonly>. - Avoid placing active template categories on the main template page.
- Avoid long prose inside the main template code.
- Keep examples medically accurate when documenting medical templates.
Suggested sections for W8MD template documentation
Most W8MD template documentation pages should use some or all of these sections:
== Usage == == Parameters == == Examples == == TemplateData == == Tracking categories == == See also ==
TemplateData
If VisualEditor or TemplateWizard is enabled on W8MD.com, a TemplateData block may be added to documentation pages.
Example:
<templatedata>
{
"description": "Displays documentation for a template from its /doc subpage.",
"params": {
"1": {
"label": "Documentation page",
"description": "Optional custom documentation page to transclude.",
"type": "wiki-page-name",
"required": false
}
}
}
</templatedata>
Troubleshooting
| Problem | Possible cause | Fix |
|---|---|---|
| Documentation does not appear | The /doc page does not exist
|
Create the documentation subpage, such as Template:Example/doc
|
| Categories appear on article pages | Categories were placed directly inside the template | Move categories to the /doc page inside <includeonly>...</includeonly>
|
| Example code is being executed | Code examples were not wrapped in <pre> or <nowiki>
|
Wrap examples in <pre>...</pre>
|
| Template output looks broken | Active template code may be mixed with documentation prose | Keep active code inside <includeonly> and documentation inside <noinclude>
|
| Documentation page creates unwanted blank space | Extra line breaks around includeonly/noinclude tags | Place tags tightly around template code |
Related W8MD templates
- Template:Infobox public health
- Template:Infobox medical condition
- Template:Infobox medical intervention
- Template:Cite web
- Template:Cite journal
- Template:Short description
- Template:W8MD
- Template:GLP-1
Technical notes
This template assumes that W8MD.com has ParserFunctions enabled if the main Template:Documentation uses {{#ifexist:}}.
The main template normally checks whether a documentation subpage exists. If it exists, the documentation is displayed. If it does not exist, the template displays a prompt to create one.
See also
- Help:Template
- Help:Transclusion
- Help:Infobox
- Help:Citation templates
- Template:Documentation
- Template:Infobox public health
- Template:Cite web
- Template:Cite journal
<templatedata> {
"description": "Displays documentation for W8MD templates from a /doc subpage.",
"params": {
"1": {
"label": "Documentation page",
"description": "Optional custom documentation page to transclude instead of the default /doc page.",
"type": "wiki-page-name",
"required": false,
"example": "Template:Infobox public health/doc"
}
}
} </templatedata>
Documentation helper template for displaying template documentation subpages
Template:Documentation is a helper template used on template pages to display documentation from a separate documentation subpage, usually named /doc.
This follows the common MediaWiki pattern of keeping template code separate from explanatory documentation. MediaWiki templates are transcluded using double braces, and documentation subpages make it easier to protect or maintain template code while still allowing usage notes, examples, and categories to be edited separately.
Usage
Place this at the bottom of a template page, outside the active template code:
<noinclude>
{{Documentation}}
</noinclude>
A typical template page should look like this:
<includeonly>
Template code goes here.
</includeonly><noinclude>
{{Documentation}}
</noinclude>
Custom documentation page
By default, this template transcludes documentation from:
{{FULLPAGENAME}}/doc
You can also specify a custom documentation page:
{{Documentation|Template:Example/doc}}
Recommended /doc page structure
A good documentation subpage usually includes:
== Usage == == Parameters == == Examples == == See also == <includeonly> [[Category:Templates]] </includeonly>
Why use documentation subpages?
Documentation subpages are useful because they:
- Keep template code clean and easier to maintain.
- Allow categories to be placed on the documentation page instead of inside active template code.
- Allow usage examples and parameter explanations without affecting template output.
- Make protected templates easier to document.
- Reduce accidental edits to working template code.
Notes
- Add template categories to the
/docpage, not the main template page. - Place categories inside
<includeonly>...</includeonly>on the documentation page. - Use
<noinclude>{{Documentation}}</noinclude>at the bottom of templates. - Use
<nowiki>...</nowiki>or<pre>...</pre>when showing template code examples.
See also
- Template:Infobox public health
- Template:Cite web
- Template:Cite journal
- Help:Template
- Help:Transclusion
