From 0ac3c4d6314df5fe40571a83e157a425ab7ce16d Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 15 Jul 2023 16:55:32 +0100 Subject: docs(lua): move function docs to lua files --- runtime/lua/vim/_meta/json.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 runtime/lua/vim/_meta/json.lua (limited to 'runtime/lua/vim/_meta/json.lua') diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua new file mode 100644 index 0000000000..15e81d5004 --- /dev/null +++ b/runtime/lua/vim/_meta/json.lua @@ -0,0 +1,35 @@ +--- @meta + +--- @defgroup lua-json +--- +--- @brief The \*vim.json\* module provides encoding and decoding of Lua objects to and +--- from JSON-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|. + +--- Decodes (or "unpacks") the JSON-encoded {str} to a Lua object. +--- +--- - Decodes JSON "null" as |vim.NIL| (controllable by {opts}, see below). +--- - Decodes empty object as |vim.empty_dict()|. +--- - Decodes empty array as `{}` (empty Lua table). +--- +--- Example: +---
lua
+--- :lua vim.print(vim.json.decode('{"bar":[],"foo":{},"zub":null}'))
+--- --> { bar = {}, foo = vim.empty_dict(), zub = vim.NIL }
+--- 
+--- Parameters: ~ +--- • {str} Stringified JSON data. +--- • {opts} Options map keys: +--- • luanil: { object: bool, array: bool } +--- • `luanil.object=true` converts `null` in JSON objects to +--- Lua `nil` instead of `vim.NIL`. +--- • `luanil.array=true` converts `null` in JSON arrays to Lua +--- `nil` instead of `vim.NIL`. +--- @param str string +--- @param opts? table +--- @return any +function vim.json.decode(str, opts) end + +--- Encodes (or "packs") Lua object {obj} as JSON in a Lua string. +--- @param obj any +--- @return string +function vim.json.encode(obj) end -- cgit From c2d7c2826ca77b0ca31bec511fdcdf1e4abaf946 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 17 Jul 2023 15:13:54 +0100 Subject: docs(lua): change *lua-foo* -> *vim.foo* --- runtime/lua/vim/_meta/json.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/_meta/json.lua') diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua index 15e81d5004..2580b56870 100644 --- a/runtime/lua/vim/_meta/json.lua +++ b/runtime/lua/vim/_meta/json.lua @@ -1,8 +1,8 @@ --- @meta ---- @defgroup lua-json +--- @defgroup vim.json --- ---- @brief The \*vim.json\* module provides encoding and decoding of Lua objects to and +--- This module provides encoding and decoding of Lua objects to and --- from JSON-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|. --- Decodes (or "unpacks") the JSON-encoded {str} to a Lua object. -- cgit From 69d49727d7766d799aa1989bf67e763258b868e6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 17 Jul 2023 16:32:56 +0100 Subject: fix: luacheck --- runtime/lua/vim/_meta/json.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/lua/vim/_meta/json.lua') diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua index 2580b56870..76a6c7b733 100644 --- a/runtime/lua/vim/_meta/json.lua +++ b/runtime/lua/vim/_meta/json.lua @@ -1,5 +1,7 @@ --- @meta +-- luacheck: no unused args + --- @defgroup vim.json --- --- This module provides encoding and decoding of Lua objects to and -- cgit From 2e92065686f62851318150a315591c30b8306a4b Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Thu, 14 Sep 2023 08:23:01 -0500 Subject: docs: replace
 with ``` (#25136)

---
 runtime/lua/vim/_meta/json.lua | 37 ++++++++++++++++++-------------------
 1 file changed, 18 insertions(+), 19 deletions(-)

(limited to 'runtime/lua/vim/_meta/json.lua')

diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua
index 76a6c7b733..edf905c7c6 100644
--- a/runtime/lua/vim/_meta/json.lua
+++ b/runtime/lua/vim/_meta/json.lua
@@ -1,8 +1,8 @@
---- @meta
+---@meta
 
 -- luacheck: no unused args
 
---- @defgroup vim.json
+---@defgroup vim.json
 ---
 --- This module provides encoding and decoding of Lua objects to and
 --- from JSON-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|.
@@ -14,24 +14,23 @@
 --- - Decodes empty array as `{}` (empty Lua table).
 ---
 --- Example:
---- 
lua
---- :lua vim.print(vim.json.decode('{"bar":[],"foo":{},"zub":null}'))
---- --> { bar = {}, foo = vim.empty_dict(), zub = vim.NIL }
---- 
---- Parameters: ~ ---- • {str} Stringified JSON data. ---- • {opts} Options map keys: ---- • luanil: { object: bool, array: bool } ---- • `luanil.object=true` converts `null` in JSON objects to ---- Lua `nil` instead of `vim.NIL`. ---- • `luanil.array=true` converts `null` in JSON arrays to Lua ---- `nil` instead of `vim.NIL`. ---- @param str string ---- @param opts? table ---- @return any +--- +--- ```lua +--- vim.print(vim.json.decode('{"bar":[],"foo":{},"zub":null}')) +--- -- { bar = {}, foo = vim.empty_dict(), zub = vim.NIL } +--- ``` +--- +---@param str string Stringified JSON data. +---@param opts? table Options table with keys: +--- - luanil: (table) Table with keys: +--- * object: (boolean) When true, converts `null` in JSON objects +--- to Lua `nil` instead of |vim.NIL|. +--- * array: (boolean) When true, converts `null` in JSON arrays +--- to Lua `nil` instead of |vim.NIL|. +---@return any function vim.json.decode(str, opts) end --- Encodes (or "packs") Lua object {obj} as JSON in a Lua string. ---- @param obj any ---- @return string +---@param obj any +---@return string function vim.json.encode(obj) end -- cgit From dae6770b761a5e760c6c4d7e618bb13afa961376 Mon Sep 17 00:00:00 2001 From: Maria José Solano Date: Fri, 22 Sep 2023 13:00:31 -0700 Subject: fix(meta): include vim.json --- runtime/lua/vim/_meta/json.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/lua/vim/_meta/json.lua') diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua index edf905c7c6..e010086615 100644 --- a/runtime/lua/vim/_meta/json.lua +++ b/runtime/lua/vim/_meta/json.lua @@ -1,5 +1,8 @@ ---@meta +---@nodoc +vim.json = {} + -- luacheck: no unused args ---@defgroup vim.json -- cgit