forked from Kong/docs.konghq.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldoc.ltp
313 lines (292 loc) · 8.31 KB
/
ldoc.ltp
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
---
# if module then
title: Lua Reference - $(module.name)
# else
title: Lua Reference
# end
layout: default
---
# local base_url = "lua-reference/"
# local no_spaces = ldoc.no_spaces
# local iter = ldoc.modules.iter
# local display_name = ldoc.display_name
# local function ref_to_module(mod) return ldoc.ref_to_module(mod):gsub("%.%./", "../../"):gsub(".html", "") end
# local function href(see) return ldoc.href(see):gsub("%.%./", "../../"):gsub(".html", "") end
# local function no_jumps(s) return s:gsub("\n", ""):gsub("[ ]+", " ") end
# local function trim(s) return (s:gsub("^%s*(.-)%s*$", "%1")) end
# local function M(txt, item) return trim(ldoc.markup(txt,item,ldoc.plain)) end
<header class="page-header">
<div class="container">
<div class="page-header-icon">
<img src="/assets/images/icons/icn-documentation.svg" alt="Documentation" />
</div>
<div class="page-header-title">
<h1>$(ldoc.project)</h1>
<p>$(ldoc.title)</p>
</div>
{% if site.data.kong_versions.size > 1 %}
<div class="dropdown page-header-right">
<button class="page-header-btn" id="version-dropdown" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Version {{page.kong_version}}
{% if page.kong_version == site.data.kong_latest.release %}<em>(latest)</em>{% endif %}
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="version-dropdown">
{% for ver in site.data.kong_versions %}
{% if page.kong_version != ver.release %}
<li>
{% if ver.lua_doc %}
<a href="/docs/{{ver.release}}/$(base_url)"{% if ver.release == page.kong_version %} class="active"{% endif %}>
{{ver.release}}
{% if ver.release == site.data.kong_latest.release %}(latest){% endif %}
</a>
{% else %}
<span>Not available for {{ver.release}}</span>
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</header>
<div class="container">
<aside class="page-navigation">
<nav>
<ul>
<li>
<a href="/docs/{{page.kong_version}}"><h5>Back to docs</h5></a>
</li>
<li>
<a href="/docs/{{page.kong_version}}/$(base_url)"><h5>Index</h5></a>
</li>
# local this_mod = module and module.name
# for kind, mods, type in ldoc.kinds() do
# if ldoc.allowed_in_contents(type,module) then
<li>
<h5>$(kind)</h5>
<ul>
# for mod in mods() do
# local name = display_name(mod)
# if mod.name == this_mod then
<li>$(name)</li>
# else
<li><a href="$(ref_to_module(mod))">$(name)</a></li>
# end
# end
</ul>
</li>
# end
# end
</ul>
</nav>
</aside>
<div class="page-content-container">
<div class="page-content">
<div class="content">
# ------- TITLE
# if ldoc.body then -- verbatim HTML as contents; 'non-code' entries
$(ldoc.body)
# elseif module then -- module documentation
<h1><code>$(module.name)</code></h1>
<p>$(M(module.summary,module))</p>
<p>$(M(module.description,module))</p>
# ------- USAGE
# if module.usage then
<h3>Usage:</h3>
<ul>
# for usage in iter(module.usage) do
<li><pre>$(ldoc.escape(usage))</pre></li>
# end
</ul>
# end -- if usage
# if module.info then
<h3>Info:</h3>
<ul>
# for tag, value in iter(module.info) do
<li><strong>$(tag)</strong>: $(M(value,module))</li>
# end
</ul>
# end -- if module.info
# ------- SUMMARY
# for kind, items in module.kinds() do
<h2><a href="#$(no_spaces(kind))">$(kind)</a></h2>
<table class="function_list">
# for item in items() do
<tr>
<td class="name"><a href="#$(item.name)">$(display_name(item))</a></td>
<td class="summary">$(M(item.summary,item))</td>
</tr>
# end
</table>
# end
# ------- CONTENT
# for kind, items in module.kinds() do
# local kitem = module.kinds:get_item(kind)
# local has_description = kitem and ldoc.descript(kitem) ~= ""
<h2 class="section-header $(has_description and 'has-description')"><a name="$(no_spaces(kind))">$(kind)</a></h2>
$(M(module.kinds:get_section_description(kind),nil))
# if kitem then
# if has_description then
<div class="section-description">
$(M(ldoc.descript(kitem),kitem))
</div>
# end
# if kitem.usage then
<h3>Usage:</h3>
<pre class="example">$(ldoc.prettify(kitem.usage[1]))</pre>
# end
# end -- if kitem
# ------- FUNCTIONS
<dl class="function">
# for item in items() do
<hr />
<dt>
<h4><a name="$(item.name)">$(item.name)</a></h4>
# if ldoc.prettify_files and ldoc.is_file_prettified[item.module.file.filename] then
<a href="$(ldoc.source_ref(item))">line $(item.lineno)</a>
# end
</dt>
<dd>
$(M(ldoc.descript(item), item))
# ------- FUNCTION TAGS
# if ldoc.custom_tags then
# for custom in iter(ldoc.custom_tags) do
# local tag = item.tags[custom[1]]
# if tag and not custom.hidden then
<h5>$(custom.title or custom[1]):</h5>
<ul>
# for value in iter(tag) do
<li>$(M(value))</li>
# end
# end -- if tag
</ul>
# end -- iter tags
# end
# ------/ FUNCTION TAGS
# ------- FUNCTIONS PARAMS
# if item.params and #item.params > 0 then
# local subnames = module.kinds:type_of(item).subnames
# if subnames then
<h5>$(subnames):</h5>
# end
<ul>
# for param in iter(item.params) do
# local param, sublist = item:subparam(param)
# if sublist then
<li><code class="parameter">$(sublist)</code>
$(M(item.params.map[sublist], item))
<ul>
# end
# 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)
<li>
<code class="parameter">$(name)</code>
# if tp ~= '' then
<span class="types">$(tp)</span>
# end
$(M(item.params.map[p], item))
# if def == true then
(<em>optional</em>)
# elseif def then
(<em>default</em> $(def))
# end
# if item:readonly(p) then
<em>readonly</em>
# end
</li>
# end -- for p
# if sublist then
</li>
</ul>
# end
# end -- for param
</ul>
# end
# ------/ FUNCTIONS PARAMS
# ------- FUNCTIONS RETURNS
# if item.retgroups then
# local groups = item.retgroups
<h5>Returns:</h5>
# for i, group in ldoc.ipairs(groups) do
<ul>
# for r in group:iter() do
# local type, ctypes = item:return_type(r)
# local rt = ldoc.typename(type)
<li>
# if rt ~= '' then
<span class="types">$(rt)</span>
# end
$(M(r.text, item))
# if ctypes then
<ul>
# for c in ctypes:iter() do
<li>
<code class="parameter">$(c.name)</code>
<span class="types">$(ldoc.typename(c.type))</span>
$(M(c.comment, item))
</li>
# end
</ul>
# end -- if ctypes
</li>
# end -- for r
</ul>
# if i < #groups then
<h5>Or</h5>
# end
# end
# end -- if returns
# if item.raise then
<h5>Raises:</h5>
$(M(item.raise, item))
# end
# ------- SEE
# if item.see then
<h5>See also:</h5>
<ul>
# for see in iter(item.see) do
<li><a href="$(href(see))">$(see.label)</a></li>
# end
</ul>
# end -- if see
# ------- USAGE
# if item.usage then
<h5>Usage:</h5>
<ul>
# for usage in iter(item.usage) do
<li><pre class="example">$(ldoc.prettify(usage))</pre></li>
# end
</ul>
# end -- usage
# ------/ FUNCTIONS RETURNS
</dd>
# end -- for items()
</dl>
# ------/ FUNCTIONS
# end -- for module.kinds()
# else -- elseif module
# if ldoc.description then
<h2>$(M(ldoc.description,nil))</h2>
# end
# if ldoc.full_description then
<p>$(M(ldoc.full_description,nil))</p>
# end
# for kind, mods in ldoc.kinds() do
<h2>$(kind)</h2>
# kind = kind:lower()
<table class="module_list">
# for m in mods() do
<tr>
<td class="name"><a href="$(ref_to_module(m))">$(m.name)</a></td>
<td class="summary">$(M(ldoc.strip_header(m.summary),m))</td>
</tr>
# end -- for modules
</table>
# end -- for kinds
# end
</div>
</div>
</div>
</div>