Compare commits

...

2 Commits

5 changed files with 105 additions and 25 deletions

3
.gitignore vendored
View File

@ -1,5 +1,4 @@
apidoc.md
apidoc.html
*.cpio *.cpio
*.af *.af
/target /target
/doc

View File

@ -7,5 +7,8 @@ echo _OSVERSION=\"PsychOS 2.0a2-$(git rev-parse --short HEAD)\" > target/version
cat target/version.lua target/init.lua > target/tinit.lua cat target/version.lua target/init.lua > target/tinit.lua
mv target/tinit.lua target/init.lua mv target/tinit.lua target/init.lua
cp -r service/ lib/ cfg/ target/ cp -r service/ lib/ cfg/ target/
$LUA finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md #$LUA finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md
rm target/version.lua rm target/version.lua
rm -r doc/
$LUA finddesc2.lua doc/ $(find lib/ module/ -type f|sort)
pandoc doc/apidoc.md --template=template.tex -o doc/apidoc.pdf

View File

@ -1,27 +1,59 @@
#!/usr/bin/env lua
local doc = require "lib/doc"
local tA = {...} local tA = {...}
local docfiles = {}
for _,file in pairs(tA) do local outpath = table.remove(tA,1)
docfiles[file] = {}
local f = io.open(file) print(outpath)
local lines = {}
for l in f:read("*a"):gmatch("[^\n]+") do local function formatDocs(fd)
if l:find("function") and not l:find("local") then local rs = ""
lines[#lines+1] = l for name,finfo in pairs(fd) do
if rs:len() > 0 then
rs = rs .. "\n\n"
end end
local as = ""
for k,v in pairs(finfo.args) do
if k > 1 then
as = as .. ", "
end
as = as .. v[1]
if v[2] then
as = as .. "^"..v[2].."^"
end
end
local rt = ""
for k,v in pairs(finfo.outtypes or {}) do
if rt:len() > 0 then
rt = rt .. ", "
else
rt = ": "
end
rt = rt .. v
end
rs = string.format("%s## %s(%s)%s\n%s",rs,name,as,rt,finfo.description)
end end
for k,v in pairs(lines) do return rs
local name, args, desc = v:match("function%s+(.+)%s*%((.*)%)%s*%-%-%s*(.+)") end
if name and args and desc then
docfiles[file][#docfiles[file]+1] = string.format("## %s(%s)\n%s\n",name,args,desc) os.execute("mkdir -p "..outpath)
end local ad = io.open(outpath.."/apidoc.md","w")
for k,v in pairs(tA) do
local fd = doc.parsefile(v)
local ds = formatDocs(fd)
print(string.format("%s: %i",v,ds:len()))
if ds and ds:len() > 0 then
os.execute("mkdir -p $(dirname \""..outpath.."/"..v.."\")")
local f = io.open(outpath.."/"..v:gsub("%.lua$",".md"),"wb")
f:write(string.format("# %s\n\n",v))
f:write(ds)
f:write("\n\n")
f:close()
ad:write(string.format("# %s\n\n",v))
ad:write(ds)
ad:write("\n\n")
end end
end end
for k,v in pairs(docfiles) do ad:close()
if #v > 0 then
print("\n# "..k)
for l,m in pairs(v) do
print(m)
end
end
end

View File

@ -36,7 +36,7 @@ function event.listen(e,f) -- string function -- -- run function *f* for every o
end end,string.format("[%d] %s listener",os.pid(),e)) end end,string.format("[%d] %s listener",os.pid(),e))
end end
function event.ignore(e,f) -- string function -- stop function *f* running for every occurance of event *e* function event.ignore(e,f) -- string function -- -- stop function *f* running for every occurance of event *e*
computer.pushSignal("unlisten",e,tostring(f)) computer.pushSignal("unlisten",e,tostring(f))
end end

46
template.tex Normal file
View File

@ -0,0 +1,46 @@
\documentclass[11pt,twoside,a4paper]{article}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{standalone}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{listings}
\usepackage{color}
\usepackage{sectsty}
\usepackage[cm]{fullpage}
\lstset{
commentstyle=\color{cyan}, % comment style
keywordstyle=\color{cyan}, % keyword style
stringstyle=\color{red}, % string literal style
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
numbersep=5pt, % how far the line-numbers are from the code
numberstyle=\tiny\color{gray}, % the style that is used for the line-numbers
}
\hypersetup{
colorlinks=true
}
\subsectionfont{\ttfamily}
% pandoc stuff
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\let\stdsection\section
\renewcommand\section{\newpage\stdsection}
\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\newcommand{\ignore}[1]{}
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
\author{$for(author)$$author$$sep$ \and $endfor$}
\date{}
\begin{document}
\pagenumbering{gobble}
\maketitle
\newpage
\pagenumbering{alph}
\tableofcontents
\newpage
\pagenumbering{arabic}
$body$
\end{document}