Module:Autotaxobox/doc
{{High-use|120639}}
 {{Module rating|protected}}
 &lt;!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --&gt;
 
 [[Module:Autotaxobox]] {{Toolbar|style=font-size:90% |separator=dot
      | 1 = [[:Module talk:Autotaxobox|talk]]
      | 2 = {{edit|1=Module:Autotaxobox|2=edit}}
      | 3 = {{history|Module:Autotaxobox|hist}}
      | 4 = [{{fullurl:Special:WhatLinksHere/:Module:Autotaxobox|limit=999}} links]
      | 5 = [[Module:Autotaxobox/doc|doc]]
      | 6 = [[Special:PrefixIndex/Module:Autotaxobox|subpages]]
      | 7 = [[Module:Autotaxobox/sandbox|sandbox]]
      | 8 = [[Module talk:Autotaxobox/testcases|testcases]]
 }}
 
 The purpose of this module is to provide support for automated taxobox templates (such as {{tl|Automatic taxobox}} or {{tl|Speciesbox}}), avoiding Mediawiki template expansion depth errors in the traversal of the taxonomic hierarchies encoded in taxonomy templates.
 
 Currently processing is arbitrarily limited to hierarchies containing at most {{#invoke:Autotaxobox|getMaxSearchLevels}} levels.
 
 == taxoboxColour ==
 Given a taxon name, this function returns the correct colour of an automated taxobox for that taxon. It does so by searching up the taxonomic hierarchy for a 'real' taxon (i.e. not ''incertae sedis'') that sets the taxobox colour, and then returning that colour. If no 'real' taxon is found, then if an ''incertae sedis'' taxon was found, the ''incertae sedis'' colour is returned, otherwise &quot;transparent&quot; is returned. (If the taxonomic hierarchy is too deep to process, the error colour is returned.)
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|taxoboxColour|''taxon_name''}}&lt;/code&gt;
 
 Parameters:
 
 :The unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists.
 
 Examples:
 
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxoboxColour|Felis}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxoboxColour|Felis}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxoboxColour|Acacia}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxoboxColour|Acacia}}
 
 == taxoboxList ==
 Given a taxon name, this function returns the rows of taxa in an automated taxobox, based on the taxonomic
 hierarchy for the supplied taxon.
 
 Usage:
 
 &lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|taxoboxList|''taxon_name''&lt;br&gt;
 |display_taxa = ''the number of taxa above taxon_name to force to be displayed''&lt;br&gt;
 |authority = ''taxonomic authority for taxon_name''&lt;br&gt;
 |parent_authority = ''taxonomic authority for taxon_name's parent''&lt;br&gt;
 |gparent_authority = ''taxonomic authority for taxon_name's grandparent''&lt;br&gt;
 |ggparent_authority = ''taxonomic authority for taxon_name's greatgrandparent''&lt;br&gt;
 |ggparent_authority = ''taxonomic authority for taxon_name's greatgreatgrandparent''&lt;br&gt;
 |bold_first = ''bold to embolden taxon_name in its row''&lt;br&gt;
 }}&lt;/code&gt;
 
 Parameters:
 
 :The unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists. The others are explained above.
 
 Examples:
 
 &lt;pre&gt;{| class=&quot;wikitable&quot;
 {{#invoke:Autotaxobox|taxoboxList|Felis|authority=Linnaeus, 1758}}
 |}&lt;/pre&gt; →
 {| class=&quot;wikitable&quot;
 {{#invoke:Autotaxobox|taxoboxList|Felis|authority=Linnaeus, 1758}}
 |}
 
 == taxonomyList ==
 Given a taxon name, this function returns the rows of the taxonomy table displayed on the &quot;Template:Taxonomy/''taxon_name''&quot; page, based on the taxonomic hierarchy for the supplied taxon name.
 
 When &lt;em&gt;descending&lt;/em&gt; the taxonomic hierarchy, if a rank is found that is either at the same level or higher than a rank already encountered (e.g. a family is found below a subfamily), the cell displaying the rank is given a reddish background. The numerical values defined in &lt;code&gt;getRankTable()&lt;/code&gt; are used to determine the correct sequence of ranks.
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|taxonomyList|''taxon_name''}}&lt;/code&gt;
 
 Parameters:
 
 :The unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists.
 
 Examples:
 &lt;pre&gt;{| class=&quot;wikitable&quot;
 {{#invoke:Autotaxobox|taxonomyList|Felis}}
 |}&lt;/pre&gt; →
 {| class=&quot;wikitable&quot;
 {{#invoke:Autotaxobox|taxonomyList|Felis}}
 |}
 
 == callTaxonomyKey ==
 This function prepares for, and then calls, {{tl|Taxonomy key}} to display a taxonomy
 template page. It does this by building up the information the template
 requires, following one &lt;code&gt;same_as&lt;/code&gt; link if present, and then calling it.
 
 Usage:
 
 &lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|callTaxonomyKey
 |parent= &lt;br&gt;
 |rank= &lt;br&gt;
 |extinct= &lt;br&gt;
 |always_display= &lt;br&gt;
 |link_target=value of 'link' parameter in the taxonomy template&lt;br&gt;
 |link_text=value of unnamed parameter in the taxonomy template&lt;br&gt;
 |same_as=&lt;br&gt;
 }}&lt;/code&gt;
 
 == taxonInfo ==
 Given the names of a taxon and the required item of information stored in the taxon's taxonomy template, this function returns the value of the item, following one &quot;same as&quot; link if available and the value would otherwise be the empty string. The function would normally be used externally via {{tl|Taxon info}}.
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|taxonInfo|''taxon_name''|''item_name''}}&lt;/code&gt;
 
 Parameters:
 
 :The first unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists.
 :The possible values of the second unnamed parameter are given at {{tl|Taxon info/doc}}.
 
 Examples:
 
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonInfo|Felis|rank}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonInfo|Felis|rank}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonInfo|Aves/skip|same_as}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonInfo|Aves/skip|same_as}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonInfo|Aves/skip|parent}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonInfo|Aves/skip|parent}}
 
 == taxonLink ==
 Returns a wikilink to a taxon, if required including '†' before it and
 ' (?)' after it, and optionally italicized or bolded without a wikilink.
 It would normally be used via {{tl|Taxon link}}. Some parameters can, under
 some circumstances, be omitted.
 
 Usage:
 
 &lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|taxonLink&lt;br&gt;
 |taxon= &lt;/code&gt;(having '/?' at the end triggers the output of ' (?)')&lt;code&gt;&lt;br&gt;
 |extinct= &lt;/code&gt;('yes' or 'true' trigger the output of '†')&lt;code&gt;&lt;br&gt;
 |bold= &lt;/code&gt;('yes' makes the core output bold and not wikilinked)&lt;code&gt;&lt;br&gt;
 |italic= &lt;/code&gt;('yes' makes the core output italic)&lt;code&gt;&lt;br&gt;
 |link_target=''target for the wikilink''&lt;br&gt;
 |plain_link_text= ''text of the wikilink'' &lt;/code&gt;(without †, italics, etc.)&lt;code&gt;&lt;br&gt;
 }}&lt;/code&gt;
 
 Examples:
 
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonLink|taxon=Felis|italic=yes}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonLink|taxon=Felis|italic=yes}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonLink|taxon=Incertae sedis/Animalia}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonLink|taxon=Incertae sedis/Animalia}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonLink|link_target=Pterosaur|plain_link_text=Pterosauromorpha|extinct=yes}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonLink|link_target=Pterosaur|plain_link_text=Pterosauromorpha|extinct=yes}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|taxonLink|taxon=Dinosauria/?|link_target=Dinosaur|plain_link_text=Dinosauria|extinct=yes}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|taxonLink|taxon=Dinosauria/?|link_target=Dinosaur|plain_link_text=Dinosauria|extinct=yes}}
 
 ==showRankTable==
 Returns a sortable wikitable containing the ranks and corresponding numerical values defined in &lt;code&gt;getRankTable()&lt;/code&gt; and used in checking the consistency of a taxonomic hierarchy. If a taxon has a value in the rank table, it should always be lower than one higher in the taxonomic hierarchy.
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|showRankTable}}&lt;/code&gt;
 
 ==Utilities==
 These functions are intended to be used only in analysing taxonomic hierarchies, e.g. in testing and debugging, and not for direct use in templates used in the automated taxobox system.
 
 ===nth===
 Given a taxon name, this function returns the ''n''th taxon above it in the taxonomic hierarchy.
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|nth|''taxon_name''|n=''integer''}}&lt;/code&gt;
 
 Parameters:
 
 :The unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists.
 :'''n''' is the level whose taxon is to be found
 
 Examples:
 
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|nth|Felis|n=1}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|nth|Felis|n=1}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|nth|Felis|n=15}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|nth|Felis|n=15}}
 
 ===nLevels===
 Given a taxon name, this function returns the number of levels at and above it in the taxonomic hierarchy.
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|nLevels|''taxon_name''}}&lt;/code&gt;
 
 Parameters:
 
 :The unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists.
 
 Examples:
 
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|nLevels|Felis}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|nLevels|Felis}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|nLevels|Pteranodon}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|nLevels|Pteranodon}}
 
 ===listAll===
 Given a taxon name, this function returns a comma-separated list of all the levels at and above it in the taxonomic hierarchy.
 
 Usage:
 
 :&lt;code&gt;&lt;nowiki&gt;{{&lt;/nowiki&gt;#invoke:Autotaxobox|listAll|''taxon_name''}}&lt;/code&gt;
 
 Parameters:
 
 :The unnamed parameter should be the name of a taxon for which &quot;Template:Taxonomy/''taxon_name''&quot; exists.
 
 Examples:
 
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|listAll|Plantae}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|listAll|Plantae}}
 :&lt;nowiki&gt;{{#invoke:Autotaxobox|listAll|Felis}}&lt;/nowiki&gt; → {{#invoke:Autotaxobox|listAll|Felis}}
 
 &lt;includeonly&gt;{{#ifeq:{{SUBPAGENAME}}|sandbox | |
 &lt;!-- Categories below this line, please; interwikis at Wikidata --&gt;