Jump to content

Module:Section sizes/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mathglot (talk | contribs) at 01:18, 22 September 2024 (Add second entry point section_length_get; add usage examples and param descriptions.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This module creates a wikitable that lists each section in a page along with that section's size in bytes. Each section is wikilinked to its target in the page; subsections are indented. Cells for section sizes are shaded according to the size; the smallest section's background is white, and the largest section's background is red.

Usage

This module has two entry points: size, and section_length_get.

Use size to emit the section table:

{{#invoke:Section sizes|size|<page name>|style=<style string>}}

Entry point size() takes two arguments from frame:

<page name> (required) – the first positional parameter is the page name; may include namespace
|style= (optional) – css string suitable for use in the table's style= attribute; for example to render the table at the right side of the page:
{{#invoke:Section sizes|size|<page name>|style=float:right; margin-left:.5em}}
Use entry point section_length_get to return an article or section length statistic:

{{#invoke:Section sizes|section_length_get|<page name>|<section name>}}
{{#invoke:Section sizes|section_length_get|<page name>|<section name> |_all}}
{{#invoke:Section sizes|section_length_get|<page name>|<token>}}

Entry point section_length_get() takes one, two, or three arguments from frame:

<page name> (required) – the first positional parameter is the page name; may include namespace
<section name> (optional) – the second positional parameter is either the section name, or one of three tokens (if param 2 is absent, the default is _lead)
<sectionName> – returns the length of the given section
_lead – returns the length of the lead section (this is the default, if param 2 is absent)
_max – returns the length of the longest section
_total – returns the length of the article (should = {{PAGESIZE}} )
_all (optional) – the third positional parameter is the string _all; this includes the total length of the section whose name is given in parameter 2, including all its subsections.

See also