User:Animal lover 666/Adnacent stations tutorial

How to use the Template:Adjacent stations system
There are two steps involved: first you must create the module for the transportation system, and then you add the template on relevant articles.

The transportation system module
This must be created as a subpage of Module:Adjacent stations. Enter the name of the transportation system in the following box:

The extreme basics of Lua modules
Lua, the language used for modules, has 6 types. We will be using only 2 of them explicitly - string and table.

A string is a piece of text - a word, phrase, a textual representation of a number, etc. A table is a collection of ordered key-value pairs, where the keys are unique. We will be explicitly using only string values for keys, although we will have values with no explicit keys and there the implicit keys are numbers.

A literal string will be written by surrounding the content with double quotes. On the rare occasion that such a string will itself contain double quotes, we will put a backslash before it, e.g. Note that the textual representation of a number is not the same as the number itself; and that adding 0's at the beginning of a string which represents a number makes it a different string -  and   are different strings.

All standard uses of square brackets, as used in articles, equally work when used in Lua modules. This includes categories and media (File: namespace); to link to these with a standard link, place a colon after the openning square brackets, just as you would in wikicode. This also includes links to sections or manually-defined bookmarks using the # character. What doesn't work in modules is the use of templates; please write out the desired output directly.

A table will be written as a collection of key/value pairs, wrapped in curly brackets. Pairs will be separated by commas; a comma after the last pair is technically unnecessary, but permitted and will frequently make subsequent updates easier. When explicitly stating the key, it will be wrapped in square brackets, and after the close bracket will be an equal sign. New line characters may technically go any place other than the middle of a literal string; they will actually be used where it helps human readability.

A sample table, taken from Module:Adjacent stations/CTA: Note that in this table, the key  (a string) gets a table as a value.

An other table, this one from Module:Adjacent stations/London Underground:

Look at the value with the key. It's a table with 3 implicit keys and one explicit key. Note that the order of implicit keys does matter, but not the order.of explicit keys or their locations relative to the implicit ones.

Occasionally you may run into a value of  or  ; these are values of the boolean type (not to be confused with   or , which are strings).

You may want to add comments to your module. Usually you will use single-line comments, which start with two dashes which are not followed by an open square bracket; this comment ends at the end of the line, although the next line could also be a comment line. Occasionally you may want a multi-line comment; while you can start each line with 2 dashes, there's an other way: start with 2 dashes followed immediately, not even a space in between, with a double square bracket. This comment continues until it runs into a double close square bracket. You can also "lengthen" the openning by adding equals signs between the openning square brackets; you need the same number between the closing brackets.

Any module must return a value of the table type. In these modules, one generally creates a table called, and then returns it.

The structure of Adjacent stations submodules
The basic module has the following sections:
 * 1) The header - contains various values used in the main part of the module, usually format strings.
 * 2) The system definitions - includes the following:
 * 3) an optional   parameter - exists to allow multiple language versions on the same wiki. On English Wikipedia there are currently 2 options -   (default) and  ; the only actual difference is that the GB version uses the word "towards", while the US version uses the word "toward" with no s. The decision of when to use this parameter is based on WP:ENGVAR.
 * 4) a , which gets a full image usage format. For example, in Module:Adjacent stations/BART, the value is.
 * 5) a , which gets the wikicode for displaying the title. Usually this will be a wikilink.
 * 6) The station format section - to convert the station name to the article name
 * 7) The line section - a list of lines

Station format list
This section is intended to translate the station name, as used in a parameter in the Template:Adjacent stations template, into a link. In most cases, the visible text of the link is identical with the name in the template parameter; there are a few exceptions, as will be discussed later. When it is, we simply must produce the article nane.

In most cases, there will be a general format good for most or all stations. The format is a string, which uses  as a place holder for the station name. An example with no exceptions can be found in Module:Adjacent stations/Israel Railways:

In this system, there are no exceptions. So for the  station, the article is at Netanya railway station.

Usually, however, there will be some exceptions. These are listed in the station format table, with the station name as the key and the article name as the value. For example, in Module:Adjacent stations/Cuyahoga Valley Scenic Railroad:

In this system, nearly all the stations use the same format. For example,  has its article at Akron Northside station. There is one exception - the article for  is at Peninsula Depot, not at Peninsula station.

The exception for  could have alternatively been written as a format, as. When there's only one exception to a pattern, there is little need to do this; however, if there are several exceptions using the same format, the format can be given a name at the top of the module, and the name - without quotes - can be used in the station format table as needed. For example, in Module:Adjacent stations/South Australian Railways, the following line can be found at the top of the module:

And the following is the station format table:

In this system, any station not on the list is simply appended with ; the station   has its article at Tuni railway station, Adelaide; and the other three stations are all do e based on the format at the beginning of the module - for example, the   station has its article at Taringa railway station, South Australia.

Of course, you are not limited to 1 exception format. In fact, Module:Adjacent stations/Amtrak has 55 such formats.

Some times there will be multiple stations with the same name in the same system. In these cases, you should place a table of names, using the line names as keys. The following can be found in the station format table for Module:Adjacent stations/São Paulo Metropolitan Trains:

In this case, when handling line  or   (note that these are textual representations of numbers, not the numbers themselves), it will take Lapa (Line 7) (CPTM); and for line   it will take Lapa (Line 8) (CPTM).

You can also use a single default output. For example, in Module:Adjacent stations/Long Island Rail Road the following entry can be found in the station format table:

In this case, if it finds  in any line except , it will take Rosa Parks Hempstead Transit Center; for  , it will use the format called  , which is  , and use the Hempstead station (SRRLI) article in stead.

Some times, different branches of the same line will have identically named stations. An example of this can be found in Module:Adjacent stations/MBTA:

In this case, for the  line, it will use different values based on the branch.

Use of full wikicode for station
In most cases, the name of the station as entered into the template is the name as should be displayed to the reader. However, there are some exceptions:


 * 1) Station aliases - short names to be used in the template, with longer names being displayed to the reader. For example, in Module:Adjacent stations/Istanbul Metro, you will find the entry   Another reason for station aliases is to use names which can be typed on an English-language keyboard in the wikicode but display other characters to the reader. The station list in Module:Adjacent stations/KSR has many of those.
 * 2) A related reason is to handle station names with a | character. Although there are ways around this issue, the simplest solution is to use a name without that character in the wikicode, and let the module handle it. For example, Module:Adjacent stations/Barcelona Metro has several - including  . Note that in the link, the first time the character appears separates the link target from the link text, but any subsequent use of this character shows up visibe to the user.
 * 3) A less common reason is for use of psudo-stations - entities which are not truely stations, but the easiest way to handle some aspect of the templates is to pretend that they are. For example, it would look awkward to the reader to see that London Underground's Piccadilly line has termini at "Uxbridge, Rayners Lane, Heathrow Terminal 4 or Heathrow Terminal 5" (with appropriate links); the Heathrow termini are handled in Module:Adjacent stations/London Underground with the following psudo-station:.
 * 4) An other rare use is to include an image along with the name. For example, in Module:Adjacent stations/CTA, there is a station entry . This station entry would be rendered as O'Hare Pictograms-nps-airport.svg.

Line list
A sample of a simple section:

This example, from Module:Adjacent stations/NYCDOT, is a single-line system. It does have more than the basic parameters, but it does give some idea of what the line looks like in the template:
 * 1)  is the name of the line, as it shows up in the template (a link, not raw text)
 * 2)  is the RGB color code on either side of the name of the line (see RGB color model for more details. This should generally be the color used by the system to indicate this line, if one exists.
 * 3)  and , the ends of the line. The left will generally be the one farther west and the right will be the one farther east, but exceptions to this rule do exist.