diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2011-06-24 00:11:37 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2011-06-24 00:11:37 -0400 |
commit | 9bbd1702850fa4f5ee0235181b9ffe40ec1f3133 (patch) | |
tree | 0b66bf8cf572818b1f506d3a5e67a3a4bf032db2 /scripts | |
parent | a591de5df7c1f264f4642ecba9c86a24620f5a46 (diff) |
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')
-rw-r--r-- | scripts/adeptsensedoc.lua | 35 | ||||
-rwxr-xr-x | scripts/gen_iface.lua | 22 |
2 files changed, 39 insertions, 18 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() diff --git a/scripts/gen_iface.lua b/scripts/gen_iface.lua index 4c2aeff7..311f3a92 100755 --- a/scripts/gen_iface.lua +++ b/scripts/gen_iface.lua @@ -14,6 +14,7 @@ local types = { keymod = 6, string = 7, stringresult = 8, cells = 9, textrange = 10, findtext = 11, formatrange = 12 } +local s = '_G._SCINTILLA.constants' f = io.open('../core/iface.lua', 'w') @@ -35,7 +36,7 @@ for item in iface:match('Constants%[%] = (%b{})'):sub(2, -2):gmatch('%b{}') do not name:find('^SCLEX_') then if name == 'SC_MASK_FOLDERS' then value = '-33554432' end constants[#constants + 1] = string_format('%s=%s', name, value) - fielddoc[#fielddoc + 1] = string_format('-- @field %s %d', name, value) + fielddoc[#fielddoc + 1] = string_format('-- * `%s.%s`: %d', s, name, value) end end @@ -71,7 +72,7 @@ local events = { } for event, value in pairs(events) do constants[#constants + 1] = string_format('%s=%d', event, value) - fielddoc[#fielddoc + 1] = string_format('-- @field %s %d', event, value) + fielddoc[#fielddoc + 1] = string_format('-- * `%s.%s`: %d', s, event, value) end -- Lexers added to constants. local lexers = { @@ -82,7 +83,7 @@ local lexers = { } for lexer, value in pairs(lexers) do constants[#constants + 1] = string_format('%s=%d', lexer, value) - fielddoc[#fielddoc + 1] = string_format('-- @field %s %d', lexer, value) + fielddoc[#fielddoc + 1] = string_format('-- * `%s.%s`: %d', s, lexer, value) end -- Write constants. @@ -91,9 +92,7 @@ f:write [[ -- Scintilla constants. -- @class table -- @name constants -]] -f:write(table.concat(fielddoc, '\n')) -f:write('\nconstants = {') +constants = {]] f:write(table.concat(constants, ',')) f:write('}\n\n') @@ -179,3 +178,14 @@ end ]] f:close() + +f = io.open('../core/._SCINTILLA.luadoc', 'w') +f:write [[ +-- Copyright 2007-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE. +-- This is a DUMMY FILE used for making Adeptsense for built-in constants in the +-- global _SCINTILLA.constants table. + +]] +f:write(table.concat(fielddoc, '\n')) +f:write('\n') +f:close() |