diff options
author | 2011-06-24 00:11:37 -0400 | |
---|---|---|
committer | 2011-06-24 00:11:37 -0400 | |
commit | 9bbd1702850fa4f5ee0235181b9ffe40ec1f3133 (patch) | |
tree | 0b66bf8cf572818b1f506d3a5e67a3a4bf032db2 /scripts/adeptsensedoc.lua | |
parent | a591de5df7c1f264f4642ecba9c86a24620f5a46 (diff) | |
download | textadept-9bbd1702850fa4f5ee0235181b9ffe40ec1f3133.tar.gz textadept-9bbd1702850fa4f5ee0235181b9ffe40ec1f3133.zip |
Add ability to fake modules for generating Adeptsense.
With the new absolute field recognition, it is possible have a non-existant
module name in scripts/adeptsensedoc.lua's add_field() function. For example,
A '_G._SCINTILLA.constants.SCLEX_LPEG' field would look-up the
'_SCINTILLA.constants' module which does not exist; it is a table. Instead of
throwing an error, create a fake module so the appropriate tags and apidoc
are created ('SCLEX_LPEG _ 0;" F class:_SCINTILLA.constants') but do not create
tags and apidoc for the fake module.
Diffstat (limited to 'scripts/adeptsensedoc.lua')
-rw-r--r-- | scripts/adeptsensedoc.lua | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/scripts/adeptsensedoc.lua b/scripts/adeptsensedoc.lua index 86c761c9..0ba564ab 100644 --- a/scripts/adeptsensedoc.lua +++ b/scripts/adeptsensedoc.lua @@ -118,6 +118,13 @@ function start(doc) doc = doc:gsub('%[([^%]]+)%]%b[]', '%1'):gsub('%[([^%]]+)%]%b()', '%1') field.description = doc local m = modules[field.module] + if not m then + local name = field.module + _G.print("Module '"..name.."' does not exist. Faking...") + m = { name = name, functions = {}, fake = true } + modules[#modules + 1] = name + modules[name] = m + end if not m.fields then m.fields = {} end m.fields[#m.fields + 1] = field.name m.fields[field.name] = field @@ -164,19 +171,21 @@ function start(doc) for _, m in ipairs(modules) do m = modules[m] local module = m.name - -- Tag the module and write the apidoc. - write_tag(ctags, module, 'm', '') - if module:find('%.') then - -- Tag the last part of the module as a table of the first part. - local parent, child = module:match('^(.-)%.([^%.]+)$') - write_tag(ctags, child, 't', 'class:'..parent) - elseif module ~= '_G' then - -- Tag the module as a global table. - write_tag(ctags, module, 't', 'class:_G') - write_tag(ctags, module, 't', '') + if not m.fake then + -- Tag the module and write the apidoc. + write_tag(ctags, module, 'm', '') + if module:find('%.') then + -- Tag the last part of the module as a table of the first part. + local parent, child = module:match('^(.-)%.([^%.]+)$') + write_tag(ctags, child, 't', 'class:'..parent) + elseif module ~= '_G' then + -- Tag the module as a global table. + write_tag(ctags, module, 't', 'class:_G') + write_tag(ctags, module, 't', '') + end + m.modifier = '[module]' + write_apidoc(apidoc, { name = '_G' }, m) end - m.modifier = '[module]' - write_apidoc(apidoc, { name = '_G' }, m) -- Tag the functions and write the apidoc. for _, f in ipairs(m.functions) do if not f:find('no_functions') then -- ignore placeholders @@ -215,6 +224,8 @@ function start(doc) write_apidoc(apidoc, m, m.fields[f]) end end + table.sort(ctags) + table.sort(apidoc) local f = io.open(options.output_dir..'/tags', 'w') f:write(table.concat(ctags, '\n')) f:close() |