Browse Source

documentation of a sort

Izaya 2 weeks ago
parent
commit
95e6a18216
2 changed files with 34 additions and 1 deletions
  1. 7
    1
      README.md
  2. 27
    0
      finddesc.lua

+ 7
- 1
README.md View File

@@ -1,3 +1,9 @@
1 1
 # OC-PsychOS2
2 2
 
3
-Operating system for OpenComputers
3
+A lightweight, multi-user operating system for OpenComputers
4
+
5
+## Documentation
6
+
7
+To generate function documentation, run:
8
+
9
+    ./finddesc.lua module/* lib/* > apidoc.md

+ 27
- 0
finddesc.lua View File

@@ -0,0 +1,27 @@
1
+local tA = {...}
2
+local docfiles = {}
3
+for _,file in pairs(tA) do
4
+ docfiles[file] = {}
5
+ local f = io.open(file)
6
+ local lines = {}
7
+ for l in f:read("*a"):gmatch("[^\n]+") do
8
+  if l:find("function") and not l:find("local") then
9
+   lines[#lines+1] = l
10
+  end
11
+ end
12
+ for k,v in pairs(lines) do
13
+  local name, args, desc = v:match("function%s+(.+)%s*%((.*)%)%s*%-%-%s*(.+)")
14
+  if name and args and desc then
15
+   docfiles[file][#docfiles[file]+1] = string.format("##%s(%s)\n%s",name,args,desc)
16
+  end
17
+ end
18
+end
19
+
20
+for k,v in pairs(docfiles) do
21
+ if #v > 0 then
22
+  print("#"..k)
23
+  for l,m in pairs(v) do
24
+   print(m)
25
+  end
26
+ end
27
+end

Loading…
Cancel
Save