-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathldoc.ltp
More file actions
143 lines (134 loc) · 4.48 KB
/
ldoc.ltp
File metadata and controls
143 lines (134 loc) · 4.48 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
>local iter = ldoc.modules.iter
>local M = ldoc.markup
>local lev = ldoc.level or 2
>local lev1, lev2 = ('#'):rep(lev), ('#'):rep(lev + 1)
>local styleTitle = function(text) return "<h3>"..text..":</h3>" end
>local abbc, abbsh, abbs = "??? realm-client", "??? realm-shared", "??? realm-server"
>local realms= {client = abbc, shared = abbsh, server = abbs}
>local hiddenanchor = function(text, realm) return "##### "..ldoc.realm_anchor_format(text, realm) end
>local indexorder = {"Globals", "Libraries", "Classes", "Hooks", "Plugins"}
>local show_return = not ldoc.no_return_or_parms
>local show_parms = show_return
>local no_spaces = ldoc.no_spaces
>if module and not ldoc.no_summary and #module.items > 0 then
$("# "..module.fname)
$(module.summary)
$(module.description)
>for kind, items in module.kinds() do
$(lev1) $(kind)
>local kitem = module.kinds:get_item(kind)
>if kitem then
$(ldoc.descript(kitem))
>end -- if kitem
>for item in items() do
>local realmtype = abbsh
> if item.tags and item.tags.realm then
> for val in iter(item.tags.realm) do realmtype = realms[val] break end
> end -- if
$(realmtype) $("\"<a id="..item.name.."></a>"..ldoc.display_name(item).."\"")
$(hiddenanchor(item.name, realmtype))
> if item.tags and item.tags.internal then
!!! warning "Internal"
This is used internally - although you're able to use it you probably shouldn't.
> end -- if internal
> if item.tags and item.tags.pluginwarning then
> local plugin_name
> for val in iter(item.tags.pluginwarning) do plugin_name = val break end
??? info "Plugin function"
This is defined and used within the [$(plugin_name)](../../plugins/$(plugin_name)) plugin. As such, its functionality might differ in different schemas, or be unavailable.
> end -- if pluginwarning
$(ldoc.usage_format(ldoc.descript(item), 1))
> if show_parms and item.params and #item.params > 0 then
> local subnames = module.kinds:type_of(item).subnames
> if subnames then
$(styleTitle(subnames))
> end -- if
> for parm in iter(item.params) do
> local param,sublist = item:subparam(parm)
> if sublist then
<span class="parameter">$(sublist)</span>$(M(item.params.map[sublist],item))
> end -- if
> for p in iter(param) do
> local name,tp,def = item:display_name_of(p), ldoc.typename(item:type_of_param(p)), item:default_of_param(p)
> if tp == '' then tp = "vararg" end
<span class="types">$(tp)</span>
<span class="parameter">$(name)</span>
> if def == true then
$("<em><ins>`optional`</ins></em>")
> elseif def then
$("<em><ins>`optional. default`: `")$(def)$("`</ins></em>")
> end -- if
$(M(item.params.map[p],item))
> if item:readonly(p) then
$("<em>readonly</em>")
> end -- if
> end -- for p
> end -- if params
> end -- for parm
> if show_return and item.retgroups then local groups = item.retgroups
$(styleTitle("Returns"))
> for i,group in ldoc.ipairs(groups) do
> for r in group:iter() do local type, ctypes = item:return_type(r); local rt = ldoc.typename(type)
> if rt ~= '' then
<span class="types">$(rt)</span>
> end
$(M(r.text,item))
> if ctypes then
> for c in ctypes:iter() do
<span class="parameter">$(c.name)</span>
<span class="types">$(ldoc.typename(c.type))</span>
$(M(c.comment,item))
> end
> end -- if ctypes
> end -- for r
> if i < #groups then
<h4>Or</h4>
> end
> end -- for group
> end -- if returns
> if show_return and item.raise then
<h3>Raises:</h3>
$(M(item.raise,item))
> end
> if item.see then
<h3>See also:</h3>
<ul>
> for see in iter(item.see) do
<li><a href="$(ldoc.href(see))">$(see.label )</a></li>
> end -- for
</ul>
> end -- if see
> if item.usage then
<h3>Usage:</h3>
<ul>
> for usage in iter(item.usage) do
```lua linenums="1"
$(ldoc.usage_format(usage, 2))
```
> end -- for
</ul>
> end -- if usage
>end -- for item
>end -- for kind
>else -- if module
> if ldoc.description then
<h2>$(M(ldoc.description,nil))</h2>
> end
> if ldoc.full_description then
$(M(ldoc.full_description,nil))
> end
> local allmods, i = {}
> for kind, mods in ldoc.kinds() do
> allmods[kind] = mods
> end -- for kinds
> for kind in iter(indexorder) do
> local mods = allmods[kind]
<h3>$(kind)</h3>
> kind = kind:lower()
| Name | Summary |
|-------|------|
> for m in mods() do
|[$(m.name)]($(no_spaces(kind))/$(m.name).md)|$(m.summary)|
> end -- for modules
> end -- for indexorder
>end -- if module