Skip to content

Commit 6618c2f

Browse files
authored
Merge pull request #3070 from AndreasMatthias/fix_doc_filenames
fix: incorrect file names in doc.json
2 parents 807ae52 + 44d2824 commit 6618c2f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
55
* `FIX` incorrect argument skip pattern for `--check_out_path=`, which incorrectly skips the next argument
6+
* `FIX` incorrect file names in file doc.json
67
* `FIX` remove extra `./` path prefix in the check report when using `--check=.`
78

89
## 3.13.6

script/cli/doc/export.lua

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ local getLabel = require 'core.hover.label'
88
local jsonb = require 'json-beautify'
99
local util = require 'utility'
1010
local markdown = require 'provider.markdown'
11+
local fs = require 'bee.filesystem'
12+
local furi = require 'file-uri'
1113

1214
---@alias doctype
1315
---| 'doc.alias'
@@ -55,13 +57,14 @@ local markdown = require 'provider.markdown'
5557
local export = {}
5658

5759
function export.getLocalPath(uri)
58-
--remove uri root (and prefix)
59-
local local_file_uri = uri
60-
local i, j = local_file_uri:find(DOC)
61-
if not j then
62-
return '[FOREIGN] '..uri
60+
local file_canonical = fs.canonical(furi.decode(uri)):string()
61+
local doc_canonical = fs.canonical(DOC):string()
62+
local relativePath = fs.relative(file_canonical, doc_canonical):string()
63+
if relativePath == "" or relativePath:sub(1, 2) == '..' then
64+
-- not under project directory
65+
return '[FOREIGN] ' .. file_canonical
6366
end
64-
return local_file_uri:sub( j + 1 )
67+
return relativePath
6568
end
6669

6770
function export.positionOf(rowcol)

script/cli/doc/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function doc.runCLI()
185185
return
186186
end
187187

188-
local rootUri = furi.encode(fs.absolute(fs.path(DOC)):string())
188+
local rootUri = furi.encode(fs.canonical(fs.path(DOC)):string())
189189
if not rootUri then
190190
print(lang.script('CLI_CHECK_ERROR_URI', DOC))
191191
return

0 commit comments

Comments
 (0)