2019-03-29 13:54:34 -07:00
|
|
|
--[[--------------------------------------------------------------------------
|
|
|
|
-- Copyright (C) 2012 by Simon Dales --
|
|
|
|
-- simon@purrsoft.co.uk --
|
|
|
|
-- --
|
|
|
|
-- This program is free software; you can redistribute it and/or modify --
|
|
|
|
-- it under the terms of the GNU General Public License as published by --
|
|
|
|
-- the Free Software Foundation; either version 2 of the License, or --
|
|
|
|
-- (at your option) any later version. --
|
|
|
|
-- --
|
|
|
|
-- This program is distributed in the hope that it will be useful, --
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
|
|
|
|
-- GNU General Public License for more details. --
|
|
|
|
-- --
|
|
|
|
-- You should have received a copy of the GNU General Public License --
|
|
|
|
-- along with this program; if not, write to the --
|
|
|
|
-- Free Software Foundation, Inc., --
|
|
|
|
-- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
|
|
|
|
----------------------------------------------------------------------------]]
|
|
|
|
|
|
|
|
--[[!
|
2019-12-31 07:52:14 -07:00
|
|
|
Lua-to-Doxygen converter
|
2019-03-29 13:54:34 -07:00
|
|
|
|
2019-12-31 07:52:14 -07:00
|
|
|
Partially from lua2dox
|
|
|
|
http://search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
Running
|
|
|
|
-------
|
|
|
|
|
2019-12-31 07:52:14 -07:00
|
|
|
This file "lua2dox.lua" gets called by "lua2dox_filter" (bash).
|
2019-03-29 13:54:34 -07:00
|
|
|
|
2019-12-31 07:52:14 -07:00
|
|
|
Doxygen must be on your system. You can experiment like so:
|
2019-03-29 13:54:34 -07:00
|
|
|
|
2019-12-31 07:52:14 -07:00
|
|
|
- Run "doxygen -g" to create a default Doxyfile.
|
|
|
|
- Then alter it to let it recognise lua. Add the two following lines:
|
|
|
|
FILE_PATTERNS = *.lua
|
|
|
|
FILTER_PATTERNS = *.lua=lua2dox_filter
|
|
|
|
- Then run "doxygen".
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
The core function reads the input file (filename or stdin) and outputs some pseudo C-ish language.
|
|
|
|
It only has to be good enough for doxygen to see it as legal.
|
|
|
|
|
|
|
|
One limitation is that each line is treated separately (except for long comments).
|
|
|
|
The implication is that class and function declarations must be on the same line.
|
|
|
|
Some functions can have their parameter lists extended over multiple lines to make it look neat.
|
|
|
|
Managing this where there are also some comments is a bit more coding than I want to do at this stage,
|
|
|
|
so it will probably not document accurately if we do do this.
|
|
|
|
|
|
|
|
However I have put in a hack that will insert the "missing" close paren.
|
|
|
|
The effect is that you will get the function documented, but not with the parameter list you might expect.
|
|
|
|
]]
|
|
|
|
|
2022-10-10 04:21:19 -07:00
|
|
|
local function class()
|
2022-10-10 04:10:57 -07:00
|
|
|
local newClass = {} -- a new class newClass
|
2019-03-29 13:54:34 -07:00
|
|
|
-- the class will be the metatable for all its newInstanceects,
|
|
|
|
-- and they will look up their methods in it.
|
|
|
|
newClass.__index = newClass
|
|
|
|
|
|
|
|
-- expose a constructor which can be called by <classname>(<args>)
|
2022-10-10 04:21:19 -07:00
|
|
|
setmetatable(newClass, {
|
|
|
|
__call = function(class_tbl, ...)
|
|
|
|
local newInstance = {}
|
|
|
|
setmetatable(newInstance, newClass)
|
|
|
|
--if init then
|
|
|
|
-- init(newInstance,...)
|
|
|
|
if class_tbl.init then
|
|
|
|
class_tbl.init(newInstance, ...)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
2022-10-10 04:21:19 -07:00
|
|
|
return newInstance
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
2022-10-10 04:21:19 -07:00
|
|
|
})
|
2019-03-29 13:54:34 -07:00
|
|
|
return newClass
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief write to stdout
|
2021-09-19 16:35:38 -07:00
|
|
|
local function TCore_IO_write(Str)
|
2022-10-10 04:10:57 -07:00
|
|
|
if Str then
|
2019-03-29 13:54:34 -07:00
|
|
|
io.write(Str)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief write to stdout
|
2021-09-19 16:35:38 -07:00
|
|
|
local function TCore_IO_writeln(Str)
|
2022-10-10 04:10:57 -07:00
|
|
|
if Str then
|
2019-03-29 13:54:34 -07:00
|
|
|
io.write(Str)
|
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
io.write('\n')
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief trims a string
|
2021-09-19 16:35:38 -07:00
|
|
|
local function string_trim(Str)
|
2022-10-10 04:10:57 -07:00
|
|
|
return Str:match('^%s*(.-)%s*$')
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief split a string
|
2021-09-19 16:35:38 -07:00
|
|
|
--!
|
2019-03-29 13:54:34 -07:00
|
|
|
--! \param Str
|
|
|
|
--! \param Pattern
|
|
|
|
--! \returns table of string fragments
|
2022-09-28 04:22:08 -07:00
|
|
|
---@return string[]
|
2021-09-19 16:35:38 -07:00
|
|
|
local function string_split(Str, Pattern)
|
2019-03-29 13:54:34 -07:00
|
|
|
local splitStr = {}
|
2022-10-10 04:10:57 -07:00
|
|
|
local fpat = '(.-)' .. Pattern
|
2019-03-29 13:54:34 -07:00
|
|
|
local last_end = 1
|
2022-10-10 04:10:57 -07:00
|
|
|
local str, e, cap = string.find(Str, fpat, 1)
|
2019-03-29 13:54:34 -07:00
|
|
|
while str do
|
2022-10-10 04:10:57 -07:00
|
|
|
if str ~= 1 or cap ~= '' then
|
|
|
|
table.insert(splitStr, cap)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
last_end = e + 1
|
|
|
|
str, e, cap = string.find(Str, fpat, last_end)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
if last_end <= #Str then
|
2022-10-10 04:10:57 -07:00
|
|
|
cap = string.sub(Str, last_end)
|
2019-03-29 13:54:34 -07:00
|
|
|
table.insert(splitStr, cap)
|
|
|
|
end
|
|
|
|
return splitStr
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \class TCore_Commandline
|
|
|
|
--! \brief reads/parses commandline
|
2021-09-19 16:35:38 -07:00
|
|
|
local TCore_Commandline = class()
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
--! \brief constructor
|
|
|
|
function TCore_Commandline.init(this)
|
|
|
|
this.argv = arg
|
|
|
|
this.parsed = {}
|
|
|
|
this.params = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief get value
|
2022-10-10 04:10:57 -07:00
|
|
|
function TCore_Commandline.getRaw(this, Key, Default)
|
2019-03-29 13:54:34 -07:00
|
|
|
local val = this.argv[Key]
|
|
|
|
if not val then
|
|
|
|
val = Default
|
|
|
|
end
|
|
|
|
return val
|
|
|
|
end
|
|
|
|
|
|
|
|
-------------------------------
|
|
|
|
--! \brief file buffer
|
2021-09-19 16:35:38 -07:00
|
|
|
--!
|
2019-03-29 13:54:34 -07:00
|
|
|
--! an input file buffer
|
2021-09-19 16:35:38 -07:00
|
|
|
local TStream_Read = class()
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
--! \brief get contents of file
|
2021-09-19 16:35:38 -07:00
|
|
|
--!
|
2019-03-29 13:54:34 -07:00
|
|
|
--! \param Filename name of file to read (or nil == stdin)
|
2022-10-10 04:10:57 -07:00
|
|
|
function TStream_Read.getContents(this, Filename)
|
2021-09-19 16:35:38 -07:00
|
|
|
assert(Filename)
|
2019-03-29 13:54:34 -07:00
|
|
|
-- get lines from file
|
2021-09-19 16:35:38 -07:00
|
|
|
-- syphon lines to our table
|
2022-10-10 04:10:57 -07:00
|
|
|
local filecontents = {}
|
2021-09-19 16:35:38 -07:00
|
|
|
for line in io.lines(Filename) do
|
2022-10-10 04:10:57 -07:00
|
|
|
table.insert(filecontents, line)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
if filecontents then
|
|
|
|
this.filecontents = filecontents
|
|
|
|
this.contentsLen = #filecontents
|
|
|
|
this.currentLineNo = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
return filecontents
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief get lineno
|
|
|
|
function TStream_Read.getLineNo(this)
|
|
|
|
return this.currentLineNo
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief get a line
|
|
|
|
function TStream_Read.getLine(this)
|
|
|
|
local line
|
|
|
|
if this.currentLine then
|
|
|
|
line = this.currentLine
|
|
|
|
this.currentLine = nil
|
|
|
|
else
|
|
|
|
-- get line
|
2022-10-10 04:10:57 -07:00
|
|
|
if this.currentLineNo <= this.contentsLen then
|
2019-03-29 13:54:34 -07:00
|
|
|
line = this.filecontents[this.currentLineNo]
|
|
|
|
this.currentLineNo = this.currentLineNo + 1
|
|
|
|
else
|
|
|
|
line = ''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return line
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief save line fragment
|
2022-10-10 04:10:57 -07:00
|
|
|
function TStream_Read.ungetLine(this, LineFrag)
|
2019-03-29 13:54:34 -07:00
|
|
|
this.currentLine = LineFrag
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief is it eof?
|
|
|
|
function TStream_Read.eof(this)
|
2022-10-10 04:10:57 -07:00
|
|
|
if this.currentLine or this.currentLineNo <= this.contentsLen then
|
2019-03-29 13:54:34 -07:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief output stream
|
2021-09-19 16:35:38 -07:00
|
|
|
local TStream_Write = class()
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
--! \brief constructor
|
|
|
|
function TStream_Write.init(this)
|
|
|
|
this.tailLine = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief write immediately
|
2022-10-10 04:10:57 -07:00
|
|
|
function TStream_Write.write(_, Str)
|
2019-03-29 13:54:34 -07:00
|
|
|
TCore_IO_write(Str)
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief write immediately
|
2022-10-10 04:10:57 -07:00
|
|
|
function TStream_Write.writeln(_, Str)
|
2019-03-29 13:54:34 -07:00
|
|
|
TCore_IO_writeln(Str)
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief write immediately
|
2022-10-10 04:10:57 -07:00
|
|
|
function TStream_Write.writelnComment(_, Str)
|
2019-03-29 13:54:34 -07:00
|
|
|
TCore_IO_write('// ZZ: ')
|
|
|
|
TCore_IO_writeln(Str)
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief write to tail
|
2022-10-10 04:10:57 -07:00
|
|
|
function TStream_Write.writelnTail(this, Line)
|
2019-03-29 13:54:34 -07:00
|
|
|
if not Line then
|
|
|
|
Line = ''
|
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
table.insert(this.tailLine, Line)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
2022-04-15 03:35:06 -07:00
|
|
|
--! \brief output tail lines
|
2019-03-29 13:54:34 -07:00
|
|
|
function TStream_Write.write_tailLines(this)
|
2022-10-10 04:10:57 -07:00
|
|
|
for _, line in ipairs(this.tailLine) do
|
2019-03-29 13:54:34 -07:00
|
|
|
TCore_IO_writeln(line)
|
|
|
|
end
|
|
|
|
TCore_IO_write('// Lua2DoX new eof')
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief input filter
|
2021-09-19 16:35:38 -07:00
|
|
|
local TLua2DoX_filter = class()
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
--! \brief allow us to do errormessages
|
2022-10-10 04:10:57 -07:00
|
|
|
function TLua2DoX_filter.warning(this, Line, LineNo, Legend)
|
2019-03-29 13:54:34 -07:00
|
|
|
this.outStream:writelnTail(
|
2022-10-10 04:10:57 -07:00
|
|
|
'//! \todo warning! ' .. Legend .. ' (@' .. LineNo .. ')"' .. Line .. '"'
|
2019-03-29 13:54:34 -07:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief trim comment off end of string
|
|
|
|
--!
|
|
|
|
--! If the string has a comment on the end, this trims it off.
|
|
|
|
--!
|
|
|
|
local function TString_removeCommentFromLine(Line)
|
2022-10-10 04:10:57 -07:00
|
|
|
local pos_comment = string.find(Line, '%-%-')
|
2019-03-29 13:54:34 -07:00
|
|
|
local tailComment
|
|
|
|
if pos_comment then
|
2022-10-10 04:10:57 -07:00
|
|
|
Line = string.sub(Line, 1, pos_comment - 1)
|
|
|
|
tailComment = string.sub(Line, pos_comment)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
return Line, tailComment
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief get directive from magic
|
|
|
|
local function getMagicDirective(Line)
|
2022-10-10 04:10:57 -07:00
|
|
|
local macro, tail
|
2019-03-29 13:54:34 -07:00
|
|
|
local macroStr = '[\\@]'
|
2022-10-10 04:10:57 -07:00
|
|
|
local pos_macro = string.find(Line, macroStr)
|
2019-03-29 13:54:34 -07:00
|
|
|
if pos_macro then
|
|
|
|
--! ....\\ macro...stuff
|
|
|
|
--! ....\@ macro...stuff
|
2022-10-10 04:10:57 -07:00
|
|
|
local line = string.sub(Line, pos_macro + 1)
|
|
|
|
local space = string.find(line, '%s+')
|
2019-03-29 13:54:34 -07:00
|
|
|
if space then
|
2022-10-10 04:10:57 -07:00
|
|
|
macro = string.sub(line, 1, space - 1)
|
|
|
|
tail = string_trim(string.sub(line, space + 1))
|
2019-03-29 13:54:34 -07:00
|
|
|
else
|
|
|
|
macro = line
|
2022-10-10 04:10:57 -07:00
|
|
|
tail = ''
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
return macro, tail
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief check comment for fn
|
2022-10-10 04:10:57 -07:00
|
|
|
local function checkComment4fn(Fn_magic, MagicLines)
|
2019-03-29 13:54:34 -07:00
|
|
|
local fn_magic = Fn_magic
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
-- TCore_IO_writeln('// checkComment4fn "' .. MagicLines .. '"')
|
2019-03-29 13:54:34 -07:00
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
local magicLines = string_split(MagicLines, '\n')
|
2019-03-29 13:54:34 -07:00
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
local macro, tail
|
2019-03-29 13:54:34 -07:00
|
|
|
|
2021-09-19 16:35:38 -07:00
|
|
|
for _, line in ipairs(magicLines) do
|
2022-10-10 04:10:57 -07:00
|
|
|
macro, tail = getMagicDirective(line)
|
2019-03-29 13:54:34 -07:00
|
|
|
if macro == 'fn' then
|
|
|
|
fn_magic = tail
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
-- TCore_IO_writeln('// found fn "' .. fn_magic .. '"')
|
2021-09-19 16:35:38 -07:00
|
|
|
--else
|
2019-03-29 13:54:34 -07:00
|
|
|
--TCore_IO_writeln('// not found fn "' .. line .. '"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return fn_magic
|
|
|
|
end
|
2022-09-28 04:22:08 -07:00
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
local types = { 'number', 'string', 'table', 'list', 'boolean', 'function' }
|
2022-09-28 04:22:08 -07:00
|
|
|
|
2019-03-29 13:54:34 -07:00
|
|
|
--! \brief run the filter
|
2022-10-10 04:10:57 -07:00
|
|
|
function TLua2DoX_filter.readfile(this, AppStamp, Filename)
|
2019-03-29 13:54:34 -07:00
|
|
|
local inStream = TStream_Read()
|
|
|
|
local outStream = TStream_Write()
|
|
|
|
this.outStream = outStream -- save to this obj
|
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
if inStream:getContents(Filename) then
|
2019-03-29 13:54:34 -07:00
|
|
|
-- output the file
|
|
|
|
local line
|
|
|
|
local fn_magic -- function name/def from magic comment
|
|
|
|
|
|
|
|
outStream:writelnTail('// #######################')
|
|
|
|
outStream:writelnTail('// app run:' .. AppStamp)
|
|
|
|
outStream:writelnTail('// #######################')
|
|
|
|
outStream:writelnTail()
|
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
local state = '' -- luacheck: ignore 231 variable is set but never accessed.
|
2021-09-19 16:35:38 -07:00
|
|
|
local offset = 0
|
2022-09-27 23:56:47 -07:00
|
|
|
local generic = {}
|
|
|
|
local l = 0
|
2021-09-19 16:35:38 -07:00
|
|
|
while not (inStream:eof()) do
|
2019-03-29 13:54:34 -07:00
|
|
|
line = string_trim(inStream:getLine())
|
2022-09-27 23:56:47 -07:00
|
|
|
l = l + 1
|
2022-10-10 04:10:57 -07:00
|
|
|
if string.sub(line, 1, 2) == '--' then -- it's a comment
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
-- Allow people to write style similar to EmmyLua (since they are basically the same)
|
|
|
|
-- instead of silently skipping things that start with ---
|
|
|
|
if string.sub(line, 3, 3) == '@' then -- it's a magic comment
|
|
|
|
offset = 0
|
|
|
|
elseif string.sub(line, 1, 4) == '---@' then -- it's a magic comment
|
|
|
|
offset = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment
|
2019-05-25 01:00:41 -07:00
|
|
|
state = 'in_magic_comment'
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
local magic = string.sub(line, 4 + offset)
|
2022-05-12 07:02:46 -07:00
|
|
|
|
|
|
|
local magic_split = string_split(magic, ' ')
|
2022-09-28 04:22:08 -07:00
|
|
|
if magic_split[1] == 'param' then
|
|
|
|
for _, type in ipairs(types) do
|
2022-10-10 04:10:57 -07:00
|
|
|
magic = magic:gsub('^param%s+([a-zA-Z_?]+)%s+.*%((' .. type .. ')%)', 'param %1 %2')
|
|
|
|
magic =
|
|
|
|
magic:gsub('^param%s+([a-zA-Z_?]+)%s+.*%((' .. type .. '|nil)%)', 'param %1 %2')
|
2022-09-28 04:22:08 -07:00
|
|
|
end
|
|
|
|
magic_split = string_split(magic, ' ')
|
|
|
|
elseif magic_split[1] == 'return' then
|
|
|
|
for _, type in ipairs(types) do
|
2022-10-10 04:10:57 -07:00
|
|
|
magic = magic:gsub('^return%s+.*%((' .. type .. ')%)', 'return %1')
|
|
|
|
magic = magic:gsub('^return%s+.*%((' .. type .. '|nil)%)', 'return %1')
|
2022-09-28 04:22:08 -07:00
|
|
|
end
|
|
|
|
magic_split = string_split(magic, ' ')
|
|
|
|
end
|
2022-05-12 07:02:46 -07:00
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
if magic_split[1] == 'generic' then
|
|
|
|
local generic_name, generic_type = line:match('@generic%s*(%w+)%s*:?%s*(.*)')
|
|
|
|
if generic_type == '' then
|
|
|
|
generic_type = 'any'
|
2022-09-27 23:56:47 -07:00
|
|
|
end
|
|
|
|
generic[generic_name] = generic_type
|
2022-09-28 04:22:08 -07:00
|
|
|
else
|
|
|
|
local type_index = 2
|
|
|
|
if magic_split[1] == 'param' then
|
|
|
|
type_index = type_index + 1
|
2022-09-28 00:11:21 -07:00
|
|
|
end
|
2022-05-12 07:02:46 -07:00
|
|
|
|
2022-09-28 04:22:08 -07:00
|
|
|
if magic_split[type_index] then
|
|
|
|
-- fix optional parameters
|
2022-10-10 04:10:57 -07:00
|
|
|
if magic_split[type_index] and magic_split[2]:find('%?$') then
|
|
|
|
if not magic_split[type_index]:find('nil') then
|
|
|
|
magic_split[type_index] = magic_split[type_index] .. '|nil'
|
2022-09-28 04:22:08 -07:00
|
|
|
end
|
|
|
|
magic_split[2] = magic_split[2]:sub(1, -2)
|
|
|
|
end
|
|
|
|
-- replace generic types
|
|
|
|
if magic_split[type_index] then
|
|
|
|
for k, v in pairs(generic) do
|
|
|
|
magic_split[type_index] = magic_split[type_index]:gsub(k, v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- surround some types by ()
|
|
|
|
for _, type in ipairs(types) do
|
2022-10-10 04:10:57 -07:00
|
|
|
magic_split[type_index] =
|
|
|
|
magic_split[type_index]:gsub('^(' .. type .. '|nil):?$', '(%1)')
|
|
|
|
magic_split[type_index] =
|
|
|
|
magic_split[type_index]:gsub('^(' .. type .. '):?$', '(%1)')
|
2022-09-28 04:22:08 -07:00
|
|
|
end
|
2022-09-27 23:56:47 -07:00
|
|
|
end
|
|
|
|
|
2022-09-28 04:22:08 -07:00
|
|
|
magic = table.concat(magic_split, ' ')
|
2022-05-12 07:02:46 -07:00
|
|
|
|
2022-09-27 23:56:47 -07:00
|
|
|
outStream:writeln('/// @' .. magic)
|
2022-10-10 04:10:57 -07:00
|
|
|
fn_magic = checkComment4fn(fn_magic, magic)
|
2022-09-27 23:56:47 -07:00
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
elseif string.sub(line, 3, 3) == '-' then -- it's a nonmagic doc comment
|
|
|
|
local comment = string.sub(line, 4)
|
|
|
|
outStream:writeln('/// ' .. comment)
|
|
|
|
elseif string.sub(line, 3, 4) == '[[' then -- it's a long comment
|
|
|
|
line = string.sub(line, 5) -- nibble head
|
2019-03-29 13:54:34 -07:00
|
|
|
local comment = ''
|
2022-10-10 04:10:57 -07:00
|
|
|
local closeSquare, hitend, thisComment
|
|
|
|
while not hitend and (not inStream:eof()) do
|
|
|
|
closeSquare = string.find(line, ']]')
|
2019-03-29 13:54:34 -07:00
|
|
|
if not closeSquare then -- need to look on another line
|
|
|
|
thisComment = line .. '\n'
|
|
|
|
line = inStream:getLine()
|
|
|
|
else
|
2022-10-10 04:10:57 -07:00
|
|
|
thisComment = string.sub(line, 1, closeSquare - 1)
|
2019-03-29 13:54:34 -07:00
|
|
|
hitend = true
|
|
|
|
|
|
|
|
-- unget the tail of the line
|
|
|
|
-- in most cases it's empty. This may make us less efficient but
|
|
|
|
-- easier to program
|
2022-10-10 04:10:57 -07:00
|
|
|
inStream:ungetLine(string_trim(string.sub(line, closeSquare + 2)))
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
comment = comment .. thisComment
|
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
if string.sub(comment, 1, 1) == '@' then -- it's a long magic comment
|
2019-03-29 13:54:34 -07:00
|
|
|
outStream:write('/*' .. comment .. '*/ ')
|
2022-10-10 04:10:57 -07:00
|
|
|
fn_magic = checkComment4fn(fn_magic, comment)
|
2019-03-29 13:54:34 -07:00
|
|
|
else -- discard
|
|
|
|
outStream:write('/* zz:' .. comment .. '*/ ')
|
|
|
|
fn_magic = nil
|
|
|
|
end
|
2019-05-25 01:00:41 -07:00
|
|
|
-- TODO(justinmk): Uncomment this if we want "--" lines to continue the
|
|
|
|
-- preceding magic ("---", "--@", …) lines.
|
|
|
|
-- elseif state == 'in_magic_comment' then -- next line of magic comment
|
|
|
|
-- outStream:writeln('/// '.. line:sub(3))
|
|
|
|
else -- discard
|
2019-03-29 13:54:34 -07:00
|
|
|
outStream:writeln('// zz:"' .. line .. '"')
|
|
|
|
fn_magic = nil
|
|
|
|
end
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
elseif string.find(line, '^function') or string.find(line, '^local%s+function') then
|
2022-09-27 23:56:47 -07:00
|
|
|
generic = {}
|
2022-10-10 04:10:57 -07:00
|
|
|
state = 'in_function' -- it's a function
|
|
|
|
local pos_fn = string.find(line, 'function')
|
2019-03-29 13:54:34 -07:00
|
|
|
-- function
|
|
|
|
-- ....v...
|
|
|
|
if pos_fn then
|
|
|
|
-- we've got a function
|
2022-10-10 04:10:57 -07:00
|
|
|
local fn = TString_removeCommentFromLine(string_trim(string.sub(line, pos_fn + 8)))
|
2019-03-29 13:54:34 -07:00
|
|
|
if fn_magic then
|
|
|
|
fn = fn_magic
|
|
|
|
end
|
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
if string.sub(fn, 1, 1) == '(' then
|
2019-03-29 13:54:34 -07:00
|
|
|
-- it's an anonymous function
|
|
|
|
outStream:writelnComment(line)
|
|
|
|
else
|
|
|
|
-- fn has a name, so is interesting
|
|
|
|
|
|
|
|
-- want to fix for iffy declarations
|
2022-10-10 04:10:57 -07:00
|
|
|
local open_paren = string.find(fn, '[%({]')
|
2019-03-29 13:54:34 -07:00
|
|
|
if open_paren then
|
|
|
|
-- we might have a missing close paren
|
2022-10-10 04:10:57 -07:00
|
|
|
if not string.find(fn, '%)') then
|
2019-03-29 13:54:34 -07:00
|
|
|
fn = fn .. ' ___MissingCloseParenHere___)'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-01 05:19:48 -07:00
|
|
|
-- Big hax
|
2022-10-10 04:10:57 -07:00
|
|
|
if string.find(fn, ':') then
|
2021-05-01 05:19:48 -07:00
|
|
|
-- TODO: We need to add a first parameter of "SELF" here
|
|
|
|
-- local colon_place = string.find(fn, ":")
|
|
|
|
-- local name = string.sub(fn, 1, colon_place)
|
2022-10-10 04:10:57 -07:00
|
|
|
fn = fn:gsub(':', '.', 1)
|
|
|
|
outStream:writeln('/// @param self')
|
2021-05-01 05:19:48 -07:00
|
|
|
|
2022-10-10 04:10:57 -07:00
|
|
|
local paren_start = string.find(fn, '(', 1, true)
|
|
|
|
local paren_finish = string.find(fn, ')', 1, true)
|
2021-05-01 05:19:48 -07:00
|
|
|
|
|
|
|
-- Nothing in between the parens
|
|
|
|
local comma
|
|
|
|
if paren_finish == paren_start + 1 then
|
2022-10-10 04:10:57 -07:00
|
|
|
comma = ''
|
2021-05-01 05:19:48 -07:00
|
|
|
else
|
2022-10-10 04:10:57 -07:00
|
|
|
comma = ', '
|
2021-05-01 05:19:48 -07:00
|
|
|
end
|
2022-10-10 04:10:57 -07:00
|
|
|
fn = string.sub(fn, 1, paren_start)
|
|
|
|
.. 'self'
|
|
|
|
.. comma
|
|
|
|
.. string.sub(fn, paren_start + 1)
|
2021-05-01 05:19:48 -07:00
|
|
|
end
|
|
|
|
|
2019-10-26 19:58:28 -07:00
|
|
|
-- add vanilla function
|
2022-10-10 04:21:19 -07:00
|
|
|
outStream:writeln('function ' .. fn .. '{}')
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
else
|
2022-10-10 04:10:57 -07:00
|
|
|
this:warning(inStream:getLineNo(), 'something weird here')
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
fn_magic = nil -- mustn't indavertently use it again
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
|
|
|
|
-- TODO: If we can make this learn how to generate these, that would be helpful.
|
|
|
|
-- elseif string.find(line, "^M%['.*'%] = function") then
|
|
|
|
-- state = 'in_function' -- it's a function
|
|
|
|
-- outStream:writeln("function textDocument/publishDiagnostics(...){}")
|
|
|
|
|
|
|
|
-- fn_magic = nil -- mustn't indavertently use it again
|
2019-03-29 13:54:34 -07:00
|
|
|
else
|
2022-10-10 04:10:57 -07:00
|
|
|
state = '' -- unknown
|
|
|
|
if #line > 0 then -- we don't know what this line means, so just comment it out
|
2019-03-29 13:54:34 -07:00
|
|
|
outStream:writeln('// zz: ' .. line)
|
|
|
|
else
|
|
|
|
outStream:writeln() -- keep this line blank
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- output the tail
|
|
|
|
outStream:write_tailLines()
|
|
|
|
else
|
|
|
|
outStream:writeln('!empty file')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--! \brief this application
|
2021-09-19 16:35:38 -07:00
|
|
|
local TApp = class()
|
2019-03-29 13:54:34 -07:00
|
|
|
|
|
|
|
--! \brief constructor
|
|
|
|
function TApp.init(this)
|
2022-10-10 04:21:19 -07:00
|
|
|
this.timestamp = os.date('%c %Z', os.time())
|
2019-03-29 13:54:34 -07:00
|
|
|
this.name = 'Lua2DoX'
|
|
|
|
this.version = '0.2 20130128'
|
|
|
|
this.copyright = 'Copyright (c) Simon Dales 2012-13'
|
|
|
|
end
|
|
|
|
|
|
|
|
function TApp.getRunStamp(this)
|
2022-10-10 04:10:57 -07:00
|
|
|
return this.name .. ' (' .. this.version .. ') ' .. this.timestamp
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
function TApp.getVersion(this)
|
2021-09-19 16:35:38 -07:00
|
|
|
return this.name .. ' (' .. this.version .. ') '
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
function TApp.getCopyright(this)
|
2021-09-19 16:35:38 -07:00
|
|
|
return this.copyright
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
local This_app = TApp()
|
|
|
|
|
|
|
|
--main
|
|
|
|
local cl = TCore_Commandline()
|
|
|
|
|
|
|
|
local argv1 = cl:getRaw(2)
|
|
|
|
if argv1 == '--help' then
|
|
|
|
TCore_IO_writeln(This_app:getVersion())
|
|
|
|
TCore_IO_writeln(This_app:getCopyright())
|
|
|
|
TCore_IO_writeln([[
|
|
|
|
run as:
|
|
|
|
lua2dox_filter <param>
|
|
|
|
--------------
|
|
|
|
Param:
|
|
|
|
<filename> : interprets filename
|
|
|
|
--version : show version/copyright info
|
|
|
|
--help : this help text]])
|
|
|
|
elseif argv1 == '--version' then
|
|
|
|
TCore_IO_writeln(This_app:getVersion())
|
|
|
|
TCore_IO_writeln(This_app:getCopyright())
|
|
|
|
else
|
|
|
|
-- it's a filter
|
|
|
|
local appStamp = This_app:getRunStamp()
|
|
|
|
local filename = argv1
|
|
|
|
|
|
|
|
local filter = TLua2DoX_filter()
|
2022-10-10 04:10:57 -07:00
|
|
|
filter:readfile(appStamp, filename)
|
2019-03-29 13:54:34 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
--eof
|