Codebase list lua-ldoc / e8d898f
Merge tag '1.3.13' nil-description error patch Julian Wollrath 10 years ago
17 changed file(s) with 397 addition(s) and 202 deletion(s). Raw diff Collapse all Expand all
395395 -- @class module
396396 -- @name simple
397397
398 becomes:
399
398400 ------------
399401 -- a simple module.
400402 -- (LDoc)
556558
557559 An LDoc feature which is particularly useful for C extensions is _module merging_. If several
558560 files are all marked as `@module lib` then a single module `lib` is generated, containing all
559 the docs from the separate files.
561 the docs from the separate files. For this, use `merge=true`.
560562
561563 See 'tests/examples/mylib.c' for the full example.
562564
565567 For example, to process all files in the 'lua' directory:
566568
567569 $ ldoc lua
568 output written to docs/
569
570 Thereafter the `docs` directory will contain `index.html` which points to individual modules
570 output written to doc/
571
572 Thereafter the `doc` directory will contain `index.html` which points to individual modules
571573 in the `modules` subdirectory. The `--dir` flag can specify where the output is generated,
572574 and will ensure that the directory exists. The output structure is like LuaDoc: there is an
573575 `index.html` and the individual modules are in the `modules` subdirectory. This applies to
589591 has an explicit `@module PACKAGE.NAME`. If it does not, then `ldoc` will still attempt to
590592 deduce the module name, but may need help with `--package/-b` as above.
591593
594 A special case is if you simply say 'ldoc .'. Then there _must_ be a `config.ld` file
595 available in the directory, and it can specify the file:
596
597 file = "mymod.lua"
598 title = "mymod documentation"
599 description = "mymod does some simple but useful things"
600
601 `file` can of course point to a directory, just as with the `--file` option. This mode makes
602 it particularly easy for the user to build the documentation, by allowing you to specify
603 everything explicitly in the configuration.
604
605 In `config.ld`, `file` may be a Lua table, containing file names or directories; if it has
606 an `exclude` field then that will be used to exclude files from the list, for example
607 `{'examples', exclude = {'examples/slow.lua'}}`.
608
609 A particular configuration file can be specified with the `-c` flag. Configuration files don't
610 _have_ to contain a `file` field, but in that case LDoc does need an explicit file on the command
611 line. This is useful if you have some defaults you wish to apply to all of your docs.
612
613 ## Markdown Support
614
592615 `format = 'markdown'` can be used in your `config.ld` and will be used to process summaries
593 and descriptions. This requires [markdown.lua](http://www.frykholm.se/files/markdown.lua) by
594 Niklas Frykholm to be installed (this can be most easily done with `luarocks install
595 markdown`.) A much faster alternative is
596 [lua-discount](http://asbradbury.org/projects/lua-discount/) which you can use by setting
597 `format` to 'discount' after installing using `luarocks install lua-discount`) The
598 [discount](http://www.pell.portland.or.us/~orc/Code/discount/) Markdown processor
599 additionally has more features than the pure Lua version, such as PHP-Extra style tables.
600 As a special case, LDoc will fall back to using `markdown.lua` if it cannot find `discount`.
601
602 `format = 'markdown'` can be used in your `config.ld` and will be used to process summaries
603 and descriptions. This requires a markdown processor.
616 and descriptions; you can also use the `-f` flag. This requires a markdown processor.
604617 LDoc knows how to use:
605618
606619 - [markdown.lua](http://www.frykholm.se/files/markdown.lua) a pure Lua processor by
607 Niklas Frykholm (this can be installed easily with `luarocks install markdown`.)
620 Niklas Frykholm. For convenience, LDoc comes with a copy of markdown.lua.
608621 - [lua-discount](http://asbradbury.org/projects/lua-discount/), a faster alternative
609622 (installed with `luarocks install lua-discount`). lua-discount uses the C
610623 [discount](http://www.pell.portland.or.us/~orc/Code/discount/) Markdown processor which has
614627
615628 You can request the processor you like with `format = 'markdown|discount|lunamark'`, and
616629 LDoc will attempt to use it. If it can't find it, it will look for one of the other
617 markdown processors. If it can't find any markdown processer, it will fall back to text
618 processing.
619
620
621 A special case is if you simply say 'ldoc .'. Then there _must_ be a `config.ld` file
622 available in the directory, and it can specify the file:
623
624 file = "mymod.lua"
625 title = "mymod documentation"
626 description = "mymod does some simple but useful things"
627
628 `file` can of course point to a directory, just as with the `--file` option. This mode makes
629 it particularly easy for the user to build the documentation, by allowing you to specify
630 everything explicitly in the configuration.
631
632 In `config.ld`, `file` may be a Lua table, containing file names or directories; if it has
633 an `exclude` field then that will be used to exclude files from the list, for example
634 `{'examples', exclude = {'examples/slow.lua'}}`.
635
630 markdown processors.
631
632 Even with the default of 'plain' some minimal processing takes place, in particular empty lines
633 are treated as line breaks.
634
635 This formatting applies to all of a project, including any readmes and so forth. You may want
636 Markdown for this 'narrative' documentation, but not for your code comments. `plain=true` will
637 switch off formatting for code.
636638
637639 ## Processing Single Modules
638640
640642 special case when a single module file is specified. Here an index would be redundant, so
641643 the single HTML file generated contains the module documentation.
642644
643 $ ldoc mylib.lua --> results in docs/index.html
644 $ ldoc --output mylib mylib.lua --> results in docs/mylib.html
645 $ ldoc mylib.lua --> results in doc/index.html
646 $ ldoc --output mylib mylib.lua --> results in doc/mylib.html
645647 $ ldoc --output mylib --dir html mylib.lua --> results in html/mylib.html
646648
647649 The default sections used by LDoc are 'Functions', 'Tables' and 'Fields', corresponding to
784786
785787 ## Customizing the Page
786788
789 A basic customization is to override the default UTF-8 encoding using `charset`. For instance,
790 Brazillian software would find it useful to put `charset='ISO-8859-1'` in `config.ld`, or use
791 the @charset tag for individual files.
792
787793 Setting `no_return_or_parms` to `true` will suppress the display of 'param' and 'return'
788794 tags. This may appeal to programmers who dislike the traditional @tag soup xDoc style and
789795 prefer to comment functions just with a description. This is particularly useful when using
810816 no_return_or_parms = true
811817 format = 'discount'
812818
813
814819 Generally, using Markdown gives you the opportunity to structure your documentation in any
815820 way you want; particularly if using lua-discount and its [table
816821 syntax](http://michelf.com/projects/php-markdown/extra/#table); the desired result can often
833838 examples = {'examples', exclude = {'examples/slow.lua'}}
834839
835840 That is, all files in the `examples` folder are to be pretty-printed, except for `slow.lua`
836 which is meant to be called from one of the examples. The see-reference to `testu.lua`
841 which is meant to be called from one of the examples. Now a see-reference to `testu.lua`
837842 resolves to 'examples/testu.lua.html'.
838843
839844 Examples may link back to the API documentation, for instance the example `input.lua` has a
840845 @\{spawn_process} inline reference.
846
847 By default, LDoc uses a built-in Lua code 'prettifier'. See-references are allowed in comments,
848 and also in code if they're enclosed in backticks.
849
850 [lxsh](https://github.com/xolox/lua-lxsh)
851 can be used (available from LuaRocks) if you want support for C as well. `pretty='lxsh'` will
852 cause `lxsh` to be used, if available.
841853
842854 ## Readme files
843855
857869 Another name for `readme` is `topics`, which is more descriptive. From LDoc 1.2,
858870 `readme/topics` can be a list of documents. These act as a top-level table-of-contents for
859871 your documentation. Currently, if you want them in a particular order, then use names like
860 `01-introduction.md` etc which sort appropriately.
872 `01-introduction.md` etc, which sort appropriately.
861873
862874 The first line of a document may be a Markdown `#` title. If so, then LDoc will regard the
863875 next level as the subheadings, normally second-level `##`. But if the title is already
974986 - `all` show local functions, etc as well in the docs
975987 - `format` markup processor, can be 'plain' (default), 'markdown' or 'discount'
976988 - `output` output name (default 'index')
977 - `dir` directory for output files (default 'docs')
989 - `dir` directory for output files (default 'doc')
990 - `colon` use colon style, instead of @ tag style
991 - `boilerplate` ignore first comment in all source files (e.g. license comments)
978992 - `ext` extension for output (default 'html')
979993 - `one` use a one-column layout
980994 - `style`, `template`: together these specify the directories for the style and and the
981995 template. In `config.ld` they may also be `true`, meaning use the same directory as the
982996 configuration file.
997 - `merge` allow documentation from different files to be merged into modules without
998 explicit @submodule tag
983999
9841000 These only appear in `config.ld`:
9851001
9861002 - `description` a project description used under the project title
9871003 - `examples` a directory or file: can be a table
988 - `readme` name of readme file (to be processed with Markdown)
1004 - `readme` or `topics` readme files (to be processed with Markdown)
1005 - `pretty` code prettify 'lua' (default) or 'lxsh'
1006 - `charset` use if you want to override the UTF-8 default (also @charset in files)
9891007 - `no_return_or_parms` don't show parameters or return values in output
9901008 - `backtick_references` whether references in backticks will be resolved
1009 - `plain` set to true if `format` is set but you don't want code comments processed
1010 - `wrap` ??
9911011 - `manual_url` point to an alternative or local location for the Lua manual, e.g.
9921012 'file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html'
993 - `one` use a one-column output format
9941013 - `no_summary` suppress the Contents summary
1014 - `custom_see_handler` function that filters see-references
1015 - `not_luadoc` set to `true` if the docs break LuaDoc compatibility
9951016
9961017 Available functions are:
9971018
114114 if tags.summary ~= '' then return false end
115115 for tag, value in pairs(tags) do
116116 if known_tags._annotation_tags[tag] then
117 tags.class = 'annotation'
118 tags.summary = value
117 tags:add('class','annotation')
118 tags:add('summary',value)
119119 local item_name = last_item and last_item.tags.name or '?'
120 tags.name = item_name..'-'..tag..acount
120 tags:add('name',item_name..'-'..tag..acount)
121121 acount = acount + 1
122122 return true
123123 end
219219 if mod then
220220 print('found master module',mf)
221221 this_mod = mod
222 if this_mod.section then
223 print '***closing section from master module***'
224 this_mod.section = nil
225 end
222226 submodule = true
223227 end
224228 end
263267 -- add the item to the module's item list
264268 if this_mod then
265269 -- new-style modules will have qualified names like 'mod.foo'
270 --require 'pl.pretty'.dump(item.tags)
266271 local mod,fname = split_dotted_name(item.name)
267272 -- warning for inferred unqualified names in new style modules
268273 -- (retired until we handle methods like Set:unset() properly)
314319 end
315320 end
316321 end
317 section_description = this_section.summary..' '..this_section.description
322 section_description = this_section.summary..' '..(this_section.description or '')
318323 elseif item.tags.within then
319324 section_description = item.tags.within
320325 item.section = section_description
383388 end
384389 end
385390
391 function Item:trailing_warning (kind,tag,rest)
392 if type(rest)=='string' and #rest > 0 then
393 Item.warning(self,kind.." tag: '"..tag..'" has trailing text; use no_luadoc=true\n'..rest)
394 end
395 end
396
386397 function Item:set_tag (tag,value)
387398 local ttype = known_tags[tag]
399 local args = self.file.args
388400
389401 if ttype == TAG_MULTI or ttype == TAG_MULTI_LINE then -- value is always a List!
390402 if getmetatable(value) ~= List then
391403 value = List{value}
392404 end
393 if ttype ~= TAG_MULTI_LINE then
405 if ttype ~= TAG_MULTI_LINE and args and args.not_luadoc then
394406 local last = value[#value]
395407 if type(last) == 'string' and last:match '\n' then
396408 local line,rest = last:match('([^\n]+)(.*)')
409421 value = value[1]
410422 modifiers = value.modifiers
411423 end
424 if value == nil then self:error("Tag without value: "..tag) end
412425 local id, rest = tools.extract_identifier(value)
413426 self.tags[tag] = id
414 self:add_to_description(rest)
427 if args and args.not_luadoc then
428 self:add_to_description(rest)
429 else
430 self:trailing_warning('id',tag,rest)
431 end
415432 elseif ttype == TAG_SINGLE then
416433 self.tags[tag] = value
417434 elseif ttype == TAG_FLAG then
418435 self.tags[tag] = true
419 self:add_to_description(value)
436 if args.not_luadoc then
437 self:add_to_description(value)
438 else
439 self:trailing_warning('flag',tag,value)
440 end
420441 else
421442 Item.warning(self,"unknown tag: '"..tag.."' "..tostring(ttype))
422443 end
741762 end
742763
743764 Module.warning, Module.error = Item.warning, Item.error
744
745765
746766 -------- Resolving References -----------------
747767
2323 # local use_li = ldoc.use_li
2424 # local display_name = ldoc.display_name
2525 # local iter = ldoc.modules.iter
26 # local M = ldoc.markup
26 # ---local M = ldoc.markup
27 # local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end
2728 # local nowrap = ldoc.wrap and '' or 'nowrap'
2829
2930 <!-- Menu -->
248249 </div> <!-- id="content" -->
249250 </div> <!-- id="main" -->
250251 <div id="about">
251 <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3.11</a></i>
252 <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3.12</a></i>
252253 </div> <!-- id="about" -->
253254 </div> <!-- id="container" -->
254255 </body>
1616 -- iden n
1717 -- keyword do
1818 -- </pre>
19 -- See the Guide for further <a href="../../index.html#lexer">discussion</a> <br>
20 -- @class module
21 -- @name pl.lexer
19 --
20 -- Based on pl.lexer from Penlight
2221
2322 local strfind = string.find
2423 local strsub = string.sub
2524 local append = table.insert
26 --[[
27 module ('pl.lexer',utils._module)
28 ]]
2925
3026 local function assert_arg(idx,val,tp)
3127 if type(val) ~= tp then
6763 tok = tok:sub(2,-2)
6864 end
6965 return "string",tok
66 end
67
68 -- strings enclosed in back ticks
69 local function bdump(tok,options)
70 if options and options.string then
71 tok = tok:sub(2,-2)
72 end
73 return "backtick",tok
7074 end
7175
7276 -- long Lua strings need extra work to get rid of the quotes
171175 if file then
172176 s = file:read()
173177 if not s then return nil end -- empty file
178 if s:match '^\239\187' then -- UTF-8 BOM Abomination
179 s = s:sub(4)
180 end
174181 s = s ..'\n'
175182 end
176183 local sz = #s
294301 {STRING3,sdump},
295302 {STRING1,sdump},
296303 {STRING2,sdump},
304 {'^`[^`]+`',bdump},
297305 {'^%-%-%[(=*)%[.-%]%1%]',cdump},
298306 {'^%-%-.-\n',cdump},
299307 {'^%[(=*)%[.-%]%1%]',sdump_l},
44
55 <http://www.frykholm.se/files/markdown.lua>
66
7 **Author:** Niklas Frykholm, <niklas@frykholm.se>
7 **Author:** Niklas Frykholm, <niklas@frykholm.se>
88 **Date:** 31 May 2008
99
1010 This is an implementation of the popular text markup language Markdown in pure Lua.
4646 software and associated documentation files (the "Software"), to deal in the Software
4747 without restriction, including without limitation the rights to use, copy, modify, merge,
4848 publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
49 to whom the Software is furnished to do so, subject to the following conditions:
49 to whom the Software is furnished to do so, subject to the following conditions:
5050
5151 The above copyright notice and this permission notice shall be included in all copies
52 or substantial portions of the Software.
52 or substantial portions of the Software.
5353
5454 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5555 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
129129 -- Locks table t from changes, writes an error if someone attempts to change the table.
130130 -- This is useful for detecting variables that have "accidently" been made global. Something
131131 -- I tend to do all too much.
132 function lock(t)
133 function lock_new_index(t, k, v)
132 function M.lock(t)
133 local function lock_new_index(t, k, v)
134134 error("module has been locked -- " .. k .. " must be declared local", 2)
135135 end
136136
137137 local mt = {__newindex = lock_new_index}
138 if getmetatable(t) then mt.__index = getmetatable(t).__index end
138 if getmetatable(t) then
139 mt.__index = getmetatable(t).__index
140 end
139141 setmetatable(t, mt)
140142 end
141143
142144 -- Returns the result of mapping the values in table t through the function f
143 function map(t, f)
145 local function map(t, f)
144146 local out = {}
145147 for k,v in pairs(t) do out[k] = f(v,k) end
146148 return out
147149 end
148150
149151 -- The identity function, useful as a placeholder.
150 function identity(text) return text end
152 local function identity(text) return text end
151153
152154 -- Functional style if statement. (NOTE: no short circuit evaluation)
153 function iff(t, a, b) if t then return a else return b end end
155 local function iff(t, a, b) if t then return a else return b end end
154156
155157 -- Splits the text into an array of separate lines.
156 function split(text, sep)
158 local function split(text, sep)
157159 sep = sep or "\n"
158160 local lines = {}
159161 local pos = 1
167169 end
168170
169171 -- Converts tabs to spaces
170 function detab(text)
172 local function detab(text)
171173 local tab_width = 4
172174 local function rep(match)
173175 local spaces = -match:len()
179181 end
180182
181183 -- Applies string.find for every pattern in the list and returns the first match
182 function find_first(s, patterns, index)
184 local function find_first(s, patterns, index)
183185 local res = {}
184186 for _,p in ipairs(patterns) do
185187 local match = {s:find(p, index)}
191193 -- If a replacement array is specified, the range [start, stop] in the array is replaced
192194 -- with the replacement array and the resulting array is returned. Without a replacement
193195 -- array the section of the array between start and stop is returned.
194 function splice(array, start, stop, replacement)
196 local function splice(array, start, stop, replacement)
195197 if replacement then
196198 local n = stop - start + 1
197199 while n > 0 do
212214 end
213215
214216 -- Outdents the text one step.
215 function outdent(text)
217 local function outdent(text)
216218 text = "\n" .. text
217219 text = text:gsub("\n ? ? ?", "\n")
218220 text = text:sub(2)
220222 end
221223
222224 -- Indents the text one step.
223 function indent(text)
225 local function indent(text)
224226 text = text:gsub("\n", "\n ")
225227 return text
226228 end
227229
228 -- Does a simple tokenization of html data. Returns the data as a list of tokens.
230 -- Does a simple tokenization of html data. Returns the data as a list of tokens.
229231 -- Each token is a table with a type field (which is either "tag" or "text") and
230232 -- a text field (which contains the original token data).
231 function tokenize_html(html)
233 local function tokenize_html(html)
232234 local tokens = {}
233235 local pos = 1
234236 while true do
238240 break
239241 end
240242 if start ~= pos then table.insert(tokens, {type="text", text = html:sub(pos, start-1)}) end
241
243
242244 local _, stop
243245 if html:match("^<!%-%-", start) then
244246 _,stop = html:find("%-%->", start)
248250 _,stop = html:find("%b<>", start)
249251 end
250252 if not stop then
251 -- error("Could not match html tag " .. html:sub(start,start+30))
253 -- error("Could not match html tag " .. html:sub(start,start+30))
252254 table.insert(tokens, {type="text", text=html:sub(start, start)})
253255 pos = start + 1
254256 else
271273 local HASH = {
272274 -- Has the hash been inited.
273275 inited = false,
274
276
275277 -- The unique string prepended to all hash values. This is to ensure
276278 -- that hash values do not accidently coincide with an actual existing
277279 -- string in the document.
278280 identifier = "",
279
281
280282 -- Counter that counts up for each new hash instance.
281283 counter = 0,
282
284
283285 -- Hash table.
284286 table = {}
285287 }
286288
287289 -- Inits hashing. Creates a hash_identifier that doesn't occur anywhere
288290 -- in the text.
289 function init_hash(text)
291 local function init_hash(text)
290292 HASH.inited = true
291293 HASH.identifier = ""
292294 HASH.counter = 0
293295 HASH.table = {}
294
296
295297 local s = "HASH"
296298 local counter = 0
297299 local id
304306 end
305307
306308 -- Returns the hashed value for s.
307 function hash(s)
309 local function hash(s)
308310 assert(HASH.inited)
309311 if not HASH.table[s] then
310312 HASH.counter = HASH.counter + 1
319321 ----------------------------------------------------------------------
320322
321323 -- The protection module is used to "protect" parts of a document
322 -- so that they are not modified by subsequent processing steps.
324 -- so that they are not modified by subsequent processing steps.
323325 -- Protected parts are saved in a table for later unprotection
324326
325327 -- Protection data
341343 -- Nested data.
342344 -- </div>
343345 -- </div>
344 function block_pattern(tag)
346 local function block_pattern(tag)
345347 return "\n<" .. tag .. ".-\n</" .. tag .. ">[ \t]*\n"
346348 end
347349
348350 -- Pattern for matching a block tag that begins and ends with a newline
349 function line_pattern(tag)
351 local function line_pattern(tag)
350352 return "\n<" .. tag .. ".-</" .. tag .. ">[ \t]*\n"
351353 end
352354
353355 -- Protects the range of characters from start to stop in the text and
354356 -- returns the protected string.
355 function protect_range(text, start, stop)
357 local function protect_range(text, start, stop)
356358 local s = text:sub(start, stop)
357359 local h = hash(s)
358360 PD.blocks[h] = s
362364
363365 -- Protect every part of the text that matches any of the patterns. The first
364366 -- matching pattern is protected first, etc.
365 function protect_matches(text, patterns)
367 local function protect_matches(text, patterns)
366368 while true do
367369 local start, stop = find_first(text, patterns)
368370 if not start then break end
372374 end
373375
374376 -- Protects blocklevel tags in the specified text
375 function protect(text)
377 local function protect(text)
376378 -- First protect potentially nested block tags
377379 text = protect_matches(text, map(PD.tags, block_pattern))
378380 -- Then protect block tags at the line level.
384386 end
385387
386388 -- Returns true if the string s is a hash resulting from protection
387 function is_protected(s)
389 local function is_protected(s)
388390 return PD.blocks[s]
389391 end
390392
391393 -- Unprotects the specified text by expanding all the nonces
392 function unprotect(text)
394 local function unprotect(text)
393395 for k,v in pairs(PD.blocks) do
394396 v = v:gsub("%%", "%%%%")
395397 text = text:gsub(k, v)
409411 -- Returns true if the line is a ruler of (char) characters.
410412 -- The line must contain at least three char characters and contain only spaces and
411413 -- char characters.
412 function is_ruler_of(line, char)
414 local function is_ruler_of(line, char)
413415 if not line:match("^[ %" .. char .. "]*$") then return false end
414416 if not line:match("%" .. char .. ".*%" .. char .. ".*%" .. char) then return false end
415417 return true
416418 end
417419
418420 -- Identifies the block level formatting present in the line
419 function classify(line)
421 local function classify(line)
420422 local info = {line = line, text = line}
421
423
422424 if line:match("^ ") then
423425 info.type = "indented"
424426 info.outdented = line:sub(5)
425427 return info
426428 end
427
429
428430 for _,c in ipairs({'*', '-', '_', '='}) do
429431 if is_ruler_of(line, c) then
430432 info.type = "ruler"
432434 return info
433435 end
434436 end
435
437
436438 if line == "" then
437439 info.type = "blank"
438440 return info
439441 end
440
442
441443 if line:match("^(#+)[ \t]*(.-)[ \t]*#*[ \t]*$") then
442444 local m1, m2 = line:match("^(#+)[ \t]*(.-)[ \t]*#*[ \t]*$")
443445 info.type = "header"
445447 info.text = m2
446448 return info
447449 end
448
450
449451 if line:match("^ ? ? ?(%d+)%.[ \t]+(.+)") then
450452 local number, text = line:match("^ ? ? ?(%d+)%.[ \t]+(.+)")
451453 info.type = "list_item"
454456 info.text = text
455457 return info
456458 end
457
459
458460 if line:match("^ ? ? ?([%*%+%-])[ \t]+(.+)") then
459461 local bullet, text = line:match("^ ? ? ?([%*%+%-])[ \t]+(.+)")
460462 info.type = "list_item"
463465 info.text= text
464466 return info
465467 end
466
468
467469 if line:match("^>[ \t]?(.*)") then
468470 info.type = "blockquote"
469471 info.text = line:match("^>[ \t]?(.*)")
470472 return info
471473 end
472
474
473475 if is_protected(line) then
474476 info.type = "raw"
475477 info.html = unprotect(line)
476478 return info
477479 end
478
480
479481 info.type = "normal"
480482 return info
481483 end
482484
483485 -- Find headers constisting of a normal line followed by a ruler and converts them to
484486 -- header entries.
485 function headers(array)
487 local function headers(array)
486488 local i = 1
487489 while i <= #array - 1 do
488 if array[i].type == "normal" and array[i+1].type == "ruler" and
490 if array[i].type == "normal" and array[i+1].type == "ruler" and
489491 (array[i+1].ruler_char == "-" or array[i+1].ruler_char == "=") then
490492 local info = {line = array[i].line}
491493 info.text = info.line
499501 return array
500502 end
501503
504 local block_transform, blocks_to_html, encode_code, span_transform, encode_backslash_escapes
505
502506 -- Find list blocks and convert them to protected data blocks
503 function lists(array, sublist)
507 local function lists(array, sublist)
504508 local function process_list(arr)
505509 local function any_blanks(arr)
506510 for i = 1, #arr do
508512 end
509513 return false
510514 end
511
515
512516 local function split_list_items(arr)
513517 local acc = {arr[1]}
514518 local res = {}
523527 table.insert(res, acc)
524528 return res
525529 end
526
530
527531 local function process_list_item(lines, block)
528532 while lines[#lines].type == "blank" do
529533 table.remove(lines)
530534 end
531
535
532536 local itemtext = lines[1].text
533537 for i=2,#lines do
534538 itemtext = itemtext .. "\n" .. outdent(lines[i].line)
547551 return " <li>" .. itemtext .. "</li>"
548552 end
549553 end
550
554
551555 local block_list = any_blanks(arr)
552556 local items = split_list_items(arr)
553557 local out = ""
560564 return "<ul>\n" .. out .. "</ul>"
561565 end
562566 end
563
567
564568 -- Finds the range of lines composing the first list in the array. A list
565569 -- starts with (^ list_item) or (blank list_item) and ends with
566570 -- (blank* $) or (blank normal).
585589 local function find_list_end(array, start)
586590 local pos = #array
587591 for i = start, #array-1 do
588 if array[i].type == "blank" and array[i+1].type ~= "list_item"
592 if array[i].type == "blank" and array[i+1].type ~= "list_item"
589593 and array[i+1].type ~= "indented" and array[i+1].type ~= "blank" then
590594 pos = i-1
591595 break
596600 end
597601 return pos
598602 end
599
603
600604 local start = find_list_start(array, sublist)
601605 if not start then return nil end
602606 return start, find_list_end(array, start)
603607 end
604
608
605609 while true do
606610 local start, stop = find_list(array, sublist)
607611 if not start then break end
613617 }
614618 array = splice(array, start, stop, {info})
615619 end
616
620
617621 -- Convert any remaining list items to normal
618622 for _,line in ipairs(array) do
619623 if line.type == "list_item" then line.type = "normal" end
620624 end
621
625
622626 return array
623627 end
624628
625629 -- Find and convert blockquote markers.
626 function blockquotes(lines)
630 local function blockquotes(lines)
627631 local function find_blockquote(lines)
628632 local start
629633 for i,line in ipairs(lines) do
633637 end
634638 end
635639 if not start then return nil end
636
640
637641 local stop = #lines
638642 for i = start+1, #lines do
639643 if lines[i].type == "blank" or lines[i].type == "blockquote" then
646650 while lines[stop].type == "blank" do stop = stop - 1 end
647651 return start, stop
648652 end
649
653
650654 local function process_blockquote(lines)
651655 local raw = lines[1].text
652656 for i = 2,#lines do
657661 return "<blockquote>\n " .. bt ..
658662 "\n</blockquote>"
659663 end
660
664
661665 while true do
662666 local start, stop = find_blockquote(lines)
663667 if not start then break end
673677 end
674678
675679 -- Find and convert codeblocks.
676 function codeblocks(lines)
680 local function codeblocks(lines)
677681 local function find_codeblock(lines)
678682 local start
679683 for i,line in ipairs(lines) do
680684 if line.type == "indented" then start = i break end
681685 end
682686 if not start then return nil end
683
687
684688 local stop = #lines
685689 for i = start+1, #lines do
686690 if lines[i].type ~= "indented" and lines[i].type ~= "blank" then
691695 while lines[stop].type == "blank" do stop = stop - 1 end
692696 return start, stop
693697 end
694
698
695699 local function process_codeblock(lines)
696700 local raw = detab(encode_code(outdent(lines[1].line)))
697701 for i = 2,#lines do
699703 end
700704 return "<pre><code>" .. raw .. "\n</code></pre>"
701705 end
702
706
703707 while true do
704708 local start, stop = find_codeblock(lines)
705709 if not start then break end
726730 table.insert(out, line.html)
727731 elseif line.type == "normal" then
728732 local s = line.line
729
733
730734 while i+1 <= #lines and lines[i+1].type == "normal" do
731735 i = i + 1
732736 s = s .. "\n" .. lines[i].line
733737 end
734
738
735739 if no_paragraphs then
736740 table.insert(out, span_transform(s))
737741 else
763767
764768 -- Debug function for printing a line array to see the result
765769 -- of partial transforms.
766 function print_lines(lines)
770 local function print_lines(lines)
767771 for i, line in ipairs(lines) do
768772 print(i, line.type, line.text or line.line)
769773 end
777781
778782 -- These characters may need to be escaped because they have a special
779783 -- meaning in markdown.
780 escape_chars = "'\\`*_{}[]()>#+-.!'"
781 escape_table = {}
782
783 function init_escape_table()
784 local escape_chars = "'\\`*_{}[]()>#+-.!'"
785 local escape_table = {}
786
787 local function init_escape_table()
784788 escape_table = {}
785789 for i = 1,#escape_chars do
786790 local c = escape_chars:sub(i,i)
789793 end
790794
791795 -- Adds a new escape to the escape table.
792 function add_escape(text)
796 local function add_escape(text)
793797 if not escape_table[text] then
794798 escape_table[text] = hash(text)
795799 end
796800 return escape_table[text]
797 end
801 end
798802
799803 -- Escape characters that should not be disturbed by markdown.
800 function escape_special_chars(text)
804 local function escape_special_chars(text)
801805 local tokens = tokenize_html(text)
802
806
803807 local out = ""
804808 for _, token in ipairs(tokens) do
805809 local t = token.text
825829 end
826830
827831 -- Unescape characters that have been encoded.
828 function unescape_special_chars(t)
832 local function unescape_special_chars(t)
829833 local tin = t
830834 for k,v in pairs(escape_table) do
831835 k = k:gsub("%%", "%%%%")
849853 end
850854
851855 -- Handle backtick blocks.
852 function code_spans(s)
856 local function code_spans(s)
853857 s = s:gsub("\\\\", escape_table["\\"])
854858 s = s:gsub("\\`", escape_table["`"])
855859
879883 end
880884
881885 -- Encode alt text... enodes &, and ".
882 function encode_alt(s)
886 local function encode_alt(s)
883887 if not s then return s end
884888 s = s:gsub('&', '&amp;')
885889 s = s:gsub('"', '&quot;')
887891 return s
888892 end
889893
894 local link_database
895
890896 -- Handle image references
891 function images(text)
897 local function images(text)
892898 local function reference_link(alt, id)
893899 alt = encode_alt(alt:match("%b[]"):sub(2,-2))
894900 id = id:match("%[(.*)%]"):lower()
901907 if title then title = " title=\"" .. title .. "\"" else title = "" end
902908 return add_escape ('<img src="' .. url .. '" alt="' .. alt .. '"' .. title .. "/>")
903909 end
904
910
905911 local function inline_link(alt, link)
906912 alt = encode_alt(alt:match("%b[]"):sub(2,-2))
907913 local url, title = link:match("%(<?(.-)>?[ \t]*['\"](.+)['\"]")
914920 return add_escape('<img src="' .. url .. '" alt="' .. alt .. '"/>')
915921 end
916922 end
917
923
918924 text = text:gsub("!(%b[])[ \t]*\n?[ \t]*(%b[])", reference_link)
919925 text = text:gsub("!(%b[])(%b())", inline_link)
920926 return text
921927 end
922928
923929 -- Handle anchor references
924 function anchors(text)
930 local function anchors(text)
925931 local function reference_link(text, id)
926932 text = text:match("%b[]"):sub(2,-2)
927933 id = id:match("%b[]"):sub(2,-2):lower()
934940 if title then title = " title=\"" .. title .. "\"" else title = "" end
935941 return add_escape("<a href=\"" .. url .. "\"" .. title .. ">") .. text .. add_escape("</a>")
936942 end
937
943
938944 local function inline_link(text, link)
939945 text = text:match("%b[]"):sub(2,-2)
940946 local url, title = link:match("%(<?(.-)>?[ \t]*['\"](.+)['\"]")
947953 return add_escape("<a href=\"" .. url .. "\">") .. text .. add_escape("</a>")
948954 end
949955 end
950
956
951957 text = text:gsub("(%b[])[ \t]*\n?[ \t]*(%b[])", reference_link)
952958 text = text:gsub("(%b[])(%b())", inline_link)
953959 return text
954960 end
955961
956962 -- Handle auto links, i.e. <http://www.google.com/>.
957 function auto_links(text)
963 local function auto_links(text)
958964 local function link(s)
959965 return add_escape("<a href=\"" .. s .. "\">") .. s .. "</a>"
960966 end
968974 local plain = {code = function(c) return c end, count = 0, rate = 0.1}
969975 local codes = {hex, dec, plain}
970976 local function swap(t,k1,k2) local temp = t[k2] t[k2] = t[k1] t[k1] = temp end
971
977
972978 local out = ""
973979 for i = 1,s:len() do
974980 for _,code in ipairs(codes) do code.count = code.count + code.rate end
975981 if codes[1].count < codes[2].count then swap(codes,1,2) end
976982 if codes[2].count < codes[3].count then swap(codes,2,3) end
977983 if codes[1].count < codes[2].count then swap(codes,1,2) end
978
984
979985 local code = codes[1]
980986 local c = s:sub(i,i)
981987 -- Force encoding of "@" to make email address more invisible.
982988 if c == "@" and code == plain then code = codes[2] end
983989 out = out .. code.code(c)
984990 code.count = code.count - 1
985 end
991 end
986992 return out
987993 end
988994 local function mail(s)
9941000 -- links
9951001 text = text:gsub("<(https?:[^'\">%s]+)>", link)
9961002 text = text:gsub("<(ftp:[^'\">%s]+)>", link)
997
1003
9981004 -- mail
9991005 text = text:gsub("<mailto:([^'\">%s]+)>", mail)
10001006 text = text:gsub("<([-.%w]+%@[-.%w]+)>", mail)
10031009
10041010 -- Encode free standing amps (&) and angles (<)... note that this does not
10051011 -- encode free >.
1006 function amps_and_angles(s)
1012 local function amps_and_angles(s)
10071013 -- encode amps not part of &..; expression
10081014 local pos = 1
10091015 while true do
10181024 pos = amp+1
10191025 end
10201026 end
1021
1027
10221028 -- encode naked <'s
10231029 s = s:gsub("<([^a-zA-Z/?$!])", "&lt;%1")
10241030 s = s:gsub("<$", "&lt;")
1025
1031
10261032 -- what about >, nothing done in the original markdown source to handle them
10271033 return s
10281034 end
10291035
10301036 -- Handles emphasis markers (* and _) in the text.
1031 function emphasis(text)
1037 local function emphasis(text)
10321038 for _, s in ipairs {"%*%*", "%_%_"} do
10331039 text = text:gsub(s .. "([^%s][%*%_]?)" .. s, "<strong>%1</strong>")
10341040 text = text:gsub(s .. "([^%s][^<>]-[^%s][%*%_]?)" .. s, "<strong>%1</strong>")
10431049 end
10441050
10451051 -- Handles line break markers in the text.
1046 function line_breaks(text)
1052 local function line_breaks(text)
10471053 return text:gsub(" +\n", " <br/>\n")
10481054 end
10491055
10661072
10671073 -- Cleanup the text by normalizing some possible variations to make further
10681074 -- processing easier.
1069 function cleanup(text)
1075 local function cleanup(text)
10701076 -- Standardize line endings
10711077 text = text:gsub("\r\n", "\n") -- DOS to UNIX
10721078 text = text:gsub("\r", "\n") -- Mac to UNIX
1073
1079
10741080 -- Convert all tabs to spaces
10751081 text = detab(text)
1076
1082
10771083 -- Strip lines with only spaces and tabs
10781084 while true do
10791085 local subs
10801086 text, subs = text:gsub("\n[ \t]+\n", "\n\n")
10811087 if subs == 0 then break end
10821088 end
1083
1089
10841090 return "\n" .. text .. "\n"
10851091 end
10861092
10871093 -- Strips link definitions from the text and stores the data in a lookup table.
1088 function strip_link_definitions(text)
1094 local function strip_link_definitions(text)
10891095 local linkdb = {}
1090
1096
10911097 local function link_def(id, url, title)
10921098 id = id:match("%[(.+)%]"):lower()
10931099 linkdb[id] = linkdb[id] or {}
11001106 local def_title1 = def_no_title .. "[ \t]+\n?[ \t]*[\"'(]([^\n]+)[\"')][ \t]*"
11011107 local def_title2 = def_no_title .. "[ \t]*\n[ \t]*[\"'(]([^\n]+)[\"')][ \t]*"
11021108 local def_title3 = def_no_title .. "[ \t]*\n?[ \t]+[\"'(]([^\n]+)[\"')][ \t]*"
1103
1109
11041110 text = text:gsub(def_title1, link_def)
11051111 text = text:gsub(def_title2, link_def)
11061112 text = text:gsub(def_title3, link_def)
11111117 link_database = {}
11121118
11131119 -- Main markdown processing function
1114 function markdown(text)
1120 local function markdown(text)
11151121 init_hash(text)
11161122 init_escape_table()
1117
1123
11181124 text = cleanup(text)
11191125 text = protect(text)
11201126 text, link_database = strip_link_definitions(text)
11311137 M.lock(M)
11321138
11331139 -- Expose markdown function to the world
1134 markdown = M.markdown
1140 _G.markdown = M.markdown
11351141
11361142 -- Class for parsing command-line options
11371143 local OptionParser = {}
11671173 -- where successfully parsed and false otherwise.
11681174 function OptionParser:run(args)
11691175 local pos = 1
1176 local param
11701177 while pos <= #args do
11711178 local arg = args[pos]
11721179 if arg == "--" then
12241231 if not options.wrap_header then return s end
12251232 local header = ""
12261233 if options.header then
1227 local f = io.open(options.header) or error("Could not open file: " .. options.header)
1234 local f = io.open(options.header) or error("Could not open file: " .. options.header)
12281235 header = f:read("*a")
12291236 f:close()
12301237 else
12381245 </head>
12391246 <body>
12401247 ]]
1241 local title = options.title or s:match("<h1>(.-)</h1>") or s:match("<h2>(.-)</h2>") or
1248 local title = options.title or s:match("<h1>(.-)</h1>") or s:match("<h2>(.-)</h2>") or
12421249 s:match("<h3>(.-)</h3>") or "Untitled"
12431250 header = header:gsub("TITLE", title)
12441251 if options.inline_style then
12451252 local style = ""
12461253 local f = io.open(options.stylesheet)
1247 if f then
1248 style = f:read("*a") f:close()
1254 if f then
1255 style = f:read("*a") f:close()
12491256 else
12501257 error("Could not include style sheet " .. options.stylesheet .. ": File not found")
12511258 end
12641271 end
12651272 return header .. s .. footer
12661273 end
1267
1268 -- Generate output path name from input path name given options.
1274
1275 -- Generate output path name from input path name given options.
12691276 local function outpath(path, options)
12701277 if options.append then return path .. ".html" end
12711278 local m = path:match("^(.+%.html)[^/\\]+$") if m then return m end
12721279 m = path:match("^(.+%.)[^/\\]*$") if m and path ~= m .. "html" then return m .. "html" end
12731280 return path .. ".html"
12741281 end
1275
1282
12761283 -- Default commandline options
12771284 local options = {
12781285 wrap_header = true,
13151322 op:param("s", "style", function(x) options.stylesheet = x end)
13161323 op:flag("l", "inline-style", function(x) options.inline_style = true end)
13171324 op:flag("a", "append", function() options.append = true end)
1318 op:flag("t", "test", function()
1325 op:flag("t", "test", function()
13191326 local n = arg[0]:gsub("markdown.lua", "markdown-tests.lua")
13201327 local f = io.open(n)
1321 if f then
1322 f:close() dofile(n)
1328 if f then
1329 f:close() dofile(n)
13231330 else
13241331 error("Cannot find markdown-tests.lua")
13251332 end
1326 run_stdin = false
1333 run_stdin = false
13271334 end)
13281335 op:flag("h", "help", function() print(help) run_stdin = false end)
1329 op:arg(function(path)
1336 op:arg(function(path)
13301337 local file = io.open(path) or error("Could not open file: " .. path)
13311338 local s = file:read("*a")
13321339 file:close()
13371344 run_stdin = false
13381345 end
13391346 )
1340
1347
13411348 if not op:run(arg) then
13421349 print(help)
13431350 run_stdin = false
13491356 io.write(s)
13501357 end
13511358 end
1352
1359
13531360 -- If we are being run from the command-line, act accordingly
13541361 if arg and arg[0]:find("markdown%.lua$") then
13551362 run_command_line(arg)
13561363 else
13571364 return markdown
1358 end
1365 end
232232 end
233233 end
234234
235
236235 local function text_processor(ldoc)
237236 return function(txt,item)
238237 if txt == nil then return '' end
242241 end
243242 end
244243
244 local plain_processor
245245
246246 local function markdown_processor(ldoc, formatter)
247 return function (txt,item)
247 return function (txt,item,plain)
248248 if txt == nil then return '' end
249 if plain then
250 if not plain_processor then
251 plain_processor = text_processor(ldoc)
252 end
253 return plain_processor(txt,item)
254 end
249255 if utils.is_type(item,doc.File) then
250256 txt = process_multiline_markdown(ldoc, txt, item)
251257 else
256262 return (txt:gsub('^%s*<p>(.+)</p>%s*$','%1'))
257263 end
258264 end
259
260265
261266 local function get_processor(ldoc, format)
262267 if format == 'plain' then return text_processor(ldoc) end
6969 return preamble,tag_items
7070 end
7171
72 -- Tags are stored as an ordered map
7273 local Tags = {}
7374 Tags.__index = Tags
7475
7879 end
7980
8081 function Tags:add (tag,value)
81 self[tag] = value
82 --print('adding',tag,value)
82 rawset(self,tag,value)
8383 self._order:append(tag)
8484 end
8585
210210 else
211211 mod,t,v = lang:parse_module_call(tok,t,v)
212212 if mod ~= '...' then
213 add_module({summary='(no description)'},mod,true)
213 add_module(Tags.new{summary='(no description)'},mod,true)
214214 first_comment = false
215215 module_found = true
216216 end
334334 end
335335 end
336336 if is_local or tags['local'] then
337 tags['local'] = true
337 tags:add('local',true)
338338 end
339339 if tags.name then
340340 current_item = F:new_item(tags,line)
2323 return ('<span class="%s">%s</span>'):format(t,val)
2424 end
2525
26 local spans = {keyword=true,number=true,string=true,comment=true,global=true}
26 local spans = {keyword=true,number=true,string=true,comment=true,global=true,backtick=true}
2727
2828 function prettify.lua (fname, code, initial_lineno, pre)
2929 local res = List()
4646 t = 'global'
4747 end
4848 if spans[t] then
49 if t == 'comment' then -- may contain @{ref}
49 if t == 'comment' or t == 'backtick' then -- may contain @{ref} or `..`
5050 val = prettify.resolve_inline_references(val,error_reporter)
5151 end
5252 res:append(span(t,val))
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 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
3434
3535 --- @usage
3636 local usage = [[
37 ldoc, a documentation generator for Lua, vs 1.3.11
38 -d,--dir (default docs) output directory
37 ldoc, a documentation generator for Lua, vs 1.3.12
38 -d,--dir (default doc) output directory
3939 -o,--output (default 'index') output name
4040 -v,--verbose verbose
4141 -a,--all show local functions, etc, in docs
6262 <file> (string) source file or directory containing source
6363
6464 `ldoc .` reads options from an `config.ld` file in same directory;
65 `ldoc -c path/to/myconfig.ld .` reads options from `path/to/myconfig.ld`
65 `ldoc -c path/to/myconfig.ld <file>` reads options from `path/to/myconfig.ld`
66 and processes <file> if 'file' was not defined in the ld file.
6667 ]]
6768 local args = lapp(usage)
6869 local lfs = require 'lfs'
183184 local ldoc_contents = {
184185 'alias','add_language_extension','new_type','add_section', 'tparam_alias',
185186 'file','project','title','package','format','output','dir','ext', 'topics',
186 'one','style','template','description','examples', 'pretty', 'charset',
187 'readme','all','manual_url', 'ignore', 'colon','boilerplate','merge', 'wrap',
187 'one','style','template','description','examples', 'pretty', 'charset', 'plain',
188 'readme','all','manual_url', 'ignore', 'colon',
189 'boilerplate','merge', 'wrap', 'not_luadoc',
188190 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
189191 }
190192 ldoc_contents = tablex.makeset(ldoc_contents)
360362
361363 override 'colon'
362364 override 'merge'
365 override 'not_luadoc'
363366
364367 if type(args.file) == 'table' then
365368 -- this can only be set from config file so we can assume it's already read
0 --- simplified LDoc style
0 --- simplified LDoc colon style.
1 -- You have to use -C flag or 'colon=true' for this one!
12 module 'easy'
23
34 --- First one.
00 ------------
11 -- Yet another module.
2 -- Description can continue after simple tags, if you
3 -- like - but to keep backwards compatibility, say 'not_luadoc=true'
24 -- @module four
3 -- Description can continue after simple tags, if you
4 -- like
55 -- @author bob, james
66 -- @license MIT
77 -- @copyright InfoReich 2013
11 A non-doc comment
22 multi-line
33 probably containing license information!
4 Doesn't use module(), but module name is inferred from file name
4 Doesn't use module(), but module name is inferred from file name.
5 If you have initial licence comments that look like doc comments,
6 then set `boilerplate=true`
57 ]]
68 ------------
79 -- Test module,
11 -- Alternative to no-magic style.
22 -- Description here
33 ----
4
5 --- documented, but private
6 local function question ()
7 end
48
59 --- answer to everything.
610 -- @return magic number
1010 -- suppress @params and the summary at the top
1111 no_return_or_parms=true
1212 no_summary=true
13 not_luadoc=true
14
6969
7070 --[[-----------------
7171 @table Vector.Opts
72 Options table format for `Vector.options`
72 Options table format for `Vector:options`
7373
74 autoconvert: try to convert strings to numbers
74 * `autoconvert`: try to convert strings to numbers
75 * `adder`: function used to perform addition and subtraction
76 * `multiplier`: function used to perform multiplication and division
7577
76 adder: function used to perform addition and subtraction
77
78 multiplier: function used to perform multiplication and division
7978 @usage
8079 v = Vector {{1},{2}}
8180 v:options {adder = function(x,y) return {x[1]+y[1]} end}