updated finddesc to use the new doc library, allowing type annotations and building a directory of documentation
This commit is contained in:
parent
a917016a66
commit
4f3bac551e
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
apidoc.md
|
|
||||||
apidoc.html
|
|
||||||
*.cpio
|
*.cpio
|
||||||
*.af
|
*.af
|
||||||
/target
|
/target
|
||||||
|
/doc
|
||||||
|
5
build.sh
5
build.sh
@ -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
|
||||||
|
72
finddesc.lua
72
finddesc.lua
@ -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
|
||||||
|
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
|
||||||
end
|
end
|
||||||
for k,v in pairs(lines) do
|
local rt = ""
|
||||||
local name, args, desc = v:match("function%s+(.+)%s*%((.*)%)%s*%-%-%s*(.+)")
|
for k,v in pairs(finfo.outtypes or {}) do
|
||||||
if name and args and desc then
|
if rt:len() > 0 then
|
||||||
docfiles[file][#docfiles[file]+1] = string.format("## %s(%s)\n%s\n",name,args,desc)
|
rt = rt .. ", "
|
||||||
|
else
|
||||||
|
rt = ": "
|
||||||
end
|
end
|
||||||
|
rt = rt .. v
|
||||||
|
end
|
||||||
|
rs = string.format("%s## %s(%s)%s\n%s",rs,name,as,rt,finfo.description)
|
||||||
|
end
|
||||||
|
return rs
|
||||||
|
end
|
||||||
|
|
||||||
|
os.execute("mkdir -p "..outpath)
|
||||||
|
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
|
|
||||||
|
46
template.tex
Normal file
46
template.tex
Normal 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}
|
Loading…
Reference in New Issue
Block a user