new_type() can now specify subfield; Colon mode must be explicitly switched on with -C,--colon or in config.ld
This commit is contained in:
parent
5e87bcf400
commit
10b5819667
16
docs/doc.md
16
docs/doc.md
|
@ -470,6 +470,22 @@ And then used as any other type:
|
||||||
|
|
||||||
This will also create a new module section called 'Macros'.
|
This will also create a new module section called 'Macros'.
|
||||||
|
|
||||||
|
If your new type has arguments or fields, then specify the name:
|
||||||
|
|
||||||
|
new_type("macro","Macros",false,"param")
|
||||||
|
|
||||||
|
(The third argument means that this is not a _project level_ tag)
|
||||||
|
|
||||||
|
Then you may say:
|
||||||
|
|
||||||
|
-----
|
||||||
|
-- A macro with arguments.
|
||||||
|
-- @macro second_macro
|
||||||
|
-- @param x the argument
|
||||||
|
|
||||||
|
And the arguments will be displayed under the subsection 'param'
|
||||||
|
|
||||||
|
|
||||||
## Inferring more from Code
|
## Inferring more from Code
|
||||||
|
|
||||||
The qualified name of a function will be inferred from any `function` keyword following the
|
The qualified name of a function will be inferred from any `function` keyword following the
|
||||||
|
|
13
ldoc.lua
13
ldoc.lua
|
@ -53,7 +53,7 @@ ldoc, a documentation generator for Lua, vs 1.3.1
|
||||||
-c,--config (default config.ld) configuration name
|
-c,--config (default config.ld) configuration name
|
||||||
-i,--ignore ignore any 'no doc comment or no module' warnings
|
-i,--ignore ignore any 'no doc comment or no module' warnings
|
||||||
-D,--define (default none) set a flag to be used in config.ld
|
-D,--define (default none) set a flag to be used in config.ld
|
||||||
-N,--nocolon don't treat colons specially
|
-C,--colon use colon style
|
||||||
-B,--boilerplate ignore first comment in source files
|
-B,--boilerplate ignore first comment in source files
|
||||||
--dump debug output dump
|
--dump debug output dump
|
||||||
--filter (default none) filter output as Lua data (e.g pl.pretty.dump)
|
--filter (default none) filter output as Lua data (e.g pl.pretty.dump)
|
||||||
|
@ -160,12 +160,12 @@ function ldoc.add_section (name, title, subname)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- new tags can be added, which can be on a project level.
|
-- new tags can be added, which can be on a project level.
|
||||||
function ldoc.new_type (tag, header, project_level)
|
function ldoc.new_type (tag, header, project_level,subfield)
|
||||||
doc.add_tag(tag,doc.TAG_TYPE,project_level)
|
doc.add_tag(tag,doc.TAG_TYPE,project_level)
|
||||||
if project_level then
|
if project_level then
|
||||||
ProjectMap:add_kind(tag,header)
|
ProjectMap:add_kind(tag,header,subfield)
|
||||||
else
|
else
|
||||||
ModuleMap:add_kind(tag,header)
|
ModuleMap:add_kind(tag,header,subfield)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ local ldoc_contents = {
|
||||||
'alias','add_language_extension','new_type','add_section', 'tparam_alias',
|
'alias','add_language_extension','new_type','add_section', 'tparam_alias',
|
||||||
'file','project','title','package','format','output','dir','ext', 'topics',
|
'file','project','title','package','format','output','dir','ext', 'topics',
|
||||||
'one','style','template','description','examples',
|
'one','style','template','description','examples',
|
||||||
'readme','all','manual_url', 'ignore', 'nocolon','boilerplate',
|
'readme','all','manual_url', 'ignore', 'colon','boilerplate',
|
||||||
'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
|
'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
|
||||||
}
|
}
|
||||||
ldoc_contents = tablex.makeset(ldoc_contents)
|
ldoc_contents = tablex.makeset(ldoc_contents)
|
||||||
|
@ -250,7 +250,6 @@ if args.module then
|
||||||
if not fullpath then
|
if not fullpath then
|
||||||
quit(mod)
|
quit(mod)
|
||||||
else
|
else
|
||||||
args.nocolon = on_docpath
|
|
||||||
args.file = fullpath
|
args.file = fullpath
|
||||||
args.module = mod
|
args.module = mod
|
||||||
end
|
end
|
||||||
|
@ -348,6 +347,7 @@ local process_file_list = tools.process_file_list
|
||||||
|
|
||||||
setup_package_base()
|
setup_package_base()
|
||||||
|
|
||||||
|
override 'colon'
|
||||||
|
|
||||||
if type(args.file) == 'table' then
|
if type(args.file) == 'table' then
|
||||||
-- this can only be set from config file so we can assume it's already read
|
-- this can only be set from config file so we can assume it's already read
|
||||||
|
@ -561,7 +561,6 @@ override 'output'
|
||||||
override 'dir'
|
override 'dir'
|
||||||
override 'ext'
|
override 'ext'
|
||||||
override 'one'
|
override 'one'
|
||||||
override 'nocolon'
|
|
||||||
override 'boilerplate'
|
override 'boilerplate'
|
||||||
|
|
||||||
if not args.ext:find '^%.' then
|
if not args.ext:find '^%.' then
|
||||||
|
|
|
@ -96,7 +96,7 @@ end
|
||||||
local function extract_tags (s,args)
|
local function extract_tags (s,args)
|
||||||
local preamble,tag_items
|
local preamble,tag_items
|
||||||
if s:match '^%s*$' then return {} end
|
if s:match '^%s*$' then return {} end
|
||||||
if not args.nocolon and s:match ':%s' and not s:match '@%a' then
|
if args.colon then --and s:match ':%s' and not s:match '@%a' then
|
||||||
preamble,tag_items = parse_colon_tags(s)
|
preamble,tag_items = parse_colon_tags(s)
|
||||||
else
|
else
|
||||||
preamble,tag_items = parse_at_tags(s)
|
preamble,tag_items = parse_at_tags(s)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
----------------------
|
||||||
|
-- Showing off Colon mode.
|
||||||
|
-- If you hate @ tags, you can use colons. However, you need to specify colon
|
||||||
|
-- mode explicitly -C or --colon, or `colon=true` in the config.ld. Be careful
|
||||||
|
-- not to use a colon followed by a space for any other purpose!
|
||||||
|
--
|
||||||
|
-- So the incantation in this case is `ldoc -C colon.lua`.
|
||||||
|
|
||||||
|
-- module: colon
|
||||||
|
|
||||||
|
|
||||||
|
--- first useless function.
|
||||||
|
-- Optional type specifiers are allowed in this format.
|
||||||
|
-- As an extension, '?' is short for '?|'.
|
||||||
|
-- Note how these types are rendered!
|
||||||
|
-- string: name
|
||||||
|
-- int: age
|
||||||
|
-- ?person2: options
|
||||||
|
-- treturn: ?table|string
|
||||||
|
function one (name,age,options)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- explicit table in colon format.
|
||||||
|
-- Note how '!' lets you use a type name directly.
|
||||||
|
-- string: surname
|
||||||
|
-- string: birthdate
|
||||||
|
-- !person2: options
|
||||||
|
-- table: person3
|
|
@ -15,17 +15,6 @@
|
||||||
function one (name,age)
|
function one (name,age)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- second useless function.
|
|
||||||
-- If you hate @ tags, you can use colons.
|
|
||||||
-- Optional type specifiers are allowed in this format.
|
|
||||||
-- As an extension, '?' is short for '?|'.
|
|
||||||
-- Note how these types are rendered!
|
|
||||||
-- string: name
|
|
||||||
-- int: age
|
|
||||||
-- ?person2: options
|
|
||||||
-- treturn: ?table|string
|
|
||||||
function two (name,age,options)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- third useless function.
|
--- third useless function.
|
||||||
-- Can always put comments inline, may
|
-- Can always put comments inline, may
|
||||||
|
@ -50,9 +39,3 @@ person = {
|
||||||
-- @int age
|
-- @int age
|
||||||
-- @table person2
|
-- @table person2
|
||||||
|
|
||||||
--- explicit table in colon format.
|
|
||||||
-- Note how '!' lets you use a type name directly.
|
|
||||||
-- string: surname
|
|
||||||
-- string: birthdate
|
|
||||||
-- !person2: options
|
|
||||||
-- table: person3
|
|
||||||
|
|
Loading…
Reference in New Issue