From 6c9ad3f31da9cf490144179ce7593223c7f88f4d Mon Sep 17 00:00:00 2001 From: Thad Guidry Date: Thu, 5 Nov 2020 00:57:12 -0600 Subject: [PATCH] Improve documentation of reinterpret GREL function (#3315) * add clarity for reinterpret docs Helps fix #3292 * update reinterpret docs phrasing We agreed to use "encoding" to be friendly to user exposed messaging instead of "encoder" and "decoder" that is used internally. * fix serializeReinterpret() test json --- .../google/refine/expr/functions/strings/Reinterpret.java | 8 ++++---- .../refine/expr/functions/strings/ReinterpretTests.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main/src/com/google/refine/expr/functions/strings/Reinterpret.java b/main/src/com/google/refine/expr/functions/strings/Reinterpret.java index 9d7904bd0..c11cee24a 100644 --- a/main/src/com/google/refine/expr/functions/strings/Reinterpret.java +++ b/main/src/com/google/refine/expr/functions/strings/Reinterpret.java @@ -66,7 +66,7 @@ public class Reinterpret implements Function { return reinterpret(str, decoder, encoder); } } - return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 2 or 3 arguments"); + return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects String to reinterpret with a given target encoding and optional source encoding"); } private Object reinterpret(String str, String decoder, String encoder) { @@ -89,7 +89,7 @@ public class Reinterpret implements Function { result = new String(bytes, encoder); } } catch (UnsupportedEncodingException e) { - return new EvalError(ControlFunctionRegistry.getFunctionName(this) + ": encoding '" + encoder + "' is not available or recognized."); + return new EvalError(ControlFunctionRegistry.getFunctionName(this) + ": target encoding '" + encoder + "' is not available or recognized."); } return result; @@ -97,12 +97,12 @@ public class Reinterpret implements Function { @Override public String getDescription() { - return "Returns s reinterpreted thru the given encoder."; + return "Returns s reinterpreted using a target encoding and optional source encoding."; } @Override public String getParams() { - return "string s, string encoder"; + return "string s, string target encoding, string source encoding"; } @Override diff --git a/main/tests/server/src/com/google/refine/expr/functions/strings/ReinterpretTests.java b/main/tests/server/src/com/google/refine/expr/functions/strings/ReinterpretTests.java index e40107cb1..66ab267fe 100644 --- a/main/tests/server/src/com/google/refine/expr/functions/strings/ReinterpretTests.java +++ b/main/tests/server/src/com/google/refine/expr/functions/strings/ReinterpretTests.java @@ -33,7 +33,7 @@ import com.google.refine.util.TestUtils; public class ReinterpretTests { @Test public void serializeReinterpret() { - String json = "{\"description\":\"Returns s reinterpreted thru the given encoder.\",\"params\":\"string s, string encoder\",\"returns\":\"string\"}"; + String json = "{\"description\":\"Returns s reinterpreted using a target encoding and optional source encoding.\",\"params\":\"string s, string target encoding, string source encoding\",\"returns\":\"string\"}"; TestUtils.isSerializedTo(new Reinterpret(), json); } }