refactor: Drop completely unused variable references
This commit is contained in:
parent
f1b3f76aca
commit
92a6714d9a
2
ldoc.lua
2
ldoc.lua
|
@ -90,7 +90,7 @@ local global = require 'ldoc.builtin.globals'
|
|||
local markup = require 'ldoc.markup'
|
||||
local parse = require 'ldoc.parse'
|
||||
local KindMap = tools.KindMap
|
||||
local Item,File,Module = doc.Item,doc.File,doc.Module
|
||||
local Item,File = doc.Item,doc.File
|
||||
local quit = utils.quit
|
||||
|
||||
if args.version then
|
||||
|
|
11
ldoc/doc.lua
11
ldoc/doc.lua
|
@ -251,9 +251,9 @@ function File:finish()
|
|||
end
|
||||
end
|
||||
elseif item.type == 'submodule' then
|
||||
local mf
|
||||
local _
|
||||
submodule = true
|
||||
this_mod,mf = self:find_module_in_files(item.name)
|
||||
this_mod,_ = self:find_module_in_files(item.name)
|
||||
if this_mod == nil then
|
||||
self:error("'"..item.name.."' not found for submodule")
|
||||
end
|
||||
|
@ -489,7 +489,6 @@ 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
|
||||
|
@ -500,7 +499,6 @@ function Item:set_tag (tag,value)
|
|||
end
|
||||
end
|
||||
value = value[1]
|
||||
modifiers = value.modifiers
|
||||
end
|
||||
if value == nil then self:error("Tag without value: "..tag) end
|
||||
local id, rest = tools.extract_identifier(value)
|
||||
|
@ -1050,8 +1048,6 @@ function Module:hunt_for_reference (packmod, modules)
|
|||
return mod_ref
|
||||
end
|
||||
|
||||
local err = io.stderr
|
||||
|
||||
local function custom_see_references (s)
|
||||
for pat, action in pairs(see_reference_handlers) do
|
||||
if s:match(pat) then
|
||||
|
@ -1087,7 +1083,7 @@ end
|
|||
|
||||
function Module:process_see_reference (s,modules,istype)
|
||||
if s == nil then return nil end
|
||||
local mod_ref,fun_ref,name,packmod
|
||||
local fun_ref
|
||||
local ref = custom_see_references(s)
|
||||
if ref then return ref end
|
||||
if not s:match '^[%w_%.\\%:%-]+$' or not s:match '[%w_]$' then
|
||||
|
@ -1289,7 +1285,6 @@ function File:dump(verbose)
|
|||
end
|
||||
|
||||
function Item:dump(verbose)
|
||||
local tags = self.tags
|
||||
local name = self.name
|
||||
if self.type == 'function' then
|
||||
name = name .. self.args
|
||||
|
|
|
@ -154,7 +154,7 @@ function html.generate_output(ldoc, args, project)
|
|||
end
|
||||
|
||||
function ldoc.include_file (file)
|
||||
local text,e = utils.readfile(file)
|
||||
local text,_ = utils.readfile(file)
|
||||
if not text then quit("unable to include "..file)
|
||||
else
|
||||
return text
|
||||
|
@ -234,7 +234,7 @@ function ldoc.source_ref (fun)
|
|||
local types = {}
|
||||
for name in tp:gmatch("[^|]+") do
|
||||
local sym = name:match '([%w%.%:]+)'
|
||||
local ref,err = markup.process_reference(sym,true)
|
||||
local ref,_ = markup.process_reference(sym,true)
|
||||
if ref then
|
||||
if ref.label and sym == name then
|
||||
name = ref.label
|
||||
|
@ -273,7 +273,7 @@ function ldoc.source_ref (fun)
|
|||
ldoc.doc_charset = (m and m.tags.charset) or ldoc.charset
|
||||
end
|
||||
|
||||
local module_template,err = utils.readfile (path.join(args.template,ldoc.templ))
|
||||
local module_template,_ = utils.readfile (path.join(args.template,ldoc.templ))
|
||||
if not module_template then
|
||||
quit("template not found at '"..args.template.."' Use -l to specify directory containing ldoc.ltp")
|
||||
end
|
||||
|
|
|
@ -150,7 +150,7 @@ function Lua:item_follows(t,v,tok)
|
|||
case = 1
|
||||
parser = parse_lua_function_header
|
||||
elseif t == 'iden' then
|
||||
local name,t,v = tools.get_fun_name(tok,v)
|
||||
local name,t,_ = tools.get_fun_name(tok,v)
|
||||
if t ~= '=' then return nil,"not 'name = function,table or value'" end
|
||||
t,v = tnext(tok)
|
||||
if t == 'keyword' and v == 'function' then -- case [2]
|
||||
|
@ -229,7 +229,7 @@ function Lua:parse_module_modifier (tags, tok, F)
|
|||
if tags.class ~= 'field' then return nil,"cannot deduce @usage" end
|
||||
local t1= tnext(tok)
|
||||
if t1 ~= '[' then return nil, t1..' '..': not a long string' end
|
||||
local t, v = tools.grab_block_comment('',tok,'%]%]')
|
||||
local _, v = tools.grab_block_comment('',tok,'%]%]')
|
||||
return true, v, 'usage'
|
||||
elseif tags.export then
|
||||
if tags.class ~= 'table' then return nil, "cannot deduce @export" end
|
||||
|
@ -285,12 +285,13 @@ function CC:item_follows (t,v,tok)
|
|||
return false
|
||||
end
|
||||
if t == 'iden' or t == 'keyword' then --
|
||||
local _
|
||||
if v == self.extra.export then -- this is not part of the return type!
|
||||
t,v = tnext(tok)
|
||||
_,v = tnext(tok)
|
||||
end
|
||||
-- types may have multiple tokens: example, const char *bonzo(...)
|
||||
local return_type, name = v
|
||||
t,v = tnext(tok)
|
||||
_,v = tnext(tok)
|
||||
name = v
|
||||
t,v = tnext(tok)
|
||||
while t ~= '(' do
|
||||
|
@ -305,7 +306,7 @@ function CC:item_follows (t,v,tok)
|
|||
end
|
||||
tags:add('class','function')
|
||||
if t == '(' then
|
||||
tags.formal_args,t,v = tools.get_parameters(tok,')',',',self)
|
||||
tags.formal_args,t,_ = tools.get_parameters(tok,')',',',self)
|
||||
if return_type ~= 'void' then
|
||||
tags.formal_args.return_type = return_type
|
||||
end
|
||||
|
@ -342,25 +343,26 @@ function Moon:item_follows (t,v,tok)
|
|||
if t == 'iden' then
|
||||
local name,t,v = tools.get_fun_name(tok,v,'')
|
||||
if name == 'class' then
|
||||
name,t,v = tools.get_fun_name(tok,v,'')
|
||||
local _
|
||||
name,_,_ = tools.get_fun_name(tok,v,'')
|
||||
-- class!
|
||||
return function(tags,tok)
|
||||
tags:add('class','type')
|
||||
tags:add('name',name)
|
||||
end
|
||||
elseif t == '=' or t == ':' then -- function/method
|
||||
local fat = false
|
||||
t,v = tnext(tok)
|
||||
local _
|
||||
t,_ = tnext(tok)
|
||||
return function(tags,tok)
|
||||
if not tags.name then
|
||||
tags:add('name',name)
|
||||
end
|
||||
if t == '(' then
|
||||
tags.formal_args,t,v = tools.get_parameters(tok,')',',',self)
|
||||
tags.formal_args,t,_ = tools.get_parameters(tok,')',',',self)
|
||||
else
|
||||
tags.formal_args = List()
|
||||
end
|
||||
t,v = tnext(tok)
|
||||
t,_ = tnext(tok)
|
||||
tags:add('class','function')
|
||||
if t ~= '>' then
|
||||
tags.static = true
|
||||
|
|
|
@ -171,7 +171,7 @@ function lexer.scan (s,matches,filter,options)
|
|||
end
|
||||
matches = plain_matches
|
||||
end
|
||||
local i1,i2,idx,res1,res2,tok,pat,fun,capt
|
||||
local i1,i2,tok,pat,fun
|
||||
local line = 1
|
||||
if file then
|
||||
s = file:read()
|
||||
|
|
|
@ -1218,7 +1218,7 @@ local function run_command_line(arg)
|
|||
local function run(s, options)
|
||||
s = markdown(s)
|
||||
if not options.wrap_header then return s end
|
||||
local header = ""
|
||||
local header
|
||||
if options.header then
|
||||
local f = io.open(options.header) or error("Could not open file: " .. options.header)
|
||||
header = f:read("*a")
|
||||
|
|
|
@ -7,7 +7,7 @@ local doc = require 'ldoc.doc'
|
|||
local utils = require 'pl.utils'
|
||||
local stringx = require 'pl.stringx'
|
||||
local prettify = require 'ldoc.prettify'
|
||||
local quit, concat, lstrip = utils.quit, table.concat, stringx.lstrip
|
||||
local concat = table.concat
|
||||
local markup = {}
|
||||
|
||||
local backtick_references
|
||||
|
@ -53,7 +53,7 @@ local function resolve_inline_references (ldoc, txt, item, plain)
|
|||
end))
|
||||
if backtick_references then
|
||||
res = res:gsub('`([^`]+)`',function(name)
|
||||
local ref,err = markup.process_reference(name)
|
||||
local ref,_ = markup.process_reference(name)
|
||||
local label = name
|
||||
if name and do_escape then
|
||||
label = name:gsub('_', '\\_')
|
||||
|
@ -135,10 +135,10 @@ local function process_multiline_markdown(ldoc, txt, F, filename, deflang)
|
|||
local function pretty_code (code, lang)
|
||||
code = concat(code,'\n')
|
||||
if code ~= '' then
|
||||
local err
|
||||
local _
|
||||
-- If we omit the following '\n', a '--' (or '//') comment on the
|
||||
-- last line won't be recognized.
|
||||
code, err = prettify.code(lang,filename,code..'\n',L,false)
|
||||
code, _ = prettify.code(lang,filename,code..'\n',L,false)
|
||||
code = resolve_inline_references(ldoc, code, err_item,true)
|
||||
append(res,'<pre>')
|
||||
append(res, code)
|
||||
|
|
|
@ -170,7 +170,6 @@ end
|
|||
-- module if there isn't an explicit module name specified.
|
||||
|
||||
local function parse_file(fname, lang, package, args)
|
||||
local line,f = 1
|
||||
local F = File(fname)
|
||||
local module_found, first_comment = false,true
|
||||
local current_item, module_item
|
||||
|
@ -187,7 +186,6 @@ local function parse_file(fname, lang, package, args)
|
|||
end
|
||||
|
||||
function F:warning (msg,kind,line)
|
||||
kind = kind or 'warning'
|
||||
line = line or lineno()
|
||||
Item.had_warning = true
|
||||
io.stderr:write(fname..':'..line..': '..msg,'\n')
|
||||
|
@ -299,7 +297,7 @@ local function parse_file(fname, lang, package, args)
|
|||
module_found = tags.name
|
||||
-- might be a module returning a single function!
|
||||
if tags.param or tags['return'] then
|
||||
local parms, ret, summ = tags.param, tags['return'],tags.summary
|
||||
local parms, ret = tags.param, tags['return']
|
||||
local name = tags.name
|
||||
tags.param = nil
|
||||
tags['return'] = nil
|
||||
|
|
|
@ -30,8 +30,8 @@ local spans = {keyword=true,number=true,string=true,comment=true,global=true,bac
|
|||
local cpp_lang = {C = true, c = true, cpp = true, cxx = true, h = true}
|
||||
|
||||
function prettify.lua (lang, fname, code, initial_lineno, pre, linenos)
|
||||
local res, lexer, tokenizer = List(), require 'ldoc.lexer'
|
||||
local tnext = lexer.skipws
|
||||
local res, lexer = List(), require 'ldoc.lexer'
|
||||
local tokenizer
|
||||
local ik = 1
|
||||
if not cpp_lang[lang] then
|
||||
tokenizer = lexer.lua
|
||||
|
|
|
@ -79,7 +79,7 @@ end
|
|||
|
||||
function KindMap:put_kind_first (kind)
|
||||
-- find this kind in our kind list
|
||||
local kinds = self.klass.kinds,kind
|
||||
local kinds = self.klass.kinds
|
||||
local idx = tablex.find(kinds,kind)
|
||||
-- and swop with the start!
|
||||
if idx then
|
||||
|
@ -232,8 +232,9 @@ end
|
|||
function M.check_file (f,original)
|
||||
if not path.exists(f) or path.getmtime(original) > path.getmtime(f) then
|
||||
local text,err = utils.readfile(original)
|
||||
local _
|
||||
if text then
|
||||
text,err = utils.writefile(f,text)
|
||||
_,err = utils.writefile(f,text)
|
||||
end
|
||||
if err then
|
||||
quit("Could not copy "..original.." to "..f)
|
||||
|
@ -250,13 +251,12 @@ function M.writefile(name,text)
|
|||
end
|
||||
|
||||
function M.name_of (lpath)
|
||||
local ext
|
||||
lpath,ext = path.splitext(lpath)
|
||||
local _
|
||||
lpath,_ = path.splitext(lpath)
|
||||
return lpath
|
||||
end
|
||||
|
||||
function M.this_module_name (basename,fname)
|
||||
local ext
|
||||
if basename == '' then
|
||||
return M.name_of(fname)
|
||||
end
|
||||
|
@ -429,7 +429,7 @@ end
|
|||
-- Set `colon` to be the secondary separator, '' for none.
|
||||
function M.get_fun_name (tok,first,colon)
|
||||
local res = {}
|
||||
local t,name,sep
|
||||
local t,name,sep,_
|
||||
colon = colon or ':'
|
||||
if not first then
|
||||
t,name = tnext(tok)
|
||||
|
@ -441,7 +441,7 @@ function M.get_fun_name (tok,first,colon)
|
|||
while sep == '.' or sep == colon do
|
||||
append(res,name)
|
||||
append(res,sep)
|
||||
t,name = tnext(tok)
|
||||
_,name = tnext(tok)
|
||||
t,sep = tnext(tok)
|
||||
end
|
||||
append(res,name)
|
||||
|
|
Loading…
Reference in New Issue