From 43dd734e81dc85b1003cf743c3a7761b375443b1 Mon Sep 17 00:00:00 2001 From: Gabor Boros Date: Sun, 8 May 2022 09:51:22 +0200 Subject: [PATCH 1/4] docs: add fmt command Signed-off-by: Gabor Boros --- _jekyll/_data/api_java.yml | 2 ++ _jekyll/_data/api_javascript.yml | 2 ++ _jekyll/_data/api_python.yml | 2 ++ _jekyll/_data/api_ruby.yml | 2 ++ api/java/index.md | 22 ++++++++++++ api/java/string-manipulation/downcase.md | 1 + api/java/string-manipulation/fmt.md | 35 ++++++++++++++++++ api/java/string-manipulation/match.md | 1 + api/java/string-manipulation/split.md | 1 + api/java/string-manipulation/upcase.md | 1 + api/javascript/index.md | 22 ++++++++++++ .../string-manipulation/downcase.md | 1 + api/javascript/string-manipulation/fmt.md | 36 +++++++++++++++++++ api/javascript/string-manipulation/match.md | 1 + api/javascript/string-manipulation/split.md | 1 + api/javascript/string-manipulation/upcase.md | 1 + api/python/index.md | 19 ++++++++++ api/python/string-manipulation/downcase.md | 1 + api/python/string-manipulation/fmt.md | 36 +++++++++++++++++++ api/python/string-manipulation/match.md | 1 + api/python/string-manipulation/split.md | 1 + api/python/string-manipulation/upcase.md | 1 + api/ruby/index.md | 17 +++++++++ api/ruby/string-manipulation/downcase.md | 1 + api/ruby/string-manipulation/fmt.md | 36 +++++++++++++++++++ api/ruby/string-manipulation/match.md | 1 + api/ruby/string-manipulation/split.md | 1 + api/ruby/string-manipulation/upcase.md | 1 + 28 files changed, 247 insertions(+) create mode 100644 api/java/string-manipulation/fmt.md create mode 100644 api/javascript/string-manipulation/fmt.md create mode 100644 api/python/string-manipulation/fmt.md create mode 100644 api/ruby/string-manipulation/fmt.md diff --git a/_jekyll/_data/api_java.yml b/_jekyll/_data/api_java.yml index 9c23dba89..3d337dd14 100644 --- a/_jekyll/_data/api_java.yml +++ b/_jekyll/_data/api_java.yml @@ -219,6 +219,8 @@ permalink: upcase - name: downcase permalink: downcase + - name: fmt + permalink: fmt - section: name: Math and logic commands: diff --git a/_jekyll/_data/api_javascript.yml b/_jekyll/_data/api_javascript.yml index 20765c0cd..792ba81b0 100644 --- a/_jekyll/_data/api_javascript.yml +++ b/_jekyll/_data/api_javascript.yml @@ -219,6 +219,8 @@ permalink: upcase - name: downcase permalink: downcase + - name: fmt + permalink: fmt - section: name: Math and logic commands: diff --git a/_jekyll/_data/api_python.yml b/_jekyll/_data/api_python.yml index 1c97924ac..04c8c7b48 100644 --- a/_jekyll/_data/api_python.yml +++ b/_jekyll/_data/api_python.yml @@ -217,6 +217,8 @@ permalink: upcase - name: downcase permalink: downcase + - name: fmt + permalink: fmt - section: name: Math and logic commands: diff --git a/_jekyll/_data/api_ruby.yml b/_jekyll/_data/api_ruby.yml index cc95c6480..a4a224d92 100644 --- a/_jekyll/_data/api_ruby.yml +++ b/_jekyll/_data/api_ruby.yml @@ -215,6 +215,8 @@ permalink: upcase - name: downcase permalink: downcase + - name: fmt + permalink: fmt - section: name: Math and logic commands: diff --git a/api/java/index.md b/api/java/index.md index ed5089274..6c7f90d9e 100644 --- a/api/java/index.md +++ b/api/java/index.md @@ -1932,6 +1932,28 @@ Result: [Read more about this command →](split/) +## [fmt](fmt/) ## + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```js +r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback) +``` + +Result: + +```js +"Bob loves candy floss." +``` + +[Read more about this command →](fmt/) + ## [upcase](upcase/) ## {% apibody %} diff --git a/api/java/string-manipulation/downcase.md b/api/java/string-manipulation/downcase.md index 94f535720..65a15ae4c 100644 --- a/api/java/string-manipulation/downcase.md +++ b/api/java/string-manipulation/downcase.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/java/string-manipulation/fmt.md b/api/java/string-manipulation/fmt.md new file mode 100644 index 000000000..2030b7d6f --- /dev/null +++ b/api/java/string-manipulation/fmt.md @@ -0,0 +1,35 @@ +--- +layout: api-command +language: Java +permalink: api/java/fmt/ +command: fmt +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +# Description # + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```java +r.fmt("{name} loves {candy}.", + r.hashMap("name", "Bob").with("candy", "candy floss") +).run(conn, callback) +``` + +Result: + +```java +"Bob loves candy floss." +``` diff --git a/api/java/string-manipulation/match.md b/api/java/string-manipulation/match.md index 19f0bc1dd..8ba6bd727 100644 --- a/api/java/string-manipulation/match.md +++ b/api/java/string-manipulation/match.md @@ -10,6 +10,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/java/string-manipulation/split.md b/api/java/string-manipulation/split.md index eeedc6146..483e48ef8 100644 --- a/api/java/string-manipulation/split.md +++ b/api/java/string-manipulation/split.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ + fmt: fmt/ --- # Command syntax # diff --git a/api/java/string-manipulation/upcase.md b/api/java/string-manipulation/upcase.md index 51ad851e9..72b0f6a2a 100644 --- a/api/java/string-manipulation/upcase.md +++ b/api/java/string-manipulation/upcase.md @@ -7,6 +7,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/javascript/index.md b/api/javascript/index.md index 3dc424e59..1d2737ff7 100644 --- a/api/javascript/index.md +++ b/api/javascript/index.md @@ -2009,6 +2009,28 @@ Result: [Read more about this command →](split/) +## [fmt](fmt/) ## + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```js +r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback) +``` + +Result: + +```js +"Bob loves candy floss." +``` + +[Read more about this command →](fmt/) + ## [upcase](upcase/) ## {% apibody %} diff --git a/api/javascript/string-manipulation/downcase.md b/api/javascript/string-manipulation/downcase.md index 89296144e..0900ce66b 100644 --- a/api/javascript/string-manipulation/downcase.md +++ b/api/javascript/string-manipulation/downcase.md @@ -10,6 +10,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/javascript/string-manipulation/fmt.md b/api/javascript/string-manipulation/fmt.md new file mode 100644 index 000000000..dcdbfff46 --- /dev/null +++ b/api/javascript/string-manipulation/fmt.md @@ -0,0 +1,36 @@ +--- +layout: api-command +language: JavaScript +permalink: api/javascript/fmt/ +command: fmt +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +# Description # + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```js +r.fmt("{name} loves {candy}.", { + "name": "Bob", + "candy": "candy floss", +}).run(conn, callback) +``` + +Result: + +```js +"Bob loves candy floss." +``` diff --git a/api/javascript/string-manipulation/match.md b/api/javascript/string-manipulation/match.md index b9e141cb4..2199725d0 100644 --- a/api/javascript/string-manipulation/match.md +++ b/api/javascript/string-manipulation/match.md @@ -10,6 +10,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/javascript/string-manipulation/split.md b/api/javascript/string-manipulation/split.md index c70be4828..578e6b49e 100644 --- a/api/javascript/string-manipulation/split.md +++ b/api/javascript/string-manipulation/split.md @@ -10,6 +10,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ + fmt: fmt/ --- # Command syntax # diff --git a/api/javascript/string-manipulation/upcase.md b/api/javascript/string-manipulation/upcase.md index 789fcc5d4..8667e2311 100644 --- a/api/javascript/string-manipulation/upcase.md +++ b/api/javascript/string-manipulation/upcase.md @@ -10,6 +10,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/python/index.md b/api/python/index.md index 034b25c04..c08b1b3a7 100644 --- a/api/python/index.md +++ b/api/python/index.md @@ -1899,6 +1899,25 @@ __Example:__ Split on whitespace. [Read more about this command →](split/) +## [fmt](fmt/) ## + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```py +r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback) +"Bob loves candy floss." +``` + +[Read more about this command →](fmt/) + +## [upcase](upcase/) ## + ## [upcase](upcase/) ## {% apibody %} diff --git a/api/python/string-manipulation/downcase.md b/api/python/string-manipulation/downcase.md index c05e7df3c..350c0c4dd 100644 --- a/api/python/string-manipulation/downcase.md +++ b/api/python/string-manipulation/downcase.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/python/string-manipulation/fmt.md b/api/python/string-manipulation/fmt.md new file mode 100644 index 000000000..7b2d86de7 --- /dev/null +++ b/api/python/string-manipulation/fmt.md @@ -0,0 +1,36 @@ +--- +layout: api-command +language: Python +permalink: api/python/fmt/ +command: fmt +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +# Description # + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```py +r.fmt("{name} loves {candy}.", { + "name": "Bob", + "candy": "candy floss", +}).run(conn, callback) +``` + +Result: + +```py +"Bob loves candy floss." +``` diff --git a/api/python/string-manipulation/match.md b/api/python/string-manipulation/match.md index 0daed787b..512997362 100644 --- a/api/python/string-manipulation/match.md +++ b/api/python/string-manipulation/match.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/python/string-manipulation/split.md b/api/python/string-manipulation/split.md index dff7849b7..4a51aa2ec 100644 --- a/api/python/string-manipulation/split.md +++ b/api/python/string-manipulation/split.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ + fmt: fmt/ --- # Command syntax # diff --git a/api/python/string-manipulation/upcase.md b/api/python/string-manipulation/upcase.md index bea86c6cf..93c2ca2cb 100644 --- a/api/python/string-manipulation/upcase.md +++ b/api/python/string-manipulation/upcase.md @@ -7,6 +7,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/ruby/index.md b/api/ruby/index.md index 9db3c53ab..ecb68e531 100644 --- a/api/ruby/index.md +++ b/api/ruby/index.md @@ -1877,6 +1877,23 @@ __Example:__ Split on whitespace. [Read more about this command →](split/) +## [fmt](fmt/) ## + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```rb +r.fmt("{name} loves {candy}.", {"name" => "Bob", "candy" => "candy floss"}).run(conn, callback) +"Bob loves candy floss." +``` + +[Read more about this command →](fmt/) + ## [upcase](upcase/) ## {% apibody %} diff --git a/api/ruby/string-manipulation/downcase.md b/api/ruby/string-manipulation/downcase.md index 015228f12..07ea7960e 100644 --- a/api/ruby/string-manipulation/downcase.md +++ b/api/ruby/string-manipulation/downcase.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/ruby/string-manipulation/fmt.md b/api/ruby/string-manipulation/fmt.md new file mode 100644 index 000000000..8791f59e1 --- /dev/null +++ b/api/ruby/string-manipulation/fmt.md @@ -0,0 +1,36 @@ +--- +layout: api-command +language: Ruby +permalink: api/ruby/fmt/ +command: fmt +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.fmt(string, object) → string +{% endapibody %} + +# Description # + +Formats a template string based on a string-string key-value object. + +__Example:__ + +```rb +r.fmt("{name} loves {candy}.", { + "name" => "Bob", + "candy" => "candy floss", +}).run(conn, callback) +``` + +Result: + +```rb +"Bob loves candy floss." +``` diff --git a/api/ruby/string-manipulation/match.md b/api/ruby/string-manipulation/match.md index d2a8d18a1..d33b3198a 100644 --- a/api/ruby/string-manipulation/match.md +++ b/api/ruby/string-manipulation/match.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ + fmt: fmt/ --- # Command syntax # diff --git a/api/ruby/string-manipulation/split.md b/api/ruby/string-manipulation/split.md index da2ac201e..1486a6c2e 100644 --- a/api/ruby/string-manipulation/split.md +++ b/api/ruby/string-manipulation/split.md @@ -7,6 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ + fmt: fmt/ --- # Command syntax # diff --git a/api/ruby/string-manipulation/upcase.md b/api/ruby/string-manipulation/upcase.md index dc3b83e6f..11b764443 100644 --- a/api/ruby/string-manipulation/upcase.md +++ b/api/ruby/string-manipulation/upcase.md @@ -7,6 +7,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ + fmt: fmt/ --- # Command syntax # From 2e1074a16e7da99fd8cdc3c254e3eec3f111826b Mon Sep 17 00:00:00 2001 From: Gabor Boros Date: Sun, 8 May 2022 09:51:48 +0200 Subject: [PATCH 2/4] fix: update dataexplorer to work with py3 Signed-off-by: Gabor Boros --- _scripts/dataexplorer.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/_scripts/dataexplorer.py b/_scripts/dataexplorer.py index 03942fdce..933eef3f8 100644 --- a/_scripts/dataexplorer.py +++ b/_scripts/dataexplorer.py @@ -1,10 +1,9 @@ +import codecs +import json +import os import re import markdown -import os -import sys import yaml -import json -import codecs IGNORED_FILES = ["index.md", "accessing-rql/event_emitter.md"] @@ -118,7 +117,7 @@ def add_io_field(file_name, result): if is_yaml == True: yaml_raw += line - yaml_data = yaml.load(yaml_raw) + yaml_data = yaml.load(yaml_raw, Loader=yaml.Loader) if "io" in yaml_data: result[yaml_data["permalink"]]["io"] = yaml_data["io"] else: @@ -131,7 +130,7 @@ def browse_files(base, result): for path, dirs, files in os.walk(base): rel = path[len(base)+1:] for item in files: - print os.path.join(rel, item) + print(os.path.join(rel, item)) if os.path.join(rel, item) not in IGNORED_FILES: add_io_field(os.path.join(path, item), result) From b0a8594f1529ad4db396885dc8d4bb303db8435a Mon Sep 17 00:00:00 2001 From: Gabor Boros Date: Sun, 8 May 2022 09:57:33 +0200 Subject: [PATCH 3/4] docs: add io to fmt.md Signed-off-by: Gabor Boros --- api/java/string-manipulation/fmt.md | 3 +++ api/javascript/string-manipulation/fmt.md | 3 +++ api/python/string-manipulation/fmt.md | 3 +++ api/ruby/string-manipulation/fmt.md | 3 +++ 4 files changed, 12 insertions(+) diff --git a/api/java/string-manipulation/fmt.md b/api/java/string-manipulation/fmt.md index 2030b7d6f..99a763bb1 100644 --- a/api/java/string-manipulation/fmt.md +++ b/api/java/string-manipulation/fmt.md @@ -3,6 +3,9 @@ layout: api-command language: Java permalink: api/java/fmt/ command: fmt +io: + - - r + - string related_commands: match: match/ split: split/ diff --git a/api/javascript/string-manipulation/fmt.md b/api/javascript/string-manipulation/fmt.md index dcdbfff46..9bf27f434 100644 --- a/api/javascript/string-manipulation/fmt.md +++ b/api/javascript/string-manipulation/fmt.md @@ -3,6 +3,9 @@ layout: api-command language: JavaScript permalink: api/javascript/fmt/ command: fmt +io: + - - r + - string related_commands: match: match/ split: split/ diff --git a/api/python/string-manipulation/fmt.md b/api/python/string-manipulation/fmt.md index 7b2d86de7..d6c55c569 100644 --- a/api/python/string-manipulation/fmt.md +++ b/api/python/string-manipulation/fmt.md @@ -3,6 +3,9 @@ layout: api-command language: Python permalink: api/python/fmt/ command: fmt +io: + - - r + - string related_commands: match: match/ split: split/ diff --git a/api/ruby/string-manipulation/fmt.md b/api/ruby/string-manipulation/fmt.md index 8791f59e1..a709f97ae 100644 --- a/api/ruby/string-manipulation/fmt.md +++ b/api/ruby/string-manipulation/fmt.md @@ -3,6 +3,9 @@ layout: api-command language: Ruby permalink: api/ruby/fmt/ command: fmt +io: + - - r + - string related_commands: match: match/ split: split/ From a379d4de26b390ba6546ff8557a5c96145e8f3ac Mon Sep 17 00:00:00 2001 From: Gabor Boros Date: Sun, 15 May 2022 15:58:11 +0200 Subject: [PATCH 4/4] docs: update format docs Signed-off-by: Gabor Boros --- _jekyll/_data/api_java.yml | 4 +- _jekyll/_data/api_javascript.yml | 4 +- _jekyll/_data/api_python.yml | 4 +- _jekyll/_data/api_ruby.yml | 4 +- api/java/index.md | 34 +++++++++--- api/java/string-manipulation/downcase.md | 2 +- api/java/string-manipulation/fmt.md | 38 ------------- api/java/string-manipulation/format.md | 54 ++++++++++++++++++ api/java/string-manipulation/match.md | 2 +- api/java/string-manipulation/split.md | 2 +- api/java/string-manipulation/upcase.md | 2 +- api/javascript/index.md | 31 +++++++++-- .../string-manipulation/downcase.md | 2 +- api/javascript/string-manipulation/fmt.md | 39 ------------- api/javascript/string-manipulation/format.md | 55 +++++++++++++++++++ api/javascript/string-manipulation/match.md | 2 +- api/javascript/string-manipulation/split.md | 2 +- api/javascript/string-manipulation/upcase.md | 2 +- api/python/index.md | 36 ++++++++++-- api/python/string-manipulation/downcase.md | 2 +- api/python/string-manipulation/fmt.md | 39 ------------- api/python/string-manipulation/format.md | 55 +++++++++++++++++++ api/python/string-manipulation/match.md | 2 +- api/python/string-manipulation/split.md | 2 +- api/python/string-manipulation/upcase.md | 2 +- api/ruby/index.md | 36 ++++++++++-- api/ruby/string-manipulation/downcase.md | 2 +- api/ruby/string-manipulation/fmt.md | 39 ------------- api/ruby/string-manipulation/format.md | 55 +++++++++++++++++++ api/ruby/string-manipulation/match.md | 2 +- api/ruby/string-manipulation/split.md | 2 +- api/ruby/string-manipulation/upcase.md | 2 +- 32 files changed, 354 insertions(+), 205 deletions(-) delete mode 100644 api/java/string-manipulation/fmt.md create mode 100644 api/java/string-manipulation/format.md delete mode 100644 api/javascript/string-manipulation/fmt.md create mode 100644 api/javascript/string-manipulation/format.md delete mode 100644 api/python/string-manipulation/fmt.md create mode 100644 api/python/string-manipulation/format.md delete mode 100644 api/ruby/string-manipulation/fmt.md create mode 100644 api/ruby/string-manipulation/format.md diff --git a/_jekyll/_data/api_java.yml b/_jekyll/_data/api_java.yml index 3d337dd14..9af2a7df6 100644 --- a/_jekyll/_data/api_java.yml +++ b/_jekyll/_data/api_java.yml @@ -219,8 +219,8 @@ permalink: upcase - name: downcase permalink: downcase - - name: fmt - permalink: fmt + - name: format + permalink: format - section: name: Math and logic commands: diff --git a/_jekyll/_data/api_javascript.yml b/_jekyll/_data/api_javascript.yml index 792ba81b0..c3f78b5b8 100644 --- a/_jekyll/_data/api_javascript.yml +++ b/_jekyll/_data/api_javascript.yml @@ -219,8 +219,8 @@ permalink: upcase - name: downcase permalink: downcase - - name: fmt - permalink: fmt + - name: format + permalink: format - section: name: Math and logic commands: diff --git a/_jekyll/_data/api_python.yml b/_jekyll/_data/api_python.yml index 04c8c7b48..c806405c8 100644 --- a/_jekyll/_data/api_python.yml +++ b/_jekyll/_data/api_python.yml @@ -217,8 +217,8 @@ permalink: upcase - name: downcase permalink: downcase - - name: fmt - permalink: fmt + - name: format + permalink: format - section: name: Math and logic commands: diff --git a/_jekyll/_data/api_ruby.yml b/_jekyll/_data/api_ruby.yml index a4a224d92..0456ac412 100644 --- a/_jekyll/_data/api_ruby.yml +++ b/_jekyll/_data/api_ruby.yml @@ -215,8 +215,8 @@ permalink: upcase - name: downcase permalink: downcase - - name: fmt - permalink: fmt + - name: format + permalink: format - section: name: Math and logic commands: diff --git a/api/java/index.md b/api/java/index.md index 6c7f90d9e..a6716d89c 100644 --- a/api/java/index.md +++ b/api/java/index.md @@ -1932,27 +1932,45 @@ Result: [Read more about this command →](split/) -## [fmt](fmt/) ## +## [format](format/) ## {% apibody %} -r.fmt(string, object) → string +r.format(string, object) → string {% endapibody %} -Formats a template string based on a string-string key-value object. +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. -__Example:__ +__Example:__ Using simple parameters for formatting. -```js -r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback) +```java +r.format("{name} loves {candy}.", + r.hashMap("name", "Bob").with("candy", "candy floss") +).run(conn, callback) ``` Result: -```js +```java "Bob loves candy floss." ``` -[Read more about this command →](fmt/) +__Example:__ Using row for formatting. + +```java +r.table("movies").map({ + id: r.row('id'), + ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}) +``` + +Result: + +```java +// `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` + +[Read more about this command →](format/) ## [upcase](upcase/) ## diff --git a/api/java/string-manipulation/downcase.md b/api/java/string-manipulation/downcase.md index 65a15ae4c..b26eedddb 100644 --- a/api/java/string-manipulation/downcase.md +++ b/api/java/string-manipulation/downcase.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/java/string-manipulation/fmt.md b/api/java/string-manipulation/fmt.md deleted file mode 100644 index 99a763bb1..000000000 --- a/api/java/string-manipulation/fmt.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -layout: api-command -language: Java -permalink: api/java/fmt/ -command: fmt -io: - - - r - - string -related_commands: - match: match/ - split: split/ - upcase: upcase/ - downcase: downcase/ ---- - -# Command syntax # - -{% apibody %} -r.fmt(string, object) → string -{% endapibody %} - -# Description # - -Formats a template string based on a string-string key-value object. - -__Example:__ - -```java -r.fmt("{name} loves {candy}.", - r.hashMap("name", "Bob").with("candy", "candy floss") -).run(conn, callback) -``` - -Result: - -```java -"Bob loves candy floss." -``` diff --git a/api/java/string-manipulation/format.md b/api/java/string-manipulation/format.md new file mode 100644 index 000000000..655c23585 --- /dev/null +++ b/api/java/string-manipulation/format.md @@ -0,0 +1,54 @@ +--- +layout: api-command +language: Java +permalink: api/java/format/ +command: format +io: + - - r + - string +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.format(string, object) → string +{% endapibody %} + +# Description # + +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. + +__Example:__ Using simple parameters for formatting. + +```java +r.format("{name} loves {candy}.", + r.hashMap("name", "Bob").with("candy", "candy floss") +).run(conn, callback) +``` + +Result: + +```java +"Bob loves candy floss." +``` + +__Example:__ Using row for formatting. + +```java +r.table("movies").map({ + id: r.row('id'), + ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}) +``` + +Result: + +```java +// `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` diff --git a/api/java/string-manipulation/match.md b/api/java/string-manipulation/match.md index 8ba6bd727..5123e2a2e 100644 --- a/api/java/string-manipulation/match.md +++ b/api/java/string-manipulation/match.md @@ -10,7 +10,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/java/string-manipulation/split.md b/api/java/string-manipulation/split.md index 483e48ef8..ed2f194a9 100644 --- a/api/java/string-manipulation/split.md +++ b/api/java/string-manipulation/split.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/java/string-manipulation/upcase.md b/api/java/string-manipulation/upcase.md index 72b0f6a2a..a751a15d8 100644 --- a/api/java/string-manipulation/upcase.md +++ b/api/java/string-manipulation/upcase.md @@ -7,7 +7,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/javascript/index.md b/api/javascript/index.md index 1d2737ff7..6de5289ad 100644 --- a/api/javascript/index.md +++ b/api/javascript/index.md @@ -2009,18 +2009,21 @@ Result: [Read more about this command →](split/) -## [fmt](fmt/) ## +## [format](format/) ## {% apibody %} -r.fmt(string, object) → string +r.format(string, object) → string {% endapibody %} -Formats a template string based on a string-string key-value object. +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. -__Example:__ +__Example:__ Using simple parameters for formatting. ```js -r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback) +r.format("{name} loves {candy}.", { + "name": "Bob", + "candy": "candy floss", +}).run(conn, callback) ``` Result: @@ -2029,7 +2032,23 @@ Result: "Bob loves candy floss." ``` -[Read more about this command →](fmt/) +__Example:__ Using row for formatting. + +```js +r.table("movies").map({ + id: r.row('id'), + ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}) +``` + +Result: + +```js +// `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` + +[Read more about this command →](format/) ## [upcase](upcase/) ## diff --git a/api/javascript/string-manipulation/downcase.md b/api/javascript/string-manipulation/downcase.md index 0900ce66b..21305d983 100644 --- a/api/javascript/string-manipulation/downcase.md +++ b/api/javascript/string-manipulation/downcase.md @@ -10,7 +10,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/javascript/string-manipulation/fmt.md b/api/javascript/string-manipulation/fmt.md deleted file mode 100644 index 9bf27f434..000000000 --- a/api/javascript/string-manipulation/fmt.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -layout: api-command -language: JavaScript -permalink: api/javascript/fmt/ -command: fmt -io: - - - r - - string -related_commands: - match: match/ - split: split/ - upcase: upcase/ - downcase: downcase/ ---- - -# Command syntax # - -{% apibody %} -r.fmt(string, object) → string -{% endapibody %} - -# Description # - -Formats a template string based on a string-string key-value object. - -__Example:__ - -```js -r.fmt("{name} loves {candy}.", { - "name": "Bob", - "candy": "candy floss", -}).run(conn, callback) -``` - -Result: - -```js -"Bob loves candy floss." -``` diff --git a/api/javascript/string-manipulation/format.md b/api/javascript/string-manipulation/format.md new file mode 100644 index 000000000..31fafd5f1 --- /dev/null +++ b/api/javascript/string-manipulation/format.md @@ -0,0 +1,55 @@ +--- +layout: api-command +language: JavaScript +permalink: api/javascript/format/ +command: format +io: + - - r + - string +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.format(string, object) → string +{% endapibody %} + +# Description # + +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. + +__Example:__ Using simple parameters for formatting. + +```js +r.format("{name} loves {candy}.", { + "name": "Bob", + "candy": "candy floss", +}).run(conn, callback) +``` + +Result: + +```js +"Bob loves candy floss." +``` + +__Example:__ Using row for formatting. + +```js +r.table("movies").map({ + id: r.row('id'), + ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}) +``` + +Result: + +```js +// `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` diff --git a/api/javascript/string-manipulation/match.md b/api/javascript/string-manipulation/match.md index 2199725d0..702fb4d1c 100644 --- a/api/javascript/string-manipulation/match.md +++ b/api/javascript/string-manipulation/match.md @@ -10,7 +10,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/javascript/string-manipulation/split.md b/api/javascript/string-manipulation/split.md index 578e6b49e..07fbe50bd 100644 --- a/api/javascript/string-manipulation/split.md +++ b/api/javascript/string-manipulation/split.md @@ -10,7 +10,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/javascript/string-manipulation/upcase.md b/api/javascript/string-manipulation/upcase.md index 8667e2311..e65c5544f 100644 --- a/api/javascript/string-manipulation/upcase.md +++ b/api/javascript/string-manipulation/upcase.md @@ -10,7 +10,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/python/index.md b/api/python/index.md index c08b1b3a7..5762bab54 100644 --- a/api/python/index.md +++ b/api/python/index.md @@ -1899,22 +1899,46 @@ __Example:__ Split on whitespace. [Read more about this command →](split/) -## [fmt](fmt/) ## +## [format](format/) ## {% apibody %} -r.fmt(string, object) → string +r.format(string, object) → string {% endapibody %} -Formats a template string based on a string-string key-value object. +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. -__Example:__ +__Example:__ Using simple parameters for formatting. + +```py +r.format("{name} loves {candy}.", { + "name": "Bob", + "candy": "candy floss", +}).run(conn) +``` + +Result: ```py -r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback) "Bob loves candy floss." ``` -[Read more about this command →](fmt/) +__Example:__ Using row for formatting. + +```py +r.table("movies").map({ + id: r.row('id'), + ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}).run(conn) +``` + +Result: + +```py +# `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` + +[Read more about this command →](format/) ## [upcase](upcase/) ## diff --git a/api/python/string-manipulation/downcase.md b/api/python/string-manipulation/downcase.md index 350c0c4dd..00e9dec5a 100644 --- a/api/python/string-manipulation/downcase.md +++ b/api/python/string-manipulation/downcase.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/python/string-manipulation/fmt.md b/api/python/string-manipulation/fmt.md deleted file mode 100644 index d6c55c569..000000000 --- a/api/python/string-manipulation/fmt.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -layout: api-command -language: Python -permalink: api/python/fmt/ -command: fmt -io: - - - r - - string -related_commands: - match: match/ - split: split/ - upcase: upcase/ - downcase: downcase/ ---- - -# Command syntax # - -{% apibody %} -r.fmt(string, object) → string -{% endapibody %} - -# Description # - -Formats a template string based on a string-string key-value object. - -__Example:__ - -```py -r.fmt("{name} loves {candy}.", { - "name": "Bob", - "candy": "candy floss", -}).run(conn, callback) -``` - -Result: - -```py -"Bob loves candy floss." -``` diff --git a/api/python/string-manipulation/format.md b/api/python/string-manipulation/format.md new file mode 100644 index 000000000..b30db0fd8 --- /dev/null +++ b/api/python/string-manipulation/format.md @@ -0,0 +1,55 @@ +--- +layout: api-command +language: Python +permalink: api/python/format/ +command: format +io: + - - r + - string +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.format(string, object) → string +{% endapibody %} + +# Description # + +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. + +__Example:__ Using simple parameters for formatting. + +```py +r.format("{name} loves {candy}.", { + "name": "Bob", + "candy": "candy floss", +}).run(conn) +``` + +Result: + +```py +"Bob loves candy floss." +``` + +__Example:__ Using row for formatting. + +```py +r.table("movies").map({ + id: r.row('id'), + ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}).run(conn) +``` + +Result: + +```py +# `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` diff --git a/api/python/string-manipulation/match.md b/api/python/string-manipulation/match.md index 512997362..955aa43d1 100644 --- a/api/python/string-manipulation/match.md +++ b/api/python/string-manipulation/match.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/python/string-manipulation/split.md b/api/python/string-manipulation/split.md index 4a51aa2ec..42926c183 100644 --- a/api/python/string-manipulation/split.md +++ b/api/python/string-manipulation/split.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/python/string-manipulation/upcase.md b/api/python/string-manipulation/upcase.md index 93c2ca2cb..867450d12 100644 --- a/api/python/string-manipulation/upcase.md +++ b/api/python/string-manipulation/upcase.md @@ -7,7 +7,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/ruby/index.md b/api/ruby/index.md index ecb68e531..47b5b9838 100644 --- a/api/ruby/index.md +++ b/api/ruby/index.md @@ -1877,22 +1877,46 @@ __Example:__ Split on whitespace. [Read more about this command →](split/) -## [fmt](fmt/) ## +## [format](format/) ## {% apibody %} -r.fmt(string, object) → string +r.format(string, object) → string {% endapibody %} -Formats a template string based on a string-string key-value object. +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. -__Example:__ +__Example:__ Using simple parameters for formatting. + +```rb +r.format("{name} loves {candy}.", { + "name" => "Bob", + "candy" => "candy floss", +}).run(conn) +``` + +Result: ```rb -r.fmt("{name} loves {candy}.", {"name" => "Bob", "candy" => "candy floss"}).run(conn, callback) "Bob loves candy floss." ``` -[Read more about this command →](fmt/) +__Example:__ Using row for formatting. + +```rb +r.table("movies").map({ + "id" => r.row('id'), + "ratings" => r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}).run(conn) +``` + +Result: + +```rb +# `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` + +[Read more about this command →](format/) ## [upcase](upcase/) ## diff --git a/api/ruby/string-manipulation/downcase.md b/api/ruby/string-manipulation/downcase.md index 07ea7960e..7f531629a 100644 --- a/api/ruby/string-manipulation/downcase.md +++ b/api/ruby/string-manipulation/downcase.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/ruby/string-manipulation/fmt.md b/api/ruby/string-manipulation/fmt.md deleted file mode 100644 index a709f97ae..000000000 --- a/api/ruby/string-manipulation/fmt.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -layout: api-command -language: Ruby -permalink: api/ruby/fmt/ -command: fmt -io: - - - r - - string -related_commands: - match: match/ - split: split/ - upcase: upcase/ - downcase: downcase/ ---- - -# Command syntax # - -{% apibody %} -r.fmt(string, object) → string -{% endapibody %} - -# Description # - -Formats a template string based on a string-string key-value object. - -__Example:__ - -```rb -r.fmt("{name} loves {candy}.", { - "name" => "Bob", - "candy" => "candy floss", -}).run(conn, callback) -``` - -Result: - -```rb -"Bob loves candy floss." -``` diff --git a/api/ruby/string-manipulation/format.md b/api/ruby/string-manipulation/format.md new file mode 100644 index 000000000..719107709 --- /dev/null +++ b/api/ruby/string-manipulation/format.md @@ -0,0 +1,55 @@ +--- +layout: api-command +language: Ruby +permalink: api/ruby/format/ +command: format +io: + - - r + - string +related_commands: + match: match/ + split: split/ + upcase: upcase/ + downcase: downcase/ +--- + +# Command syntax # + +{% apibody %} +r.format(string, object) → string +{% endapibody %} + +# Description # + +Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands. + +__Example:__ Using simple parameters for formatting. + +```rb +r.format("{name} loves {candy}.", { + "name" => "Bob", + "candy" => "candy floss", +}).run(conn) +``` + +Result: + +```rb +"Bob loves candy floss." +``` + +__Example:__ Using row for formatting. + +```rb +r.table("movies").map({ + "id" => r.row('id'), + "ratings" => r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) +}).run(conn) +``` + +Result: + +```rb +# `ratings` is the result of the HTTP request +[{ id: 1, ratings: { positive: 99, negative: 0 }}] +``` diff --git a/api/ruby/string-manipulation/match.md b/api/ruby/string-manipulation/match.md index d33b3198a..e219b1bfe 100644 --- a/api/ruby/string-manipulation/match.md +++ b/api/ruby/string-manipulation/match.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/ruby/string-manipulation/split.md b/api/ruby/string-manipulation/split.md index 1486a6c2e..5ad8d0eba 100644 --- a/api/ruby/string-manipulation/split.md +++ b/api/ruby/string-manipulation/split.md @@ -7,7 +7,7 @@ related_commands: upcase: upcase/ downcase: downcase/ match: match/ - fmt: fmt/ + format: format/ --- # Command syntax # diff --git a/api/ruby/string-manipulation/upcase.md b/api/ruby/string-manipulation/upcase.md index 11b764443..939b8cd15 100644 --- a/api/ruby/string-manipulation/upcase.md +++ b/api/ruby/string-manipulation/upcase.md @@ -7,7 +7,7 @@ related_commands: downcase: downcase/ match: match/ split: split/ - fmt: fmt/ + format: format/ --- # Command syntax #