1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
return [[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><%- options.title %></title>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.0.0/build/styles/default.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.0.0/build/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<%- navbar %>
<article>
<% if header.data_file then %>
<% local reffd = io.open(header.data_file,"r") %>
<p><%- reffd:read("*a") %>
<% reffd:close() %>
<% else %>
<section>
<h3><%- header.name %></h3>
<% if header.short_desc then %>
<p><%- header.short_desc %>
<% header.short_desc = nil %>
<% end %>
<% if header.desc then %>
<p><%- header.desc or "" %>
<% header.desc = nil %>
<% end %>
<% if header.inherits then %>
<p>Inherits from
<% assert(header.inherits,"Failed to find field 'inherits'") %>
<% for _,name in pairs(header.inherits) do %>
<a href="<%- name %>.html"><%- name %></a>
<% end %>
<% end %>
</section>
<% local funcorder = {} %>
<% assert(header and type(header) == "table", "Failed to find header") %>
<% for funcname,_ in pairs(header) do %>
<% table.insert(funcorder,funcname) %>
<% end %>
<% table.sort(funcorder) %>
<section>
<h4>Contents</h4>
<table>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<% assert(funcorder and type(funcorder) == "table" , "Failed to find 'funcorder'") %>
<% for _, funcname in ipairs(funcorder) do %>
<% local data = header[funcname] %>
<% if data and data.short_desc then %>
<tr>
<% if data.type == "function" or data.type == "method" then %>
<td><%- funcsig({funcname = funcname, func = header[funcname]}) %></td>
<td><%- data.short_desc %></td>
<% else %>
<td><%- data.name %></td>
<td><%- data.short_desc %></td>
<% end %>
</tr>
<% end %>
<% end %>
</table>
</section>
<hr>
<% local func_sec = assert(et.compile(require("mdoc.files.func"))) %>
<% assert(funcorder and type(funcorder) == "table", "Failed to find funcorder 2") %>
<% for _, funcname in ipairs(funcorder) do %>
<% local data = header[funcname] %>
<% if data.type then %>
<% if data.type == "method" or data.type == "function" then %>
<%- assert(func_sec{
name = funcname,
data = data
}) %>
<hr>
<% elseif data.type == "field" then %>
<h4><%- funcname %></h4>
<p><%- data.desc or "" %>
<hr>
<% else %>
<% if funcname ~= "name" and funcname ~= "type" then %>
<p>Unknown field type: <%- data.type or "" %> for <%- funcname %>
<p><%- tostring(data) %>
<p><%- tostring(header) %>
<hr>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
</article>
</body>
</html>
]]
|