Codebase list lua-ldoc / 05727ec
- comments within formal arguments: last comment may be outside the closing parenthesis. If comments are of form TYPE:COMMENT then equivalent to @tparam not @param. See tests/factory/mymod.lua - @constructor tag attaches CLASS. as prefix to name - No more implicit use of "require 'pl'". steve donovan 11 years ago
9 changed file(s) with 81 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
11 -- Defining the ldoc document model.
22
33
4 require 'pl'
4 local class = require 'pl.class'
5 local utils = require 'pl.utils'
6 local List = require 'pl.List'
57
68 local doc = {}
79 local global = require 'ldoc.builtin.globals'
221223 -- if it was a class, then the name should be 'Class:foo'
222224 local stype = this_mod.section.type
223225 if doc.class_tag(stype) then
224 local prefix = this_mod.section.name .. ':'
225 local i1,i2 = item.name:find(prefix)
226 if not has_prefix(item.name,prefix) and not item.tags.constructor then
226 local prefix = this_mod.section.name .. (not item.tags.constructor and ':' or '.')
227 if not has_prefix(item.name,prefix) then
227228 item.name = prefix .. item.name
228229 end
229230 if stype == 'factory' then
415416 else
416417 self.parameter = 'field'
417418 end
418 local params = read_del(tags,self.parameter)
419 local names, comments, modifiers = List(), List(), List()
419 local field = self.parameter
420 local params = read_del(tags,field)
421 local names, comments = List(), List()
420422 if params then
421423 for line in params:iter() do
422424 local name, comment = line :match('%s*([%w_%.:]+)(.*)')
446448 end
447449 end
448450 names:append(name)
449 -- ldoc allows comments in the formal arg list to be used
450 comments:append (fargs.comments[name] or pcomments[i] or '')
451 local comment = pcomments[i]
452 if not comment then
453 -- ldoc allows comments in the formal arg list to be used, if they aren't specified with @param
454 -- Further, these comments may start with a type followed by a colon, and are then equivalent
455 -- to a @tparam
456 comment = fargs.comments[name]
457 if comment then
458 comment = comment:gsub('^%-+%s*','')
459 local type,rest = comment:match '([^:]+):(.*)'
460 if type then
461 if not self.modifiers[field] then self.modifiers[field] = List() end
462 self.modifiers[field]:append {type = type}
463 comment = rest
464 end
465 end
466 end
467 comments:append (comment or '')
451468 end
452469 -- A formal argument of ... may match any number of params, however.
453470 if #pnames > #fargs then
467484 -- adding name-value pairs to the params list (this is
468485 -- also done for any associated modifiers)
469486 self.params = names
470 local pmods = self.modifiers[self.parameter]
487 local pmods = self.modifiers[field]
471488 for i,name in ipairs(self.params) do
472489 self.params[name] = comments[i]
473490 if pmods then
542559 local err = io.stderr
543560
544561 local function custom_see_references (s)
545 --err:write('next',next(see_reference_handlers),'\n')
546562 for pat, action in pairs(see_reference_handlers) do
547 --err:write('pair ',pair,'\n')
548563 if s:match(pat) then
549564 local label, href = action(s:match(pat))
550565 return {href = href, label = label}
1212 -- generalizes the idea of these project-level categories and in fact custom categories
1313 -- can be created (refered to as 'kinds' in the code)
1414
15 local List = require 'pl.List'
16 local utils = require 'pl.utils'
17 local path = require 'pl.path'
18 local stringx = require 'pl.stringx'
1519 local template = require 'pl.template'
1620 local tools = require 'ldoc.tools'
1721 local markup = require 'ldoc.markup'
22 -- This encapsulates the different strategies needed for parsing C and Lua
33 -- source code.
44
5 require 'pl'
6
5 local class = require 'pl.class'
6 local utils = require 'pl.utils'
77 local tools = require 'ldoc.tools'
88 local lexer = require 'ldoc.lexer'
99
22 -- Currently just does Markdown, but this is intended to
33 -- be the general module for managing other formats as well.
44
5 require 'pl'
65 local doc = require 'ldoc.doc'
76 local utils = require 'pl.utils'
7 local stringx = require 'pl.stringx'
88 local prettify = require 'ldoc.prettify'
99 local quit, concat, lstrip = utils.quit, table.concat, stringx.lstrip
1010 local markup = {}
00 -- parsing code for doc comments
11
2 require 'pl'
2 local List = require 'pl.List'
3 local Map = require 'pl.Map'
4 local stringio = require 'pl.stringio'
35 local lexer = require 'ldoc.lexer'
46 local tools = require 'ldoc.tools'
57 local doc = require 'ldoc.doc'
22 -- for known modules and functions.
33 -- A module reference to an example `test-fun.lua` would look like
44 -- `@{example:test-fun}`.
5 require 'pl'
5 local List = require 'pl.List'
66 local lexer = require 'ldoc.lexer'
77 local globals = require 'ldoc.builtin.globals'
88 local tnext = lexer.skipws
11 -- General utility functions for ldoc
22 -- @module tools
33
4 require 'pl'
4 local class = require 'pl.class'
5 local List = require 'pl.List'
6 local path = require 'pl.path'
7 local utils = require 'pl.utils'
58 local tools = {}
69 local M = tools
710 local append = table.insert
299302 end
300303 end
301304
305 if next(args.comments) then -- we had argument comments
306 -- but the last one may be outside the parens! (Geoff style)
307 local n = #args
308 if not args.comments[n] then
309 local t = {tok()}
310 if type_of(t) == 'comment' then
311 set_comment(n,t)
312 end
313 end
314 end
315
302316 return args
303317 end
304318
1515 -- @license MIT/X11
1616 -- @script ldoc
1717
18 require 'pl'
18 local class = require 'pl.class'
19 local app = require 'pl.app'
20 local path = require 'pl.path'
21 local utils = require 'pl.utils'
22 local List = require 'pl.List'
23 local stringx = require 'pl.stringx'
24 local tablex = require 'pl.tablex'
25
1926
2027 local append = table.insert
2128
0 --- mymod
1
2 local mymod = {}
3
4 --- everything!
5 function mymod.query (
6 a, --string: first arg
7 b, --int: second arg
8 c --table: arg
9 )
10 end
11
12
13 --- for everything.
14 function mymod.answer (
15 a, -- first arg
16 b, -- second arg
17 c) -- third arg
18 end
19
20 return mymod