Anda dapat membuat halaman dokumentasi untuk buat pada modul Scribunto ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
require('strict') localItalicTitle=require('Module:Italic title') localp={}-- functions made public locall={}-- internal functions, kept separate -- ============================================================================= -- main implements Template:Virusbox; see the documentation of that template -- for details. -- ============================================================================= functionp.main(frame) localargs ifframe.args['direct']=='yes'thenargs=frame.args elseargs=frame:getParent().argsend -- --------------------------------------------------------------------- -- pick up taxobox parameters from the caller that need to be processed; -- most are passed on unchanged -- --------------------------------------------------------------------- localname=args['name']or'' localtaxon=args['taxon']or'' localparent=args['parent']or'' localspecies=args['species']or'' localstrain=args['strain']or'' localserotype=args['serotype']or'' localvirus=args['virus']or'' localdisplayParents=args['display_parents']or'1' --[[ local authority = args['authority'] or '' local parentAuthority = args['parent_authority'] or '' local gParentAuthority = args['grandparent_authority'] or '' local ggParentAuthority = args['greatgrandparent_authority'] or '' local gggParentAuthority = args['greatgreatgrandparent_authority'] or '' local typeGenusAuthority = args['type_genus_authority'] or '' ]] localsubdivision=args['subdivision']or'' localsubdivisionRanks=args['subdivision_ranks']or'' localsubdivisionRef=args['subdivision_ref']orargs['subdivision ref']or'' -- ------------------------------------------------------ -- set the taxobox parameters determined by this function -- ------------------------------------------------------ localautoTaxon,autoTaxonType,infraTaxon,infraTaxonRank,targetTaxon,targetTaxonRank=l.paramChk(frame,taxon,parent,species,strain,serotype,virus) -- set default taxobox name/title localitalicsRequired=frame:expandTemplate{title='Is italic taxon',args={targetTaxonRank,virus='yes'}}=='yes' ifname==''then ifautoTaxonType=='ERROR'then name='<span class="error">ERROR: parameter(s) specifying taxon are incorrect; see [[Template:Virusbox/doc#Usage|documentation]]</span>' else name=targetTaxon ifitalicsRequiredthen name="''"..targetTaxon.."''" end end end -- the page name (title) should be italicized if it's the same as the target taxon and that is italicized localcurrentPage=mw.title.getCurrentTitle() localpagename=currentPage.text ifpagename==targetTaxonthen ifitalicsRequiredthenItalicTitle._main({})end end -- is the auto-taxon name bold or linked (i.e. will it be the last row in the taxobox or not)? localboldFirst='bold' ifautoTaxonType=='PARENT'thenboldFirst='link'end -- italicize and link species name, or embolden if nothing below ifspecies~=''then ifinfraTaxon~=''then species="''[["..species.."]]''" else species="'''''"..species.."'''''" end end -- embolden lowest rank ifinfraTaxon~=''then infraTaxon="'''"..infraTaxon.."'''" end -- set offset and fix display_parents if there are ranks below autoTaxon localoffset=0 ifinfraTaxon~=''thenoffset=offset+1end ifspecies~=''thenoffset=offset+1end ifoffset~=0then displayParents=tostring(tonumber(displayParents)-offset) end -- fill in a missing subdivision_ranks parameter ifsubdivision~=''andsubdivisionRanks==''then subdivisionRanks=frame:expandTemplate{title='Children rank',args={targetTaxonRank}} end -- ------------------------------------------------ -- now call Taxobox/core with all of its parameters -- ------------------------------------------------ localres=frame:expandTemplate{title='Taxobox/core',args= {['edit link']='e', virus='yes', colour=frame:expandTemplate{title='Taxobox colour',args={'virus'}}, name=name, parent=autoTaxon, bold_first=boldFirst, --[[ authority = authority, parent_authority = parentAuthority, grandparent_authority = gparentAuthority, grandparent_authority = gparentAuthority, greatgrandparent_authority = ggparentAuthority, greatgreatgrandparent_authority = gggparentAuthority, offset = tostring(offset), ]] image=args['image']or'', image_upright=args['image_upright']or'', image_alt=args['image_alt']or'', image_caption=args['image_caption']or'', image2=args['image2']or'', image2_upright=args['image2_upright']or'', image2_alt=args['image2_alt']or'', image2_caption=args['image2_caption']or'', species=species, virus_infrasp=infraTaxon, virus_infrasp_rank=infraTaxonRank, display_taxa=displayParents, type_genus=args['type_genus']or'', --type_genus_authority = args['type_genus_authority'] or '', type_species=args['type_species']or'', --type_species_authority = args['type_species_authority'] or '' subdivision_ranks=subdivisionRanks, subdivision_ref=subdivisionRef, subdivision=subdivision, type_strain=args['type_strain']or'', synonyms=args['synonyms']or'', synonyms_ref=args['synonyms_ref']or'', range_map=args['range_map']or'', range_map_upright=args['range_map_upright']or'', range_map_alt=args['range_map_alt']or'', range_map_caption=args['range_map_caption']or'', }} -- put page in error-tracking category if required ifautoTaxonType=='ERROR'then res=res..frame:expandTemplate{title='Main other',args={'[[Kategori:Virusbox dengan parameter keliru yang menentukan takson]]'}} end returnres end -- ============================================================================= -- paramChk checks the taxon-specifying parameters for consistency, selecting -- the target taxon (the taxon that is the target of the taxobox), the -- infra-taxon (the taxon below species level), if any, and the 'auto-taxon', -- the taxon that is the entry point into the automated taxobox system. -- ============================================================================= functionl.paramChk(frame,taxon,parent,species,strain,serotype,virus) -- set target taxon and infra-taxon localinfraTaxon='' localinfraTaxonRank='' localtargetTaxon localtargetTaxonRank ifstrain~=''then infraTaxon=strain infraTaxonRank='strain' targetTaxon=infraTaxon targetTaxonRank=infraTaxonRank elseifserotype~=''then infraTaxon=serotype infraTaxonRank='serotype' targetTaxon=infraTaxon targetTaxonRank=infraTaxonRank elseifvirus~=''then infraTaxon=virus infraTaxonRank='virus' targetTaxon=infraTaxon targetTaxonRank=infraTaxonRank elseifspecies~=''then targetTaxon=species targetTaxonRank='species' else targetTaxon=taxon targetTaxonRank=frame:expandTemplate{title='Taxon info',args={targetTaxon,'rank'}} end -- set the autotaxon (entry into the automated taxobox system) if the -- parameters are valid; the default is invalid localautoTaxon='' localautoTaxonType='ERROR' iftaxon~=''then ifparent..species..infraTaxon==''then autoTaxon=taxon autoTaxonType='TAXON' end elseifparent~=''and(species~=''orinfraTaxon~='')then autoTaxon=parent autoTaxonType='PARENT' end -- check for multiple infra-taxa localcount=0 ifstrain~=''thencount=count+1end ifserotype~=''thencount=count+1end ifvirus~=''thencount=count+1end ifcount>1thenautoTaxonType='ERROR'end returnautoTaxon,autoTaxonType,infraTaxon,infraTaxonRank,targetTaxon,targetTaxonRank end returnp