Module:Autocat/doc
This is the documentation page for Module:Autocat
It is the module that runs Template:T template.
Contents
How it works
- First, it catches any category page title, e.g. 2000 births.
- Later, this title is split into parts. Takes all the numbers from the beginning and make them the year parameter; because for this type of categories year always is at the beginning (for now, until there would be cases in the future that disproves this situation). After the year, if there are year-based suffixes, like in 2000s there is the "s", or, 21st-century there is the "st-century", clean those. Finally tha all latter word(s) role as category name. In this case the year is 2000, and the category name is births.
- Now, we need to access some sort of data. Module:Autocat/data/people contains the births object (of course, there would be different data modules, the module detects it).
- At the top of the category page, from the year that the category is in, 5 upwards and 5 downwards category links are added in a header bar. Also, there is a parent bar right below the main bar. In this one, the upper stage categories are listed, for example in 2000 births category, which is a year category, there should be 2000s births type of categories right below in the parent bar. But this parent bar only shows up if the parent category exists. The pattern continues through all stages, in the 2000s births category, the parent bar now contains 21st century births type of categories, since we are now in a decade category. Module always tries to find the parent category and put a parent bar. There can only be two bars in one category pages, and those are one header bar and one parent bar.
- Right below these bars, there are descriptions. If the object has a special description text specified in the data, it can be shown in the page.
- On the up right corner of the page, there can be a Commons link template. This module, finds the wikidata item of the current page, and checks if the item has a commons category, if so, it automatically inserts a commons link.
- And lastly the category is added to all parents which are extracted from the data, all with their sort keys as well.
Structure of objects
Structure of a simple object (each object can have similar labels):
k["births"] = { parents = {"beginnings", "people"}, sort_keys = {"B", "B"}, stage = 4, description = "'''People born''' {{{hide|in the}}} {{{type}}} {{{year}}}", see = {"deaths"}, byCat = "up", }
parents=
This is the list of the parent categories' category names. In the example above, the first parent would be beginnings. This means, the module needs to take the year parameter from the category page title, and add before this parent's category name. The year is 2000. So the result should be 2000 beginnings. In this case, the module goes to the parent category's object:
k["beginnings"] = { parents = {"categories"}, sort_keys = {"B"}, stage = 4, see = {"endings"}, }
For the second parent people, the same functions repeat.
Later on, the category needs to be added to the upper stage category, 2000 is a year so the upper stage for this should be a decade, but which decade? The module detects this through a function and finds the result 2000s, in the end the category name would be 2000s births. For each object, the upper stage is automatically detected. Which means, if the template is used in 2000s births, the module understands that this is a decade category and the upper stage should be a century, but only the topic for the category is sorted in that upper stage on Wikipedia. For an object, how many stages there are is explained in the stage=
title below.
sort_keys=
This is a table type. In this table, there are sort keys for all the parents. A sort key specifies the sorting letter in the parent category. For example in the [[Category:2020 in art|E]]
code, E is a sort key. Each category, can be added to their parents with different sort keys. The important thing is that the parents and the sort keys should be in the same order.
stage=
It specifies in which periods of time that the topic are categorised on Wikipedia at the time. In the example above, the stage value is 4. Which means, births type categories are sorted by year, decade, century, and, millennium:
But on the other hand, compilation albums has this value of 2:
k["compilation albums"] = { parents = {"albums"}, sort_keys = {"C"}, stage = 2, }
It is clear that, the stage number 2, means that compilation albums has categories by year or decade. This stage value can be changed later.
description=
If the object has a special description text specified in the data, it can be shown in the page.
{{{hide|}}}
is used to hide any text in a "by category", it is common to hide prefixes or suffixes that normally go with the years.{{{type}}}
is for the stage of time, could be year, decade, century, millennium or date or period or time.{{{year}}}
the year parameter for the page, for "by categories" this parameter becomes the type.
see=
If there should be category links at the top with Template:T, they can be listed on this label. In the example {"deaths"}
code means to go look for the deaths object. This value is always a table, inside there could be "deaths" and other object names. So, births object provides us a link in the end.
portals=
If there should be portal links at the top with Template:T, they can be listed on this label as a table.
byCat=
This label is for "by categories" only. Values are:
up
: It is used to indicate that this topic hasn't got any "... by date", "... by time", "... by period" category.no
: This means that in any "... by date", "... by time", "... by period" category, the category has no main category, therefore should not be in one.any other title
: If any "... by date", "... by time", "... by period" category, has a main category with a different name, for example in Buildings and structures by millennium of completion category, the main category is not "Buildings and structures by date of completion" but Buildings and structures by date. It is a different pattern.
If this value is a table, the first value of the table should be either "up" or "no" (it is the usage as above), and the second one is "any other title" (it is the same usage as above).
Data modules
If there is so many data on a page, the pages can be divided by their main categories.
List
All the data:
Period | Year | Suffix |
---|---|---|
beginnings | ||
beginnings by period | ||
parents: categories see also: endings | ||
disestablishments | ||
disestablishments by period | ||
parents: endings description: This category is for organizations, places or other things abolished or disestablished {{{hide|in the}}} {{{type}}} {{{year}}} see also: establishments | ||
endings | ||
endings by period | ||
parents: categories see also: beginnings | ||
establishments | ||
establishments by period | ||
parents: beginnings description: This category is for organizations, places or other things founded or established {{{hide|in the}}} {{{type}}} {{{year}}} see also: disestablishments |
Period | Year | Suffix |
---|---|---|
births | ||
parents: beginnings, people description: People born {{{hide|in the}}} {{{type}}} {{{year}}} see also: deaths | ||
deaths | ||
deaths by period | ||
parents: endings, people description: People who died {{{hide|in the}}} {{{type}}} {{{year}}} see also: births | ||
people | ||
people by period | ||
parents: categories see also: births, deaths |
Period | Year | Suffix |
---|---|---|
albums | ||
albums by period | ||
parents: in music, works | ||
compilation albums | ||
compilation albums by period | ||
parents: albums | ||
in music | ||
music by period | ||
parents: in the arts | ||
in the arts | ||
the arts by period | ||
parents: categories | ||
works | ||
works by period | ||
parents: categories, in the arts description: Works published, created or produced {{{hide|in the}}} {{{type}}} {{{year}}} |