summaryrefslogtreecommitdiff
path: root/script/cli
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-12-01 16:54:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-12-01 16:54:29 +0800
commit1d140319f065fccf60044d2766d9a5864dc7b0b8 (patch)
treeeb201b57e47063eb305306236548f4a818a2d99c /script/cli
parent1b67188ff42542031c23e011a474a759a10df380 (diff)
downloadlua-language-server-1d140319f065fccf60044d2766d9a5864dc7b0b8.zip
update json.lua
Diffstat (limited to 'script/cli')
-rw-r--r--script/cli/check.lua4
-rw-r--r--script/cli/doc.lua6
-rw-r--r--script/cli/doc2md.lua6
3 files changed, 9 insertions, 7 deletions
diff --git a/script/cli/check.lua b/script/cli/check.lua
index 0addd4d0..37b6ad15 100644
--- a/script/cli/check.lua
+++ b/script/cli/check.lua
@@ -4,7 +4,7 @@ local ws = require 'workspace'
local files = require 'files'
local diag = require 'provider.diagnostic'
local util = require 'utility'
-local json = require 'json-beautify'
+local jsonb = require 'json-beautify'
local lang = require 'language'
local define = require 'proto.define'
local config = require 'config.config'
@@ -93,7 +93,7 @@ if count == 0 then
print(lang.script('CLI_CHECK_SUCCESS'))
else
local outpath = LOGPATH .. '/check.json'
- util.saveFile(outpath, json.beautify(results))
+ util.saveFile(outpath, jsonb.beautify(results))
print(lang.script('CLI_CHECK_RESULTS', count, outpath))
end
diff --git a/script/cli/doc.lua b/script/cli/doc.lua
index 6d5fe596..7ba40c78 100644
--- a/script/cli/doc.lua
+++ b/script/cli/doc.lua
@@ -3,7 +3,7 @@ local furi = require 'file-uri'
local ws = require 'workspace'
local files = require 'files'
local util = require 'utility'
-local json = require 'json-beautify'
+local jsonb = require 'json-beautify'
local lang = require 'language'
local define = require 'proto.define'
local config = require 'config.config'
@@ -258,7 +258,7 @@ lclient():start(function (client)
end)
local outpath = LOGPATH .. '/doc.json'
-json.supportSparseArray = true
-util.saveFile(outpath, json.beautify(results))
+jsonb.supportSparseArray = true
+util.saveFile(outpath, jsonb.beautify(results))
require 'cli.doc2md'
diff --git a/script/cli/doc2md.lua b/script/cli/doc2md.lua
index 70941d0c..8c0956f1 100644
--- a/script/cli/doc2md.lua
+++ b/script/cli/doc2md.lua
@@ -1,13 +1,15 @@
-- This is an example of how to process the generated `doc.json` file.
-- You can use it to generate a markdown file or a html file.
-local json = require 'json'
+local jsonc = require 'jsonc'
local util = require 'utility'
local markdown = require 'provider.markdown'
-local doc = json.decode(util.loadFile(LOGPATH .. '/doc.json'))
+local doc = jsonc.decode_jsonc(util.loadFile(LOGPATH .. '/doc.json'))
local md = markdown()
+assert(type(doc) == 'table')
+
for _, class in ipairs(doc) do
md:add('md', '# ' .. class.name)
md:emptyLine()