git.iko.soy/typeable/pandoc
on 2.0.6 help sign in
typeable/pandoc/tools/update-lua-docs.lua
47 lines 1.1 kB history raw
1local in_module_section = false
3-- Generate tmp folder
4local tmp_folder = os.tmpname()
5os.remove(tmp_folder)
6os.execute("mkdir -p " .. tmp_folder)
8function extend(list1, list2)
9 for i = 1, #list2 do
10 list1[#list1 + 1] = list2[i]
11 end
12end
14function module_blocks(module_filenames)
15 local blocks = {}
16 for _, filename in pairs(module_filenames) do
17 os.execute("ldoc -q -l tools -d " .. tmp_folder .. " " .. filename)
18 local module_file = io.open(tmp_folder .. "/index.html")
19 local module_html = module_file:read("*a")
20 local module_doc = pandoc.read(module_html, "html")
21 extend(blocks, module_doc.blocks)
22 end
23 return blocks
24end
26function Header (el)
27 if in_module_section then
28 if el.level == 1 then
29 in_module_section = false
30 return el
31 else
32 return {}
33 end
34 elseif el.identifier == "module-pandoc" then
35 in_module_section = true
36 return module_blocks{'data/pandoc.lua'}
37 elseif el.identifier == "module-pandoc.list" then
38 in_module_section = true
39 return module_blocks{'data/List.lua'}
40 end
41end
43function Block (el)
44 if in_module_section then
45 return {}
46 end
47end