User:PerfektesChaos/js/jsonXMLutils
JavaScript gadget – several tools for JSON and XML template documentation.
Usage
editInclude the following lines into your common.js, global.js etc.:
mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/jsonXMLutils/r.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript",
"text/javascript" );
TemplateData
editGeneration from scratch
editAt every stage in template namespace there is a button offered to create a new TemplateData JSON structure:
- in edit mode on top of page, close to (disabled) MediaWiki button for TemplateData maintenance.
- in view mode at the end of the page, close to categories.
If clicked, a textarea field is opened. When in edit mode, the regular edit form is searched for template programming. If characteristical parameters like {{{1}}}
are detected, the field is intialised with a parameter list in alphabetical order.
The textarea can be filled interactively with any list of parameters, the significant part of a transclusion, a copy master, or simply a list with parameter names on single lines.
When happy, clicking the [submit] button creates a JSON pattern instead of the textarea, following the sequence in textarea.
Analyzing and pretty print
editExistence of a TemplateData definition is recognized and the current JSON code may be formatted in standard format. That can be copied back to the place of definition.
Also the data will be
- analyzed semantically, e.g. for invalid language codes or values of
type
– outdated values will be updated; - analyzed syntactically, e.g. for invalid JSON data types;
- analyzed structurally, e.g. for unknown (mistyped) names of TemplateData components;
The result, if any, is prepended as nonconformity report.
An empty schema is provided for recommended fields, if not yet present.
A button is offered
- in edit mode on top of page, close to MediaWiki button for TemplateData maintenance.
- in view mode at the end of the page, close to categories.
Retrieving XML pendant
editBased upon TemplateData information the corresponding XML can be generated and copied into target page.
A button is available close to the button for JSON pretty print.
Vorlagenmeister
editVorlagenmeister uses XML for description of template parameters, building interactive form for filling in current parameter data since 2007.
Page view
editXML code will be re-displayed with syntax highlighting on /XML
subpages.
Lines are expected to be in monospace formatting already, by indentation of at least one space.
Source code editing
editCodeEditor will be activated on /XML
subpages.
Other languages
editThis gadget is prepared for multilingual support.
- If you like a version in your own language, please forward translations to me:
- This documentation page.
- The
I18N.texts
mapping on top of source code. - Further ISO 639 language codes your translation might support.
Intermediately, programmers can override any I18N.texts
component by providing a respective component at:
mw.libs.jsonXMLutils = { config = { /* ... */ } };
Codes
editSource code |
|
ResourceLoader |
|
Namespaces |
|
mw.libs
|
jsonXMLutils
|