blob: 9cc6c38589ba15144e1aaec9743748a94ae0287d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-- This is an example of how to process the generated `doc.json` file.
-- You can use it to generate a markdown file or a html file.
local jsonc = require 'jsonc'
local util = require 'utility'
local markdown = require 'provider.markdown'
local export = {}
function export.buildMD(outputPath)
local doc = jsonc.decode_jsonc(util.loadFile(outputPath .. '/doc.json'))
local md = markdown()
assert(type(doc) == 'table')
for _, class in ipairs(doc) do
md:add('md', '# ' .. class.name)
md:emptyLine()
md:add('md', class.desc)
md:emptyLine()
local mark = {}
for _, field in ipairs(class.fields) do
if not mark[field.name] then
mark[field.name] = true
md:add('md', '## ' .. field.name)
md:emptyLine()
md:add('lua', field.extends.view)
md:emptyLine()
md:add('md', field.desc)
md:emptyLine()
end
end
md:splitLine()
end
local mdPath = outputPath .. '/doc.md'
util.saveFile(mdPath, md:string())
return mdPath
end
return export
|