Codebase list lua-ldoc / 4642e35
a custom styling example steve donovan 12 years ago
6 changed file(s) with 570 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 LDoc License
1 -----------
2 Copyright (C) 2011 Steve Donovan.
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21
0 file = 'simple.lua'
1 project = 'simple'
2 description = [[
3 a simple project
4
5 ##References
6
7 - [Background]()
8 - [Discussion]()
9
10 ]]
11 style = true
12 template = true
13 format = 'markdown'
0 /* BEGIN RESET
1
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 2.8.2r1
6 */
7 html {
8 color: #000;
9 background: #FFF;
10 }
11 body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
12 margin: 0;
13 padding: 0;
14 }
15 table {
16 border-collapse: collapse;
17 border-spacing: 0;
18 }
19 fieldset,img {
20 border: 0;
21 }
22 address,caption,cite,code,dfn,em,strong,th,var,optgroup {
23 font-style: inherit;
24 font-weight: inherit;
25 }
26 del,ins {
27 text-decoration: none;
28 }
29 li {
30 list-style: bullet;
31 margin-left: 20px;
32 }
33 caption,th {
34 text-align: left;
35 }
36 h1,h2,h3,h4,h5,h6 {
37 font-size: 100%;
38 font-weight: bold;
39 }
40 q:before,q:after {
41 content: '';
42 }
43 abbr,acronym {
44 border: 0;
45 font-variant: normal;
46 }
47 sup {
48 vertical-align: baseline;
49 }
50 sub {
51 vertical-align: baseline;
52 }
53 legend {
54 color: #000;
55 }
56 input,button,textarea,select,optgroup,option {
57 font-family: inherit;
58 font-size: inherit;
59 font-style: inherit;
60 font-weight: inherit;
61 }
62 input,button,textarea,select {*font-size:100%;
63 }
64 /* END RESET */
65
66 body {
67 margin-left: 1em;
68 margin-right: 1em;
69 font-family: arial, helvetica, geneva, sans-serif;
70 background-color: #ffffff; margin: 0px;
71 }
72
73 code, tt { font-family: monospace; }
74
75 body, p, td, th { font-size: .95em; line-height: 1.2em;}
76
77 p, ul { margin: 10px 0 0 10px;}
78
79 strong { font-weight: bold;}
80
81 em { font-style: italic;}
82
83 h1 {
84 font-size: 1.5em;
85 margin: 0 0 20px 0;
86 }
87 h2, h3, h4 { margin: 15px 0 10px 0; }
88 h2 { font-size: 1.25em; }
89 h3 { font-size: 1.15em; }
90 h4 { font-size: 1.06em; }
91
92 a:link { font-weight: bold; color: #004080; text-decoration: none; }
93 a:visited { font-weight: bold; color: #006699; text-decoration: none; }
94 a:link:hover { text-decoration: underline; }
95
96 hr {
97 color:#cccccc;
98 background: #00007f;
99 height: 1px;
100 }
101
102 blockquote { margin-left: 3em; }
103
104 ul { list-style-type: disc; }
105
106 p.name {
107 font-family: "Andale Mono", monospace;
108 padding-top: 1em;
109 }
110
111 pre.example {
112 background-color: rgb(245, 245, 245);
113 border: 1px solid silver;
114 padding: 10px;
115 margin: 10px 0 10px 0;
116 font-family: "Andale Mono", monospace;
117 font-size: .85em;
118 }
119
120 pre {
121 background-color: rgb(245, 245, 245);
122 border: 1px solid silver;
123 padding: 10px;
124 margin: 10px 0 10px 0;
125 font-family: "Andale Mono", monospace;
126 }
127
128
129 table.index { border: 1px #00007f; }
130 table.index td { text-align: left; vertical-align: top; }
131
132 #container {
133 margin-left: 1em;
134 margin-right: 1em;
135 background-color: #f0f0f0;
136 }
137
138 #product {
139 text-align: center;
140 border-bottom: 1px solid #cccccc;
141 background-color: #ffffff;
142 }
143
144 #product big {
145 font-size: 2em;
146 }
147
148 #main {
149 background-color: #f0f0ff;
150 border-left: 2px solid #cccccc;
151 }
152
153 #navigation {
154 float: left;
155 width: 14em;
156 vertical-align: top;
157 background-color: #f0f0f0;
158 overflow: visible;
159 }
160
161 #navigation h2 {
162 background-color:#e7e7e7;
163 font-size:1.1em;
164 color:#000000;
165 text-align: left;
166 padding:0.2em;
167 border-top:1px solid #dddddd;
168 border-bottom:1px solid #dddddd;
169 }
170
171 #navigation ul
172 {
173 font-size:1em;
174 list-style-type: none;
175 margin: 1px 1px 10px 1px;
176 }
177
178 #navigation li {
179 text-indent: -1em;
180 display: block;
181 margin: 3px 0px 0px 22px;
182 }
183
184 #navigation li li a {
185 margin: 0px 3px 0px -1em;
186 }
187
188 #content {
189 margin-left: 14em;
190 width: 40em;
191 padding: 1em;
192 border-left: 2px solid #cccccc;
193 border-right: 2px solid #cccccc;
194 background-color: #f0ffff;
195 }
196
197 #about {
198 clear: both;
199 padding: 5px;
200 border-top: 2px solid #cccccc;
201 background-color: #ffffff;
202 }
203
204 @media print {
205 body {
206 font: 12pt "Times New Roman", "TimeNR", Times, serif;
207 }
208 a { font-weight: bold; color: #004080; text-decoration: underline; }
209
210 #main {
211 background-color: #ffffff;
212 border-left: 0px;
213 }
214
215 #container {
216 margin-left: 2%;
217 margin-right: 2%;
218 background-color: #ffffff;
219 }
220
221 #content {
222 padding: 1em;
223 background-color: #ffffff;
224 }
225
226 #navigation {
227 display: none;
228 }
229 pre.example {
230 font-family: "Andale Mono", monospace;
231 font-size: 10pt;
232 page-break-inside: avoid;
233 }
234 }
235
236 table.module_list td {
237 border-width: 1px;
238 padding: 3px;
239 border-style: solid;
240 border-color: #cccccc;
241 }
242 table.module_list td.name { background-color: #f0f0f0; }
243 table.module_list td.summary { width: 100%; }
244
245 table.file_list {
246 border-width: 1px;
247 border-style: solid;
248 border-color: #cccccc;
249 border-collapse: collapse;
250 }
251 table.file_list td {
252 border-width: 1px;
253 padding: 3px;
254 border-style: solid;
255 border-color: #cccccc;
256 }
257
258 table.file_list td.name { background-color: #fff0ff; }
259
260 table.file_list td.summary { width: 100%; }
261
262 table.function_list {
263 border-width: 1px;
264 border-style: solid;
265 border-color: #aaaaaa;
266 border-collapse: collapse;
267 }
268 table.function_list td {
269 border-width: 1px;
270 padding: 3px;
271 border-style: solid;
272 border-color: #eeeeee;
273 }
274
275 table.function_list td.name { background-color: #f0f0ff; }
276
277 table.function_list td.summary { width: 100%; }
278
279 table.table_list {
280 border-width: 1px;
281 border-style: solid;
282 border-color: #cccccc;
283 border-collapse: collapse;
284 }
285 table.table_list td {
286 border-width: 1px;
287 padding: 3px;
288 border-style: solid;
289 border-color: #cccccc;
290 }
291
292 table.table_list td.name { background-color: #f0f0f0; }
293
294 table.table_list td.summary { width: 100%; }
295
296 dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
297 dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
298 dl.table h3, dl.function h3 {font-size: .95em;}
0 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
1 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html>
3 <head>
4 <title>$(ldoc.title)</title>
5 <link rel="stylesheet" href="$(ldoc.css)" type="text/css" />
6 </head>
7 <body>
8
9 <div id="container">
10
11 <div id="product">
12 <div id="product_logo"></div>
13 <div id="product_name"><big><b></b></big></div>
14 <div id="product_description"></div>
15 </div> <!-- id="product" -->
16
17 <div id="main">
18
19 # local iter = ldoc.modules.iter
20 # local M = ldoc.markup
21
22 <!-- Menu -->
23
24 # local function no_spaces(s) return s:gsub('%s','_') end
25 # local function use_li(ls)
26 # if #ls > 1 then return '<li>','</li>' else return '','' end
27 # end
28 # local function display_name(item)
29 # if item.type == 'function' then return item.name..'&nbsp;'..item.args
30 # else return item.name end
31 # end
32
33
34 <div id="navigation">
35 <h1>$(ldoc.project)</h1>
36 # if not ldoc.single then
37 <ul>
38 <li><a href="../index.html">Index</a></li>
39 </ul>
40 # else
41 <p>$(M(ldoc.description))</p>
42 # end
43
44 # if module then
45 <hr/>
46 <ul>
47 # for kind, items in module.kinds() do
48 # for item in items() do
49 <li><a href="$(item.name)">$(display_name(item))</a></li>
50 # end
51 # end
52 </ul>
53 # end
54
55 </div>
56
57 <div id="content">
58
59 # if module then
60
61 <h1>Module <code>$(module.name)</code></h1>
62
63 <p>$(M(module.summary))</p>
64 <p>$(M(module.description))</p>
65
66 <br/>
67 <br/>
68
69 # --- currently works for both Functions and Tables. The params field either contains
70 # --- function parameters or table fields.
71 # for kind, items in module.kinds() do
72 <dl class="function">
73 # for item in items() do
74 <dt>
75 <a name = "$(item.name)"></a>
76 <strong>$(display_name(item))</strong>
77 </dt>
78 <dd>
79 $(M(item.summary))
80 $(M(item.description))
81
82 # if item.usage then
83 # local li,il = use_li(item.usage)
84 <h3>Usage:</h3>
85 <ul>
86 # for usage in iter(item.usage) do
87 $(li)<pre class="example">$(usage)</pre>$(il)
88 # end -- for
89 </ul>
90 # end -- if usage
91
92 # if item.see then
93 # local li,il = use_li(item.see)
94 <h3>see also:</h3>
95 <ul>
96 # for see in iter(item.see) do
97 $(li)<a href="$(see.mod).html#$(see.name)">$(see.label)</a>$(il)
98 # end -- for
99 </ul>
100 # end -- if see
101 </dd>
102 # end -- for items
103 </dl>
104 # end -- for kinds
105
106 # else -- if module
107
108 # if ldoc.description then
109 <p>$(M(ldoc.description))</p>
110 # end
111
112 # for kind, mods in ldoc.kinds() do
113 <h2>$(kind)</h2>
114 # kind = kind:lower()
115 # for m in mods() do
116 <table class="module_list">
117 <tr>
118 <td class="name"><a href="$(no_spaces(kind))/$(m.name).html">$(m.name)</a></td>
119 <td class="summary">$(M(m.summary))</td>
120 </tr>
121 # end -- for modules
122 </table>
123 # end -- for kinds
124 # end -- if module
125
126 </div> <!-- id="content" -->
127 </div> <!-- id="main" -->
128 <div id="about">
129 </div> <!-- id="about" -->
130 </div> <!-- id="container" -->
131 </body>
132 </html>
133
0 ---------------------------
1 -- Test module providing bonzo.dog.
2 -- Rest is a longer description
3 -- @class module
4 -- @name mod1
5
6 --- zero function. Two new ldoc features here; item types
7 -- can be used directly as tags, and aliases for tags
8 -- can be defined in config.lp.
9 -- @function zero_fun
10 -- @p k1 first
11 -- @p k2 second
12
13 --- first function. Some description
14 -- @param p1 first parameter
15 -- @param p2 second parameter
16 function mod1.first_fun(p1,p2)
17 end
18
19 -------------------------
20 -- second function.
21 -- @param ... var args!
22 function mod1.second_function(...)
23 end
24
25 ------------
26 -- third function. Can also provide parameter comments inline,
27 -- provided they follow this pattern.
28 function mod1.third_function(
29 alpha, -- correction A
30 beta, -- correction B
31 gamma -- factor C
32 )
33 end
34
35 -----
36 -- A useful macro. This is an example of a custom 'kind'.
37 -- @macro first_macro
38 -- @see second_function
39
40 ---- general configuration table
41 -- @table config
42 -- @field A alpha
43 -- @field B beta
44 -- @field C gamma
45 mod1.config = {
46 A = 1,
47 B = 2,
48 C = 3
49 }
50
51 --[[--
52 Another function. Using a Lua block comment
53 @param p a parameter
54 ]]
55 function mod1.zero_function(p)
56 end
57
58
59
0 ---------------
1 -- Markdown-flavoured and very simple no-structure style.
2 --
3 -- Here the idea is to structure the document entirely with [Markdown]().
4 --
5 -- Using the default markdown processor can be a little irritating: you are
6 -- required to give a blank line before starting lists. The default stylesheet
7 -- is not quite right, either.
8 --
9 module 'mod'
10
11 --- Combine two strings _first_ and _second_ in interesting ways.
12 function combine(first,second)
13 end
14
15 --- Split a string _str_. Returns the first part and the second part, so that
16 -- `combine(first,second)` is equal to _s_.
17 function split(s)
18 end
19
20 --- Split a string _text_ into a table.
21 -- Returns:
22 --
23 -- - `name` the name of the text
24 -- - `pairs` an array of pairs
25 -- - `key`
26 -- - `value`
27 -- - `length`
28 --
29
30 function split_table (text)
31 end
32
33 --- A table of useful constants.
34 --
35 -- - `alpha` first correction factor
36 -- - `beta` second correction factor
37 --
38 -- @table constants
39
40