docs: generate keyword-link.txt for codelink

This commit is contained in:
Daniel Kolesa 2016-08-19 14:19:09 +01:00
parent 1e42cae8a2
commit feafdb85a4
3 changed files with 20 additions and 6 deletions

View File

@ -12,8 +12,10 @@ M.add = function(key, lang)
end
M.build = function()
local writer = require("docgen.writer")
local dutil = require("docgen.util")
for lang, rfs in pairs(key_refs) do
local f = require("docgen.writer").Writer({ "ref", lang, "keyword-list" })
local f = writer.Writer({ "ref", lang, "keyword-list" })
local arr = {}
for refn, v in pairs(rfs) do
arr[#arr + 1] = refn
@ -22,6 +24,12 @@ M.build = function()
f:write_raw(table.concat(arr, "\n"))
f:write_nl()
f:finish()
local lf = writer.Writer({ "ref", lang, "keyword-link" })
lf:write_raw("/", dutil.path_join(
dutil.get_root(), "ref", lang, "key", "{FNAME}"
))
lf:write_nl()
lf:finish()
end
end

View File

@ -3,7 +3,7 @@ local ffi = require("ffi")
local M = {}
local doc_root
local doc_root, root_ns
local path_sep, rep_sep = "/", "\\"
if ffi.os == "Windows" then
@ -11,7 +11,7 @@ if ffi.os == "Windows" then
end
M.path_join = function(...)
return table.concat({ ... }, path_sep):gsub(rep_sep, path_sep)
return (table.concat({ ... }, path_sep):gsub(rep_sep, path_sep))
end
M.path_to_nspace = function(p)
@ -26,6 +26,10 @@ M.make_page = function(path)
return M.path_join(doc_root, path .. ".txt")
end
M.get_root = function()
return root_ns
end
M.mkdir_r = function(dirn)
assert(cutil.file_mkpath(dirn and M.path_join(doc_root, dirn) or doc_root))
end
@ -58,8 +62,9 @@ M.str_split = function(str, delim)
return t
end
M.init = function(root)
M.init = function(root, rns)
doc_root = root:gsub(rep_sep, path_sep)
root_ns = rns:gsub(rep_sep, path_sep)
end
return M

View File

@ -1085,8 +1085,9 @@ getopt.parse {
else
dr = opts["r"]
end
dr = dutil.path_join(dr, dutil.nspace_to_path(rootns))
dutil.init(dr)
local pns = dutil.nspace_to_path(rootns)
dr = dutil.path_join(dr, pns)
dutil.init(dr, pns)
if #args == 0 then
dtree.scan_directory()
else