Template talk:Ship

Initial documentation
This template easily formats wikilinks to warship articles so as to synchronize Wikipedia's article titling policy with common body-text usage. It cuts the amount of piping to a minimum, inserts italics in the appropriate place, and (arguably) makes deciphering the markup somewhat easier.

To insert a wikilink to warship, insert the below string:  PREFIX name  For example, to create HMS Vanguard (which is automatically linked to HMS Vanguard (S28)), insert  HMS Vanguard  Or, to create USS Nimitz (linked to USS Nimitz (CVN-68)), insert  USS Nimitz 

The Tom 17:14, 25 August 2005 (UTC)

Main page usage
Shouldn't this template be protected, since it is transcluded onto the main page? A•N•N•A  foxlove r   hello!  20:42, 29 March 2007 (UTC)

Alternatives
You may want to use USS or HMS. They are a bit shorter to type, and now offer some (optional) flexibilty about what to display. USS Enterprise would be equal to USS Enterprise (CVN-65). It really gets shorter if you want to display the hull number, such as HMS Repulse (1916) from. HMS Repulse (1916) More reasoning on Template talk:USS. --J Clear 23:20, 22 April 2007 (UTC)

Apparently Meaningless Terminal 6
In the example USS Enterprise (CVN-65), the final '6' has meaning? If so, what?

Yours utterly baffled.--Toddy1 20:42, 27 September 2007 (UTC)


 * Option 6 looks like a feature used in HMS and USS, but not in this template. --Kralizec! (talk) 00:51, 28 September 2007 (UTC)

Feature request
The question above from got me thinking. Could someone with a better understanding of template parser functions add some of the functionality of HMS and USS into this template? Specifically I feel the following optional display control parameters would be very useful (note that #6 below works as the default on HMS/USS, while option #6 on HMS/USS works as the default on warship):

Thoughts? Suggestions? Volunteers? --Kralizec! (talk) 01:35, 28 September 2007 (UTC)

Transclusion cost/benefit?
I recently edited the Tribal class destroyer (1936) page to replace many confusing links to vessels with this template, however these were reverted shortly afterward and the editor pointed me toward the Wikipedia:Transclusion costs and benefits while noting on my talk page that this template is too taxing for server processing. Does anyone have any thoughts about this? I would argue that the benefits of standardizing and simplifying links to articles on vessels, not to mention the kilobytes saved, would trump any minuscule increase in server effort....Thanks! Plasma east 15:29, 16 November 2007 (UTC)


 * If I may make a suggestion ... bring this up at the WP:SHIPS talk page. That ways it will be seen by heaps more eyes!   --Kralizec! (talk) 15:38, 16 November 2007 (UTC)

Standardization
I've asked TomTheHand to modify this template's syntax to include the optional display parameters used in HMS, USS, and USNS. To bring this template in agreement with the others, after the change, the default output will display the prefix, name, and pennant/hull number. (This change of default output will not adversely affect existing articles, as the syntax of preexisting transclusions will be modified to produce the same output as before.) More important, of course, is that you'll be able to control display using parameters that are familiar from our other templates. Maralia (talk) 15:20, 17 December 2007 (UTC)


 * I posted the following to Maralia's talk, but figured I'd post it here too to get better exposure. Please give feedback!  Once we're all satisfied I'll copy it from my user space to here.

I've done a little work on the warship issue, but I've run into some problems. First, the good news:
 * I think this is more intuitive:
 * produces
 * It's less characters than '4=2' or 'disp=2' also. Maralia (talk) 06:07, 19 December 2007 (UTC)
 * Oooh... I didn't realize you could do that. Spiffy.  Ok, I'll copy the updated template from my user space tonight. TomTheHand (talk) 21:56, 19 December 2007 (UTC)

Change request for parameter audit
Request that the line

-->]]

be changed to read

-->]]

This modification would make no visible change to the template's operation, but helps generate a list of occurrences of HMCS undefined. Cheers. H aus Talk 19:12, 1 December 2008 (UTC)


 * Actually, please use this version of the sandbox template (less the sandbox notice). It incorporates Haus' request plus additional code for tracking the parameters USS, HMS, HMAS, and HMNZS. I have tested the code on the testcases page. This version also eliminates the text that displays on the template page that is now superfluous with the current template documentaion. — Bellhalla (talk) 20:34, 1 December 2008 (UTC)


 * Yes check.svg Done. --Kralizec! (talk) 22:46, 1 December 2008 (UTC)

Links for parameter audits
— Bellhalla (talk) 23:56, 1 December 2008 (UTC)
 * HMAS
 * HMCS
 * HMNZS
 * HMS
 * USS

Edit request
Please update the template to this version in the sandbox (less the sandbox template notice at the top). This eliminates the code snippet:



that was intended to track usage of this template with certain prefixes. Example: when USS is used as a prefix, the redlinked template is transcluded, which, in theory, allows one to determine usage (by looking at "What links here" for use ). Then the specific could be used instead of this, the more generic template. However, since and others of the same functionality already themselves call, the redlinked template is called for all uses of the prefix whether through  or  making it impossible to determine which template was invoked, and making this bit of code unnecessary and needlessly complicating many pages. — Bellhalla (talk) 17:35, 26 January 2009 (UTC)


 * Done, though if you look at the source code, does the sandbox notice need to be removed as well? Thanks, Woody (talk) 17:52, 26 January 2009 (UTC)


 * Yes, it should. :) — Bellhalla (talk) 17:58, 26 January 2009 (UTC)


 * Done, regards, Woody (talk) 18:18, 26 January 2009 (UTC)

Another edit request
Please replace this second line of the template code: This will add the capability for optional output with the ship prefix unlinked. This is useful for situations where the prefix is of the sort like "Japanese battleship". So if the desired output is: one will be able to type: rather than: The new optional parameter is a named (vs. numbered only) parameter and should not affect any uses of the template unless explicitly invoked. Thanks. — Bellhalla (talk) 17:46, 18 February 2009 (UTC)
 * Japanese battleship Yamato
 * ✅, regards, Woody (talk) 18:15, 18 February 2009 (UTC)
 * Wow. That was fast. Thanks, Woody. — Bellhalla (talk) 18:18, 18 February 2009 (UTC)

Ignore leading/trailing spaces in parameters
An editor recently accidentally put a space before the second parameter, as in. This resulted in an extra space being put between "battleship" and "Musashi." While I realize that the error is easily correctable, it would seem desirable to have the code self-correct such errors. Would it be possible for this template to ignore leading spaces in parameters? Mamyles (talk) 22:15, 5 March 2015 (UTC)

Module:WPSHIPS utilities
@DePiep: Sometime ago I wrote some Lua code in Module:WPSHIPS utilities:

it fixed the up bug:

and does a better job of error reporting than the current live version:

You might want to have a look and perhaps implement that module function. I think that all that it is missing is categorization.

—Trappist the monk (talk) 11:58, 28 February 2018 (UTC)
 * I see. I've noted (written down) several more quirks to look at. - DePiep (talk) 12:03, 28 February 2018 (UTC)
 * Thanks for pointing me to this. This is my opinion: sure the template should use this Lua module in the long run. However, as of today the module needs more development and full testing. But currently I don't have the time & resources to dive into this. I propose this:
 * 1. I finalize edits & tests in the /sandbox, then announce it (at this talkpage), to go live in a few days.
 * 2. Any time after this, someone can finalize and test the module code, then switch to Lua by proper process.
 * The point is, I am almost done editing & testing code, and using a refined parsing version does no harm. Especially not wrt switching over to the module any time later. -DePiep (talk) 10:54, 1 March 2018 (UTC)


 * FWIW: there are two types of template: ship including HMS shortcuts, and MV which has its own code (as have all the propulsion templates SV, SS, SV, SP, MY, MS). There is also the Sclass set. -DePiep (talk) 14:57, 2 March 2018 (UTC)

Sclass

 * Zumwalt-class destroyer does not use a template in its lede. -DePiep (talk) 23:50, 2 March 2018 (UTC)

Slashing MS into M/S
For the record. The module should notice (functional change).


 * I have turned into calling regular  code . As those other 50,  shortcuts do.


 * Next to I have created M/S. The slash alters the label (what shows), but not the target page. There are seven slashed prefix templates like this.

Before today, the slash was a extra numbered option in (8, 14). Now, even follows the 1–6 label options. And the tracking categories. No backlog usage existing (all previous usages of such 8 and 14 have been edited). -DePiep (talk) 22:20, 16 March 2018 (UTC)

Proposed template changes
I propose to make the following changes to Ship. See also the /testcases. Please don't feel intimidated by this brick of text ;-). Most of it is quite obvious, also I tried to demo it etcetera. Please comment below.

Useful links and language

 * See /testcases
 * Prefix shortcut templates: found ~50 ; WPSHIPS shortcut templates is incomplete and possibly outdated.
 * Tracking categories, new. (Both, while in test phase, are not used. They will be populated when this goes live -- for mainspace pages only) :
 * Wording:
 * page, label (targetpage and wikilabel): parts of the wikilink
 * 1: prefix ("HMS")
 * 2: name ship's name ("Invincible")
 * 3: disambiguator, like: hull number, year of launch, ... ("H75")
 * 4: format setting. Options: (blank), (omitted), 1, 2, 3, 4, 5, 6
 * 3: disambiguator, like: hull number, year of launch, ... ("H75")
 * 4: format setting. Options: (blank), (omitted), 1, 2, 3, 4, 5, 6

Content

 * C1 (format=4): When format 4: no error, no message, treat as default ((blank)). IOW: treat as regular option, no exception calling in /documentation. See demo.
 * C2 (format=5): When no name is used in the label, then don't add brackets to hull number (format code 1 vs 5).
 * Also: in these cases, show hull number (ID) in italics (See by Trappist the monk).
 * {|class=wikitable style="font-size:90%"

! id ! Template usage ! Current result ! Sandbox version
 * format=none (basic)
 * HMCS Kootenay
 * HMCS Kootenay (H75)
 * format=1 (italics)
 * HMCS Kootenay
 * H75
 * H75
 * format=5 (changes)
 * HMCS Kootenay
 * HMCS (H75)
 * HMCS&#32;H75
 * }
 * HMCS Kootenay
 * HMCS (H75)
 * HMCS&#32;H75
 * }


 * C3 (no subst): Remove option " "
 * 1. Many of the shortcuts do not apply it (do not pass through), so they fail to subst with ugly result.
 * 2. subst is counterproductive: we loose the tracking of that ship.


 * C4 (page parameter): Add new parameter page. It will overwrite as target page, label formatting unchanged. Allows to solve any link-vs-formatting issue, that is: formatting job still usable, without having to evade the template. IOW: another ship's name catched for tracking, instead of an editor going handcoding ;-)See demo. withdrawn, see s.


 * C5 (nolink): Not in sandbox, asking for opinions only: Add option "Do not wikilink, format as instructed" (new options 10, 11, 12, 13, 14, 15, 16). This invites the editor to use standard formatting throughout, and allows us to track more ships. Would yield "HMCS Kootenay (H75)": well-formatted, not linked, and tracked through . Opinions?


 * C6 (hull number missing): When 3 was required and missing, the message "Hull Number Missing" appeared in the article. This message is removed (and the page is categorised)


 * {|class=wikitable style="font-size:90%"

! Row id ! Template usage ! Live version ! Sandbox version
 * format=1
 * HMCS Kootenay
 * HMCS Kootenay
 * format=3
 * HMCS Kootenay
 * HMCS Kootenay
 * format=5
 * HMCS Kootenay
 * HMCS Kootenay
 * }
 * format=5
 * HMCS Kootenay
 * HMCS Kootenay
 * }
 * }
 * }


 * Please below

Maintenance

 * Use (new and dedicated)
 * Also lists warnings (that is: to be checked, not an error per se).
 * Warning/error types result in sort values (no name=N; foo=U, etc.).


 * No error message inline (see 4 change)
 * up: when yes, y, 1, true, prevent repeating the prefix (remove waring from documentation).
 * Track & edit ambiguous option foo


 * Tracked:
 * up Should be yes/y/1/true; no means no; +categorise when unclear like foo
 * 4 Was: "Invalid Optional Parameter" error message. Now: returns the default (&lt;blank>, and categorise
 * (omitted), (blank), 1,2,3,4,5,6, otherwise categorise
 * (missing): ship's name missing, categorise
 * (missing) AND 1,3,5: ship's (disambiguator) missing while explicitly asked for, categorise
 * (used) New parameter, track to check


 * Use (new and dedicated) (See tests)


 * Adjust documentation (and remove two elaborate distracting warnings).


 * Please below

Postponed
This is a first sweep of easy checks and changes, the low hanging fruit. In the near future, Module:WPSHIPS utilities could be finalised and used (see also above). It can introduce smarter checks. For example:
 * Error checking: returns redlink (expensive)?
 * Error checking: returns DAB page (expensive)?
 * Any true logic on missing parts (when is "HMS D123" identifying and so missing name is no error)?
 * Can hardcoded prefix variants, like MV, be brought under ?
 * Use more specific error categories


 * -DePiep (talk) 14:35, 1 March 2018 (UTC)

Comments
I have these thoughts and comments: I have these thoughts and comments: —Trappist the monk (talk) 18:34, 1 March 2018 (UTC)
 * 1) I have changed the pseudo heading 'Links and language' to an actual heading
 * 2) move to  so that WPSHIPS error categories are similarly named
 * 3) Good point about format control value ; WP:NCSHIPS says that ship names that consist of prefix and hull number italicize the hull number (as if the hull number were a 'name') so:
 * should render as:
 * HMCS&#32;H75
 * 1) I concur that this template should not be subst'd
 * 2) I'm not sure that I see much benefit in page. We have redirects that do the same thing in a standardized way.  I don't see a need to astonish readers when they land on HMS Belfast (C35) when they click HMCS Kootenay (H75).
 * 3) providing a way to render an unlinked output seems sensible; perhaps with the generically common no
 * 4) for the format control value, the template currently renders 'Invalid Optional Parameter' linked to the ship article; the text we not 'No hull number' as described in §Maintenance
 * 5) There being rather more page watchers at WT:SHIPS, you might consider posting a notice there.
 * 1) There being rather more page watchers at WT:SHIPS, you might consider posting a notice there.
 * At §Maintenance, this is wrong:
 * 4 Was: "No hull number" error message. Now: returns the default (&lt;blank>, and categorise
 * should read:
 * 4 Was: "Invalid Optional Parameter" error message. Now: returns the default (&lt;blank>, and categorise
 * —Trappist the monk (talk) 13:29, 2 March 2018 (UTC)

Please stop editing my posts. I have extracted your replies below. —Trappist the monk (talk) 15:01, 2 March 2018 (UTC)


 * Are you serious? How do you expect me reply to an 8-threaded post? You think readers/editors really gonna solve the puzzle which-reply-belongs-to-which-number? I say this: leave my replies alone, they are replies (not edits to your post). -DePiep (talk) 22:03, 2 March 2018 (UTC)


 * Below are my replies to the User:Trappist the monk post. Against Talkpage convention, Trappist the monk set them apart so they are made senseless this way. - DePiep (talk) 22:15, 2 March 2018 (UTC)


 * I took the pattern from, but I will change this if it is supported. -DePiep (talk) 14:37, 2 March 2018 (UTC)
 * Linking to Belfast is just an extreme example, incidentally HMCS Kootenay (H75) already links to a redirect (to another name). This parameter is useful when the article name does not follow the pattern, like Spray (sailing vessel). -DePiep (talk) 14:37, 2 March 2018 (UTC)
 * OK. This is for format 1 and 5 then? - DePiep (talk) 14:37, 2 March 2018 (UTC)
 * There may be cases where it is desirable to link just the hull/pennant number though I'm not sure what those cases might be. Regardless, I don't think that   should render a stand-alone hull/pennant number in italics.  My comment above was only for   which should comply with WP:NCSHIPS.
 * —Trappist the monk (talk) 15:32, 2 March 2018 (UTC)
 * Will add that one. Using the same parameter looks easier when copy/pasting the code. - DePiep (talk) 14:37, 2 March 2018 (UTC)
 * Then, perhaps instead of format codes –, prefix (or suffix) the code with a hyphen:
 * renders as:
 * HMCS&#32;H75
 * But, neither of these 'solutions' will work for the default no-format-code condition which then suggests that no is the correct parameter.
 * —Trappist the monk (talk) 15:32, 2 March 2018 (UTC)
 * OK. Changed. -DePiep (talk) 14:24, 2 March 2018 (UTC)
 * But, neither of these 'solutions' will work for the default no-format-code condition which then suggests that no is the correct parameter.
 * —Trappist the monk (talk) 15:32, 2 March 2018 (UTC)
 * OK. Changed. -DePiep (talk) 14:24, 2 March 2018 (UTC)


 * I have withdrawn the proposal to "add page" that would allow linking to a non-systematic ship's article title. It appears that using 3 (hull number, aka disambiguation term) nicely covers wikipage DAB pagenaming, while option format=2 can show the clean label form. I understand that is no need or possibility for this form: article title has no -DAB needed, but label wants to show the hull number? Like:  ❌. - DePiep (talk) 14:19, 6 March 2018 (UTC)

Result

 * -- ready to go live. Todo: adjust documentation. - DePiep (talk) 01:23, 9 March 2018 (UTC)


 * ✅. Could use a red error warning in . - DePiep (talk) 16:37, 10 March 2018 (UTC)


 * Warning in Preview: added. - DePiep (talk) 18:37, 16 March 2018 (UTC)

Created: tempaltes that add a slash: M/S
I have created a set like M/S next to existing MS. shows a slashed prefix (the target page stays unslashed).

Before, this could be done by using format code 8 or 14 in. Now, both templates use the standard set of format options (numbers 1–6).


 * use MS: MS Antenor (1957)
 * use M/S: M/S Antenor (1957) (Target page unslashed: [[MS Antenor (1957)]])
 * When the target pagename has a "/" slash, use Ship:
 * Target: [[S/Y Manitou]]
 * Use:  &rarr; S/Y Manitou

The template pairs are:
 * MV, MS MY RV SV SY
 * M/V, M/S M/Y R/V S/V S/Y

- DePiep (talk) 18:29, 16 March 2018 (UTC)

Unlink option?
Is there an unlink option? This would be useful where the name is to appear in section headings. In many cases, the name is then repeated in the following body text and the normal use of the template, and link, occurs there. Having an unlink option would allow both appearances to be made with (almost) the same wikitext, unlike at present where one is hand-coded and formatted. Andy Dingley (talk) 11:35, 29 July 2018 (UTC) PAGE ]]) 13:40, 30 July 2018 (UTC) PAGE ]]) 14:18, 30 July 2018 (UTC) PAGE ]]) 14:22, 30 July 2018 (UTC) PAGE ]]) 15:47, 30 July 2018 (UTC)
 * prepared in sandbox: no &rarr; unlinked & same format. See /testcases and /testcases2. OK?
 * Asking to add safesubst to the sandbox (Yesno is added in two places).
 * When live & stable in Ship, the prefix shortcuts like can get the pass-through for wl (see HMS/sandbox). - DePiep (talk) 13:25, 30 July 2018 (UTC)
 * Yes check.svg Done --Ahecht ([[User talk:Ahecht|TALK
 * This template must always be substed when used in section headings because links from watchlists and article histories to section headings that contain templates do not work.
 * —Trappist the monk (talk) 13:50, 30 July 2018 (UTC)
 * OK. no can also be used in inline, when a ship's name is repeatedly used. - DePiep (talk) 14:08, 30 July 2018 (UTC)
 * Is safesubst working correct now? I have added some code (in the sandbox),  (twice). If I understand   well, these  additions need some   code too. I refer to your edit . - DePiep (talk) 14:08, 30 July 2018 (UTC)
 * Square bracket open, Square bracket close, and main other aren't substable, so I didn't bother fixing it. One of the dependent templates isn't substable. I will work on it a bit and see if I can figure it out. --Ahecht ([[User talk:Ahecht|TALK
 * I got it mostly working, but main other will still show up when substed. --Ahecht ([[User talk:Ahecht|TALK
 * I did one final update, and it should subst cleanly now. Let me know if you see any other issues. --Ahecht ([[User talk:Ahecht|TALK
 * Thanks for cleaning this up. - DePiep (talk) 10:38, 31 July 2018 (UTC)

Template making all subsequent text small
All pages invoking this template appear to be causing the rest of the text on the page to appear as small. Look on any page (including this talk page) to see that all of the text that follows an invocation of the template becomes small. I doubt this behavior is intended; any chance it can be fixed? Sheahunter1 (talk) 04:56, 18 August 2018 (UTC)
 * Try purging your browser and see if that helps. I had the same problem, and it seems to have solved the issue for me. See Purge for more information. However, I don't know if purging is a permanent solution or not. - BilCat (talk) 05:33, 18 August 2018 (UTC)


 * The problem has been resolved. It appears to be an issue with the "Close Square Bracket" template (https://en.wikipedia.org/w/index.php?title=Template:Square_bracket_close&diff=855421939&oldid=855419715). 2601:601:1001:E120:4C16:D71C:9F09:C2DB (talk) 06:16, 18 August 2018 (UTC)
 * Red information icon with gradient background.svg Not done: No changes necessary. Enterprisey (talk!) 07:53, 18 August 2018 (UTC)

Template-protected edit request on 2 August 2019
Please amend the template to nowrap the ID parameter in the link text output. This is particularly necessary for hull numbers of American ships, in cases such as, in which a line break may be unsuitably placed immediately before "731". &mdash;  RAVEN PVFF  &middot; talk &middot; 15:36, 2 August 2019 (UTC)
 * ✅ — JFG talk 16:47, 9 August 2019 (UTC)

Redirects to sections
If an invocation of ship results in a redirect which redirects to a section of an article, then clicking the link takes the reader to the top of the article, not the specified section. For example: DH85868993 (talk) 03:26, 24 June 2024 (UTC)
 * ISS Enterprise (NCC-1701) is a redirect to Starship Enterprise.
 * But if you click the link produced by ISS Enterprise (= ISS Enterprise), it takes you to the top of Starship Enterprise, not the nominated section. Can this be remedied?
 * ✅ (by ) DH85868993 (talk) 13:58, 24 June 2024 (UTC)