Template:Format TemplateData/doc: Difference between revisions

Content deleted Content added
Note that {{TemplateDataHeader}} is automatically present.
 
(34 intermediate revisions by 16 users not shown)
Line 1:
{{Documentation subpage}}
{{Lua|Module:Format TemplateData}}
 
Everything below this line is a demo of Format TemplateData: read the source code, and expand the raw TemplateData section, to see how it all works.
== Usage ==
{{Format TemplateData|1=
{{FormatTemplateData|JSON={
<templatedata>
{
"description": "This template formats [[WP:VE/TD|TemplateData]] nicely on doc pages. It hides irrelevant information such as \"Default: empty\", and allows the use of formatting. Remember that the users of VisualEditor '''will not see''' this formatting; it is important to test your new TemplateData in VisualEditor to check that it makes sense without. (For all details of formatting available, see the template's page.) By default, {{tl[[Template:TemplateData header|TemplateDataHeaderTemplateData header]]}} is automatically inserted before the table.",
"format": "block",
"params": {
"JSON1": {
"label": "JSON<templatedata> template information",
"description": "If the JSON parameter is not specified, this will be processed to extract the JSON. This option allows you to use the GUI TemplateData Editor, but it's a bit wonkier than giving the actual JSON object directly.",
"description": "The code that would normally be wrapped in [[WP:TemplateData|&lt;templatedata&gt;]] tags (not including the &lt;templatedata&gt; tags themselves. Links and basic text formatting should just work in the displayed table; see this template's page for full details.",
"default": "See {{{JSON}}}.",
"required": true,
"type": "string",
},
"aliases": ["1"]
"JSON": {
},
"label": "JSON template information",
"TOC": {
"description": "The code that would normally be wrapped in [[WP:TemplateData|&lt;templatedata&gt;]] tags (not including the &lt;templatedata&gt; tags themselves. Links and basic text formatting should just work in the displayed table; see this template's page for full details. You should use HTML entities for special characters such as &lt;&gt;. <noexport><h3>Formatting options</h3>\n*'''Wikilinks''' can be specified in the usual way. They will only work in the table; in VisualEditor, the title of the link will be displayed as plain text.\n*'''External links''' can be specified by just inserting the URL; this will be clickable in the table and viewable in VisualEditor. If the URL is specified as &#91;https:&#47;&#47;en.wikipedia.org Wikipedia&#93;, this will appear as [https://en.wikipedia.org Wikipedia] in the table and https:&#47;&#47;en.wikipedia.org in VisualEditor.\n*'''[[HTML entities]]''': you may specify &amp;lt; &amp;gt; &amp;amp; &amp;quot; &amp;nbsp; and any numeric entity.*'''HTML tags''' may be used; they won't appear in VisualEditor.\n*'''&lt;noexport&gt;&lt;/noexport&gt;''' Content wrapped in these tags will appear only in the table. It will not appear in VisualEditor at all; it is useful for detailed explanations of parameters, and for content that is only useful with formatting. Newline characters are respected here.\n*'''Templates''' may be transcluded. However some templates may output content that makes the JSON invalid.</noexport>",
"label": "Show table of contents",
"type": "string",
"description": "If set to 1, inserts a table of contents for the whole page just after the description and before any parameter table.",
"default": "If neither {{{1}}} nor {{{JSON}}} is given, the page's source code is scanned for a <templatedata> tag.",
"type": "boolean",
"suggested": true
"default": "0",
},
"suggested": true
"TOC": {
},
"label": "Show table of contents",
"description": "If set to 1, inserts a table of contents for the whole page just after the description and before any parameter table.",
"type": "boolean",
"default": "0",
"suggested": true
},
"header": {
"label": "Show TemplateDataHeader",
"description": "If set to 0, hides the TemplateDataHeader{{[[Template:TemplateData header|TemplateData header]]}} template. This is not generally recommended.",
"type": "boolean",
"default": "1"
},
"lazy": {
"label": "Prevent TemplateData output",
"description": "If set, other than to 0, prevents any real TemplateData being produced. Potentially useful if there are multiple instances of this template on a page but only one should be active. To clarify, this means that this template will ''not'' be understood by VisualEditor.",
"type": "boolean",
"default": "0"
}
},
}
"description": "This template formats [[WP:VE/TD|TemplateData]] nicely on doc pages. It hides irrelevant information such as \"Default: empty\", and allows the use of formatting. Remember that the users of VisualEditor '''will not see''' this formatting; it is important to test your new TemplateData in VisualEditor to check that it makes sense without. (For all details of formatting available, see the template's page.) By default, {{tl|TemplateDataHeader}} is automatically inserted before the table."
</templatedata>
} }}
===Formatting options===
 
*'''Wikilinks''' can be specified in the usual way. They will only work in the table; in VisualEditor, the title of the link will be displayed as plain text.
== Using the template ==
*'''External links''' can be specified by just inserting the URL; this will be clickable in the table and viewable in VisualEditor. If the URL is specified as <nowiki>[https://en.wikipedia.org Wikipedia]</nowiki>, this will appear as [https://en.wikipedia.org Wikipedia] in the table and <nowiki>https://en.wikipedia.org</nowiki> in VisualEditor.
Add the <code>&lt;templatedata&gt;</code> as usual, and then enclose it in a template call like <code><nowiki>{{Format TemplateData|1=<templatedata>...</templatedata>}}</nowiki></code>.
*'''Bold and italics''' can be specified with apostrophes in the normal way. The text will be unformatted in VisualEditor.
 
*'''[[HTML entities]]''': you may specify &amp;lt; &amp;gt; &amp;amp; &amp;quot; &amp;nbsp; and any numeric entity.
==Maintenance categories==
*'''HTML tags''' may be used; they won't appear in VisualEditor.
* {{clc|Templates with TemplateData errors}} – the template adds this category to template documentation pages with malformed TemplateData code.
*'''&lt;noexport&gt;&lt;/noexport&gt;''' Content wrapped in these tags will appear only in the table. It will not appear in VisualEditor at all; it is useful for detailed explanations of parameters, and for content that is only useful with formatting. Newline characters are respected here.
 
*'''Templates''' may be transcluded. However some templates may output content that makes the JSON invalid.
==See also==
* {{tl|Template data}}
* {{tl|TemplateData header}}
* {{tl|Crude TemplateData}}
* {{tl|Format TemplateData}}
* {{tl|Template parameter usage}}
* {{tl|TemplateData}}
 
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:TemplateData]]
 
}}</includeonly>