tables inside 'classes' are implicitly 'static'; respect blank lines even if not using markdown; fall back to bundled markdown.lua if not found elsewhere
This commit is contained in:
parent
dee7cd200a
commit
717eac46e5
|
@ -0,0 +1,3 @@
|
|||
tabsize=3
|
||||
indent.size=3
|
||||
use.tabs=0
|
|
@ -297,12 +297,12 @@ function File:finish()
|
|||
local this_section = this_mod.section
|
||||
item.section = this_section.display_name
|
||||
-- if it was a class, then if the name is unqualified then it becomes
|
||||
-- 'Class:foo' (unless explicitly flagged as being a constructor)
|
||||
-- 'Class:foo' (unless flagged as being a constructor, static or not a function)
|
||||
local stype = this_section.type
|
||||
if doc.class_tag(stype) then
|
||||
if not item.name:match '[:%.]' then -- not qualified
|
||||
local class = this_section.name
|
||||
local static = item.tags.constructor or item.tags.static
|
||||
local static = item.tags.constructor or item.tags.static or item.type ~= 'function'
|
||||
item.name = class..(not static and ':' or '.')..item.name
|
||||
end
|
||||
if stype == 'factory' then
|
||||
|
@ -401,12 +401,14 @@ function Item:set_tag (tag,value)
|
|||
end
|
||||
self.tags[tag] = value
|
||||
elseif ttype == TAG_ID then
|
||||
local modifiers
|
||||
if type(value) == 'table' then
|
||||
if value.append then -- it was a List!
|
||||
-- such tags are _not_ multiple, e.g. name
|
||||
self:error("'"..tag.."' cannot have multiple values")
|
||||
end
|
||||
value = value[1]
|
||||
modifiers = value.modifiers
|
||||
end
|
||||
local id, rest = tools.extract_identifier(value)
|
||||
self.tags[tag] = id
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -199,17 +199,24 @@ end
|
|||
|
||||
local formatters =
|
||||
{
|
||||
markdown = generic_formatter,
|
||||
markdown = function(format)
|
||||
local ok, markdown = pcall(require, 'markdown')
|
||||
if not ok then
|
||||
print('format: using built-in markdown')
|
||||
ok, markdown = pcall(require, 'ldoc.markdown')
|
||||
end
|
||||
return ok and markdown
|
||||
end,
|
||||
discount = generic_formatter,
|
||||
lunamark = function(format)
|
||||
local ok, lunamark = pcall(require, format)
|
||||
if ok then
|
||||
local writer = lunamark.writer.html.new()
|
||||
local parse = lunamark.reader.markdown.new(writer,
|
||||
{ smart = true })
|
||||
return function(text) return parse(text) end
|
||||
end
|
||||
local ok, lunamark = pcall(require, format)
|
||||
if ok then
|
||||
local writer = lunamark.writer.html.new()
|
||||
local parse = lunamark.reader.markdown.new(writer,
|
||||
{ smart = true })
|
||||
return function(text) return parse(text) end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,6 +237,8 @@ end
|
|||
local function text_processor(ldoc)
|
||||
return function(txt,item)
|
||||
if txt == nil then return '' end
|
||||
-- hack to separate paragraphs with blank lines
|
||||
txt = txt:gsub('\n\n','\n<p>')
|
||||
return resolve_inline_references(ldoc, txt, item, true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
project = 'usage'
|
||||
file = 'usage.lua'
|
||||
examples='usage.lua'
|
||||
-- can specify both the Markdown processor
|
||||
-- and the prettifier - this will use lxsh if available
|
||||
-- can specify the Markdown processor (falls back to markdown.lua)
|
||||
format='markdown'
|
||||
-- if you don't use markdown you may wish for backticks to be
|
||||
-- expanded if they enclose a reference.
|
||||
backtick_references = true
|
||||
-- and the prettifier - this will use lxsh _if_ available
|
||||
pretty='lxsh'
|
||||
-- suppress @params and the summary at the top
|
||||
no_return_or_parms=true
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
--[[--------
|
||||
A simple module with examples.
|
||||
|
||||
Even without markdown formatting, blank lines are respected.
|
||||
|
||||
@module usage
|
||||
]]
|
||||
|
||||
|
@ -61,6 +63,26 @@ end
|
|||
function Vector:add (v)
|
||||
end
|
||||
|
||||
----------
|
||||
-- set vector options. `opts` is a `Vector.Opts` table.
|
||||
function Vector:options (opts)
|
||||
end
|
||||
|
||||
--[[-----------------
|
||||
@table Vector.Opts
|
||||
Options table format for `Vector.options`
|
||||
|
||||
autoconvert: try to convert strings to numbers
|
||||
|
||||
adder: function used to perform addition and subtraction
|
||||
|
||||
multiplier: function used to perform multiplication and division
|
||||
@usage
|
||||
v = Vector {{1},{2}}
|
||||
v:options {adder = function(x,y) return {x[1]+y[1]} end}
|
||||
assert(v:add(1) == Vector{{2},{3}})
|
||||
]]
|
||||
|
||||
return usage
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue