Module:Highest archive number/doc: Difference between revisions
mNo edit summary |
add start parameter docs |
||
Line 2: | Line 2: | ||
This module finds the highest archive number for a given set of numbered archive pages. The only input required is the prefix of the archive set. For example, for [[Talk:France/Archive 1]], [[Talk:France/Archive 2]], etc., the prefix would be "Talk:France/Archive ". |
This module finds the highest archive number for a given set of numbered archive pages. The only input required is the prefix of the archive set. For example, for [[Talk:France/Archive 1]], [[Talk:France/Archive 2]], etc., the prefix would be "Talk:France/Archive ". |
||
The module uses |
The module uses an [[exponential search]] algorithm, so it will make relatively few [[WP:EXPENSIVE|expensive function calls]] even for large numbers of archives. (The expensive function call is necessary to determine whether an individual archive exists.) For 1-10 archive pages, the module typically uses 4-6 expensive function calls; for 20-100 archives, it uses 6-12 calls; and for hundreds of archives, it uses 12-20 calls. |
||
Because the module uses an exponential search, no gaps are allowed in the archive numbers; if there are any gaps, then the module may return the number of any archive page that exists where the following archive page does not exist. However, archive numbers do not have to start at 1; if they start at a higher number, you can specify this number in the <code>start</code> parameter. |
|||
== Usage == |
== Usage == |
||
=== From wikitext === |
=== From wikitext === |
||
From wikitext this module is usually used via the {{tl|highest archive number}} template. However, it is also possible to use it directly from invoke with the syntax <code><nowiki>{{#invoke:highest archive number|main|</nowiki>''prefix''<nowiki>}}</nowiki></code>. |
From wikitext this module is usually used via the {{tl|highest archive number}} template. However, it is also possible to use it directly from invoke with the syntax <code><nowiki>{{#invoke:highest archive number|main|</nowiki>''prefix''<nowiki>|start=</nowiki>''start''<nowiki>}}</nowiki></code>. |
||
=== From Lua === |
=== From Lua === |
||
Line 20: | Line 22: | ||
<source lang="lua"> |
<source lang="lua"> |
||
mHAN._main(prefix) |
mHAN._main(prefix, start) |
||
</source> |
</source> |
||
Line 39: | Line 41: | ||
| {{code|mHAN._main("Talk:Byzantine Empire/Archive ")|lua}} |
| {{code|mHAN._main("Talk:Byzantine Empire/Archive ")|lua}} |
||
| {{#invoke:highest archive number|main|Talk:Byzantine Empire/Archive }} |
| {{#invoke:highest archive number|main|Talk:Byzantine Empire/Archive }} |
||
|- |
|||
| <code><nowiki>{{#invoke:highest archive number/sandbox|main|Wikipedia talk:WikiProject Chemicals/Archive |start=2005}}</nowiki></code> |
|||
| {{code|mHAN._main("Wikipedia talk:WikiProject Chemicals/Archive ", 2005)|lua}} |
|||
| {{#invoke:highest archive number/sandbox|main|Wikipedia talk:WikiProject Chemicals/Archive |start=2005}} |
|||
|} |
|} |
||
Revision as of 15:56, 8 October 2019
This module finds the highest archive number for a given set of numbered archive pages. The only input required is the prefix of the archive set. For example, for Talk:France/Archive 1, Talk:France/Archive 2, etc., the prefix would be "Talk:France/Archive ".
The module uses an exponential search algorithm, so it will make relatively few expensive function calls even for large numbers of archives. (The expensive function call is necessary to determine whether an individual archive exists.) For 1-10 archive pages, the module typically uses 4-6 expensive function calls; for 20-100 archives, it uses 6-12 calls; and for hundreds of archives, it uses 12-20 calls.
Because the module uses an exponential search, no gaps are allowed in the archive numbers; if there are any gaps, then the module may return the number of any archive page that exists where the following archive page does not exist. However, archive numbers do not have to start at 1; if they start at a higher number, you can specify this number in the start
parameter.
Usage
From wikitext
From wikitext this module is usually used via the {{highest archive number}} template. However, it is also possible to use it directly from invoke with the syntax {{#invoke:highest archive number|main|prefix|start=start}}
.
From Lua
Load the module with the following code:
local mHAN = require('Module:Highest archive number')
You can then use it like this:
mHAN._main(prefix, start)
The prefix variable is the prefix of the archive set.
Examples
#invoke code | Lua code | Result |
---|---|---|
{{#invoke:highest archive number|main|Wikipedia:Administrators' noticeboard/IncidentArchive}}
|
mHAN._main("Wikipedia:Administrators' noticeboard/IncidentArchive")
|
1189 |
{{#invoke:highest archive number|main|Talk:Byzantine Empire/Archive }}
|
mHAN._main("Talk:Byzantine Empire/Archive ")
|
18 |
{{#invoke:highest archive number/sandbox|main|Wikipedia talk:WikiProject Chemicals/Archive |start=2005}}
|
mHAN._main("Wikipedia talk:WikiProject Chemicals/Archive ", 2005)
|
2025 |