Template:Dochead/doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Ganaram inukshuk (talk | contribs)
m doc
Ganaram inukshuk (talk | contribs)
update doc
Line 10: Line 10:
This template is invoked by placing <code><nowiki>{{dochead}}</nowiki></code> at the top of a module or template's <code>/doc</code> subpage.
This template is invoked by placing <code><nowiki>{{dochead}}</nowiki></code> at the top of a module or template's <code>/doc</code> subpage.


On modules, unless <code>header=none</code> is passed, a header will appear to inform users that modules should be called via templates instead of being invoked directly:
For templates, header options are as follows:


<blockquote>'''Note:''' Do not invoke this module directly; use the corresponding template instead: [[mw:Help:Magic words #Page names|Template: <nowiki>{{ROOTPAGENAME}}</nowiki>]].</blockquote>
* <code>metatemplate</code>: <span style{{=}}"margin-bottom: 0.5em;">'''Note:''' This template is used to build other templates and should not be used standalone except for testing and simple usage.</span><br />


where <code>ROOTPAGENAME</code> is a [[mw:Help:Magic words|"magic word"]] that returns the name of the page without the namespace or subpages. This way, the link in the header will attempt to point to a template with the same name as the module, since this is mostly the case. If the template which calls the module has a different name, pass in <code>temp=</code> followed by the name of the template.
For modules, header options are as follows:


You can also directly specify the header using the <code>header</code> parameter.  
* <code>metamodule</code>: <span style{{=}}"margin-bottom: 0.5em;">'''Note:''' This module primarily provides functionality for other Lua modules and cannot be invoked by templates.</span><br />
* <code>dualuse</code>: <span style{{=}}"margin-bottom: 0.5em;">'''Note:''' This module may be invoked by templates using Template:<nowiki>{{ROOTPAGENAME}}</nowiki>, or used directly from other modules.</span><br />
* <code>noinvoke</code> (default): <span style{{=}}"margin-bottom: 0.5em;">'''Note:''' This module provides functionality to a template and should not be invoked directly; use the corresponding template instead: Template:<nowiki>{{ROOTPAGENAME}}</nowiki>.</span><br />
 
In either case, passing in <code>header=none</code> results in no message being displayed. A custom message may also be passed in.
 
The [[mw:Help:Magic words|"magic word"]] <code>ROOTPAGENAME</code> returns the name of the page without the namespace or subpages. By default, Lua modules that implement templates provide a link to a template of the same name. If this name is different, it can be passed in using <code>temp=Template name goes here</code>.


=== See also ===
=== See also ===

Revision as of 22:49, 23 October 2025

This template is implemented by the Lua module Module:Dochead.
This template invokes the following functions: dochead from Dochead.

This template automatically categorizes documentation by namespace, which eliminates the need to do this manually. Currently, it is configured to place templates, modules, and their documentation inside their respective categories:

Usage

This template is invoked by placing {{dochead}} at the top of a module or template's /doc subpage.

For templates, header options are as follows:

  • metatemplate: Note: This template is used to build other templates and should not be used standalone except for testing and simple usage.

For modules, header options are as follows:

  • metamodule: Note: This module primarily provides functionality for other Lua modules and cannot be invoked by templates.
  • dualuse: Note: This module may be invoked by templates using Template:{{ROOTPAGENAME}}, or used directly from other modules.
  • noinvoke (default): Note: This module provides functionality to a template and should not be invoked directly; use the corresponding template instead: Template:{{ROOTPAGENAME}}.

In either case, passing in header=none results in no message being displayed. A custom message may also be passed in.

The "magic word" ROOTPAGENAME returns the name of the page without the namespace or subpages. By default, Lua modules that implement templates provide a link to a template of the same name. If this name is different, it can be passed in using temp=Template name goes here.

See also

Todo: update documentation

Dochead should now be able support categories on both templates and modules. Now contains new default messages that came up a lot that the single "use this module's corresponding template" message cannot capture.