Operating system for OpenComputers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
960B

  1. #!/usr/bin/env lua
  2. local doc = require "lib/doc"
  3. local ser = require "lib/serialization"
  4. local tA = {...}
  5. local outpath = table.remove(tA,1)
  6. print(outpath)
  7. local function formatDocs(fd)
  8. local rs = ""
  9. for name,finfo in pairs(fd) do
  10. if rs:len() > 0 then
  11. rs = rs .. "\n\n"
  12. end
  13. local as = ""
  14. for k,v in pairs(finfo.args) do
  15. if k > 1 then
  16. as = as .. ", "
  17. end
  18. as = as .. v[1]
  19. if v[2] then
  20. as = as .. "^"..v[2].."^"
  21. end
  22. end
  23. local rt = ""
  24. for k,v in pairs(finfo.outtypes or {}) do
  25. if rt:len() > 0 then
  26. rt = rt .. ", "
  27. else
  28. rt = ": "
  29. end
  30. rt = rt .. v
  31. end
  32. rs = string.format("%s## %s(%s)%s\n%s",rs,name,as,rt,finfo.description)
  33. end
  34. return rs
  35. end
  36. local ad = io.open(outpath,"wb")
  37. for k,v in pairs(tA) do
  38. local fd = doc.parsefile(v)
  39. local ds = ser.serialize(fd)
  40. local tn = v:match("/(.+)$")
  41. if ds:len() > 3 then
  42. ad:write(tn.."\t"..ds:gsub("\n",""):gsub(", +",",").."\n")
  43. end
  44. end
  45. ad:close()