4 changed files with 102 additions and 22 deletions
@ -1,5 +1,4 @@ |
|||
apidoc.md |
|||
apidoc.html |
|||
*.cpio |
|||
*.af |
|||
/target |
|||
/doc |
|||
|
@ -1,27 +1,59 @@ |
|||
#!/usr/bin/env lua |
|||
local doc = require "lib/doc" |
|||
local tA = {...} |
|||
local docfiles = {} |
|||
for _,file in pairs(tA) do |
|||
docfiles[file] = {} |
|||
local f = io.open(file) |
|||
local lines = {} |
|||
for l in f:read("*a"):gmatch("[^\n]+") do |
|||
if l:find("function") and not l:find("local") then |
|||
lines[#lines+1] = l |
|||
|
|||
local outpath = table.remove(tA,1) |
|||
|
|||
print(outpath) |
|||
|
|||
local function formatDocs(fd) |
|||
local rs = "" |
|||
for name,finfo in pairs(fd) do |
|||
if rs:len() > 0 then |
|||
rs = rs .. "\n\n" |
|||
end |
|||
end |
|||
for k,v in pairs(lines) do |
|||
local name, args, desc = v:match("function%s+(.+)%s*%((.*)%)%s*%-%-%s*(.+)") |
|||
if name and args and desc then |
|||
docfiles[file][#docfiles[file]+1] = string.format("## %s(%s)\n%s\n",name,args,desc) |
|||
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 |
|||
return rs |
|||
end |
|||
|
|||
for k,v in pairs(docfiles) do |
|||
if #v > 0 then |
|||
print("\n# "..k) |
|||
for l,m in pairs(v) do |
|||
print(m) |
|||
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 |
|||
|
|||
ad:close() |
|||
|
@ -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…
issues.context.reference_issue