Mooeypoo has uploaded a new change for review.
https://gerrit.wikimedia.org/r/194386
Change subject: Add an example property to parameters
......................................................................
Add an example property to parameters
The example is optional and can be translated.
Bug: T53049
Change-Id: I9e2d66a805e25409532a742521886233ce3de569
---
M Specification.md
M TemplateData.php
M TemplateDataBlob.php
M i18n/en.json
M i18n/qqq.json
M modules/ext.templateDataGenerator.data.js
6 files changed, 28 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TemplateData
refs/changes/86/194386/1
diff --git a/Specification.md b/Specification.md
index 7330233..8ed66c9 100644
--- a/Specification.md
+++ b/Specification.md
@@ -121,6 +121,11 @@
Consumers SHOULD provide this description to a the User when selecting and
altering parameter values.
+#### 3.2.2 `example`
+* Value: `null` or `InterfaceText`
+
+An example text for the parameter, to help users fill in the proper value.
+
#### 3.2.3 `required`
* Value: `boolean`
* Default: `false`
diff --git a/TemplateData.php b/TemplateData.php
index 8b361c2..be5f2d0 100644
--- a/TemplateData.php
+++ b/TemplateData.php
@@ -130,6 +130,7 @@
'templatedata-modal-table-param-default',
'templatedata-modal-table-param-deprecated',
'templatedata-modal-table-param-description',
+ 'templatedata-modal-table-param-example',
'templatedata-modal-table-param-importoption',
'templatedata-modal-table-param-importoption-subtitle',
'templatedata-modal-table-param-label',
diff --git a/TemplateDataBlob.php b/TemplateDataBlob.php
index 68cd1c2..523e19d 100644
--- a/TemplateDataBlob.php
+++ b/TemplateDataBlob.php
@@ -90,6 +90,7 @@
'required',
'suggested',
'description',
+ 'example',
'deprecated',
'aliases',
'autovalue',
@@ -232,6 +233,21 @@
$paramObj->description = null;
}
+ // Param.example
+ if ( isset( $paramObj->example ) ) {
+ if ( !is_object( $paramObj->example ) &&
!is_string( $paramObj->example ) ) {
+ // TODO: Also validate that the keys
are valid lang codes and the values strings.
+ return Status::newFatal(
+ 'templatedata-invalid-type',
+ "params.{$paramName}.example",
+ 'string|object'
+ );
+ }
+ $paramObj->example =
self::normaliseInterfaceText( $paramObj->example );
+ } else {
+ $paramObj->example = null;
+ }
+
// Param.deprecated
if ( isset( $paramObj->deprecated ) ) {
if ( !is_bool( $paramObj->deprecated ) &&
!is_string( $paramObj->deprecated ) ) {
diff --git a/i18n/en.json b/i18n/en.json
index 2cd1741..592e2af 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -63,6 +63,7 @@
"templatedata-modal-table-param-default": "Default",
"templatedata-modal-table-param-deprecated": "Deprecated",
"templatedata-modal-table-param-description": "Description ($1)",
+ "templatedata-modal-table-param-example": "Example ($1)",
"templatedata-modal-table-param-importoption": "Add $1 suggested
{{PLURAL:$1|parameter|parameters}}",
"templatedata-modal-table-param-importoption-subtitle": "Including: $1",
"templatedata-modal-table-param-label": "Label ($1)",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b57367b..73cbf97 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -70,6 +70,7 @@
"templatedata-modal-table-param-default": "Label for a parameter
property input: Default value of the parameter.\n{{Identical|Default}}",
"templatedata-modal-table-param-deprecated": "Label for a parameter
property input: Deprecated status of the parameter.\n{{Identical|Deprecated}}",
"templatedata-modal-table-param-description": "Label for a parameter
property input: Description of the parameter. $1 - currently showing
language.\n{{Identical|Description}}",
+ "templatedata-modal-table-param-example": "Label for a parameter
property input: Example value of the parameter. $1 - currently showing
language\n",
"templatedata-modal-table-param-importoption": "Label for the import
option in the parameter list in the edit dialog. $1 - number of suggested
parameters that can be imported.",
"templatedata-modal-table-param-importoption-subtitle": "A list of
suggested parameter names in the import option in the parameter list in the
edit dialog. $1 - list (or partial list) of suggested parameter names to
import.\n{{Identical|Including}}",
"templatedata-modal-table-param-label": "Label for a parameter property
input: Label of the parameter.\n\nSee
https://en.wikipedia.org/w/index.php?title=Template:Infobox_treaty/TemplateData&action=edit
for example. $1 - currently showing language.\n{{Identical|Label}}",
diff --git a/modules/ext.templateDataGenerator.data.js
b/modules/ext.templateDataGenerator.data.js
index 68c2277..811f18d 100644
--- a/modules/ext.templateDataGenerator.data.js
+++ b/modules/ext.templateDataGenerator.data.js
@@ -157,6 +157,10 @@
type: 'string',
allowLanguages: true
},
+ example: {
+ type: 'string',
+ allowLanguages: true
+ },
type: {
type: 'select',
children: [
--
To view, visit https://gerrit.wikimedia.org/r/194386
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e2d66a805e25409532a742521886233ce3de569
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TemplateData
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits