Codebase list lua-ldoc / ce2d6b8
Merge tag 'upstream/1.4.6' real 1.4.6 release Julian Wollrath 7 years ago
34 changed file(s) with 770 addition(s) and 806 deletion(s). Raw diff Collapse all Expand all
0 ## Version 1.4.4
1
2 ### Features
3 * better Lua 5.3 support
4 * handles tables with integer_keys as well as string keys
5 * `--testing` - version and date does not change
6 * `--no_args_infer` to completely switch off argument inference and parsing
7 * `custom_csv` option to specify extra CSS file
8 * explicit warnings if we cannot deduce item from following code
9 * modules may return a single _function_ (see tests/funmod.lua)
10 * honours the `SOURCE_DATE_EPOCH` environment variable
11 * Moonscript fat arrow and auto-assign ctor support
12 * Better Discount support. All varieties including Debian lua-discount package (binding to libmarkdown2)
13 * prettier output for `ldoc -m` on Unix
14 * updated global builtin documentation
15
16
17 ### Fixes
18 * consistently using Unix line-endings
19 * `--fatalwarnings` now also works with parser errors (#255)
20 * user-specific temporary directory for expanding templates
21 * blank line after comment of code block suppressed (#240)
22 * comments at end of code blocks were not highlighting
23 * strip left spaces from usage code (#191)
24 * don't parse `module` if it's a field name (e.g `foo.module()`)
25 * temporary files on Windows fix
26
027 ## Version 1.4.3
128
229 ### Features
1717 Otherwise, the output is very similar, which is no accident since the HTML templates are
1818 based directly on LuaDoc. You can ship your own customized templates and style sheets with
1919 your [own project](http://nilnor.github.com/textui/docs/) (also see Graham Hannington's
20 documentation for [Lua for z/OS](lua4z.com/doc/)). LDoc comes with three extra themes; 'pale'
20 documentation for [Lua for z/OS](http://lua4z.com/doc/)). LDoc comes with three extra themes; 'pale'
2121 for those who like whitespace, 'one' for one-column output, and 'fixed' for a fixed navigation
2222 bar down the left side.
2323
9191 * **@classmod** Like **@module** but describing a class
9292 * **@submodule** A file containing definitions that you wish to put into the named _master_ module
9393 * **@script** A Lua program
94 * **@author** (multiple), **copyright**, **@license**, **@release** only used for _project-level_ tags like **@module**
94 * **@author** (multiple), **@copyright**, **@license**, **@release** only used for _project-level_ tags like **@module**
9595 * **@function**, **@lfunction**. Functions inside a module
9696 * **@param** formal arguments of a function (multiple)
9797 * **@return** returned values of a function (multiple)
250250
251251 ### Doing modules the Lua 5.1 way
252252
253 As an alternative to using the 'module' tag as described before, you
253 As an alternative to using the 'module' tag as described previously, you
254254 can still start your modules the Lua 5.1 way:
255255
256256 --- solvers for common equations.
260260 common to see less 'magic' ways of creating modules, as seen in the description
261261 of the 'module' tag previously with the explicitely returned module table.
262262
263 #### Repeating tags
263 ### Repeating tags
264264
265265 Tags like 'param' and 'return' can be specified multiple times, whereas a type
266266 tag like 'function' can only occur once in a comment.
310310 --- we need to give a hint here for foo
311311 -- @local here
312312 function foo(...) .. end
313
313
314314 ### Alternative way of specifying tags
315315
316316 Since 1.3, LDoc allows the use of _colons_ instead of @.
317317
318318 --- a simple function.
319 -- string name person's name
319 -- string: name person's name
320320 -- int: age age of person
321321 -- !person: person object
322322 -- treturn: ?string
328328
329329 (see @{colon.lua}, rendered [here](http://stevedonovan.github.io/ldoc/examples/colon))
330330
331 ### Which files are processed
331 ## Sections
332
333 LDoc supports _explicit_ sections. By default, the implicit sections correspond to the pre-existing
334 types in a module: 'Functions', 'Tables' and 'Fields' (There is another default section
335 'Local Functions' which only appears if LDoc is invoked with the `--all` flag.) But new
336 sections can be added; the first mechanism is when you @{Adding_new_Tags|define a new type}
337 (say 'macro'). Then a new section ('Macros') is created to contain these types.
338
339 There is also a way to declare ad-hoc sections using the **@section** tag.
340 The need occurs when a module has a lot of functions that need to be put into logical
341 sections.
342
343 --- File functions.
344 -- Useful utilities for opening foobar format files.
345 -- @section file
346
347 --- open a file
348 ...
349
350 --- read a file
351 ...
352
353 --- Encoding operations.
354 -- Encoding foobar output in different ways.
355 -- @section encoding
356
357 ...
358
359 A section doc-comment has the same structure as a normal doc-comment; the summary is used as
360 the new section title, and the description will be output at the start of the function
361 details for that section; the name is not used, but must be unique.
362
363 Sections appear under 'Contents' on the left-hand side. See the
364 [winapi](http://stevedonovan.github.com/winapi/api.html) documentation for an example of how
365 this looks.
366
367 Arguably a module writer should not write such very long modules, but it is not the job of
368 the documentation tool to limit the programmer!
369
370 A specialized kind of section is `type`: it is used for documenting classes. The functions
371 (or fields) within a type section are considered to be the methods of that class.
372
373 --- A File class.
374 -- @type File
375
376 ....
377 --- get the modification time.
378 -- @return standard time since epoch
379 function File:mtime()
380 ...
381 end
382
383 (In an ideal world, we would use the word 'class' instead of 'type', but this would conflict
384 with the LuaDoc `class` tag.)
385
386 A section continues until the next section is found, `@section end`, or end of file.
387
388 You can put items into _implicit sections_ using **@within**. This allows you to put
389 adjacent functions in different sections, so that you are not forced to order your code
390 in a particular way.
391
392 With 1.4, there is another option for documenting classes, which is the top-level type
393 `classmod`. It is intended for larger classes which are implemented within one module,
394 and the advantage that methods can be put into sections.
395
396 Sometimes a module may logically span several files, which can easily happen with large
397 There will be a master module with name
398 'foo' and other files which when required add functions to that module. If these files have
399 a **@submodule** tag, their contents will be placed in the master module documentation. However,
400 a current limitation is that the master module must be processed before the submodules.
401
402 See the `tests/submodule` example for how this works in practice.
403
404 ## Which files are processed?
332405
333406 By default, LDoc will process any file ending in '.lua' or '.luadoc' in a specified
334407 directory; you may point it to a single file as well. A 'project' usually consists of many
345418
346419 If you want to document scripts, then use **@script** instead of **@module**. New with 1.4 is
347420 **@classmod** which is a module which exports a single class.
348
349421
350422 ## See References
351423
491563 the template is expanded. Generally configuration variables that effect template expansion
492564 are modifiable in this way. For instance, if you wish that the contents of a particular module
493565 be sorted, then `@set sort=true` will do it _just_ for that module.
494
495 ## Sections
496
497 LDoc supports _explicit_ sections. By default, the implicit sections correspond to the pre-existing
498 types in a module: 'Functions', 'Tables' and 'Fields' (There is another default section
499 'Local Functions' which only appears if LDoc is invoked with the `--all` flag.) But new
500 sections can be added; the first mechanism is when you @{Adding_new_Tags|define a new type}
501 (say 'macro'). Then a new section ('Macros') is created to contain these types.
502
503 There is also a way to declare ad-hoc sections using the **@section** tag.
504 The need occurs when a module has a lot of functions that need to be put into logical
505 sections.
506
507 --- File functions.
508 -- Useful utilities for opening foobar format files.
509 -- @section file
510
511 --- open a file
512 ...
513
514 --- read a file
515 ...
516
517 --- Encoding operations.
518 -- Encoding foobar output in different ways.
519 -- @section encoding
520
521 ...
522
523 A section doc-comment has the same structure as a normal doc-comment; the summary is used as
524 the new section title, and the description will be output at the start of the function
525 details for that section; the name is not used, but must be unique.
526
527 Sections appear under 'Contents' on the left-hand side. See the
528 [winapi](http://stevedonovan.github.com/winapi/api.html) documentation for an example of how
529 this looks.
530
531 Arguably a module writer should not write such very long modules, but it is not the job of
532 the documentation tool to limit the programmer!
533
534 A specialized kind of section is `type`: it is used for documenting classes. The functions
535 (or fields) within a type section are considered to be the methods of that class.
536
537 --- A File class.
538 -- @type File
539
540 ....
541 --- get the modification time.
542 -- @return standard time since epoch
543 function File:mtime()
544 ...
545 end
546
547 (In an ideal world, we would use the word 'class' instead of 'type', but this would conflict
548 with the LuaDoc `class` tag.)
549
550 A section continues until the next section is found, `@section end`, or end of file.
551
552 You can put items into an implicit section using **@within**. This allows you to put
553 adjacent functions in different sections, so that you are not forced to order your code
554 in a particular way.
555
556 With 1.4, there is another option for documenting classes, which is the top-level type
557 `classmod`. It is intended for larger classes which are implemented within one module,
558 and the advantage that methods can be put into sections.
559
560 Sometimes a module may logically span several files, which can easily happen with large
561 There will be a master module with name
562 'foo' and other files which when required add functions to that module. If these files have
563 a **@submodule** tag, their contents will be placed in the master module documentation. However,
564 a current limitation is that the master module must be processed before the submodules.
565
566 See the `tests/submodule` example for how this works in practice.
567
568 ## Differences from LuaDoc
569
570 LDoc only does 'module' documentation, so the idea of 'files' is redundant.
571
572 One added convenience is that it is easier to name entities:
573
574 ------------
575 -- a simple module.
576 -- (LuaDoc)
577 -- @class module
578 -- @name simple
579
580 becomes:
581
582 ------------
583 -- a simple module.
584 -- (LDoc)
585 -- @module simple
586
587 This is because type names (like 'function', 'module', 'table', etc) can function as tags.
588 LDoc also provides a means to add new types (e.g. 'macro') using a configuration file which
589 can be shipped with the source. If you become bored with typing 'param' repeatedly then you
590 can define an alias for it, such as 'p'. This can also be specified in the configuration file.
591
592 LDoc will also work with C/C++ files, since extension writers clearly have the same
593 documentation needs as Lua module writers.
594
595 LDoc allows you to attach a _type_ to a parameter or return value with `tparam` or `treturn`,
596 and gives the documenter the option to use Markdown to parse the contents of comments.
597 You may also include code examples which will be prettified, and readme files which will be
598 rendered with Markdown and contain prettified code blocks.
599566
600567 ## Adding new Tags
601568
721688
722689 1.4 introduces basic support for [Moonscript](http://moonscript.org). Moonscript module
723690 conventions are just the same as Lua, except for an explicit class construct.
724 @{list.moon} shows how **@classmod** can declare modules that export one class, with metamethods
691 @{List.moon} shows how **@classmod** can declare modules that export one class, with metamethods
725692 and methods put implicitly into a separate section.
726693
727694 ## Basic Usage
12461213 when using Markdown. When explicit will expand non-references in backticks into `<code>` elements
12471214 - `plain` set to true if `format` is set but you don't want code comments processed
12481215 - `wrap` set to true if you want to allow long names to wrap in the summaries
1249 - `manual_url` point to an alternative or local location for the Lua manual, e.g.
1250 'file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html'
1216 - `manual_url(url)` point to an alternative or local location for the Lua manual, e.g.
1217 'manual_url file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html'. Remember it is a function!
12511218 - `no_summary` suppress the Contents summary
12521219 - `custom_tags` define some new tags, which will be presented after the function description.
12531220 The format is `{<name>,[title=<name>,}{hidden=false,}{format=nil}}`. For instance
12541221 `custom_tags={'remark',title='Remarks'}` will add a little `Remarks` section to the docs for any function
12551222 containing this tag. `format` can be a function - if not present the default formatter will be used,
12561223 e.g. Markdown
1257 - `custom_see_handler` function that filters see-references
1258 - `custom_display_name_handler` function that formats an item's name. The arguments are the item
1224 - `custom_see_handler(pat,handler)` function that filters see-references
1225 - `custom_display_name_handler(item, default_handler)` function that formats an item's name. The arguments are the item
12591226 and the default function used to format the name. For example, to show an icon or label beside any
12601227 function tagged with a certain tag:
12611228
12741241 - `no_space_before_args` set to `true` if you do not want a space between a function's name and its arguments.
12751242 - `template_escape` overrides the usual '#' used for Lua code in templates.
12761243 This needs to be changed if the output format is Markdown, for instance.
1244 - `user_keywords` A list of keywords that will be marked in "prettified" code. Useful if
1245 you want to display your own functions in a special way. Each keyword may be styled differently
1246 (using CSS). Only works when `pretty` is set to 'lua' (the default).
1247 - `postprocess_html` function that allows a last-minute modification to the produced HTML page.
1248 The arguments are the raw HTML that's intended to be written out (a string), and the module object.
1249 The string this function returns will be what's actually gets written out.
12771250
12781251 _Available functions are:_
12791252
22 module 'global'
33
44 ---
5 -- Issues an error when the value of its argument `v` is false (i.e.,
6 -- nil or false); otherwise, returns all its arguments. `message` is an error
7 -- message; when absent, it defaults to "assertion failed!"
5 -- Issues an error when its argument `v` is false.
6 -- That is, nil or false. otherwise, returns all its arguments.
7 -- `message` is an error when absent, it defaults to "assertion failed!"
88 function assert(v , message) end
99
1010 ---
2020 -- want to control the step size you must experimentally tune the value of
2121 -- * "arg". Returns true if the step finished a collection cycle.
2222 -- * "setpause": sets `arg` as the new value for the *pause* of the collector
23 -- (see §2.10). Returns the previous value for *pause*.
23 -- (see 2.10). Returns the previous value for *pause*.
2424 -- * "setstepmul": sets `arg` as the new value for the *step multiplier*
25 -- of the collector (see §2.10). Returns the previous value for *step*.
25 -- of the collector (see 2.10). Returns the previous value for *step*.
2626 --
2727 function collectgarbage(opt , arg) end
2828
3535 function dofile(filename) end
3636
3737 ---
38 -- Terminates the last protected function called and returns `message`
39 -- as the error message. Function `error` never returns.
38 -- Terminates the last protected function called.
39 -- Returns `message` as the error message.
40 -- Function `error` never returns.
4041 -- Usually, `error` adds some information about the error position at the
4142 -- beginning of the message. The `level` argument specifies how to get the
4243 -- error position. With level 1 (the default), the error position is where the
4849 ---
4950 -- A global variable (not a function) that holds the global environment
5051 -- (that is, `_G._G = _G`). Lua itself does not use this variable; changing
51 -- its value does not affect any environment, nor vice-versa. (Use `setfenv`
52 -- to change environments.)
53 -- function _G end
54 -- * `_G._G`: _G._G
55
56 ---
57 -- Returns the current environment in use by the function.
58 -- `f` can be a Lua function or a number that specifies the function at that
59 -- stack level: Level 1 is the function calling `getfenv`. If the given
60 -- function is not a Lua function, or if `f` is 0, `getfenv` returns the
61 -- global environment. The default for `f` is 1.
62 function getfenv(f) end
52 -- its value does not affect any environment, nor vice-versa. (Set `__ENV`
53 -- to change environments in functions)
54 -- @table _G
6355
6456 ---
6557 -- If `object` does not have a metatable, returns nil. Otherwise, if the
6860 function getmetatable(object) end
6961
7062 ---
71 -- Returns three values: an iterator function, the table `t`, and 0,
63 -- For iterating over sequences. Returns three values: an iterator function, the table `t`, and 0,
7264 -- so that the construction
7365 -- for i,v in ipairs(t) do *body* end
7466 -- will iterate over the pairs (`1,t[1]`), (`2,t[2]`), ..., up to the
7668 function ipairs(t) end
7769
7870 ---
79 -- Loads a chunk using function `func` to get its pieces. Each call to
80 -- `func` must return a string that concatenates with previous results. A
81 -- return of an empty string, nil, or no value signals the end of the chunk.
82 -- If there are no errors, returns the compiled chunk as a function; otherwise,
83 -- returns nil plus the error message. The environment of the returned function
84 -- is the global environment.
85 -- `chunkname` is used as the chunk name for error messages and debug
86 -- information. When absent, it defaults to "`=(load)`".
87 function load(func , chunkname) end
88
89 ---
90 -- Similar to `load`, but gets the chunk from file `filename` or from the
71 -- Loads a chunk.
72 -- If `ld` is a string, the chunk is this string.
73 -- If `ld` is a function, load calls it repeatedly to get the chunk pieces. Each call to `ld` must return a
74 -- string that concatenates with previous results. A return of an empty string, nil, or no value
75 -- signals the end of the chunk.
76 -- If there are no syntactic errors, returns the compiled chunk as a function;
77 -- otherwise, returns nil plus the error message.
78 -- If the resulting function has upvalues, the first upvalue is set to the value of the global environment or to `env`,
79 -- if that parameter is given. When loading main chunks, the first upvalue will be the`_ENV` variable (see 2.2).
80 -- `source` is used as the source of the chunk for error messages and debug information (see 4.9).
81 -- When absent, it defaults to `ld`, if `ld` is a string, or to "=(load)" otherwise.
82 -- The string `mode` controls whether the chunk can be text or binary (that is, a precompiled chunk).
83 -- It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text).
84 -- The default is "bt"
85 function load (ld [, source [, mode [, env]]]) end
86
87 ---
88 -- Similar to `load`, but gets the chunk from file `filename`. Or from the
9189 -- standard input, if no file name is given.
92 function loadfile(filename) end
93
94 ---
95 -- Similar to `load`, but gets the chunk from the given string.
96 -- To load and run a given string, use the idiom
97 -- assert(loadstring(s))()
98 -- When absent, `chunkname` defaults to the given string.
99 function loadstring(string , chunkname) end
90 function loadfile (filename [, mode [, env]]]) end
10091
10192 ---
10293 -- Allows a program to traverse all fields of a table. Its first argument is
120111 function next(table , index) end
121112
122113 ---
114 -- For iterating over all key-value pairs of a table.
123115 -- Returns three values: the `next` function, the table `t`, and nil,
124116 -- so that the construction
125117 -- for k,v in pairs(t) do *body* end
126 -- will iterate over all key–value pairs of table `t`.
118 -- will iterate over all key-value pairs of table `t`.
127119 -- See function `next` for the caveats of modifying the table during its
128120 -- traversal.
129121 function pairs(t) end
138130 function pcall(f, arg1, ...) end
139131
140132 ---
141 -- Receives any number of arguments, and prints their values to `stdout`,
142 -- using the `tostring` function to convert them to strings. `print` is not
133 --Prints any number of values to `stdout`.
134 -- Uses the `tostring` function to convert them to strings. `print` is not
143135 -- intended for formatted output, but only as a quick way to show a value,
144136 -- typically for debugging. For formatted output, use `string.format`.
145137 function print(...) end
146138
147139 ---
148 -- Checks whether `v1` is equal to `v2`, without invoking any
140 -- Checks whether `v1` is equal to `v2`. Does not invoke any
149141 -- metamethod. Returns a boolean.
150142 function rawequal(v1, v2) end
151143
152144 ---
153 -- Gets the real value of `table[index]`, without invoking any
145 -- Gets the real value of `table[index]`. Does not invoke any
154146 -- metamethod. `table` must be a table; `index` may be any value.
155147 function rawget(table, index) end
156148
157149 ---
158 -- Sets the real value of `table[index]` to `value`, without invoking any
150 -- Sets the real value of `table[index]` to `value`. Does not invoke any
159151 -- metamethod. `table` must be a table, `index` any value different from nil,
160152 -- and `value` any Lua value.
161153 -- This function returns `table`.
162154 function rawset(table, index, value) end
163155
164156 ---
165 -- If `index` is a number, returns all arguments after argument number
157 -- Returns all arguments after argument number
166158 -- `index`. Otherwise, `index` must be the string `"#"`, and `select` returns
167159 -- the total number of extra arguments it received.
168160 function select(index, ...) end
169
170 ---
171 -- Sets the environment to be used by the given function. `f` can be a Lua
172 -- function or a number that specifies the function at that stack level: Level
173 -- 1 is the function calling `setfenv`. `setfenv` returns the given function.
174 -- As a special case, when `f` is 0 `setfenv` changes the environment of the
175 -- running thread. In this case, `setfenv` returns no values.
176 function setfenv(f, table) end
177161
178162 ---
179163 -- Sets the metatable for the given table. (You cannot change the metatable
192176 -- letter '`A`' (in either upper or lower case) represents 10, '`B`' represents
193177 -- 11, and so forth, with '`Z`' representing 35. In base 10 (the default),
194178 -- the number can have a decimal part, as well as an optional exponent part
195 -- (see §2.1). In other bases, only unsigned integers are accepted.
196 function tonumber(e , base) end
197
198 ---
199 -- Receives an argument of any type and converts it to a string in a
200 -- reasonable format. For complete control of how numbers are converted, use
201 -- `string.format`.
179 -- (see 2.1). In other bases, only unsigned integers are accepted.
180 function tonumber(e [, base]) end
181
182 ---
183 -- Converts any value to a string in a reasonable format.
184 -- For complete control of how numbers are converted, use `string.format`.
202185 -- If the metatable of `e` has a `"__tostring"` field, then `tostring` calls
203186 -- the corresponding value with `e` as argument, and uses the result of the
204187 -- call as its result.
212195 function type(v) end
213196
214197 ---
215 -- Returns the elements from the given table. This function is equivalent to
216 -- return list[i], list[i+1], ..., list[j]
217 -- except that the above code can be written only for a fixed number of
218 -- elements. By default, `i` is 1 and `j` is the length of the list, as
219 -- defined by the length operator (see §2.5.5).
220 function unpack(list , i , j) end
221
222 ---
223198 -- A global variable (not a function) that holds a string containing the
224199 -- current interpreter version. The current contents of this variable is
225200 -- "`Lua 5.1`".
226 -- function _VERSION end
227 -- * `_G._VERSION`: _G._VERSION
201 -- @table _VERSION
228202
229203 ---
230204 -- This function is similar to `pcall`, except that you can set a new
237211 -- also returns all results from the call, after this first result. In case
238212 -- of any error, `xpcall` returns false plus the result from `err`.
239213 function xpcall(f, err) end
240
241 ---
242 -- Creates a module. If there is a table in `package.loaded[name]`,
243 -- this table is the module. Otherwise, if there is a global table `t`
244 -- with the given name, this table is the module. Otherwise creates a new
245 -- table `t` and sets it as the value of the global `name` and the value of
246 -- `package.loaded[name]`. This function also initializes `t._NAME` with the
247 -- given name, `t._M` with the module (`t` itself), and `t._PACKAGE` with the
248 -- package name (the full module name minus last component; see below). Finally,
249 -- `module` sets `t` as the new environment of the current function and the
250 -- new value of `package.loaded[name]`, so that `require` returns `t`.
251 -- If `name` is a compound name (that is, one with components separated by
252 -- dots), `module` creates (or reuses, if they already exist) tables for each
253 -- component. For instance, if `name` is `a.b.c`, then `module` stores the
254 -- module table in field `c` of field `b` of global `a`.
255 -- This function can receive optional *options* after the module name, where
256 -- each option is a function to be applied over the module.
257 function module(name , ...) end
258214
259215 ---
260216 -- Loads the given module. The function starts by looking into the
22 local tools = require 'ldoc.tools'
33 local globals = {}
44 local lua52 = _VERSION:match '5.2'
5 local lua53 = _VERSION:match '5.3'
56
67
78 globals.functions = {
89 assert = true,
910 collectgarbage = true,
1011 dofile = true,
12 error = true,
1113 getmetatable = true,
1214 setmetatable = true,
1315 pairs = true,
3133 }
3234 local functions = globals.functions
3335
34 if not lua52 then
36 if lua52 or lua53 then
37 functions.rawlen = true
38 else
3539 functions.setfenv = true
3640 functions.getfenv = true
3741 functions.unpack = true
38 else
39 functions.rawlen = true
4042 end
4143
4244 local manual, fun_ref
4648 fun_ref = manual..'pdf-'
4749 end
4850
49 if lua52 then
51 if lua53 then
52 globals.tables = {
53 io = '6.8',
54 package = '6.3',
55 math = '6.7',
56 os = '6.9',
57 string = '6.4',
58 table = '6.6',
59 coroutine = '6.2',
60 debug = '6.10'
61 }
62 globals.set_manual_url 'https://www.lua.org/manual/5.3/manual.html'
63 elseif lua52 then
5064 globals.tables = {
5165 io = '6.8',
5266 package = '6.3',
5771 coroutine = '6.2',
5872 debug = '6.10'
5973 }
60 globals.set_manual_url 'http://www.lua.org/manual/5.2/manual.html'
74 globals.set_manual_url 'https://www.lua.org/manual/5.2/manual.html'
6175 else
6276 globals.tables = {
6377 io = '5.7',
6983 coroutine = '5.2',
7084 debug = '5.9'
7185 }
72 globals.set_manual_url 'http://www.lua.org/manual/5.1/manual.html'
86 globals.set_manual_url 'https://www.lua.org/manual/5.1/manual.html'
7387 end
7488
7589 local file_methods = {
170170 -- definition of what a lowercase letter is depends on the current locale.
171171 function string.upper(s) end
172172
173 ---
174 -- (5.3) Returns a binary string containing the values v1, v2, etc. packed (that is, serialized in binary form)
175 --- according to the format string fmt (see 6.4.2).
176 function string.pack (fmt, v1, v2, ···) end
177
178 ---
179 -- (5.3) Returns the size of a string resulting from string.pack with the given format.
180 -- The format string cannot have the variable-length options 's' or 'z' (see 6.4.2).
181 function string.packsize (fmt) end
182
183 ---
184 -- (5.3) Returns the values packed in string s (see string.pack) according to the format string fmt (see 6.4.2).
185 -- An optional pos marks where to start reading in s (default is 1)
186 -- After the read values, this function also returns the index of the first unread byte in s.
187 function string.unpack (fmt, s [, pos]) end
188
173189 return string
174190
1818 function table.insert(table, pos, value) end
1919
2020 ---
21 -- Returns the largest positive numerical index of the given table, or
22 -- zero if the table has no positive numerical indices. (To do its job this
23 -- function does a linear traversal of the whole table.)
24 function table.maxn(table) end
25
26 ---
2721 -- Removes from `table` the element at position `pos`, shifting down other
2822 -- elements to close the space, if necessary. Returns the value of the removed
2923 -- element. The default value for `pos` is `n`, where `n` is the length of the
3125 -- `t`.
3226 function table.remove(table , pos) end
3327
28 ---
29 -- Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "n" with
30 -- the total number of parameters. Note that the resulting table may not be a sequence.
31 function table.pack (···) end
3432 ---
3533 -- Sorts table elements in a given order,
3634 -- *in-place*, from `table[1]` to `table[n]`, where `n` is the length of the
4038 -- is not given, then the '<' operator will be used.
4139 function table.sort(table , comp) end
4240
41 ---
42 -- Returns the elements from the given table. This function is equivalent to
43 -- return list[i], list[i+1], ..., list[j]
44 -- except that the above code can be written only for a fixed number of
45 -- elements. By default, `i` is 1 and `j` is the length of the list, as
46 -- defined by the length operator (see §2.5.5).
47 function unpack(list , i , j) end
48
4349 return table
0 --- This library provides basic support for UTF-8 encoding.
1 -- @module utf8
2
3 local utf8 = {}
4
5 ---
6 -- Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence and returns
7 -- a string with the concatenation of all these sequences.
8 function utf8.char (...) end
9
10 ---
11 -- The pattern "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" , which matches exactly one
12 -- UTF-8 byte sequence, assuming that the subject is a valid UTF-8 string.
13 -- @field charpattern
14
15 ---
16 -- Iterate over all characters in string.
17 --
18 -- for p, c in utf8.codes(s) do body end
19 --
20 -- will iterate over all characters in string s, with p being the position (in bytes) and c the code point
21 -- of each character. It raises an error if it meets any invalid byte sequence.
22 function utf8.codes (s) end
23
24 ---
25 -- Returns the codepoints (as integers) from all characters in s that start between byte position i and j (both included).
26 -- The default for i is 1 and for j is i. It raises an error if it meets any invalid byte sequence.
27 function utf8.codepoint (s [, i [, j]]) end
28
29 ---
30 -- Returns the number of UTF-8 characters in string s that start between positions i and j (both inclusive).
31 -- The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus
32 -- the position of the first invalid byte.
33 function utf8.len (s [, i [, j]]) end
34
35 ---
36 -- Returns the position (in bytes) where the encoding of the n-th character of s (counting from position i) starts.
37 -- A negative n gets characters before position i. The default for i is 1 when n is non-negative
38 -- and #s + 1 otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character from the end
39 -- of the string.
40 -- If the specified character is neither in the subject nor right after its end, the function returns nil.
41 --
42 -- As a special case, when n is 0 the function returns the start of the encoding of the character that contains the i-th byte of s.
43 --
44 -- This function assumes that s is a valid UTF-8 string.
45 function utf8.offset (s, n [, i]) end
46
47
55 local utils = require 'pl.utils'
66 local List = require 'pl.List'
77 local Map = require 'pl.Map'
8 local text = require 'pl.text'
89
910 local doc = {}
1011 local global = require 'ldoc.builtin.globals'
2223 -- - 'T' tags which represent a type, like 'function' (TAG_TYPE)
2324 local known_tags = {
2425 param = 'M', see = 'M', comment = 'M', usage = 'ML', ['return'] = 'M', field = 'M', author='M',set='M';
25 class = 'id', name = 'id', pragma = 'id', alias = 'id', within = 'id',
26 class = 'id', name = 'id', pragma = 'id', alias = 'id',
2627 copyright = 'S', summary = 'S', description = 'S', release = 'S', license = 'S',
27 fixme = 'S', todo = 'S', warning = 'S', raise = 'S', charset = 'S',
28 fixme = 'S', todo = 'S', warning = 'S', raise = 'S', charset = 'S', within = 'S',
2829 ['local'] = 'N', export = 'N', private = 'N', constructor = 'N', static = 'N',include = 'S',
2930 -- project-level
3031 module = 'T', script = 'T', example = 'T', topic = 'T', submodule='T', classmod='T', file='T',
140141 tags:add('name',item_name..'-'..tag..acount)
141142 acount = acount + 1
142143 return true
143 elseif tag == 'return' then
144 elseif tags.error and tag == 'return' then
144145 last_item:set_tag(tag,value)
145146 end
146147 end
293294 end
294295 item.display_name = display_name
295296 this_mod.section = item
297 -- the purpose of this little hack is to properly distinguish
298 -- between built-in kinds and any user-defined kinds.
296299 this_mod.kinds:add_kind(display_name,display_name..' ',nil,item)
297300 this_mod.sections:append(item)
298301 this_mod.sections.by_name[lookup_name:gsub('%A','_')] = item
535538 if avalue then value = avalue..' '..value end
536539 if amod then
537540 modifiers = modifiers or {}
541 local value_tokens = utils.split(value)
538542 for m,v in pairs(amod) do
539 local idx = v:match('^%$(%d+)')
543 local idx = tonumber(v:match('^%$(%d+)'))
540544 if idx then
541545 v, value = value:match('(%S+)(.*)')
546 -- v = value_tokens[idx]
547 -- value_tokens[idx] = ''
542548 end
543549 modifiers[m] = v
544550 end
551 -- value = table.concat(value_tokens, ' ')
545552 end
546553 else -- has to be a function that at least returns tag, value
547554 return alias(tags,value,modifiers)
614621 tags.see = read_del(tags,'see')
615622 if tags.see then
616623 tags.see = tools.identifier_list(tags.see)
624 end
625 if self.usage then
626 for i = 1,#self.usage do
627 local usage = self.usage[i]:gsub('^%s*\n','')
628 self.usage[i] = text.dedent(usage)
629 end
617630 end
618631 if doc.project_level(self.type) then
619632 -- we are a module, so become one!
912925 local struct_return_type = '*'
913926
914927 function Item:build_return_groups()
928 local quote = tools.quote
915929 local modifiers = self.modifiers
916930 local retmod = modifiers['return']
917931 local groups = List()
10181032 if type(file) == 'table' then require 'pl.pretty'.dump(file); file = '?' end
10191033 file = file or '?'
10201034 io.stderr:write(file,':',self.lineno or '1',': ',self.name or '?',': ',msg,'\n')
1035 Item.had_warning = true
10211036 return nil
10221037 end
10231038
11961211 -- and try to to resolve this.
11971212 function Module:resolve_references(modules)
11981213 local found = List()
1199 for item in self.items:iter() do
1214 -- Resolve see references in item. Can be Module or Item type.
1215 local function resolve_item_references(item)
12001216 local see = item.tags.see
12011217 if see then -- this guy has @see references
12021218 item.see = List()
12111227 end
12121228 end
12131229 end
1230
1231 resolve_item_references(self); -- Resolve module-level see references.
1232 for item in self.items:iter() do
1233 resolve_item_references(item); -- Resolve item-level see references.
1234 end
12141235 -- mark as found, so we don't waste time re-searching
12151236 for f in found:iter() do
12161237 f[1].tags.see:remove_value(f[2])
12431264 end
12441265 end
12451266
1267 -- ANSI colour codes for making important stuff BOLD
1268 -- (but not on Windows)
1269 local bold,default = '\x1B[1m','\x1B[0m'
1270 if utils.dir_separator == '\\' then
1271 bold,default = '',''
1272 end
1273
12461274 function Module:dump(verbose)
12471275 if not doc.project_level(self.type) then return end
12481276 print '----'
1249 print(self.type..':',self.name,self.summary)
1277 print(self.type..':',bold..self.name,self.summary..default)
12501278 if self.description then print(self.description) end
12511279 dump_tags (self.tags)
12521280 for item in self.items:iter() do
12711299 end
12721300 if verbose then
12731301 print()
1302 io.write(bold)
12741303 print(self.type,name)
1304 io.write(default)
12751305 print(self.summary)
12761306 if self.description and self.description:match '%S' then
12771307 print 'description:'
12781308 print(self.description)
12791309 end
1280 if #self.params > 0 then
1310 if self.params and #self.params > 0 then
12811311 print 'parameters:'
12821312 for _,p in ipairs(self.params) do
12831313 print('',p,self.params.map[p])
12911321 end
12921322 dump_tags(self.tags)
12931323 else
1294 print('* '..name..' - '..self.summary)
1324 print('* '..bold..name..default..' - '..self.summary)
12951325 end
12961326 end
12971327
0 return [[
1
2 /* styles for prettification of source */
3 pre .comment { color: #558817; }
4 pre .constant { color: #a8660d; }
5 pre .escape { color: #844631; }
6 pre .keyword { color: #aa5050; font-weight: bold; }
7 pre .library { color: #0e7c6b; }
8 pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
9 pre .string { color: #8080ff; }
10 pre .number { color: #f8660d; }
11 pre .operator { color: #2239a8; font-weight: bold; }
12 pre .preprocessor, pre .prepro { color: #a33243; }
13 pre .global { color: #800080; }
14 pre .user-keyword { color: #800080; }
15 pre .prompt { color: #558817; }
16 pre .url { color: #272fc2; text-decoration: underline; }
17
18 ]]
0 return [[
1 /* BEGIN RESET
2
3 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
4 Code licensed under the BSD License:
5 http://developer.yahoo.com/yui/license.html
6 version: 2.8.2r1
7 */
8 html {
9 color: #000;
10 background: #FFF;
11 }
12 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 {
13 margin: 0;
14 padding: 0;
15 }
16 table {
17 border-collapse: collapse;
18 border-spacing: 0;
19 }
20 fieldset,img {
21 border: 0;
22 }
23 address,caption,cite,code,dfn,em,strong,th,var,optgroup {
24 font-style: inherit;
25 font-weight: inherit;
26 }
27 del,ins {
28 text-decoration: none;
29 }
30 li {
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 ]]
0 return [==[
1 /* BEGIN RESET
2
3 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
4 Code licensed under the BSD License:
5 http://developer.yahoo.com/yui/license.html
6 version: 2.8.2r1
7 */
8 html {
9 color: #000;
10 background: #FFF;
11 }
12 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 {
13 margin: 0;
14 padding: 0;
15 }
16 table {
17 border-collapse: collapse;
18 border-spacing: 0;
19 }
20 fieldset,img {
21 border: 0;
22 }
23 address,caption,cite,code,dfn,em,strong,th,var,optgroup {
24 font-style: inherit;
25 font-weight: inherit;
26 }
27 del,ins {
28 text-decoration: none;
29 }
30 li {
31 list-style: disc;
32 margin-left: 20px;
33 }
34 caption,th {
35 text-align: left;
36 }
37 h1,h2,h3,h4,h5,h6 {
38 font-size: 100%;
39 font-weight: bold;
40 }
41 q:before,q:after {
42 content: '';
43 }
44 abbr,acronym {
45 border: 0;
46 font-variant: normal;
47 }
48 sup {
49 vertical-align: baseline;
50 }
51 sub {
52 vertical-align: baseline;
53 }
54 legend {
55 color: #000;
56 }
57 input,button,textarea,select,optgroup,option {
58 font-family: inherit;
59 font-size: inherit;
60 font-style: inherit;
61 font-weight: inherit;
62 }
63 input,button,textarea,select {*font-size:100%;
64 }
65 /* END RESET */
0 return require('ldoc.html._reset_css') .. [[
661
672 body {
683 margin-left: 1em;
8823
8924 h1 {
9025 font-size: 1.5em;
91 margin: 0 0 20px 0;
26 margin: 20px 0 20px 0;
9227 }
9328 h2, h3, h4 { margin: 15px 0 10px 0; }
9429 h2 { font-size: 1.25em; }
11449 padding-top: 1em;
11550 }
11651
117 pre.example {
118 background-color: rgb(245, 245, 245);
119 border: 1px solid silver;
120 padding: 10px;
121 margin: 10px 0 10px 0;
122 font-family: "Andale Mono", monospace;
123 font-size: .85em;
124 }
125
12652 pre {
12753 background-color: rgb(245, 245, 245);
128 border: 1px solid silver;
54 border: 1px solid #C0C0C0; /* silver */
12955 padding: 10px;
13056 margin: 10px 0 10px 0;
13157 overflow: auto;
13258 font-family: "Andale Mono", monospace;
13359 }
13460
61 pre.example {
62 font-size: .85em;
63 }
13564
13665 table.index { border: 1px #00007f; }
13766 table.index td { text-align: left; vertical-align: top; }
291220 background-color: #FF9;
292221 }
293222
294 /* styles for prettification of source */
295 pre .comment { color: #558817; }
296 pre .constant { color: #a8660d; }
297 pre .escape { color: #844631; }
298 pre .keyword { color: #aa5050; font-weight: bold; }
299 pre .library { color: #0e7c6b; }
300 pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
301 pre .string { color: #8080ff; }
302 pre .number { color: #f8660d; }
303 pre .operator { color: #2239a8; font-weight: bold; }
304 pre .preprocessor, pre .prepro { color: #a33243; }
305 pre .global { color: #800080; }
306 pre .prompt { color: #558817; }
307 pre .url { color: #272fc2; text-decoration: underline; }
308 ]==]
309
310
223 ]]
224 .. require('ldoc.html._code_css')
0 return [[
1 /* BEGIN RESET
2
3 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
4 Code licensed under the BSD License:
5 http://developer.yahoo.com/yui/license.html
6 version: 2.8.2r1
7 */
8 html {
9 color: #000;
10 background: #FFF;
11 }
12 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 {
13 margin: 0;
14 padding: 0;
15 }
16 table {
17 border-collapse: collapse;
18 border-spacing: 0;
19 }
20 fieldset,img {
21 border: 0;
22 }
23 address,caption,cite,code,dfn,em,strong,th,var,optgroup {
24 font-style: inherit;
25 font-weight: inherit;
26 }
27 del,ins {
28 text-decoration: none;
29 }
30 li {
31 list-style: bullet;
32 margin-left: 20px;
33 }
34 caption,th {
35 text-align: left;
36 }
37 h1,h2,h3,h4,h5,h6 {
38 font-size: 100%;
39 font-weight: bold;
40 }
41 q:before,q:after {
42 content: '';
43 }
44 abbr,acronym {
45 border: 0;
46 font-variant: normal;
47 }
48 sup {
49 vertical-align: baseline;
50 }
51 sub {
52 vertical-align: baseline;
53 }
54 legend {
55 color: #000;
56 }
57 input,button,textarea,select,optgroup,option {
58 font-family: inherit;
59 font-size: inherit;
60 font-style: inherit;
61 font-weight: inherit;
62 }
63 input,button,textarea,select {*font-size:100%;
64 }
65 /* END RESET */
0 return require('ldoc.html._reset_css') .. [[
661
672 body {
683 margin-left: 1em;
11449 padding-top: 1em;
11550 }
11651
117 pre.example {
52 pre {
11853 background-color: rgb(245, 245, 245);
119 border: 1px solid silver;
120 padding: 10px;
121 margin: 10px 0 10px 0;
122 font-family: "Andale Mono", monospace;
123 font-size: .85em;
124 }
125
126 pre {
127 background-color: rgb(245,245,255); // rgb(245, 245, 245);
128 border: 1px solid #cccccc; //silver;
54 border: 1px solid #C0C0C0; /* silver */
12955 padding: 10px;
13056 margin: 10px 0 10px 0;
13157 overflow: auto;
13258 font-family: "Andale Mono", monospace;
13359 }
13460
61 pre.example {
62 font-size: .85em;
63 }
13564
13665 table.index { border: 1px #00007f; }
13766 table.index td { text-align: left; vertical-align: top; }
299228 background-color: #FF9;
300229 }
301230
302 /* styles for prettification of source */
303 pre .comment { color: #558817; }
304 pre .constant { color: #a8660d; }
305 pre .escape { color: #844631; }
306 pre .keyword { color: #aa5050; font-weight: bold; }
307 pre .library { color: #0e7c6b; }
308 pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
309 pre .string { color: #8080ff; }
310 pre .number { color: #f8660d; }
311 pre .operator { color: #2239a8; font-weight: bold; }
312 pre .preprocessor, pre .prepro { color: #a33243; }
313 pre .global { color: #800080; }
314 pre .prompt { color: #558817; }
315 pre .url { color: #272fc2; text-decoration: underline; }
316231 ]]
232 .. require('ldoc.html._code_css')
55 <head>
66 <title>$(ldoc.title)</title>
77 <link rel="stylesheet" href="$(ldoc.css)" type="text/css" />
8 # if ldoc.custom_css then -- add custom CSS file if configured.
9 <link rel="stylesheet" href="$(ldoc.custom_css)" type="text/css" />
10 # end
811 </head>
912 <body>
1013
6467 # for kind, mods, type in ldoc.kinds() do
6568 # if ldoc.allowed_in_contents(type,module) then
6669 <h2>$(kind)</h2>
67 <ul class="$(kind=='Topics' and '' or 'nowrap'">
68 # for mod in mods() do local name = ldoc.module_name(mod)
70 <ul class="$(kind=='Topics' and '' or 'nowrap')">
71 # for mod in mods() do local name = display_name(mod)
6972 # if mod.name == this_mod then
7073 <li><strong>$(name)</strong></li>
7174 # else
8992 # if module.tags.include then
9093 $(M(ldoc.include_file(module.tags.include)))
9194 # end
95 # if module.see then
96 # local li,il = use_li(module.see)
97 <h3>See also:</h3>
98 <ul>
99 # for see in iter(module.see) do
100 $(li)<a href="$(ldoc.href(see))">$(see.label)</a>$(il)
101 # end -- for
102 </ul>
103 # end -- if see
92104 # if module.usage then
93105 # local li,il = use_li(module.usage)
94106 <h3>Usage:</h3>
133145 # local show_parms = show_return
134146 # for kind, items in module.kinds() do
135147 # local kitem = module.kinds:get_item(kind)
136 <h2><a name="$(no_spaces(kind))"></a>$(kind)</h2>
148 # local has_description = kitem and ldoc.descript(kitem) ~= ""
149 <h2 class="section-header $(has_description and 'has-description')"><a name="$(no_spaces(kind))"></a>$(kind)</h2>
137150 $(M(module.kinds:get_section_description(kind),nil))
138151 # if kitem then
139 $(M(ldoc.descript(kitem),kitem))
152 # if has_description then
153 <div class="section-description">
154 $(M(ldoc.descript(kitem),kitem))
155 </div>
156 # end
140157 # if kitem.usage then
141158 <h3>Usage:</h3>
142159 <pre class="example">$(ldoc.prettify(kitem.usage[1]))</pre>
147164 <dt>
148165 <a name = "$(item.name)"></a>
149166 <strong>$(display_name(item))</strong>
150 # if ldoc.prettify_files then
167 # if ldoc.prettify_files and ldoc.is_file_prettified[item.module.file.filename] then
151168 <a style="float:right;" href="$(ldoc.source_ref(item))">line $(item.lineno)</a>
152169 # end
153170 </dt>
288305 </div> <!-- id="content" -->
289306 </div> <!-- id="main" -->
290307 <div id="about">
291 <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
308 <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc $(ldoc.version)</a></i>
292309 <i style="float:right;">Last updated $(ldoc.updatetime) </i>
293310 </div> <!-- id="about" -->
294311 </div> <!-- id="container" -->
0 return [==[
1 /* BEGIN RESET
2
3 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
4 Code licensed under the BSD License:
5 http://developer.yahoo.com/yui/license.html
6 version: 2.8.2r1
7 */
8 html {
9 color: #000;
10 background: #FFF;
11 }
12 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 {
13 margin: 0;
14 padding: 0;
15 }
16 table {
17 border-collapse: collapse;
18 border-spacing: 0;
19 }
20 fieldset,img {
21 border: 0;
22 }
23 address,caption,cite,code,dfn,em,strong,th,var,optgroup {
24 font-style: inherit;
25 font-weight: inherit;
26 }
27 del,ins {
28 text-decoration: none;
29 }
30 li {
31 list-style: bullet;
32 margin-left: 20px;
33 }
34 caption,th {
35 text-align: left;
36 }
37 h1,h2,h3,h4,h5,h6 {
38 font-size: 100%;
39 font-weight: bold;
40 }
41 q:before,q:after {
42 content: '';
43 }
44 abbr,acronym {
45 border: 0;
46 font-variant: normal;
47 }
48 sup {
49 vertical-align: baseline;
50 }
51 sub {
52 vertical-align: baseline;
53 }
54 legend {
55 color: #000;
56 }
57 input,button,textarea,select,optgroup,option {
58 font-family: inherit;
59 font-size: inherit;
60 font-style: inherit;
61 font-weight: inherit;
62 }
63 input,button,textarea,select {*font-size:100%;
64 }
65 /* END RESET */
0 return require('ldoc.html._reset_css') .. [[
661
672 body {
683 margin-left: 1em;
10843 font-family: "Andale Mono", monospace;
10944 padding-top: 1em;
11045 }
111
112 pre.example {
113 background-color: rgb(245, 245, 245);
114 border: 1px solid silver;
115 padding: 10px;
116 margin: 10px 0 10px 0;
117 font-family: "Andale Mono", monospace;
118 font-size: .85em;
119 }
120
121 pre {
122 background-color: rgb(245, 245, 245);
123 border: 1px solid silver;
124 padding: 10px;
125 margin: 10px 0 10px 0;
126 font-family: "Andale Mono", monospace;
127 }
128
129
46
47 pre {
48 background-color: rgb(245, 245, 245);
49 border: 1px solid #C0C0C0; /* silver */
50 padding: 10px;
51 margin: 10px 0 10px 0;
52 overflow: auto;
53 font-family: "Andale Mono", monospace;
54 }
55
56 pre.example {
57 font-size: .85em;
58 }
59
13060 table.index { border: 1px #00007f; }
13161 table.index td { text-align: left; vertical-align: top; }
13262
267197 dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
268198 dl.table h3, dl.function h3 {font-size: .95em;}
269199
270 /* styles for prettification of source */
271 pre .comment { color: #558817; }
272 pre .constant { color: #a8660d; }
273 pre .escape { color: #844631; }
274 pre .keyword { color: #aa5050; font-weight: bold; }
275 pre .library { color: #0e7c6b; }
276 pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
277 pre .string { color: #8080ff; }
278 pre .number { color: #f8660d; }
279 pre .operator { color: #2239a8; font-weight: bold; }
280 pre .preprocessor, pre .prepro { color: #a33243; }
281 pre .global { color: #800080; }
282 pre .prompt { color: #558817; }
283 pre .url { color: #272fc2; text-decoration: underline; }
284 ]==]
200 ]]
201 .. require('ldoc.html._code_css')
0 return [[/* 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 */
0 return require('ldoc.html._reset_css') .. [[
651
662 body {
673 margin-left: 1em;
11349 padding-top: 1em;
11450 }
11551
116 pre.example {
52 pre {
11753 background-color: rgb(245, 245, 245);
118 border: 1px solid silver;
119 padding: 10px;
120 margin: 10px 0 10px 0;
121 font-family: "Andale Mono", monospace;
122 font-size: .85em;
123 }
124
125 pre {
126 background-color: rgb(245,245,255); // rgb(245, 245, 245);
127 border: 1px solid #cccccc; //silver;
54 border: 1px solid #C0C0C0; /* silver */
12855 padding: 10px;
12956 margin: 10px 0 10px 0;
13057 overflow: auto;
13158 font-family: "Andale Mono", monospace;
13259 }
13360
61 pre.example {
62 font-size: .85em;
63 }
13464
13565 table.index { border: 1px #00007f; }
13666 table.index td { text-align: left; vertical-align: top; }
290220 background-color: #FF9;
291221 }
292222
293 /* styles for prettification of source */
294 pre .comment { color: #558817; }
295 pre .constant { color: #a8660d; }
296 pre .escape { color: #844631; }
297 pre .keyword { color: #aa5050; font-weight: bold; }
298 pre .library { color: #0e7c6b; }
299 pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
300 pre .string { color: #8080ff; }
301 pre .number { color: #f8660d; }
302 pre .operator { color: #2239a8; font-weight: bold; }
303 pre .preprocessor, pre .prepro { color: #a33243; }
304 pre .global { color: #800080; }
305 pre .prompt { color: #558817; }
306 pre .url { color: #272fc2; text-decoration: underline; }
307223 ]]
224 .. require('ldoc.html._code_css')
9292
9393 -- Item descriptions come from combining the summary and description fields
9494 function ldoc.descript(item)
95 return (item.summary or '?')..' '..(item.description or '')
95 return tools.join(' ', item.summary, item.description)
9696 end
9797
9898 function ldoc.module_name (mod)
175175 end
176176
177177 function ldoc.default_display_name(item)
178 -- Project-level items:
179 if doc.project_level(item.type) then
180 return ldoc.module_name(item)
181 end
182 -- Module-level items:
178183 local name = item.display_name or item.name
179184 if item.type == 'function' or item.type == 'lfunction' then
180185 if not ldoc.no_space_before_args then
272277 quit("template not found at '"..args.template.."' Use -l to specify directory containing ldoc.ltp")
273278 end
274279
275 local css = ldoc.css
280 -- Runs a template on a module to generate HTML page.
281 local function templatize(template_str, ldoc, module)
282 local out, err = template.substitute(template_str, {
283 ldoc = ldoc,
284 module = module,
285 _escape = ldoc.template_escape
286 })
287 if not out then
288 quit(("template failed for %s: %s"):format(
289 module and module.name or ldoc.output or "index",
290 err))
291 end
292 if ldoc.postprocess_html then
293 out = ldoc.postprocess_html(out, module)
294 end
295 return cleanup_whitespaces(out)
296 end
297
298 local css, custom_css = ldoc.css, ldoc.custom_css
276299 ldoc.output = args.output
277300 ldoc.ipairs = ipairs
278301 ldoc.pairs = pairs
293316 save_and_set_ldoc(ldoc.module.tags.set)
294317 end
295318 set_charset(ldoc)
296 local out,err = template.substitute(module_template,{
297 ldoc = ldoc,
298 module = ldoc.module,
299 _escape = ldoc.template_escape
300 })
319 local out = templatize(module_template, ldoc, ldoc.module)
301320 ldoc.root = false
302 if not out then quit("template failed: "..err) end
303321 restore_ldoc()
304322
305323 check_directory(args.dir) -- make sure output directory is ok
308326
309327 if css then -- has CSS been copied?
310328 check_file(args.dir..css, path.join(args.style,css))
329 end
330
331 if custom_css then -- has custom CSS been copied?
332 check_file(args.dir..custom_css, custom_css)
311333 end
312334
313335 -- write out the module index
329351 -- e.g. when reading a topic the other Topics will be listed first.
330352 if css then
331353 ldoc.css = '../'..css
354 end
355 if custom_css then
356 ldoc.custom_css = '../'..custom_css
332357 end
333358 for m in mods:iter() do
334359 local kind, lkind, modules = unpack(m)
346371 if ldoc.body and m.postprocess then
347372 ldoc.body = m.postprocess(ldoc.body)
348373 end
349 out,err = template.substitute(module_template,{
350 module=m,
351 ldoc = ldoc,
352 _escape = ldoc.template_escape
353 })
354 if not out then
355 quit('template failed for '..m.name..': '..err)
356 else
357 out = cleanup_whitespaces(out)
358 writefile(args.dir..lkind..'/'..m.name..args.ext,out)
359 end
374 local out = templatize(module_template, ldoc, m)
375 writefile(args.dir..lkind..'/'..m.name..args.ext,out)
360376 restore_ldoc()
361377 end
362378 end
150150 parser = parse_lua_function_header
151151 elseif t == 'iden' then
152152 local name,t,v = tools.get_fun_name(tok,v)
153 if t ~= '=' then return nil end -- probably invalid code...
153 if t ~= '=' then return nil,"not 'name = function,table or value'" end
154154 t,v = tnext(tok)
155155 if t == 'keyword' and v == 'function' then -- case [2]
156156 tnext(tok) -- skip '('
188188 parse_lua_table(tags,tok)
189189 end
190190 else
191 return nil
192 end
191 return nil,'not returning function or table'
192 end
193 else
194 return nil,"not 'name=value' or 'return value'"
193195 end
194196 return parser, is_local, case
195197 end
319321 self.start_comment_ = '^%s*%-%-%-+' -- used for doc comment line start
320322 self.block_comment = '^%-%-%[=*%[%-+' -- used for block doc comments
321323 self.end_comment_ = '[^%-]%-%-+\n$' ---- exclude --- this kind of comment ---
322 self.method_call = '.'
324 self.method_call = '\\'
323325 self:finalize()
326 end
327
328 --- much like Lua, BUT auto-assign parameters start with @
329 function Moon:extract_arg (tl,idx)
330 idx = idx or 1
331 local auto_assign = tl[idx][1] == '@'
332 if auto_assign then idx = idx + 1 end
333 local res = tl[idx][2]
334 return res
324335 end
325336
326337 function Moon:item_follows (t,v,tok)
337348 tags:add('name',name)
338349 end
339350 elseif t == '=' or t == ':' then -- function/method
351 local fat = false
340352 t,v = tnext(tok)
341353 return function(tags,tok)
342354 if not tags.name then
343355 tags:add('name',name)
344356 end
345357 if t == '(' then
346 tags.formal_args,t,v = tools.get_parameters(tok)
358 tags.formal_args,t,v = tools.get_parameters(tok,')',',',self)
347359 else
348360 tags.formal_args = List()
349361 end
362 t,v = tnext(tok)
350363 tags:add('class','function')
351 if t == '=' then
352 tags.formal_args:insert(1,'self')
353 tags.formal_args.comments = {self=''}
364 if t == '>' then
365 --~ tags.formal_args:insert(1,'self')
366 --~ tags.formal_args.comments = {self=''}
367 else
368 tags.static = true
354369 end
355370 end
356371 else
357 return nil
372 return nil, "expecting '=' or ':'"
358373 end
359374 end
360375 end
304304 {'^`[^`]+`',bdump},
305305 {'^%-%-%[(=*)%[.-%]%1%]',cdump},
306306 {'^%-%-.-\n',cdump},
307 {'^%-%-.-$',cdump},
307308 {'^%[(=*)%[.-%]%1%]',sdump_l},
308309 {'^==',tdump},
309310 {'^~=',tdump},
353354 {STRING1,chdump},
354355 {STRING2,sdump},
355356 {'^//.-\n',cdump},
357 {'^//.-$',cdump},
356358 {'^/%*.-%*/',cdump},
357359 {'^==',tdump},
358360 {'^!=',tdump},
8989 end
9090 local title = line:match (title_pat)
9191 if title then
92 --- Windows line endings are the cockroaches of text
93 title = title:gsub('\r$','')
9294 -- Markdown allows trailing '#'...
9395 title = title:gsub('%s*#+$','')
9496 sections[L] = F:add_document_section(lstrip(title))
168170 end
169171 pretty_code (code,fence)
170172 line = getline() -- skip fence
173 if not line then break end
171174 end
172175 indent, line = indent_line(line)
173176 if indent >= 4 then -- indented code block
230233 end
231234 return ok and markdown
232235 end,
233 discount = generic_formatter,
236 discount = function(format)
237 local ok, markdown = pcall(require, 'discount')
238 if ok then
239 if 'function' == type(markdown) then
240 -- lua-discount by A.S. Bradbury, https://luarocks.org/modules/luarocks/lua-discount
241 elseif 'table' == type(markdown) and ('function' == type(markdown.compile) or 'function' == type(markdown.to_html)) then
242 -- discount by Craig Barnes, https://luarocks.org/modules/craigb/discount
243 -- result of apt-get install lua-discount (links against libmarkdown2)
244 local mysterious_debian_variant = markdown.to_html ~= nil
245 markdown = markdown.compile or markdown.to_html
246 return function(text)
247 local result, errmsg = markdown(text)
248 if result then
249 if mysterious_debian_variant then
250 return result
251 else
252 return result.body
253 end
254 else
255 io.stderr:write('LDoc discount failed with error ',errmsg)
256 io.exit(1)
257 end
258 end
259 else
260 ok = false
261 end
262 end
263 if not ok then
264 print('format: using built-in markdown')
265 ok, markdown = pcall(require, 'ldoc.markdown')
266 end
267 return ok and markdown
268 end,
234269 lunamark = function(format)
235270 local ok, lunamark = pcall(require, format)
236271 if ok then
318353 end
319354
320355
321 function markup.create (ldoc, format, pretty)
356 function markup.create (ldoc, format, pretty, user_keywords)
322357 local processor
323358 markup.plain = true
324359 if format == 'backtick' then
328363 backtick_references = ldoc.backtick_references
329364 global_context = ldoc.package and ldoc.package .. '.'
330365 prettify.set_prettifier(pretty)
366 prettify.set_user_keywords(user_keywords)
331367
332368 markup.process_reference = function(name,istype)
333369 if local_context == 'none.' and not name:match '%.' then
2121 -- followed by the value, which may extend over several lines.
2222 local luadoc_tag = '^%s*@(%w+)'
2323 local luadoc_tag_value = luadoc_tag..'(.*)'
24 local luadoc_tag_mod_and_value = luadoc_tag..'%[(.*)%](.*)'
24 local luadoc_tag_mod_and_value = luadoc_tag..'%[([^%]]*)%](.*)'
2525
2626 -- assumes that the doc comment consists of distinct tag lines
2727 local function parse_at_tags(text)
120120 return self._order:iter()
121121 end
122122
123 local function comment_contains_tags (comment,args)
124 return (args.colon and comment:find ': ') or (not args.colon and comment:find '@')
125 end
126
123127 -- This takes the collected comment block, and uses the docstyle to
124128 -- extract tags and values. Assume that the summary ends in a period or a question
125129 -- mark, and everything else in the preamble is the description.
192196 function F:warning (msg,kind,line)
193197 kind = kind or 'warning'
194198 line = line or lineno()
199 Item.had_warning = true
195200 io.stderr:write(fname..':'..line..': '..msg,'\n')
196201 end
197202
224229 return nil
225230 end
226231 end
227 if lang.parse_module_call and t ~= 'comment'then
228 while t and not (t == 'iden' and v == 'module') do
229 t,v = tnext(tok)
232 if lang.parse_module_call and t ~= 'comment' then
233 local prev_token
234 while t do
235 if prev_token ~= '.' and prev_token ~= ':' and t == 'iden' and v == 'module' then
236 break
237 end
238 prev_token = t
239 t, v = tnext(tok)
230240 end
231241 if not t then
232242 if not args.ignore then
235245 --return nil
236246 else
237247 mod,t,v = lang:parse_module_call(tok,t,v)
238 if mod ~= '...' then
248 if mod and mod ~= '...' then
239249 add_module(Tags.new{summary='(no description)'},mod,true)
240250 first_comment = false
241251 module_found = true
270280
271281 if t == 'space' then t,v = tnext(tok) end
272282
273 local item_follows, tags, is_local, case
283 local item_follows, tags, is_local, case, parse_error
274284 if ldoc_comment then
275285 comment = table.concat(comment)
276286 if comment:match '^%s*$' then
282292 first_comment = false
283293 else
284294 item_follows, is_local, case = lang:item_follows(t,v,tok)
285 end
286 if item_follows or comment:find '@' or comment:find ': ' then
295 if not item_follows then
296 parse_error = is_local
297 is_local = false
298 end
299 end
300
301 if item_follows or comment_contains_tags(comment,args) then
287302 tags = extract_tags(comment,args)
303
288304 -- explicitly named @module (which is recommended)
289305 if doc.project_level(tags.class) then
290306 module_found = tags.name
291307 -- might be a module returning a single function!
292308 if tags.param or tags['return'] then
293309 local parms, ret, summ = tags.param, tags['return'],tags.summary
310 local name = tags.name
294311 tags.param = nil
295312 tags['return'] = nil
296 tags.summary = nil
297 add_module(tags,tags.name,false)
313 tags['class'] = nil
314 tags['name'] = nil
315 add_module(tags,name,false)
298316 tags = {
299 summary = summ,
317 summary = '',
300318 name = 'returns...',
301319 class = 'function',
302320 ['return'] = ret,
307325 doc.expand_annotation_item(tags,current_item)
308326 -- if the item has an explicit name or defined meaning
309327 -- then don't continue to do any code analysis!
328 -- Watch out for the case where there are field or param tags
329 -- but no class, since these will be fixed up later as module/class
330 -- entities
331 if (tags.field or tags.param) and not tags.class then
332 parse_error = false
333 end
310334 if tags.name then
311335 if not tags.class then
312336 F:warning("no type specified, assuming function: '"..tags.name.."'")
313337 tags:add('class','function')
314338 end
315 item_follows, is_local = false, false
316 elseif lang:is_module_modifier (tags) then
339 item_follows, is_local, parse_error = false, false, false
340 elseif args.no_args_infer then
341 F:error("No name and type provided (no_args_infer)")
342 elseif lang:is_module_modifier (tags) then
317343 if not item_follows then
318344 F:warning("@usage or @export followed by unknown code")
319345 break
330356 end
331357 end
332358 end
359 if parse_error then
360 F:warning('definition cannot be parsed - '..parse_error)
361 end
333362 end
334363 -- some hackery necessary to find the module() call
335364 if not module_found and ldoc_comment then
358387 if item_follows then -- parse the item definition
359388 local err = item_follows(tags,tok)
360389 if err then F:error(err) end
390 elseif parse_error then
391 F:warning('definition cannot be parsed - '..parse_error)
361392 else
362393 lang:parse_extra(tags,tok,case)
363394 end
33 -- A module reference to an example `test-fun.lua` would look like
44 -- `@{example:test-fun}`.
55 local List = require 'pl.List'
6 local tablex = require 'pl.tablex'
67 local globals = require 'ldoc.builtin.globals'
78 local prettify = {}
9
10 local user_keywords = {}
811
912 local escaped_chars = {
1013 ['&'] = '&amp;',
4649 io.stderr:write(fname..':'..tok:lineno()+initial_lineno..': '..msg,'\n')
4750 end
4851 }
52 local last_t, last_val
4953 local t,val = tok()
5054 if not t then return nil,"empty file" end
5155 while t do
5761 if globals.functions[val] or globals.tables[val] then
5862 t = 'global'
5963 end
60 if spans[t] then
64 if user_keywords[val] then
65 res:append(span('user-keyword keyword-' .. val,val))
66 elseif spans[t] then
6167 if t == 'comment' or t == 'backtick' then -- may contain @{ref} or `..`
6268 val = prettify.resolve_inline_references(val,error_reporter)
6369 end
6571 else
6672 res:append(val)
6773 end
74 last_t, last_val = t,val
6875 t,val = tok()
76 end
77 if last_t == 'comment' then
78 res[#res] = span('comment',last_val:gsub('\r*\n$',''))
6979 end
7080 local last = res[#res]
7181 if last:match '\n$' then
110120 end
111121 end
112122
123 function prettify.set_user_keywords(keywords)
124 if keywords then
125 user_keywords = tablex.makeset(keywords)
126 end
127 end
128
113129 return prettify
114130
1313 local append = table.insert
1414 local lexer = require 'ldoc.lexer'
1515 local quit = utils.quit
16 local lfs = require 'lfs'
1716
1817 -- at rendering time, can access the ldoc table from any module item,
1918 -- or the item itself if it's a module
108107 local group = item[self.fieldname] -- which wd be item's type or section
109108 local kname = self.klass.types_by_tag[group] -- the kind name
110109 if not self[kname] then
111 -- print(kname,group,self.fieldname)
112110 self[kname] = M.type_iterator (items,self.fieldname,group)
113111 self.klass.descriptions[kname] = description
114112 end
201199 return s:gsub('^%s+',''):gsub('%s+$','')
202200 end
203201
202 -- Joins strings using a separator.
203 --
204 -- Empty strings and nil arguments are ignored:
205 --
206 -- assert(join('+', 'one', '', 'two', nil, 'three') == 'one+two+three')
207 -- assert(join(' ', '', '') == '')
208 --
209 -- This is especially useful for the last case demonstrated above,
210 -- where "conventional" solutions (".." or table.concat) would result
211 -- in a spurious space.
212 function M.join(sep, ...)
213 local contents = {}
214 for i = 1, select('#', ...) do
215 local value = select(i, ...)
216 if value and value ~= "" then
217 contents[#contents + 1] = value
218 end
219 end
220 return table.concat(contents, sep)
221 end
222
204223 function M.check_directory(d)
205224 if not path.isdir(d) then
206 lfs.mkdir(d)
225 if not dir.makepath(d) then
226 quit("Could not create "..d.." directory")
227 end
207228 end
208229 end
209230
220241 end
221242
222243 function M.writefile(name,text)
223 local ok,err = utils.writefile(name,text)
244 local f,err = io.open(name,"wb")
245 --~ local ok,err = utils.writefile(name,text)
224246 if err then quit(err) end
247 f:write(text)
248 f:close()
225249 end
226250
227251 function M.name_of (lpath)
314338 return text:match("%s*%-%-+%s*(.*)")
315339 end
316340 extract_arg = function(tl,idx)
317 return value_of(tl[idx or 1])
341 idx = idx or 1
342 local res = value_of(tl[idx])
343 if res == '[' then -- we do allow array indices in tables now
344 res = '['..value_of(tl[idx + 1])..']'
345 end
346 return res
318347 end
319348 end
320349
+0
-61
ldoc-1.3.12-1.rockspec less more
0 package = "ldoc"
1 version = "1.3.12-1"
2
3 source = {
4 dir="ldoc",
5 url = "http://stevedonovan.github.com/files/ldoc-1.3.12.zip"
6 }
7
8 description = {
9 summary = "A Lua Documentation Tool",
10 detailed = [[
11 LDoc is a LuaDoc-compatible documentation generator which can also
12 process C extension source. Markdown may be optionally used to
13 render comments, as well as integrated readme documentation and
14 pretty-printed example files
15 ]],
16 homepage='http://stevedonovan.github.com/ldoc',
17 maintainer='steve.j.donovan@gmail.com',
18 license = "MIT/X11",
19 }
20
21
22 dependencies = {
23 "penlight","markdown"
24 }
25
26 build = {
27 type = "builtin",
28 modules = {
29 ["ldoc.tools"] = "ldoc/tools.lua",
30 ["ldoc.lang"] = "ldoc/lang.lua",
31 ["ldoc.parse"] = "ldoc/parse.lua",
32 ["ldoc.html"] = "ldoc/html.lua",
33 ["ldoc.lexer"] = "ldoc/lexer.lua",
34 ["ldoc.markup"] = "ldoc/markup.lua",
35 ["ldoc.prettify"] = "ldoc/prettify.lua",
36 ["ldoc.doc"] = "ldoc/doc.lua",
37 ["ldoc.html.ldoc_css"] = "ldoc/html/ldoc_css.lua",
38 ["ldoc.html.ldoc_ltp"] = "ldoc/html/ldoc_ltp.lua",
39 ["ldoc.html.ldoc_one_css"] = "ldoc/html/ldoc_one_css.lua",
40 ["ldoc.builtin.globals"] = "ldoc/builtin/globals.lua",
41 ["ldoc.builtin.coroutine"] = "ldoc/builtin/coroutine.lua",
42 ["ldoc.builtin.global"] = "ldoc/builtin/global.lua",
43 ["ldoc.builtin.debug"] = "ldoc/builtin/debug.lua",
44 ["ldoc.builtin.io"] = "ldoc/builtin/io.lua",
45 ["ldoc.builtin.lfs"] = "ldoc/builtin/lfs.lua",
46 ["ldoc.builtin.lpeg"] = "ldoc/builtin/lpeg.lua",
47 ["ldoc.builtin.math"] = "ldoc/builtin/math.lua",
48 ["ldoc.builtin.os"] = "ldoc/builtin/os.lua",
49 ["ldoc.builtin.package"] = "ldoc/builtin/package.lua",
50 ["ldoc.builtin.string"] = "ldoc/builtin/string.lua",
51 ["ldoc.builtin.table"] = "ldoc/builtin/table.lua",
52 },
53 install = {
54 bin = {
55 ldoc = "ldoc.lua"
56 }
57 }
58 }
59
60
+0
-61
ldoc-1.3.8-2.rockspec less more
0 package = "ldoc"
1 version = "1.3.8-2"
2
3 source = {
4 dir="ldoc",
5 url = "http://stevedonovan.github.com/files/ldoc-1.3.8.zip"
6 }
7
8 description = {
9 summary = "A Lua Documentation Tool",
10 detailed = [[
11 LDoc is a LuaDoc-compatible documentation generator which can also
12 process C extension source. Markdown may be optionally used to
13 render comments, as well as integrated readme documentation and
14 pretty-printed example files
15 ]],
16 homepage='http://stevedonovan.github.com/ldoc',
17 maintainer='steve.j.donovan@gmail.com',
18 license = "MIT/X11",
19 }
20
21
22 dependencies = {
23 "penlight","markdown"
24 }
25
26 build = {
27 type = "builtin",
28 modules = {
29 ["ldoc.tools"] = "ldoc/tools.lua",
30 ["ldoc.lang"] = "ldoc/lang.lua",
31 ["ldoc.parse"] = "ldoc/parse.lua",
32 ["ldoc.html"] = "ldoc/html.lua",
33 ["ldoc.lexer"] = "ldoc/lexer.lua",
34 ["ldoc.markup"] = "ldoc/markup.lua",
35 ["ldoc.prettify"] = "ldoc/prettify.lua",
36 ["ldoc.doc"] = "ldoc/doc.lua",
37 ["ldoc.html.ldoc_css"] = "ldoc/html/ldoc_css.lua",
38 ["ldoc.html.ldoc_ltp"] = "ldoc/html/ldoc_ltp.lua",
39 ["ldoc.html.ldoc_one_css"] = "ldoc/html/ldoc_one_css.lua",
40 ["ldoc.builtin.globals"] = "ldoc/builtin/globals.lua",
41 ["ldoc.builtin.coroutine"] = "ldoc/builtin/coroutine.lua",
42 ["ldoc.builtin.global"] = "ldoc/builtin/global.lua",
43 ["ldoc.builtin.debug"] = "ldoc/builtin/debug.lua",
44 ["ldoc.builtin.io"] = "ldoc/builtin/io.lua",
45 ["ldoc.builtin.lfs"] = "ldoc/builtin/lfs.lua",
46 ["ldoc.builtin.lpeg"] = "ldoc/builtin/lpeg.lua",
47 ["ldoc.builtin.math"] = "ldoc/builtin/math.lua",
48 ["ldoc.builtin.os"] = "ldoc/builtin/os.lua",
49 ["ldoc.builtin.package"] = "ldoc/builtin/package.lua",
50 ["ldoc.builtin.string"] = "ldoc/builtin/string.lua",
51 ["ldoc.builtin.table"] = "ldoc/builtin/table.lua",
52 },
53 install = {
54 bin = {
55 "ldoc.lua"
56 }
57 }
58 }
59
60
22
33 source = {
44 dir="LDoc",
5 url = "git://github.com/stevedonovan/LDoc.git"
5 url = "git+https://github.com/stevedonovan/LDoc.git"
66 }
77
88 description = {
3434 ["ldoc.prettify"] = "ldoc/prettify.lua",
3535 ["ldoc.markdown"] = "ldoc/markdown.lua",
3636 ["ldoc.doc"] = "ldoc/doc.lua",
37 ["ldoc.html.ldoc_ltp"] = "ldoc/html/ldoc_ltp.lua",
38 ["ldoc.html.ldoc_md_ltp"] = "ldoc/html/ldoc_md_ltp.lua",
3739 ["ldoc.html.ldoc_css"] = "ldoc/html/ldoc_css.lua",
38 ["ldoc.html.ldoc_ltp"] = "ldoc/html/ldoc_ltp.lua",
40 ["ldoc.html._code_css"] = "ldoc/html/_code_css.lua",
41 ["ldoc.html._reset_css"] = "ldoc/html/_reset_css.lua",
3942 ["ldoc.html.ldoc_one_css"] = "ldoc/html/ldoc_one_css.lua",
4043 ["ldoc.html.ldoc_pale_css"] = "ldoc/html/ldoc_pale_css.lua",
44 ["ldoc.html.ldoc_fixed_css"] = "ldoc/html/ldoc_fixed_css.lua",
4145 ["ldoc.builtin.globals"] = "ldoc/builtin/globals.lua",
4246 ["ldoc.builtin.coroutine"] = "ldoc/builtin/coroutine.lua",
4347 ["ldoc.builtin.global"] = "ldoc/builtin/global.lua",
5862 }
5963 }
6064 }
61
66 --
77 -- C/C++ support for Lua extensions is provided.
88 --
9 -- Available from LuaRocks as 'ldoc' and as a [Zip file](http://stevedonovan.github.com/files/ldoc-1.4.2.zip)
9 -- Available from LuaRocks as 'ldoc' and as a [Zip file](http://stevedonovan.github.com/files/ldoc-1.4.3.zip)
1010 --
1111 -- [Github Page](https://github.com/stevedonovan/ldoc)
1212 --
2626
2727 -- Penlight compatibility
2828 utils.unpack = utils.unpack or unpack or table.unpack
29
3029 local append = table.insert
31
3230 local lapp = require 'pl.lapp'
31
32 local version = '1.4.6'
3333
3434 -- so we can find our private modules
3535 app.require_here()
3636
3737 --- @usage
3838 local usage = [[
39 ldoc, a documentation generator for Lua, vs 1.4.3
39 ldoc, a documentation generator for Lua, vs ]]..version..[[
40
4041 -d,--dir (default doc) output directory
4142 -o,--output (default 'index') output name
4243 -v,--verbose verbose
5657 -X,--not_luadoc break LuaDoc compatibility. Descriptions may continue after tags.
5758 -D,--define (default none) set a flag to be used in config.ld
5859 -C,--colon use colon style
60 -N,--no_args_infer don't infer arguments from source
5961 -B,--boilerplate ignore first comment in source files
6062 -M,--merge allow module merging
6163 -S,--simple no return or params, no summary
6264 -O,--one one-column output layout
65 --date (default system) use this date in generated doc
6366 --dump debug output dump
6467 --filter (default none) filter output as Lua data (e.g pl.pretty.dump)
6568 --tags (default none) show all references to given tags, comma-separated
69 --fatalwarnings non-zero exit status on any warning
70 --testing reproducible build; no date or version on output
71
6672 <file> (string) source file or directory containing source
6773
6874 `ldoc .` reads options from an `config.ld` file in same directory;
98104 self.fieldname = 'type'
99105 end
100106
101
102
103107 local lua, cc = lang.lua, lang.cc
104108
105109 local file_types = {
117121 ------- ldoc external API ------------
118122
119123 -- the ldoc table represents the API available in `config.ld`.
120 local ldoc = { charset = 'UTF-8' }
124 local ldoc = { charset = 'UTF-8', version = version }
121125
122126 local known_types, kind_names = {}
123127
141145 ModuleMap:add_kind(lookup('function','Functions','Parameters'))
142146 ModuleMap:add_kind(lookup('table','Tables','Fields'))
143147 ModuleMap:add_kind(lookup('field','Fields'))
148 ModuleMap:add_kind(lookup('type','Types'))
144149 ModuleMap:add_kind(lookup('lfunction','Local Functions','Parameters'))
145150 ModuleMap:add_kind(lookup('annotation','Issues'))
146151
232237 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
233238 'no_space_before_args','parse_extra','no_lua_ref','sort_modules','use_markdown_titles',
234239 'unqualified', 'custom_display_name_handler', 'kind_names', 'custom_references',
235 'dont_escape_underscore','global_lookup','prettify_files','convert_opt'
240 'dont_escape_underscore','global_lookup','prettify_files','convert_opt', 'user_keywords',
241 'postprocess_html',
242 'custom_css','version',
243 'no_args_infer'
236244 }
237245 ldoc_contents = tablex.makeset(ldoc_contents)
238246
417425
418426 setup_package_base()
419427
428 override 'no_args_infer'
420429 override 'colon'
421430 override 'merge'
422431 override 'not_luadoc'
463472
464473 if type(args.file) == 'table' then
465474 -- this can only be set from config file so we can assume config is already read
466 process_all_files(args.file)
467
475 process_all_files(args.file)
476
468477 elseif path.isdir(args.file) then
469478 -- use any configuration file we find, if not already specified
470479 if not config_dir then
479488 end
480489 end
481490 end
482
491
483492 process_all_files({args.file})
484
493
485494 elseif path.isfile(args.file) then
486495 -- a single file may be accompanied by a config.ld in the same dir
487496 if not config_dir then
503512 -- (this also will initialize the code prettifier used)
504513 override ('format','plain')
505514 override 'pretty'
506 ldoc.markup = markup.create(ldoc, args.format,args.pretty)
515 ldoc.markup = markup.create(ldoc, args.format, args.pretty, ldoc.user_keywords)
507516
508517 ------ 'Special' Project-level entities ---------------------------------------
509518 -- Examples and Topics do not contain code to be processed for doc comments.
527536 return item, F
528537 end
529538
530 local function prettify_source_files(files,class,linemap)
539 local function prettify_source_files(files,class,linemap)
531540 local prettify = require 'ldoc.prettify'
532541
533542 process_file_list (files, '*.*', function(f)
555564 prettify_source_files(ldoc.examples,"example")
556565 end
557566
567 ldoc.is_file_prettified = {}
568
558569 if ldoc.prettify_files then
559570 local files = List()
560571 local linemap = {}
567578 end
568579 linemap[F.filename] = ls
569580 end
581
582 if type(ldoc.prettify_files) == 'table' then
583 files = tools.expand_file_list(ldoc.prettify_files, '*.*')
584 elseif type(ldoc.prettify_files) == 'string' then
585 -- the gotcha is that if the person has a folder called 'show', only the contents
586 -- of that directory will be converted. So, we warn of this amibiguity
587 if ldoc.prettify_files == 'show' then
588 -- just fall through with all module files collected above
589 if path.exists 'show' then
590 print("Notice: if you only want to prettify files in `show`, then set prettify_files to `show/`")
591 end
592 else
593 files = tools.expand_file_list({ldoc.prettify_files}, '*.*')
594 end
595 end
596
597 ldoc.is_file_prettified = tablex.makeset(files)
570598 prettify_source_files(files,"file",linemap)
571599 end
572600
745773 local builtin_style, builtin_template = match_bang(args.style),match_bang(args.template)
746774 if builtin_style or builtin_template then
747775 -- '!' here means 'use built-in templates'
748 local tmpdir = path.join(path.is_windows and os.getenv('TMP') or '/tmp','ldoc')
776 local user = path.expanduser('~'):gsub('[/\\: ]','_')
777 local tmpdir = path.join(path.is_windows and os.getenv('TMP') or '/tmp','ldoc'..user)
749778 if not path.isdir(tmpdir) then
750779 lfs.mkdir(tmpdir)
751780 end
752781 local function tmpwrite (name)
753782 local ok,text = pcall(require,'ldoc.html.'..name:gsub('%.','_'))
754783 if not ok then
755 quit("cannot find builtin template "..name)
784 quit("cannot find builtin template "..name.." ("..text..")")
756785 end
757786 if not utils.writefile(path.join(tmpdir,name),text) then
758787 quit("cannot write to temp directory "..tmpdir)
780809 ldoc.title = ldoc.title or args.title
781810 ldoc.project = ldoc.project or args.project
782811 ldoc.package = args.package:match '%a+' and args.package or nil
783 ldoc.updatetime = os.date("%Y-%m-%d %H:%M:%S")
812
813 local source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
814 if args.testing then
815 ldoc.updatetime = "2015-01-01 12:00:00"
816 ldoc.version = 'TESTING'
817 elseif source_date_epoch == nil then
818 if args.date == 'system' then
819 ldoc.updatetime = os.date("%Y-%m-%d %H:%M:%S")
820 else
821 ldoc.updatetime = args.date
822 end
823 else
824 ldoc.updatetime = os.date("!%Y-%m-%d %H:%M:%S",source_date_epoch)
825 end
784826
785827 local html = require 'ldoc.html'
786828
790832 print 'modules'
791833 for k in pairs(module_list.by_name) do print(k) end
792834 end
835
836 if args.fatalwarnings and Item.had_warning then
837 os.exit(1)
838 end
0 local run
1 if not arg[1] then
2 run = function (dir)
3 local cmd = 'cd '..dir..' && ldoc --testing . && diff -r doc cdocs'
4 print(cmd)
5 os.execute(cmd)
6 end
7 elseif arg[1] == 'update' then
8 run = function (dir)
9 local cmd = 'cd '..dir..' && ldoc --dir cdocs --testing .'
10 print(cmd)
11 os.execute(cmd)
12 end
13 end
14
15 for _,d in ipairs{'tests','tests/example','tests/md-test'} do
16 run(d)
17 end
0 -------
1 -- @module bad
2
3 local bad = {}
4
5 --------
6 -- inference fails! Have to explicitly
7 -- declare the function and its arguments
8 bad['entry'] = function(one)
9 end
10
11 return bad
12
99 _M.Bonzo = class()
1010
1111 --- a method.
12 -- function one
12 -- function one; reference to @{one.md.classes|documentation}
1313 function Bonzo:one()
1414
1515 end
11 project = 'Basic Example'
22 file = {'types.lua','classes.lua'}
33 use_markdown_titles=true
4 topics = {'one 1.md','two.md'}
4 topics = {'one.md','two.md'}
0 -------
1 -- Summing values.
2 -- Returns a single function.
3 -- @param a first
4 -- @param b second
5 -- @param c third
6 -- @return sum of parameters
7 -- @module funmod
8
9 return function(a,b,c)
10 return a + b + c
11 end
12
0 file = 'list.moon'
0 file = 'List.moon'
11 no_return_or_parms=true
22 no_summary=true
33 format = 'markdown'
0 # Documentation
1
2 ## types
3
4 A reference to @{types.first}
5
6 A `first` topic
7
8 ## classes
9
10 A `second` topic
00 ------------
1 -- Functions with options and custom tags
1 -- ### Functions with options and custom tags.
2 -- (use `ldoc -c opt.ld opt.lua` for converting.)
23 --
34 -- @include opt.md
45
56 ---- testing [opt]
67 -- @param one
78 -- @param[opt] two
8 -- @param[opt]three
9 -- @param[opt] three
910 -- @param[opt] four
1011 -- @remark use with caution!
1112 function use_opt (one,two,three,four)
1213 end
1314
1415 --- an explicit table.
15 -- Can now use tparam aliases in table defns
16 -- Can use tparam aliases in table defns
1617 -- @string name
1718 -- @int[opt=0] age
1819 -- @table person2