Created
July 24, 2016 17:22
-
-
Save prozacgod/af5eceb4c7e7b9c7094ba9ed86f618b7 to your computer and use it in GitHub Desktop.
This dumps the documentation from an Open Peripheral device. I couldn't find one quickly so I wrote this. Improvements and formating changes welcome... (maybe an HTML dumper would look nice.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Dump open peripheral documentation to a file. | |
local args = {...} | |
if #args ~= 2 then | |
print ("doc_dump <side> <file>") | |
return | |
end | |
local perf = peripheral.wrap(args[1]) | |
local data = perf.getAdvancedMethodsData() | |
local file = fs.open(args[2], "w") | |
local function p(s) | |
--print(s) | |
file.write(s .. "\n") | |
end | |
for method, details in pairs(data) do | |
local argStr = ""; | |
for argi, argd in ipairs(details.args) do | |
argStr = argStr .. argd.name .. ", " | |
end | |
p(method .. "(" .. argStr:sub(1, -3) .. ") => " .. details.returnTypes) | |
p("") | |
p(" " .. details.description) | |
p("") | |
for argi, argd in ipairs(details.args) do | |
local opt = "" | |
if argd.optional then | |
opt = "(Optional) " | |
end | |
p(" " .. argd.name .. " (" .. argd.type .. ") " .. opt) | |
p(" " .. argd.description) | |
p("") | |
end | |
end | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment