Jump to content

Wikipedia talk:TemplateData/Tutorial

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by PamD (talk | contribs) at 23:30, 19 July 2013 (Editor for TemplateData ?: tx). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

If there is a discrete set of valid values for a parameter, e.g. collapse="yes"/"no", where do we tell the user which choices they've got? The "string" doesn't give them many pointers. --99of9 (talk) 21:58, 28 June 2013 (UTC)[reply]

The description, ideally :). Okeyes (WMF) (talk) 22:29, 28 June 2013 (UTC)[reply]

"default" tag

I discovered that there is an additional tag, "default", that shows the default value for the template parameter. Example:

<templatedata>
{
        "description": "Description of the template",
        "params": {
                "1": {
                        "label": "Label of the parameter",
                        "description": "Description of the parameter",
                        "type": "string",
                        "required": true,
                        "default": "Default text of this parameter"
                     }
                }
}
</templatedata>

It is not mentioned in this tutorial, but it is listed in the TemplateData table that is produced. Are we supposed to be using it yet? The Anonymouse (talk) 13:58, 29 June 2013 (UTC)[reply]

Yeah, using it is fine - it's just not necessary, so I tried to strip the tutorial down to "things that are required", basically :). Okeyes (WMF) (talk) 15:08, 29 June 2013 (UTC)[reply]
OK, thanks! The Anonymouse (talk) 04:32, 30 June 2013 (UTC)[reply]

More useful debugging output needed

This system is really not usable without better debugging. I just spent over an hour creating 200 lines of TemplateData for Template:Infobox disease, and when I try to save it, all I get is "JSON syntax error". I'm not going to use this system until it does a better job of pinpointing errors, or at least giving some clue about the type of error. (If anybody is interested in trying to spot the syntax error, I saved my work as a comment in Template:Infobox disease/doc.) Looie496 (talk) 16:27, 1 July 2013 (UTC)[reply]

I agree we need better debugging commentary; actually, I'm unable to find a bug with that. @Adavidb:? Okeyes (WMF) (talk) 17:14, 1 July 2013 (UTC)[reply]
There was a double-quote symbol missing from the end of the "label" entry for the "eMedicineSubj" parameter. Such syntax errors are very difficult to catch with visual review alone. I commented out various parts of the code to narrow down where the error was. The corrected version remains commented, for any additional changes before activation. —ADavidB 18:05, 1 July 2013 (UTC)[reply]
Thanks. I've uncommented it and saved it -- appears to work. I still think I'm going to wait until there are more informative error messages before making further use of this system. Regards, Looie496 (talk) 18:26, 1 July 2013 (UTC)[reply]
Seems reasonable; I've added a bug for it. Okeyes (WMF) (talk) 18:42, 1 July 2013 (UTC)[reply]

I just discovered the existence of this after an IP editor added it to Template:Colon/doc. I have two observations: firstly, the displayed output needs to link to the TemplateData documentation (perhaps link "Template parameters"), otherwise it's virtually inexplicable - I had to perform a help namespace search to find it. Secondly, if empty it should either be hidden or a message along the lines of "this template does not take any parameters" should be shown. At present it just produces a clumsy-looking empty table, as in the example above.

This isn't meant to be negatively critical of the implementation, I know it's very early days yet. — Scott talk 12:07, 2 July 2013 (UTC)[reply]

Good points, both :). I'm not sure how we'd handle the first one - what do we do with localisation, for example? - but we can look into it. Okeyes (WMF) (talk) 12:58, 2 July 2013 (UTC)[reply]

Placement

The section Wikipedia:VisualEditor/TemplateData tutorial#TemplateData implies that it doesn't matter if <TemplateData>...</TemplateData> is added to the /doc page or to the main template page. I would suggest that the <TemplateData>...</TemplateData> should be placed on the /doc page wherever possible, since if it's put on the template, it'll add pages to the job queue unnecessarily (see bugzilla:50372 and WP:VPT#TemplateData: Is it working?). --Redrose64 (talk) 16:25, 3 July 2013 (UTC)[reply]

Fair point; I'll make sure it's tweaked when we update the documentation (being written now). Okeyes (WMF) (talk) 15:09, 5 July 2013 (UTC)[reply]

Parameters in example

The order of parameters in the "Str left"-example is reversed. In Templatedata (and the step by step instruction) "string" should come first, then "count". They are unnamed parameters, the current order won't work or would return wrong results. GermanJoe (talk) 14:43, 5 July 2013 (UTC)[reply]

Oh, darn :(. We're actually about to update the tutorial :). Okeyes (WMF) (talk) 15:09, 5 July 2013 (UTC)[reply]
Fixed the template Template:Str_left for now ;). GermanJoe (talk) 07:45, 9 July 2013 (UTC)[reply]
Thanks! :D. I need to start making a list of names (in a "free cookies" way, not in a PRISM way) Okeyes (WMF) (talk) 08:13, 9 July 2013 (UTC)[reply]

Editor for TemplateData ?

Hi, is there any editor tool for TemplateData on enwiki ? On frwiki, a user made a script which allows creating/updating the <templatedata>...</templatedata> visually and very easily. Anyone willing to make the same for enwiki ? --NicoV (Talk on frwiki) 08:42, 16 July 2013 (UTC)[reply]

Ooh. I'd love if someone could take and translate that. Okeyes (WMF) (talk) 13:35, 16 July 2013 (UTC)[reply]
I posted a request on Wikipedia:WikiProject User scripts/Requests. --NicoV (Talk on frwiki) 16:39, 16 July 2013 (UTC)[reply]
Editor available at User:NicoV/TemplateDataEditor.js. --NicoV (Talk on frwiki) 23:00, 19 July 2013 (UTC)[reply]
Yes, sounds really useful, but how do we use it? Could you give a non-techie "How to do it" guide, please? Thanks. PamD 23:08, 19 July 2013 (UTC)[reply]

Sure :

  • Edit Special:MyPage/vector.js. If you are using a different skin than the Vector skin (see Preferences / Appearance), you have to edit a page with a different name, depending on your skin
  • Add a line with the following text importScript('User:NicoV/TemplateDataEditor.js');
  • Save the page
  • Read the note at the top of the page explaining how to bypass your browser cache, and follow its instructions.

Then, when you edit a template (or rather its documentation page) :

  • You should see a "TemplateData" link on the left, in the "Toolbox" section
  • Check if the template page already contains a <templatedata>...</templatedata> tag
  • If not, add an empty one <templatedata />
  • Click on the "TemplateData" link
  • You should see a big window that's quite easy to use

--NicoV (Talk on frwiki) 23:16, 19 July 2013 (UTC)[reply]

Had a go - feedback

I've just tried adding TemplateData to {{EW charity}} on its /doc page - not one of the commonest templates, but one I know and understand as I wrote it. But I don't know whether I've done it right, and from the sound of it there's a 60-hour delay before I can look at its effect. Hmm, not ideal.

Comment on the tutorial: you don't explain what to do for an optional parameter (ie that "required" can be omitted, which seems to be the case, rather than needing to be set to "false"). I also wasn't very clear what I was supposed to be putting in the various fields - perhaps if I use more templates with templatedata it will start to make more sense.

I don't like being offered a choice without any indication which is preferred or why: please indicate the "best" or "standard" place to put the TemplateData (template page or /doc page) - and it might be helpful to standardise mildly on whether it goes at top or bottom of the /doc page, if that's the better page for it to be. Unnecessary choices are hard work: just tell us where to put the TemplateData.

In the list of heavily used templates, I noted that {{hatnote}} is marked up as "done". I wanted to have a look at the effects, as it's a template with no named parameters, just one locational parameter. Editing my sandbox I clicked to transclude "Hatnote"... and got no information about the parameters, just the usual "Add parameter" and "No unused parameters" - not what I expected. Looking at the history I see the TemplateData was added on 11 June, 6 days ago. Should something useful be displayed when I try to use the template? I'm struggling rather with all of this as yet. PamD 15:59, 17 July 2013 (UTC)[reply]

Having another look, I see that it seems to tell me I need to add "required" and set it to "false". Do I really? And I've realised that one reason the example is particularly confusing is that "string" is both a parameter name and a type! There might be a clearer example perhaps? PamD 16:05, 17 July 2013 (UTC)[reply]