Template:S-line/doc

S-line is a specialised succession box template that links railway station articles.

Note: this template is called by ; an alias. If a change is made which alters/adds parameters names that template must be updated to reflect the new situation.

Usage
S-line must be encased within s-rail-start and s-end. The use of s-rail is highly recommended but not required.

S-line has the following parameters:

Making it work
S-line depends on sub-templates for the proper display of information. For an example, here are the templates necessary to properly display this box (a version of which is at Kalamazoo Transportation Center:

First of all, here's the underlying code:

Template:S-rail-start is a variant of the generic template used to begin thousands of succession boxes. Important note: No form of start template (s-rail-start or s-start) is needed when the succession box is inside the service parameter of Infobox station. Template:S-rail is used to generate headings for each grouping of rail services in a box. Here we have only one, but some particularly large terminals may have three or four (see Union Station (Chicago) or 30th Street Station). S-rail uses the translation table at Template:S-rail/lines; if the entry is undefined, it simply links the text. Therefore, Amtrak produces Amtrak, while LUL gives London Underground.

You can see that S-line takes only parameters – no linking necessary! S-line accomplishes this through two assumptions: (1) groups of articles on train stations are named in a predictable manner; (2) redirects are cheap. For S-line to produce the table above five separate templates were defined. Before discussing them, however, let's review the parameters:
 * SYSTEM: The company or grouping to which the line belongs. This is case-sensitive and must be consistent. In this case, the value is Amtrak.
 * LINE: The line name. This is also case-sensitive and must be consistent throughout. Here, we're describing the Wolverine.
 * PREVIOUS and NEXT: The names of the previous and next stations on the line. Current convention suggests West/East Left/Right, followed by North/South, but your mileage may vary. Whenever possible, succession boxes should make geographic sense (i.e. don't have one line running west-east and the other east-west).

You need templates to define the following things: the formatting/linking of the line, the formatting/linking of the previous and next stations, the display of the line's colour, and the display of the appropriate termini – all automatic.

Line
Template: lines (Template:Amtrak lines)

This template carries a translation table for the formatting/linking of the line. The template receives one parameter, from S-line. With systems that have unusual or non-uniform naming, like Amtrak, it may be necessary to have a test case for every line. The relevant line from Template:Amtrak lines is this: | Wolverine=Wolverine This links to the article on the Wolverine and italicizes the article, appropriate for a named train. This means if the article ever moves, you need only to update switch statement, not individual articles. When a system has uniform naming, you may be able to get away with a default case and only one or two exceptions, as in Template:LUL lines:

Station
Template: stations (Template:Amtrak stations)

This template carries a translation table for the formatting/linking of the line. The template receives two parameters from S-line, and , although use of the latter is not often necessary. Station will be either the PREVIOUS or NEXT parameter; both are handled the same way behind the scenes. The easiest way to start the station template is with the default case that reflects how articles on system stations are named. With Amtrak, it's done this way: | #default= (Amtrak station) Therefore, "Dowagiac" produces Dowagiac, all linked and ready to go.

Colour
Template: color (Template:Amtrak color)

Note that colour is spelled the American way in the template; the creator apologizes in advance and it's probably not worth the hassle to change it at this stage. This template is designed the same way as the others except that a default case is rare--lines within a system tend to have a different colour. Amtrak is an important exception, and doesn't even have a switch statement: the template consists only of the hex code: 004670. The pound sign is included within s-line so it isn't necessary. This also forces the use of hex codes; no nouns are permitted (e.g. red, white). The template takes one parameter,. A good example is found here at Template:SEPTA color:

Termini
Template:S-line/ left/ (Template:S-line/Amtrak left/Wolverine) Template:S-line/ right/ (Template:S-line/Amtrak right/Wolverine) These are the all-important templates which produce the "towards..." part of the templates. They can also get pretty tricky depending on the setup. The Wolverine is an easy example. It runs end-to-end from Chicago, Illinois to Pontiac, Michigan. Therefore, the "left" (westbound) template contains "Chicago" while the "right" (eastbound) template contains "Pontiac". These names are plugged in to the STATION template just as NEXT and PREVIOUS were, with the results that you can see above. A feature of S-line is that if it detects that the next station is the name as the terminus, it will display a note to that effect instead of the destination. Hence,

produces:

Now, let's say we've got a more complicated example, like the Lake Shore Limited, which runs from Chicago east to either Boston or New York. The Limited's "left" template is still a simple line of text – Chicago – but the "right" template needs a switch statement. The left and right templates receive one parameter,, from s-line, which tells them which termini to return. Here's the Limited's "right" template:

This allows three eastbound destinations: New York, Boston, or both if the train hasn't reached the junction point yet. A default statement is acceptable here if it is true for disproportionate length of the line. In order to make this work properly, you have to define the concept of "New York or Boston South" in the STATION template, like so: | New York or Boston South=New York or Boston South Here's a hypothetical example of this at work:

produces

One-way operation
For rail lines that operate in only one direction (such as going around a loop), the oneway1 or oneway2 parameters are used, to indicate that the Previous or Next station, respectively, does not have service going towards it. When these parameters are present with any non-null value, the toward [Terminal] line is replaced with One-way operation. For example, for a CTA station in the Chicago Loop:

Produces the box:

Parallel lines
For lines that operate on the same tracks and serve the same next station and final terminal, the rows1, rows2, hide1, and hide2 optional parameters can be used to have the Previous (the 1s) or Next (the 2s) Station boxes cover more than one line. The rows parameters specify how many lines the station should cover, while the hide parameters ensure that the table formatting remains intact. The two parameters must be used together, with hide specified for every line that is being covered by the first line. An example of this use can be seen in the preceding CTA box. Note that, in the preceding CTA example, the previous and oneway1 parameters could have been omitted from the Purple and Pink line entries, but were left in for consistency's sake.

Another example of this:

Produces:

Transfers
The  parameter makes it possible to show within the box lines available at a different station with which there's a direct transfer from the current station. This snippet is taken from the article about the Finchley Road tube station. The North London Line does not actually serve the station itself, but there's an official out of system transfer designated between London Underground services at Finchley Road and London Overground services at the nearby Finchley Road & Frognal station:

Produces:

Branches
The  parameter can be used to describe a subset of a. In the example hereafter, the  parameter designates four different parts of the MBTA Green Line. When passed to the left and right termini templates, the  and   parameters identify destinations. Additionally, the branch name is displayed beneath the line name.

Optionally, Template: lines/branches may be defined, which allows the linking of the branch parameter.

In this example below, the branch template (Template:MBTA lines/branches) is defined, allowing branch linking. Additionally, left and right termini are returned based on the passed  parameter:

In this example hereafter, taken from the Acton Town tube station article, the branch template (Template:LUL lines/branches) is defined, allowing branch linking. Additionally, through the  parameter, the left and right hand terminis are generated. In some cases, a  parameter can be used to supplement the   parameter. If necessary, a  parameter can be used to substitute for a   parameter.

produces:

Styles
Template: style (Template:Amtrak style)

The style template allows the modification, at a system level, of display parameters for inter-related templates, including Template:Infobox Station.

TemplateData
{   "description": "S-line is a specialised succession box template that links railway station articles", "params": { "system": { "label": "system", "description": "The system to which the line belongs", "type": "string", "required": true },       "line": { "label": "line", "description": "The name of the line", "type": "string", "required": true },       "previous": { "label": "previous", "description": "The name of the previous station, should correspond to a specific template name", "type": "string", "required": true },       "next": { "label": "next", "description": "The name of the next station, should correspond to a specific template name", "type": "string", "required": true },       "type": { "label": "type", "description": "The left-hand line branch", "type": "string", "required": false },       "type2": { "label": "type2", "description": "The right-hand line branch", "type": "string", "required": false },       "note": { "label": "note", "description": "Information about the left-hand line branch", "type": "string", "required": false },       "notemid": { "label": "notemid", "description": "Information about the station itself", "type": "string", "required": false },       "note2": { "label": "note2", "description": "Information about the right-hand line branch", "type": "string", "required": false },       "oneway1": { "label": "oneway1", "description": "Indicates that trains do not operate towards the Previous station", "type": "string", "required": false },       "oneway2": { "label": "oneway2", "description": "Indicates that trains do not operate towards the Next station", "type": "string", "required": false },       "through1": { "label": "through1", "description": "Allows, instead of a previous station, service passing to another line on the system.", "type": "string", "required": false },       "through2": { "label": "through2", "description": "Allows, instead of a next station, service passing to another line on the system.", "type": "string", "required": false },       "state1": { "label": "state1", "description": "Allows the passing of an additional station parameter. Useful for disambiguation.", "type": "string", "required": false },       "state2": { "label": "state2", "description": "Allows the passing of an additional station parameter. Useful for disambiguation.", "type": "string", "required": false },       "branch": { "label": "branch", "description": "Can be used to describe a subset of a line.", "type": "string", "required": false },       "transfer": { "label": "transfer", "description": "Used to show lines available by direct transfer at an adjoining station. ", "type": "string", "required": false },       "round1": { "label": "round1", "description": "If set displays 'Reverses direction' in left cell", "type": "string", "required": false },       "round2": { "label": "round2", "description": "If set displays 'Reverses direction' in right cell", "type": "string", "required": false },       "circular": { "label": "circular", "description": "", "type": "string", "required": false },       "circular1": { "label": "circular1", "description": "", "type": "string", "required": false },       "circular2": { "label": "circular2", "description": "", "type": "string", "required": false },       "rows1": { "label": "rows1", "description": "Number of rows for left hand column", "type": "string", "required": false },       "rowsmid": { "label": "rowsmid", "description": "Number of rows for center hand column", "type": "string", "required": false },       "rows2": { "label": "rows2", "description": "Number of rows for right hand column", "type": "string", "required": false },       "hide1": { "label": "hide1", "description": "Hides the previous station, used when a previous row has 'rows1' set", "type": "string", "required": false },       "hidemid": { "label": "hidemid", "description": "Hides this station, used when a previous row has 'rowsmid' set", "type": "string", "required": false },       "hide2": { "label": "hide2", "description": "Hides the next station, used when a previous row has 'rows2' set", "type": "string", "required": false }   } }