Wikipedia:Automated taxobox system/technical

Technical details
An accompanying page for each taxon, at Template:Taxonomy/taxon, uses a template to list the parent of each taxon. Each of the automated taxobox templates (Speciesbox, Automatic taxobox, etc. ) then consults these templates to produce a full taxonomy. By default it only displays "major" taxonomic ranks (i.e. not sub, super, nano etc), with the exception of the immediate parents to the taxon. Instructions for the manual creation of this page, if it does not yet exist, appear in the taxobox. Thus the hierarchy can be automatically generated, minimizing the work for editors of new pages whilst creating a consistent taxonomy, thus increasing the utility of Wikipedia (see ).

A list of all templates involved in generating an automated taxobox, and their relationships, can be found at WP:Automated taxobox system/map.

Maintenance
Sandboxing much of the automated taxobox system is difficult, since it relies on existing taxonomy templates. However, there are sandbox and testcase pages for some templates, e.g. Template:Automatic taxobox/sandbox and Template:Automatic taxobox/testcases.

Algorithm
The automated taxobox is placed directly above the first paragraph. Since the user is not required to enter any information about the scientific classification within the article, the automated taxobox first looks for the taxonomy template that matches the supplied taxon parameter (or, if none is supplied, the article's title, ignoring any parenthetical expressions).

If the taxon cannot be found in the database of taxonomy templates, the editor is prompted to enter the taxon's data onto a specified page where that data will be accessed for that taxon's taxobox and for all descendant taxa's taxoboxes. Contained on this page are the taxonomic rank, a link to the article about that taxon, the format which should be used when displaying that taxon in a taxobox, the name of the parent taxon, an indicator of extinction, and a list of references for all of this information.

Once the taxon is identified in the database, the system pulls all the information except the reference parameter. The same is done for this taxon's parent, and the grandparent, great-grandparent, etc., until a top-level taxon is reached (e.g. Life, Veterovata, Ichnos).

The path from the target taxon to the top-level taxon is,, traversed twice during the processing of the code – once to find the taxobox colour and once to display all the parent taxa. The traversals were converted to Lua in December 2016, which removed previous problems with expansion depth errors, and reduced the time from $$O(n^2)\,$$ – where $$n$$ corresponds to the number of levels deep the taxon in question is (including the top-level taxon) – to $$O(n)\,$$.

Once traversals are complete, the information is sorted out for each taxon. Ranks are converted to English displayable words, links are formed to each taxon, extinction daggers are added, appropriate ranks are italicized, and taxa deemed unimportant to that taxonomy are discarded. The final result should look exactly like a manual taxobox, except for the edit link in the bar that says "Scientific classification".