jenkins-bot has submitted this change and it was merged. Change subject: [BREAKING CHANGE] Change "default" property to InterfaceText ......................................................................
[BREAKING CHANGE] Change "default" property to InterfaceText Default should be InterfaceText and support languages. Bug: T54966 Change-Id: I7be3a8be72df3e5d80300bd72fcd7197e43155aa --- M Specification.md M TemplateDataBlob.php M i18n/en.json M i18n/qqq.json M modules/ext.templateDataGenerator.data.js M tests/TemplateDataBlobTest.php M tests/ext.templateData.tests.js 7 files changed, 80 insertions(+), 28 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/Specification.md b/Specification.md index 7330233..28842cd 100644 --- a/Specification.md +++ b/Specification.md @@ -180,7 +180,7 @@ Consumers MUST insert a parameter's autovalue by default if this parameter is used in a transclusion, and SHOULD indicate this value to the user and give them the opportunity to change the value. #### 3.2.10 `default` -* Value: `string` +* Value: `null` or `InterfaceText` The default value in wikitext (or description thereof) of a parameter as assumed by the template when the parameter is not present in a transclusion. diff --git a/TemplateDataBlob.php b/TemplateDataBlob.php index 68cd1c2..e737e79 100644 --- a/TemplateDataBlob.php +++ b/TemplateDataBlob.php @@ -275,15 +275,17 @@ // Param.default if ( isset( $paramObj->default ) ) { - if ( !is_string( $paramObj->default ) ) { + if ( !is_object( $paramObj->default ) && !is_string( $paramObj->default ) ) { + // TODO: Also validate that the keys are valid lang codes and the values strings. return Status::newFatal( 'templatedata-invalid-type', "params.{$paramName}.default", - 'string' + 'string|object' ); } + $paramObj->default = self::normaliseInterfaceText( $paramObj->default ); } else { - $paramObj->default = ''; + $paramObj->default = null; } // Param.type @@ -594,6 +596,11 @@ if ( $paramObj->description !== null ) { $paramObj->description = self::getInterfaceTextInLanguage( $paramObj->description, $langCode ); } + + // Param.default + if ( $paramObj->default !== null ) { + $paramObj->default = self::getInterfaceTextInLanguage( $paramObj->default, $langCode ); + } } foreach ( $data->sets as $setObj ) { @@ -753,10 +760,10 @@ // Default . Html::element( 'td', array( 'class' => array( - 'mw-templatedata-doc-muted' => $paramObj->default === '' + 'mw-templatedata-doc-muted' => $paramObj->default === null ) ), - $paramObj->default !== '' ? + $paramObj->default !== null ? $paramObj->default : wfMessage( 'templatedata-doc-param-default-empty' )->inLanguage( $lang )->text() ) diff --git a/i18n/en.json b/i18n/en.json index fdbdd17..8aaf763 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -63,7 +63,7 @@ "templatedata-modal-table-param-actions": "Actions", "templatedata-modal-table-param-aliases": "Aliases (comma separated)", "templatedata-modal-table-param-autovalue": "Auto value", - "templatedata-modal-table-param-default": "Default", + "templatedata-modal-table-param-default": "Default ($1)", "templatedata-modal-table-param-deprecated": "Deprecated", "templatedata-modal-table-param-deprecatedValue": "Deprecated guidance", "templatedata-modal-table-param-description": "Description ($1)", diff --git a/i18n/qqq.json b/i18n/qqq.json index 1771d98..7334134 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -70,7 +70,7 @@ "templatedata-modal-table-param-actions": "Label for a parameter property input: Parameter actions in the table\n{{Identical|Action}}", "templatedata-modal-table-param-aliases": "Label for a parameter property input: Aliases of the parameter, instruct the user to separate aliases with commas.", "templatedata-modal-table-param-autovalue": "Label for a parameter property input: Parameter auto value in the table", - "templatedata-modal-table-param-default": "Label for a parameter property input: Default value of the parameter.\n{{Identical|Default}}", + "templatedata-modal-table-param-default": "Label for a parameter property input: Default value of the parameter. $1 - currently showing language.\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-deprecatedValue": "Label for a parameter property input: Deprecated guidance of the parameter.", "templatedata-modal-table-param-description": "Label for a parameter property input: Description of the parameter. $1 - currently showing language.\n{{Identical|Description}}", diff --git a/modules/ext.templateDataGenerator.data.js b/modules/ext.templateDataGenerator.data.js index acc8541..0fee9b8 100644 --- a/modules/ext.templateDataGenerator.data.js +++ b/modules/ext.templateDataGenerator.data.js @@ -146,7 +146,8 @@ }, 'default': { type: 'string', - multiline: true + multiline: true, + allowLanguages: true }, autovalue: { type: 'string' diff --git a/tests/TemplateDataBlobTest.php b/tests/TemplateDataBlobTest.php index 8a1e8f3..a42afc6 100644 --- a/tests/TemplateDataBlobTest.php +++ b/tests/TemplateDataBlobTest.php @@ -92,7 +92,7 @@ "foo": { "label": null, "description": null, - "default": "", + "default": null, "required": false, "suggested": false, "deprecated": false, @@ -123,7 +123,7 @@ "comment": { "label": null, "description": null, - "default": "", + "default": null, "autovalue": null, "required": false, "suggested": false, @@ -166,7 +166,9 @@ "description": { "en": "User name of user who owns the badge" }, - "default": "Base page name of the host page", + "default": { + "en": "Base page name of the host page" + }, "required": false, "suggested": true, "deprecated": false, @@ -212,7 +214,9 @@ }, "required": true, "suggested": false, - "default": "example", + "default": { + "en": "example" + }, "deprecated": false, "aliases": [], "type": "unknown", @@ -225,7 +229,9 @@ }, "required": true, "suggested": false, - "default": "overridden", + "default": { + "en": "overridden" + }, "deprecated": false, "aliases": [], "type": "unknown", @@ -313,7 +319,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null }, @@ -324,7 +330,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null }, @@ -335,7 +341,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null } @@ -389,7 +395,9 @@ "description": { "en": "Bar description" }, - "default": "Baz", + "default": { + "en": "Baz" + }, "autovalue": "{{SomeTemplate}}", "required": true, "suggested": false, @@ -742,7 +750,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null } @@ -754,6 +762,41 @@ ', 'lang' => 'fr', 'msg' => 'Simple parameter label' + ), + array( + 'input' => '{ + "params": { + "foo": { + "default": { + "fr": "French", + "en": "English" + } + } + } + } + ', + 'output' => '{ + "description": null, + "params": { + "foo": { + "default": "French", + "required": false, + "suggested": false, + "description": null, + "deprecated": false, + "aliases": [], + "label": null, + "type": "unknown", + "autovalue": null + } + }, + "paramOrder": ["foo"], + "sets": [], + "maps" : {} + } + ', + 'lang' => 'fr', + 'msg' => 'Simple parameter default value' ), array( 'input' => '{ @@ -777,7 +820,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null } @@ -816,7 +859,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null } @@ -895,7 +938,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null }, @@ -906,7 +949,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null }, @@ -917,7 +960,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null } @@ -949,7 +992,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null }, @@ -960,7 +1003,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null }, @@ -971,7 +1014,7 @@ "description": null, "deprecated": false, "aliases": [], - "default": "", + "default": null, "type": "unknown", "autovalue": null } diff --git a/tests/ext.templateData.tests.js b/tests/ext.templateData.tests.js index 74e60c0..4cb687e 100644 --- a/tests/ext.templateData.tests.js +++ b/tests/ext.templateData.tests.js @@ -350,7 +350,8 @@ ], 'language': [ 'label', - 'description' + 'description', + 'default' ] } }; -- To view, visit https://gerrit.wikimedia.org/r/195451 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7be3a8be72df3e5d80300bd72fcd7197e43155aa Gerrit-PatchSet: 9 Gerrit-Project: mediawiki/extensions/TemplateData Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Mooeypoo <mor...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits