diff --git a/doc/en-us/api/description/builtin_modules/os/0_intro.md b/doc/en-us/api/description/builtin_modules/os/0_intro.md
new file mode 100644
index 0000000..717916c
--- /dev/null
+++ b/doc/en-us/api/description/builtin_modules/os/0_intro.md
@@ -0,0 +1 @@
+${include api/script/builtin_modules/os/0_intro.md}
diff --git a/doc/en-us/api/description/builtin_variables/0_intro.md b/doc/en-us/api/description/builtin_variables/0_intro.md
index 7d598df..d60e913 100644
--- a/doc/en-us/api/description/builtin_variables/0_intro.md
+++ b/doc/en-us/api/description/builtin_variables/0_intro.md
@@ -47,6 +47,6 @@ target("test")
${link add_defines}("-DTEST=$(var)")
```
-> ℹ️ All the parameter values of the `xmake f --xxx=...` configuration can be obtained through built-in variables, for example: `xmake f --arch=x86` corresponds to `$(arch)`, others have ` $(plat)`, `$(mode)` and so on. What are the specific parameters, you can check it out by `xmake f -h`.
+> ℹ️ All the parameter values of the `xmake f --xxx=...` configuration can be obtained through built-in variables, for example: `xmake f --arch=x86` corresponds to `$(arch)`, others have `$(plat)`, `$(mode)` and so on. What are the specific parameters, you can check it out by `xmake f -h`.
Since the support is directly obtained from the configuration options, it is convenient to extend the custom options to get the custom variables. For details on how to customize the options, see: [option](#option).
diff --git a/doc/zh-cn/api/description/builtin_modules/os/0_intro.md b/doc/zh-cn/api/description/builtin_modules/os/0_intro.md
new file mode 100644
index 0000000..717916c
--- /dev/null
+++ b/doc/zh-cn/api/description/builtin_modules/os/0_intro.md
@@ -0,0 +1 @@
+${include api/script/builtin_modules/os/0_intro.md}
diff --git a/modules/gendoc.lua b/modules/gendoc.lua
index 8fde8c1..6d74430 100644
--- a/modules/gendoc.lua
+++ b/modules/gendoc.lua
@@ -20,7 +20,6 @@
-- imports
import("core.base.option")
-import("plugins.show.lists.apis", {rootdir = os.programdir()})
import("shared.md4c")
function _load_apimetadata(filecontent, opt)
@@ -120,14 +119,14 @@ function _join_link(...)
return table.concat(table.pack(...), "/")
end
-function _make_anchor(db, key, locale, siteroot, text)
+function _make_anchor(db, key, locale, siteroot, page, text)
assert(db and key and locale and siteroot and db[locale])
if db[locale].apis[key] then
text = text or db[locale].apis[key].name
- return [[]] .. text .. [[]]
+ return '' .. text .. ''
else
text = text or key
- return [[]] .. text .. [[]]
+ return '' .. text .. ''
end
end
@@ -135,10 +134,10 @@ function _make_link(db, key, locale, siteroot, text)
assert(db and key and locale and siteroot and db[locale])
if db[locale].apis[key] then
text = text or db[locale].apis[key].name
- return [[]] .. text .. [[]]
+ return '' .. text .. ''
else
text = text or key
- return [[]] .. text .. [[]]
+ return '' .. text .. ''
end
end
@@ -185,7 +184,7 @@ function _write_header(sitemap, siteroot, title)
]], siteroot, siteroot, title))
end
-function _write_api(sitemap, db, locale, siteroot, apimetalist, apientrydata)
+function _write_api(sitemap, db, locale, siteroot, page, apimetalist, apientrydata)
local apimetadata, content = _load_apimetadata(apientrydata, {locale = locale})
assert(apimetadata.api ~= nil, "entry api is nil value")
assert(apimetadata.key ~= nil, "entry key is nil value")
@@ -193,28 +192,26 @@ function _write_api(sitemap, db, locale, siteroot, apimetalist, apientrydata)
table.insert(apimetalist, apimetadata)
vprint("apimetadata", apimetadata)
- content = content:gsub("\n### " .. apimetadata.key .. "\n", "\n### " .. _make_anchor(db, apimetadata.key, locale, siteroot) .. "\n")
-
-- TODO auto generate links
-- do not match is_arch before matching os.is_arch
- -- local orderedapikeys = table.orderkeys(db[locale].apis, function(lhs, rhs) return #lhs > #rhs end)
- -- local contentlines = content:split("\n", {strict = true})
- -- for _, line in ipairs(contentlines) do
- -- if line:find("^### " .. apimetadata.key .. "$") then
- -- line = "### " .. _make_anchor(db, apimetadata.key, locale, siteroot)
- -- else
- -- -- local lastfoundidx = 1
- -- -- for _, key in ipairs(orderedapikeys) do
- -- -- local api = db[locale].apis[key]
- -- -- local foundstart, foundend, match = line:find(api.name, lastfoundidx, true)
- -- -- if match then
- -- -- local linebegin
- -- -- line:gsub(match, _make_link(db, api.key, locale, siteroot), 1)
- -- -- end
- -- -- end
- -- end
- -- end
- -- content = table.concat(contentlines, '\n')
+ local orderedapikeys = table.orderkeys(db[locale].apis, function(lhs, rhs) return #lhs > #rhs end)
+ local contentlines = content:split("\n", {strict = true})
+ for idx, line in ipairs(contentlines) do
+ if line:find("^### " .. apimetadata.name .. "$") then
+ contentlines[idx] = "### " .. _make_anchor(db, apimetadata.key, locale, siteroot, page)
+ else
+ -- local lastfoundidx = 1
+ -- for _, key in ipairs(orderedapikeys) do
+ -- local api = db[locale].apis[key]
+ -- local foundstart, foundend, match = line:find(api.name, lastfoundidx, true)
+ -- if match then
+ -- local linebegin
+ -- line:gsub(match, _make_link(db, api.key, locale, siteroot), 1)
+ -- end
+ -- end
+ end
+ end
+ content = table.concat(contentlines, '\n')
local htmldata, errors = md4c.md2html(content)
assert(htmldata, errors)
@@ -225,14 +222,14 @@ function _write_api(sitemap, db, locale, siteroot, apimetalist, apientrydata)
findstart, findend, anchor = htmldata:find("%${anchor ([^%s${%}]+)}")
if findstart == nil then break end
- htmldata = htmldata:gsub("%${anchor [^%s${%}]+}", _make_anchor(db, anchor, locale, siteroot), 1)
+ htmldata = htmldata:gsub("%${anchor [^%s${%}]+}", _make_anchor(db, anchor, locale, siteroot, page), 1)
until not findstart
repeat
local anchor, text
findstart, findend, anchor, text = htmldata:find("%${anchor ([^%s${%}]+) ([^${%}]+)}")
if findstart == nil then break end
- htmldata = htmldata:gsub("%${anchor [^%s${%}]+ [^${%}]+}", _make_anchor(db, anchor, locale, siteroot, text), 1)
+ htmldata = htmldata:gsub("%${anchor [^%s${%}]+ [^${%}]+}", _make_anchor(db, anchor, locale, siteroot, page, text), 1)
until not findstart
repeat
local link
@@ -252,7 +249,7 @@ function _write_api(sitemap, db, locale, siteroot, apimetalist, apientrydata)
sitemap:write(htmldata)
end
-function _write_table_of_content(sitemap, db, locale, siteroot, apimetalist)
+function _write_table_of_content(sitemap, db, locale, siteroot, page, apimetalist)
local names = {
["en-us"] = "Interfaces",
["zh-cn"] = "接口"
@@ -267,8 +264,8 @@ function _write_table_of_content(sitemap, db, locale, siteroot, apimetalist)