求真百科歡迎當事人提供第一手真實資料,洗刷冤屈,終結網路霸凌。

變更

前往: 導覽搜尋

Template:Documentation/doc

增加 6,814 位元組, 6 年前
top: two significant figures is quite sufficient
{{NoteTA
| G1 = MediaWiki
}}
{{Documentation subpage}}
{{High-use|16,000+67000}}{{Shortcut|T:DOC}}
{{stack|{{Lua|Module:Documentation}}}}
<!-- -- Categories where indicated at the bottom of this page, please; interwikis at Wikidata ----> This is the {{tlf|Documentation}} template, used on almost every template page to contain that template's [[Documentation|documented instructions and information]]. For detailed instructions on how and when to use this template, see [[Wikipedia:Template documentation]] (shortcut: [[WP:TDOC]]). This template displays a green documentation box like you are seeing now and automatically loads the content from a /doc subpage. It can also load the content from other places if instructed to. This template is intended for documenting templates and other pages that are [[Wikipedia:Transclusion|transcluded]] onto other pages. It can be used in the [[Wikipedia:Template namespace|template namespace]] and most other [[Wikipedia:Namespace|namespace]]s. Use of this template allows templates to be [[Wikipedia:Protection policy|protected]] where necessary, while allowing anyone to edit the documentation and categories. ===Usage===Normally this template is used without any parameters, placed at the bottom of the template or page being documented, within a {{tag|noinclude}} container: <source lang="xml+smarty"><!--Last line of your template code--><noinclude>{{Documentation}}<!-- Add categories to the /doc subpage, not here! --></noinclude></source> Then this template automatically loads the content from the /doc subpage of the template it is used on. This template can also load the content from any other page. Like this: <source lang="xml+smarty"><!--Last line of your template code--><noinclude>{{Documentation |Template:Other page/doc}}</noinclude></source> Note that when loading the documentation from a page other than the local /doc page it becomes tricky to handle the categories. The content can also be fed directly as text. Like this: <source lang="xml+smarty"><!--Last line of your template code--><noinclude>{{Documentation 在本行下編輯模板說明 | content =(some documentation)}}</noinclude></source> When the {{para|content}} parameter is used, the doc box normally does not show the [edit] [purge] links in the top right corner. Note that if the /doc page exists, a link to it is still shown in the link box below the doc box. Parameter {{para|1}} and the {{para|content}} parameter can also be combined, like this: <source lang="xml+smarty"><!--Last line of your template code--><noinclude>{{Documentation |1=Template:Any page/doc| content ={{Template:Any page/doc |parameters}}}}</noinclude></source> Then the pagename fed as parameter 1 is used for the [edit] [purge] links and for the /doc link in the link box below the doc box. But the '''content''' parameter is used for the content shown in the doc box. The above code means that the content is transcluded as {{tnull|Template:Any page/doc{{!}}parameters}}. In this example a parameter is also fed to the /doc page being loaded. === Short cut ===Type <nowiki>{{subst:doc-code}}</nowiki> to automatically insert noinclude tags, the template call and the guiding comment. ===Best practice===The code should be added at the bottom of the template code, with no space before {{Tag|noinclude|o}} (which would cause extra space on pages where the template is used). Categories that apply to the template itself should be added to the bottom of the /doc subpage, inside {{Tag|includeonly}} tags. 这个模板自动显示“模板Interwiki links that apply to the template should be listed at [[d:|Wikidata]] (more at [[Wikipedia:Wikidata|wp:Wikidata]]). For more complex cases, see [[Wikipedia:Template documentation#Categories and interwiki links]]. If the documentation page contains {{tag|includeonly|o}} or {{tag|noinclude|o}} tags as part of the visible documentation text, replace the "<code>&lt;</code>" with "<code>&amp;lt;</code>". ===Heading===When in the Template namespace, this template shows this heading::[[File:Template-info.png|32px]] '''Template documentation''' In most other namespaces, such as "Wikipedia:", it shows this heading::'''Documentation''' But when on File (image) pages it shows this heading::'''Summary''' The '''heading''' parameter can be used to set the heading to something else. Like this: :<code><nowiki>{{ADocumentation |zhheading=Infobox documentation}}</nowiki></code> If the '''heading''' parameter is empty but defined, no heading is shown and no [edit] [purge] links are shown. Like this: :<code><nowiki>{{Documentation |heading=}}</nowiki></code> The '''heading-hansstyle''' parameter can be fed optional [[Cascading Style Sheets|CSS]] values. Without quotation marks <code>" "</code> but with the ending semicolons <code>;</code>. For example: 文档:<code>heading-style=font-size:150%;zhcolor:red;</code> ===Link box===Below the big doc box is a small link box that shows some meta-hantdata about the documentation. The link box shows different things depending on what parameters are fed to this template, and in which namespace it is used. In some cases the link box is not shown at all. To hide the link box, add the parameter: 文件{{para|link box|off}}-”框,就像你现在看到的这样。文档框中的内容由其它页面生成,. You can also insert customised text into the link box, by setting the {{seealsopara|Wikipedia:模板文件頁模式link box}}parameter. For example:<pre style="width:auto; overflow:scroll"> |link box=This documentation is automatically generated by [[Template:Country showdata]]</pre>
== 用法 ==# 在主模板中增加<code>&lt;noinclude&gt;&#123;{Documentation}&#125;&lt;/noinclude&gt;</code>。# 点击“编辑”链接,它将打开<tt>/doc</tt>子页面,并在那里填写文档。# 將分類增加在<tt>/doc</tt>子頁面的<code>&lt;includeonly&gt;&lt;/includeonly&gt;</code>中。=== 正常的/doc子页面 Automatic functions=== &lt;noinclude&gt;&#123;&#123;{{{template-name|Documentation}}}&#125;&#125;&lt;/noinclude&gt;=== 任意/doc子页面 === &lt;noinclude&gt;&#123;&#123;{{{template-name|Documentation}}}|Template:any If the documentation page/doc&#125;&#125;&lt;/noinclude&gt;=== 内联内容 === &lt;noinclude&gt;&#123;&#123;{{{template-name|Documentation}}}|content=这是一个文档。&#125;&#125;&lt;/noinclude&gt;=== 有does not exist, the [ 查看create]link includes a [ 编辑[mw:Manual:Creating pages with preloaded text|preload]] 链接的内联内容 === &lt;noinclude&gt;&#123;&#123;{{{templatepage so that clicking it will pre-name|Documentation}}} |1 = Template:模板名fill the edit form with the basic documentation page format. Preload text is also used for the /doc |content =&#123;&#123;Template:模板名sandbox and /doc|参数}} }}&lt;/noinclude>testcases [create] links.
=== 最佳用法 ===此代码应该放置在模板代码的底部“<code>&lt;noinclude></code>”之前且不加多余的空格(否则会导致使用该模板的页面上出现多余空格)。参数可以像上面这样来使用以包含任意文档页。用于模板本身的分类链接应该用 <code>&lt;includeonly> &lt;/includeonly></code> 标签来添加到文档页面。更复杂的案例请参见 [[Wikipedia:模板文件頁模式#分类链接]]。如果文档页包含 <code>includeonly</code> 或 <code>noinclude</code> 标签并作为文档的一部分,请用“<code>&amp;lt;</code>”替代“<code><</code>”。When this template is on a protected template page it now automatically adds {{tl|pp-template}}, which shows the grey or red padlock in the top right corner. So no need to manually add {{tlf|pp-template}} to templates that use {{tl|Documentation}}.
請勿在When this template is on a /doc子頁面裡再掛上sandbox subpage it automatically adds the {{tl|DocumentationTemplate sandbox notice}} ,以避免出錯.
=== 自定义显示 Subject namespaces vs. talk namespaces===替换这些值可以实现特殊的输出效果:* <code>{&#123;documentation| Terminology: ''Subject namespaces''are the opposite of 'heading'talk namespaces'' = .For instance "Template:" is the subject space of "Template talk:"This template is usually placed in a subject namespace, within {{tag|noinclude|o}} tags.But in some cases this template needs to be on the talk page: * In the Mediawiki namespace, since {{tag|noinclude|o}}<often does not work in system messages, and since the Mediawiki namespace needs to be kept clean for performance reasons. When placed on talk pages, this template usually is placed near the top of the page and without {{tag|noinclude}} tags. The /doc, /sandbox and /testcases pages should normally be in the subject namespace, except in the namespaces that do not have the MediaWiki [[meta:Help:Link#Subpage feature|subpage feature]] enabled: Main, File, Mediawiki and Category. (But currently we only show the /sandbox and /testcases links from User, User talk, Template and Template talk namespaces.) There are also a whole bunch of other technical reasons why the /doc page must be stored under the talk page for those (but only those) namespaces. This template automatically points its [create] links for the /doc, /sandbox and /testcases to the right namespace. ===Testing===You can simulate the output for a given page by using the {{para|page}} parameter. For example, if you use the code{{para|page|Template:Edit protected}}, the template will behave exactly as if it were on the page [[Template:Edit protected]], including showing the documentation from [[Template:Edit protected/doc]], linking to [[Template:Edit protected/sandbox]], etc. This parameter is useful for testing and is used extensively on the [[Module:Documentation/testcases|module testcases page]].  ===Technical details===The preload page for the /doc [create] link is [[Template:Documentation/preload]]. The preload pages for the /sandbox and /testcases [create] links are [[Template:Documentation/preload-sandbox]] and [[Template:Documentation/preload-testcases]]. For more details, see the [[Template talk:Documentation|talk page]]. ====Full syntax====<pre> {{Documentation}} {{Documentation − 改变“文档”页的标题文字。如果此处留空,整个标题行(包括第一个| content =}} {{Documentation| [ 编辑path to documentation page] 链接)也将隐藏。| heading-style = | heading = | link box = }}</pre>
== 重定向 =See also===* {{tl| 模板文档Documentation subpage}} = , a notice placed at the top of a /doc subpage explaining its role and including a link to the page it documents.* {{tl|Barnstar documentation}}, a variant of {{tl|Template docDocumentation}} = for use with [[Wikipedia:Barnstars|barnstar]] templates.* {{tl|Documentation, template/color scheme}} = presents the color scheme used by {{tl|DocDocumentation}}.* [[Wikipedia:Template documentation]] is a how-to guide to template documentation.* [[Wikipedia:Template sandbox and test cases]] explains the use of /sandbox and /testcases subpages and includes more information about template testing.* [[User:Technical 13/Scripts/editTemplateNoDoc.js]], a beta script that enables documentation to be hidden by default when editing templates.
<includeonly>{{When pagename is |/sandbox other= |/testcases= |other=<!-- 本行下加入模板的分類,跨維基連結加入Wikidata(參見-- Categories below this line, please; interwikis to Wikidata ---->[[WikipediaCategory:WikidataTemplate documentation| ]] ) -->[[Category: 模板頁的模板Template-related templates]]
}}</includeonly>