Lompat ke isi

Modul:AutosortTable/doc

Dari Wikipedia bahasa Indonesia, ensiklopedia bebas

This module helps create data tables in an automatically sorted order. As of this writing it is used primarily for the generation of the huge, dynamic tables at list of Wikipedias and Wikipedia:List of Wikipedias. For the Wikipedia editions table, the module is invoked directly to create the framework for the table, followed by content for the rows within the module's invocation. For the Edition details table, the module is invoked directly to create the framework for the table while the template {{Statistik Wikipedia}} generates content for the individual rows, also within the module's invocation. The template {{Statistik Wikipedia}} is intended to be called as an argument within the module's invocation, as it does not produce the regular wikitable (or any standard table) code itself.

The module's arguments are:

{{#invoke:AutosortTable|create|class=|style=|separator=|order=|numeric=|descending=|hidden=|caption=|rowheader=
|header = 
|footer = 
|colstyle = 
}}
Module arguments
Argument Example Notes
function create The argument create is the only function of this module, and is required.
class class=wikitable Class for the entire table. Table can be made user-sortable by including the class "sortable", but does not need to be.
style style=width: 50%; CSS for the entire table
separator separator=-- Separator string used to separate cells in the data definition. The pipe (|) is an invalid separator for this module.
order order=3, 2 Order for auto-sorting preference, takes a comma-separated list of column numbers. In the example here, the table will be sorted by column 3 first, then by column 2.
numeric numeric=2 Columns which use numeric sorting when auto-sorted. Takes comma-separated list of column numbers.
descending descending=3 Columns for which the auto-sort order should be descending (otherwise, ascending is used). Takes comma-separated list of column numbers. Here, only the third column will be auto-sorted in descending order (e.g., Zebra, Walrus, Muskrat, Emu, etc., or 12, 9, 6, 4).
hidden hidden=2 Columns which are not to be displayed (even though they may be used for row-sorting purposes). Takes comma-separated list of column numbers. Here, the second column will not be shown.
caption caption=Notable people by age Caption to be used for the table, per MOS:ACCESS
rowheader rowheader=1 Cell(s) in each non-header row to be emitted as row header, per MOS:ACCESS. Usually 1, and only 1, but accepts comma-separated list of column numbers. Causes !scope="row" to be used in the HTML for the cells specified.
header header = -- Name -- Age These are the column headings. In this example there are two columns with headings, the first is "Name", the second, "Age". Note the separators (--) which match the separator value above.
footer footer =-- Country -- Population -- Density Table footer, typically a duplication of header (see header argument above). Here, the first three columns have the footer labels shown.
colstyle colstyle = -- text-align:left; -- text-align:right; -- -- -- Adds the specified CSS styling to entire columns. Here, the first column will be left-aligned, the second column will be right-aligned, and the next three columns (with no CSS specified) will use the default styling. Note the separators (--) which match the separator value above.

Styling tricks

[sunting sumber]

While there appear to be no ways to style an individual cell when using this module, styling particular rows, columns, or the entire table can be done using CSS.

Styling the table

[sunting sumber]

The style argument allows the entire table to use a default styling. For example, |style=width:70%; text-align:center; would constrain the table width to 70% of the available window, and center the text (not including column and row headers) by default. When using multiple properties, the semicolon is necessary to separate them. Do not use the quotation marks ordinarily required in CSS or wikitable markup (as in "|style=width:70%; text-align:center;"), as it causes the CSS to be disregarded. A reminder: use CSS to constrain tables sparingly, as reduced font-size or unexpected table widths may cause accessibility problems or irritate readers.

Styling a row

[sunting sumber]

An individual row can be styled separately by including CSS prior to the first data cell. Consider this example table:

{{#invoke:AutosortTable|create|class=wikitable plainrowheaders sortable|separator=--|order=2|numeric=2|descending=2|caption=Old friends|rowheader=1
|header = -- Name -- Age -- Diet                    <!-- Table header -->
| -- Maria -- 36 -- Vegan                           <!-- Row 1 -->
| -- Peter -- 35 -- Vegetarian                      <!-- Row 2 -->
| -- Julia -- 35 -- Meat                            <!-- Row 3 -->
| -- James -- 50 -- Vegan                           <!-- Row 4 -->
| background-color: #FFDDDD -- Henry -- 45 -- Meat  <!-- Row 5, with CSS -->
| -- Ireni -- 47 -- Fish, no meat                   <!-- Row 6 -->
|colstyle = -- text-align:left; -- text-align:right; --  --  --
}}
Old friends
NameAgeDiet
James50Vegan
Ireni47Fish, no meat
Henry45Meat
Maria36Vegan
Peter35Vegetarian
Julia35Meat

The row for "Henry" gets a pink color (#FFDDDD), while the row header appropriately retains the gray formatting wikitables use for headers.

Styling a column

[sunting sumber]

An individual column can be styled separately by using CSS in the colstyle argument. In the Old friends example just above, the alignment has been set to text-align:left; and text-align:right;, respectively. Consider this similar table:

{{#invoke:AutosortTable|create|class=wikitable plainrowheaders sortable|separator=--|order=2|numeric=2|descending=2|caption=Old friends again|rowheader=1
|header = -- Name -- Age -- Diet    <!-- Table header -->
| -- Maria -- 36 -- Vegan           <!-- Row 1 -->
| -- Peter -- 35 -- Vegetarian      <!-- Row 2 -->
| -- Julia -- 35 -- Meat            <!-- Row 3 -->
| -- James -- 50 -- Vegan           <!-- Row 4 -->
| -- Henry -- 45 -- Meat            <!-- Row 5 -->
| -- Ireni -- 47 -- Fish, no meat   <!-- Row 6 -->
|colstyle = --  -- font-weight:bold; color:brown -- background-color:yellow
}}
Old friends again
NameAgeDiet
James50Vegan
Ireni47Fish, no meat
Henry45Meat
Maria36Vegan
Peter35Vegetarian
Julia35Meat

The "Age" column entries are now in bolded brown and no longer left-aligned as in the previous example. The "Diet" column here has the specified yellow background.

Sample tables

[sunting sumber]

"Wikipedia editions" example

[sunting sumber]

Here is an abbreviated version of the Wikipedia editions table at list of Wikipedias. It is a manually sortable wikitable which uses the class "plainrowheaders" (no bold, not centered) for row headers (specified here as only column 1). It is auto-sorted by the sixth column ("Active users"), which is a numeric field and should be auto-sorted in descending order (highest at the top). The content of each row in the table is entered as a separate argument (starting with a pipe [|] symbol) and includes text, wikilinks, and image file links. Please view the wikicode to see the details.

Wikipedia editions
Wikipedia name
in English
Wikipedia name
in native language
LanguageScript (ISO
15924
code)
WP
code
Active
users
Launch dateLogo
English WikipediaEnglish WikipediaEnglishLatnen120.16302001-01-1515 Januari 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in English
French WikipediaWikipédia en françaisFrenchLatnfr17.24602001-03-2323 Maret 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in French
German WikipediaDeutschsprachige WikipediaGermanLatnde17.00802001-03-1616 Maret 2001
Wikipedia logo showing "Wikipedia: The Free Encyclopedia" in German

"Edition details" example

[sunting sumber]

Here is an abbreviated version of the Edition details table at Wikipedia:List of Wikipedias. This table uses templates (using this module) to produce the individual rows for the table which this module will generate.

Like the above example, this is a manually sortable wikitable which uses the class "plainrowheaders" (no bold, not centered) for row headers (specified here as only column 1). However, this table is auto-sorted by the thirteenth column (based on the number of articles) which is hidden (although the same values are used again — and shown — in column 4 as "Articles"), and which is a numeric field and should be used for auto-sorting in descending order (highest at the top). The content of each row in the table is generated by the template {{Statistik Wikipedia}} and the call to that template is entered as a separate argument (starting with a pipe [|] symbol).

This table has some special alignment requirements, as it contains several columns containing large numbers, so the colstyle argument is used extensively. Please view the wikicode to see the details.

Details of Wikipedia editions
LanguageLanguage (local)WikiArticlesAll pagesEditsAdminsUsersActive usersFilesDepthPercentage
EnglishEnglishen6.904.05161.754.8321.249.803.88084648.195.449120.163929.1021277.410.81%
Frenchfrançaisfr2.644.52313.261.359219.438.8621445.039.93917.24672.391266.74.14%
DutchNederlandsnl2.170.7174.661.93968.157.028301.371.3603.5422019.263.4%
Russianрусскийru2.007.2388.054.660140.875.124663.653.5548.755256.093158.763.14%
Spanishespañoles1.987.1608.284.429162.862.037567.266.83914.3060197.423.11%
Chinese中文zh1.449.0917.855.27884.489.510633.609.2817.18768.209210.212.27%
Japanese日本語ja1.435.3344.216.113102.198.214402.252.03412.5874.74190.982.25%
Arabicالعربيةar1.244.4148.543.47868.258.176252.645.5205.09153.176274.871.95%
Portugueseportuguêspt1.136.3895.784.86168.730.233513.143.4008.77263.739198.81.78%
Korean한국어ko688.9683.307.81438.017.82128865.2372.15414.609166.061.08%