Template:Cite source/doc

 is a powerful template for generating in-universe, inline citations. In its most basic usage, it produces a collapsible bit of information about the source being cited, pulled directly from the infobox, intended to supplement the prefix. However, the template also has options for citing specific parts and episodes, variants of sources that don't have their own page, exact page numbers and timestamps and paths of "choose your own adventure" books.

Basic usage is very simple. When citing a source, instead of linking to the source like usual, wrap it in this template, like this:  . For example, if citing The Daleks, you would type: (TV: ) This produces the following:
 * (TV: )

You can also include linking brackets around this parameter and this parameter only. This allows you to make use of link autosuggest. For example, the following is valid: (TV: ) This produces the following:
 * (TV: )

The template will automatically strip the dab term in the display text. To specifiy custom display text, you would type the following:  . For example, if citing Project: Lazarus, which, for technical reasons, has the pagename Project Lazarus (audio story), you would type: (AUDIO: ) This produces the following:
 * (AUDIO: )

Clicking the [+] to the right of the source's name will reveal additional information about the source, intended to provide context to the reader regarding the origin of the source, allowing them to easily decide if it is something they're interested in. This information is automatically pulled from the infobox and generally requires no editor intervention (although you can customise the additional information if desired). For this to work, the page for the source being cited must be using. If it is not, an error will be produced. Information about finetuning the text displayed here can be found in the Infobox's documentation.

Exact nature of the additional information
The collapsible additional information can include the following:
 * writer(s)
 * what the source is adapted from
 * the original source's writer(s)
 * series
 * anthology
 * publisher
 * premiere network
 * release year(s)

If there are 4 or more writers, only one will be displayed with the rest replaced by "et al.". Hovering over the "et al." on desktop will show the other writers. For example:
 * (PROSE: )

Citing parts and episodes
Sources are often serialised across a number of parts. Sometimes, it can be useful to cite specific parts and episodes. Where possible, this is prefered over generic citations as it makes checking the citation and looking for the information within the source much easier (to make this even easier, consider adding a precise citation).

Named parts and episodes
To cite a specific named episode, use the following format:  . For example, to cite "The Dead Planet" from The Daleks, you would type: (TV: ) This produces:
 * (TV: )

The text provided to the |namedep= parameter must exactly match the episode's section title on the source's page, including any bracketed episode numbers. These bracketed episode numbers will be automatically stripped in the output.

The |namedpart= parameter is very similar. However, it does not produce a link to any specific sections. It has the following format:  . For example, to cite "The House Military" from The Book of the War, you would type: (PROSE: ) This produces:
 * (PROSE: )

Unamed parts and episodes
To cite a specific unnamed episode, use the following format:  . The episode number must be in the exact same format used for that episode's section title on the source's page, including capitalisation. For example, to cite part 7 of The War Games, you would type: (TV: ) This produces:
 * (TV: )

Sometimes, the episode or part's section title isn't simply in the format "Episode " or "Part " and so the link produced using this feature will be incorrect. In these situations, provide the full section's title using the |sect=</tt> parameter. For example, to cite part 2 of The Klepton Parasites, which has the section title "Part Two: 16th November 1964", you would type: (COMIC: ) This produces:
 * (COMIC: )

|sect=</tt> can also be used for linking to arbitrary sections outside of the context of episodes and parts, if desired.

Citing variants
Sources sometimes have one or more variants that aren't deserving of their own source page and so are covered on the same page as their "parent" source, such as animated reconstructions or audiobook readings. Occasionally, these variants can present unique information and so may want to be specifically cited. To do so, the variant should first be defined on the source's page using. Then, the variant being cited should be specified as follows:  </tt>. The variant name used by the |var=</tt> parameter should be exactly the same as the variant name set in as the |variant=</tt> parameter. For example, to cite the special edition of The Five Doctors, you would type: (TV: ) This produces:
 * (TV: )

This works with citing parts as well. For example, if you wanted to cite part 3 of the animated reconstruction of The Faceless Ones, you would type: (TV: ) This produces:
 * (TV: )

Precise citations
It can sometimes be useful to cite specific editions, chapters, page numbers or timestamps. The information being cited is rarely from the source as a whole, so being as precise as possible makes verifying information much easier. The precise citations can be used alongside citing parts and citing variants.

Books
To perform precise citations for books, use the |ed=</tt> and |page=</tt> parameters to define the edition and page number being cited. These can be used independetly, although it is often preferable to use |ed=</tt> with |page=</tt> as page numbers can change between editions. For example, to cite page 10 of The Eight Doctors, you would type: (PROSE: ) This produces:
 * (PROSE: )

You can also cite multiple pages. For example, to cite pages 10-20 of The Eight Doctors, you would type: (PROSE: ) This produces:
 * (PROSE: )

Note the inclusion of the "s" in "pages" in the produced citation. This "s" is added if the template detects any of the following: ",", "-", "and", "&".

Chapters can also be specified. Chapter numbers can be specified with |chaptnum=</tt> and chapter names with |chaptname=</tt>. For example, to cite chapter 1 of Doctor Who in an Exciting Adventure with the Daleks, you would type: (PROSE: ) This produces:
 * (PROSE: )

|chaptnum=</tt> follows the same logic of pluralisation that page=</tt> uses.

Using |chaptname=</tt> requires that |chaptnum=</tt> is also used. To just specify just a chapter name, or any other custom chapter text, use chapt=</tt>.

Video and audio sources
To perform precise citations for video (including TV stories, webcasts and films) and audio sources, you can define a timestamp using the <tt>|hour=</tt>, <tt>|minute=</tt> and <tt>|second=</tt> parameters. These can be used in any combination. For example, to cite the timestamp 34 minutes and 2 second of Rosa, you would type: (TV: ) This produces:
 * (TV: )

You can also define entirely custom timestamps using <tt>|timestamp=</tt>. For example, to cite the timestamp 26:54 of The Boundless Sea, you would type: (AUDIO: ) This produces:
 * (AUDIO: )

It can sometimes also be a good idea to use <tt>|ed=</tt> in these precise citations, particuarly with video sources, as exact timestamps can change between versions, such as the broadcast version, homemedia releases and oversea edits, and these don't always qualify as their own variants.

Custom precise citation text
Alternatively to everything discussed in the prior two sections, you can define entirely custom precise citation text using the <tt>|precisecite=</tt> parameter.

Citing "choose your own adventure" books
In line with the currently unpassed Forum:Revisiting fiction with branching elements and historical policy therein, you can cite specific "markers" (the terminology used in the opening post) within "choose your own adventure" gamebooks such as those in the Make Your Own Adventure with Doctor Who/Find Your Fate, Decide Your Destiny and Choose the Future series. To do this, specify the marker using <tt>|marker=</tt>. If there are marker sections on the page, make sure that the marker specified exactly matches the bit of the section header after "Marker ". For example, to cite the 2nd marker of Search for the Doctor, you would type: (PROSE: ) This produces the following:

(PROSE: )

Multiple markers should be cited in different uses of the template. To reduce clutter, the title of the story can be hidden by setting <tt>|notital=</tt> to any value. For example, to cite markers 32 and 33 of Search for the Doctor, you would type: (PROSE:, ) This produces the following:

(PROSE:, )

Some "choose your own adventure" use their own terminology and these can be used as well. In addition, entirely custom text can be specified using <tt>|path=</tt>. For example, to cite the "good" ending of Attack of the Graske, you would type: (GAME: ) This produces the following:
 * "paragraphs" uses <tt>|paragraph=</tt>
 * "outcomes" uses <tt>|outcome=</tt>
 * "pages" uses <tt>|mppage=</tt> (Multipath page)
 * "endings" uses <tt>|ending=</tt>

(GAME: )

This can be combined with <tt>|sect=</tt> to link to specific sections of the source's article.

Customising the additional information
It is possible to overwrite specific bits of information in the collapsible additional information for a specific citation using the following parameters: You only have to specify the information that you wish to change from the default. Others will be filled in automatically. For example, if you wished to be a little more precise about the release year when citing "The Dead Planet", you would type the following: (TV: ) This produces:
 * <tt>|writer=</tt>
 * <tt>|adapted from=</tt>
 * <tt>|series=</tt>
 * <tt>|anthology=</tt>
 * <tt>|publisher=</tt>
 * <tt>|network=</tt>
 * <tt>|release year=</tt>
 * (TV: )

If any of the values you wish to use for any of these bits of information contain a comma (","), you must specify the <tt>|separator=</tt> parameter with a different separator (such as ";") that then should be used when you need to specify multiple values for a bit of information, such as multiple writers.

Using this feature repeatedly on the same page may cause performance issues, but occasional usage shouldn't have much impact.

It is also possible to provide fully customised additional information using the <tt>|citationtext=</tt> parameter.

Reusing citations
Due to the number of options available, uses of this template can sometimes become very long. Therefore, much like with <tt> </tt> references, it is possible to define named citations that can be reused within the page they were defined on. This is done using the <tt>|name=</tt> parameter. To define a named citation, simply add this parameter to the template usage with a short name. For example, to define a citation named "TFOAR1" for episode 1 of the DVD edition of the animated reconstruction of The Faceless Ones at the timestamp 3 minutes and 4 seconds, you would type: (TV: ) This produces the following output as normal:
 * (TV: )

Then, to reuse this citation, you would only have to type: (TV: ) This produces:
 * (TV: )

When <tt>|name=</tt> is being used to access an already defined citation, any other parameters passed to the template are ignored. In other words, you cannot alter a named citation in later uses.

Errors and troubleshooting
Due to the complex nature of this large template, there are a number of ways in which it could go wrong and produce an error. This section details these errors, providing potential solutions.

Lua errors
If you see any errors like this, please remove the use of this template that is causing it and report it on the |talk page with as much detail as you can as soon as possible. These errors generally mean that there is some form of mistake with the template's actual code.

Error: code 1
data table empty This error means that the source's infobox was unable to collect any data to put the additional information together. To fix this, first purge the cache of the source's page and the page the citation is being used on. If that doesn't work, make sure that the infobox contains at least one of the pieces of data listed here. If all else fails, manually define the additional information using the <tt>|citation text=</tt> parameter within the infobox.

Error: Code 2
no data stored in variables, cache or SMW This error means that the template is unable to get the additional information from the source's infobox. To fix this, first check that you've actually gor the source's page name correct, including the dab term. If this doesn't work, purge the cache of the source's page and the page the citation is being used on. If this doesn't work, check that the source's page is actually using and, if it isn't, convert it so that it is. If this doesn't work, report the error on the |talk page.

Error: code 3
no story given in template transclusion This is a simple one and means that the template has been used without providing a source to actually be cited. To fix this, include a source like is shown in the first few paragraphs of this page.

Error: Code 4
no data in variables or cache and SMW returned information for multiple variants, the one required here not being clear This rather verbose error is an extreme edge case that should never occur. It means that you've attempted to cite a variant where more than one variant for that source exist and, for whatever reason, there is no additional information provided for said variant in the 2 preferred means of storing this information yet Semantic MediaWiki, the last resort, does have this information, the problem being that it is not possible to properly distinguish the multiple variants coming from SMW. To fix this, first purge the cache of the source's page and the page the citation is being used on. If that doesn't work, report the error on the |talk page.

Other issues
There are some other problems that are not automatically detectable and have no automatic fix.
 * Only some of the citation information is in the collapsible. The rest is always visible.
 * This is most likely caused by the template being used in a block of italics. For example:
 * [...](TV: [...]
 * [...](TV: )[...]
 * This is not the intended behavior. To fix this, try closing the italics before the citation and opening them again after. For example:
 * [...](TV: [...]
 * [...](TV: )[...]
 * Pretty much, this template just can't be used within italics.

Full parameters list
This section lists all parameters offered by this template.

Technical documentation
This template relies upon Module:Cite source, a module written in Lua. Documentation for this module can be found on its page.

Template data
{   "params": { "1": {           "label": "Page name", "description": "The source's page name", "example": "Project Lazarus (audio story)", "type": "wiki-page-name", "suggested": true },       "2": {            "label": "Display text", "description": "The display text of the link to the source. Usually only required if the source name contains a colon (\":\") as, in these cases, the page name will ommit it. Disambiguation terms are removed automatically.", "example": "Project: Lazarus", "type": "line", "suggested": true },       "name": { "label": "Named citation", "description": "Either the name of a previously defined named citation, or the name of this citation that allows it to be reused", "type": "line", "suggested": true },       "sect": { "label": "Section", "description": "The section of the source's page to link to.", "type": "line" },       "part": { "label": "Unamed part", "description": "The part number to cite of a serialised story with unamed parts. Will produce a link to the parts's section header on the source's page and add the parts's number to the display text in brackets. Should match the format used by the section header.", "example": "Seven", "type": "line", "suggested": true },       "ep": { "label": "Unamed episode", "description": "The episode number to cite of a serialised story with unamed episodes. Will produce a link to the episode's section header on the source's page and add the episode's number to the display text in brackets. Should match the format used by the section header.", "example": "2", "type": "line", "suggested": true },       "namedep": { "label": "Named episode", "description": "The episode to cite of a serialised story with named episodes. Will produce a link to the episode's section heading on the source's page and change the display text to the episode's name in quotation marks. Should match the format used by the section header, including any brackets (which are automatically removed in the display). ", "example": "The Dead Planet (1)", "type": "line", "suggested": true },       "namedpart": { "label": "Named part", "description": "The part to cite of a serialised story with named parts. Will not produce a link to the part's section on the sources page but will change to display text to the part's name in quotation marks.", "example": "The House Military", "suggested": true, "type": "line" },       "var": { "label": "Variant", "description": "Allows a specific variant of a source to be cited, as defined on the source's page (see template documentation for details). ", "example": "special edition", "type": "line", "suggested": true },       "precisecite": { "label": "Custom precise citation text", "description": "Allows fully custom precise citation text to be defined. ", "type": "content" },       "ed": { "label": "Edition", "description": "The edition of the source to cite. Part of the precise cite display.", "example": "1965 Armada edition", "type": "line", "suggested": true },       "chapt": { "label": "Custom precise citation chapter text", "description": "Allows for custom chapter text to be specified, such as if the chapter is named but not numbered. Part of the precise cite display.", "type": "line" },       "chaptnum": { "label": "Chapter number", "description": "The chapter number(s) of the source to cite. Part of the precise cite display.", "example": "3-4, 20", "type": "line", "suggested": true },       "chaptname": { "label": "Chapter name", "description": "The chapter name of the source to cite. Part of the precise cite display. Requires that the chapter number be specified.", "example": "A Meeting on the Common", "type": "line", "suggested": true },       "page": { "label": "Page number", "description": "The page number(s) of the source to cite. Part of the precise cite display.", "example": "3-29, 106", "type": "line", "suggested": true },       "timestamp": { "label": "Custom precise citation timestamp", "description": "Allows a custom timestamp to be specified. Part of the precise cite display.", "example": "13:20", "type": "line" },       "hour": { "label": "Timestamp hour", "description": "The hour part of the timestamp to cite from the source. Part of the precise cite display.", "example": "1", "type": "number", "suggested": true },       "minute": { "label": "Timestamp minute", "description": "The minute part of the timestamp to cite from the source. Part of the precise cite display.", "example": "12", "type": "number", "suggested": true },       "second": { "label": "Timestamp second", "description": "The seconds part of the timestamp to cite from the source. Part of the precise cite display.", "example": "54", "type": "number", "suggested": true },       "marker": { "label": "CYOA book marker", "description": "The \"marker\" used to cite for CYOA books.", "example": "32", "type": "number" },       "paragraph": { "label": "CYOA book paragraph", "description": "The \"paragraph\" used to cite for CYOA books.", "example": "32", "type": "number" },       "outcome": { "label": "CYOA book outcome", "description": "The \"outcome\" used to cite for CYOA books.", "example": "32", "type": "number" },       "mppage": { "label": "CYOA book page", "description": "The \"page\" used to cite for CYOA books.", "example": "32", "type": "number" },       "ending": { "label": "CYOA book ending", "description": "The \"ending\" used to cite for CYOA books.", "example": "32", "type": "number" },       "path": { "label": "Multipath source path", "description": "The \"path\" used to cite for multipath sources.", "example": "32", "type": "number" },       "citationtext": { "label": "Additional information override", "description": "Allows for the auto-genarated additional information to be fully overriden.", "type": "content" },       "anthology": { "label": "Anthology override", "description": "Allows the autogenerated anthology to be overriden.", "type": "wiki-page-name", "example": "Short Trips (anthology)" },       "writer": { "label": "Writer override", "description": "Allows the autogenerated writer to be overriden.", "example": "Russel T Davies", "type": "wiki-page-name" },       "publisher": { "label": "Publisher override", "description": "Allows the autogenerated publisher to be overriden.", "example": "BBC Books", "type": "wiki-page-name" },       "adapted from": { "label": "Adapted from override", "description": "Allows the autogenerated adapted from source to be overriden.", "example": "The Daleks (TV story)", "type": "wiki-page-name" },       "network": { "label": "Network override", "description": "Allows the autogenerated broadcast network to be overriden.", "example": "BBC tv", "type": "wiki-page-name" },       "release year": { "label": "Release year override", "description": "Allows the autogenerated release year to be overriden.", "example": "1963-1964", "type": "line" },       "series": { "label": "Series override", "description": "Allows the autogenerated series to be overriden. This parameter allows for arbitrary wikitext.", "example": "Doctor Who", "type": "content" },       "separator": { "label": "Overrides separator", "description": "Separator to use for listing multiple values for any overrides. ", "example": ";", "type": "line", "default": "," },       "notital": { "label": "Remove source tital", "description": "Set to any value to remove the source's name and link, leaving only the collapsible additional information.", "example": "true", "type": "line", "suggestedvalues": [ "true" ]       },        "noinfo": { "label": "Remove additional information", "description": "Set this to any value to prevent the collapsible additional information from displaying.", "example": "true", "type": "line", "suggestedvalues": [ "true" ]       },        "noital": { "label": "Remove italics", "description": "Set this to any value to prevent the source's name from being italicised. ", "example": "true", "type": "line", "suggestedvalues": [ "true" ]       },        "quote": { "label": "Force quotation marks", "description": "Set this to any value to prevent force the source's name to be wrapped in quotation marks (\"). ",           "example": "true",            "type": "line",            "suggestedvalues": [                "true"            ]        }    },    "sets": [        {            "label": "Overrides",            "params": ["citationtext", "anthology", "writer", "publisher", "adapted from", "network", "release year", "series", "separator"]        }    ],    "description": "Produces inline citations for in-universe articles with collapsible additional information.",    "format": "inline",    "paramOrder": [        "1",        "2",        "name",        "sect",        "part",        "ep",        "namedep",        "namedpart",        "var",        "precisecite",        "ed",        "chapt",        "chaptnum",        "chaptname",        "page",        "timestamp",        "hour",        "minute",        "second",        "marker",        "paragraph",        "outcome",        "mppage",        "ending", "path", "citationtext", "anthology", "writer", "publisher", "adapted from", "network", "release year", "series", "separator", "notital", "noinfo", "noital", "quote" ] }