Skip to content

Commit c5b9735

Browse files
committed
Copy libgit2 docs from json dump.
1 parent 197e332 commit c5b9735

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

β€Ždocs/libgit2.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

β€Žgit2.nobj.luaβ€Ž

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ hide_meta_info = false, --true,
88

99
include "git2.h",
1010

11+
doc[[
12+
See <a href="http://libgit2.github.com/libgit2/#HEAD">libgit2 API docs</a>.
13+
]],
14+
1115
-- Error codes
1216
export_definitions {
1317
OK = "GIT_OK",
@@ -72,3 +76,38 @@ subfiles {
7276
},
7377
}
7478

79+
--
80+
-- Load parsed libgit2 docs.
81+
--
82+
local json = require"json"
83+
local file = io.open("docs/libgit2.json", "r")
84+
local libgit2_docs = json.decode(file:read("*a"))
85+
file:close()
86+
87+
local lg_funcs = libgit2_docs.functions
88+
89+
-- Copy docs from libgit2
90+
reg_stage_parser("pre_gen",{
91+
c_call = function(self, rec, parent)
92+
local func = lg_funcs[rec.cfunc]
93+
if not func then return end
94+
-- copy C function description
95+
parent:add_record(doc(
96+
'<p>Calls <a href="http://libgit2.github.com/libgit2/#HEAD/group/' ..
97+
func.group .. '/' .. rec.cfunc .. '">' .. rec.cfunc .. '</a>:<p>' ..
98+
'<p>' .. func.comments:gsub("\n\n", "<p>")
99+
))
100+
-- copy C arg description
101+
local var_map = parent.var_map
102+
local args = func.args
103+
for i=1,#args do
104+
local arg = args[i]
105+
local name = arg.name
106+
local var = var_map[name]
107+
if var then
108+
var.desc = arg.comment
109+
end
110+
end
111+
end,
112+
})
113+

0 commit comments

Comments
 (0)