Skip to content

Commit

Permalink
Merge branch 'master' into fix_doc_defaultpath
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko authored Feb 18, 2025
2 parents a9db22d + 5657839 commit ee654a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` incorrect argument skip pattern for `--check_out_path=`, which incorrectly skips the next argument
* `CHG` default path for `--doc_out_path` is the current directory
* `FIX` incorrect error message for `--doc_update`.
* `FIX` reimplement section `luals.config` in file doc.json
* `FIX` incorrect file names in file doc.json
* `FIX` remove extra `./` path prefix in the check report when using `--check=.`

## 3.13.6
Expand Down
33 changes: 20 additions & 13 deletions script/cli/doc/export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ local getLabel = require 'core.hover.label'
local jsonb = require 'json-beautify'
local util = require 'utility'
local markdown = require 'provider.markdown'
local fs = require 'bee.filesystem'
local furi = require 'file-uri'

---@alias doctype
---| 'doc.alias'
Expand Down Expand Up @@ -55,13 +57,14 @@ local markdown = require 'provider.markdown'
local export = {}

function export.getLocalPath(uri)
--remove uri root (and prefix)
local local_file_uri = uri
local i, j = local_file_uri:find(DOC)
if not j then
return '[FOREIGN] '..uri
local file_canonical = fs.canonical(furi.decode(uri)):string()
local doc_canonical = fs.canonical(DOC):string()
local relativePath = fs.relative(file_canonical, doc_canonical):string()
if relativePath == "" or relativePath:sub(1, 2) == '..' then
-- not under project directory
return '[FOREIGN] ' .. file_canonical
end
return local_file_uri:sub( j + 1 )
return relativePath
end

function export.positionOf(rowcol)
Expand Down Expand Up @@ -214,10 +217,6 @@ export.makeDocObject['local'] = function(source, obj, has_seen)
obj.name = source[1]
end

export.makeDocObject['luals.config'] = function(source, obj, has_seen)

end

export.makeDocObject['self'] = export.makeDocObject['local']

export.makeDocObject['setfield'] = export.makeDocObject['doc.class']
Expand Down Expand Up @@ -284,17 +283,25 @@ end
---@param callback fun(i, max)
function export.makeDocs(globals, callback)
local docs = {}

for i, global in ipairs(globals) do
table.insert(docs, export.documentObject(global))
callback(i, #globals)
end

docs[#docs+1] = export.getLualsConfig()
table.sort(docs, export.sortDoc)

return docs
end

function export.getLualsConfig()
return {
name = 'LuaLS',
type = 'luals.config',
DOC = fs.canonical(fs.path(DOC)):string(),
defines = {},
fields = {}
}
end

---takes the table from `makeDocs`, serializes it, and exports it
---@async
---@param docs table
Expand Down
6 changes: 3 additions & 3 deletions script/cli/doc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local doc = {}
local function findDocJson()
local doc_json_path
if type(DOC_UPDATE) == 'string' then
doc_json_path = fs.absolute(fs.path(DOC_UPDATE)) .. '/doc.json'
doc_json_path = fs.canonical(fs.path(DOC_UPDATE)) .. '/doc.json'
else
doc_json_path = fs.current_path() .. '/doc.json'
end
Expand Down Expand Up @@ -46,7 +46,7 @@ local function getPathDocUpdate()
local doc_json_dir = doc_json_path:string():gsub('/doc.json', '')
return doc_json_dir, doc_path
else
error(string.format('Error: Cannot update "%s".', doc_json_path .. '/doc.json'))
error(string.format('Error: Cannot update "%s".', doc_json_path))
end
end

Expand Down Expand Up @@ -185,7 +185,7 @@ function doc.runCLI()
return
end

local rootUri = furi.encode(fs.absolute(fs.path(DOC)):string())
local rootUri = furi.encode(fs.canonical(fs.path(DOC)):string())
if not rootUri then
print(lang.script('CLI_CHECK_ERROR_URI', DOC))
return
Expand Down

0 comments on commit ee654a2

Please sign in to comment.