From f9da2673737d8585c573f04099f1efe0dd30f526 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Sun, 27 Oct 2019 11:58:28 +0900 Subject: scripts/lua2dox.lua: Remove class declaration block Judging class definitions in the form "string.find (line, '=% s * class% (')" must force writing class definitions in this format, but such a mechanism is Absent. Also, Lua has no formal class in the language specification, and implements inheritance with setmetadable. To detect this, we should have a parser for it, not a simple regular expression. --- scripts/lua2dox.lua | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'scripts/lua2dox.lua') diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 77cdabcc4b..438f734917 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -543,7 +543,6 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename) local fn = TString_removeCommentFromLine(string_trim(string.sub(line,pos_fn+8))) if fn_magic then fn = fn_magic - fn_magic = nil end if string.sub(fn,1,1)=='(' then @@ -554,49 +553,20 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename) -- want to fix for iffy declarations local open_paren = string.find(fn,'[%({]') - local fn0 = fn if open_paren then - fn0 = string.sub(fn,1,open_paren-1) -- we might have a missing close paren if not string.find(fn,'%)') then fn = fn .. ' ___MissingCloseParenHere___)' end end - local dot = string.find(fn0,'[%.:]') - if dot then -- it's a method - local klass = string.sub(fn,1,dot-1) - local method = string.sub(fn,dot+1) - --TCore_IO_writeln('function ' .. klass .. '::' .. method .. ftail .. '{}') - --TCore_IO_writeln(klass .. '::' .. method .. ftail .. '{}') - outStream:writeln( - '/*! \\memberof ' .. klass .. ' */ ' - .. method .. '{}' - ) - else - -- add vanilla function - - outStream:writeln(fn_type .. 'function ' .. fn .. '{}') - end + -- add vanilla function + outStream:writeln(fn_type .. 'function ' .. fn .. '{}') end else this:warning(inStream:getLineNo(),'something weird here') end fn_magic = nil -- mustn't indavertently use it again - elseif string.find(line,'=%s*class%(') then - state = 'in_class' -- it's a class declaration - local tailComment - line,tailComment = TString_removeCommentFromLine(line) - local equals = string.find(line,'=') - local klass = string_trim(string.sub(line,1,equals-1)) - local tail = string_trim(string.sub(line,equals+1)) - -- class(wibble wibble) - -- ....v. - local parent = string.sub(tail,7,-2) - if #parent>0 then - parent = ' :public ' .. parent - end - outStream:writeln('class ' .. klass .. parent .. '{};') else state = '' -- unknown if #line>0 then -- we don't know what this line means, so just comment it out -- cgit From 001e69cd4602e84219fd7cfd8ade62f0cb24097c Mon Sep 17 00:00:00 2001 From: Brian Wignall Date: Tue, 26 Nov 2019 07:15:14 -0500 Subject: doc: fix typos close #11459 --- scripts/lua2dox.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/lua2dox.lua') diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 438f734917..171621e38d 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -65,7 +65,7 @@ FILTER_PATTERNS = *.lua=lua2dox_filter Either add them to the end or find the appropriate entry in Doxyfile. -There are other lines that you might like to alter, but see futher documentation for details. +There are other lines that you might like to alter, but see further documentation for details.
  • When Doxyfile is edited run "doxygen" -- cgit From b112fe828fd2457692f556626d7657615e53cb0b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 31 Dec 2019 06:52:14 -0800 Subject: gen_vimdoc.py: generate LSP docs --- scripts/lua2dox.lua | 97 ++++++----------------------------------------------- 1 file changed, 10 insertions(+), 87 deletions(-) (limited to 'scripts/lua2dox.lua') diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 171621e38d..d4e68f9e45 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -17,61 +17,28 @@ -- Free Software Foundation, Inc., -- -- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------------]] ---[[! -\file -\brief a hack lua2dox converter -]] --[[! -\mainpage - -Introduction ------------- - -A hack lua2dox converter -Version 0.2 +Lua-to-Doxygen converter -This lets us make Doxygen output some documentation to let -us develop this code. - -It is partially cribbed from the functionality of lua2dox -(http://search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm). -Found on CPAN when looking for something else; kinda handy. - -Improved from lua2dox to make the doxygen output more friendly. -Also it runs faster in lua rather than Perl. - -Because this Perl based system is called "lua2dox"., I have decided to add ".lua" to the name -to keep the two separate. +Partially from lua2dox +http://search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm Running ------- -
      -
    1. Ensure doxygen is installed on your system and that you are familiar with its use. -Best is to try to make and document some simple C/C++/PHP to see what it produces. -You can experiment with the enclosed example code. - -
    2. Run "doxygen -g" to create a default Doxyfile. +This file "lua2dox.lua" gets called by "lua2dox_filter" (bash). -Then alter it to let it recognise lua. Add the two following lines: +Doxygen must be on your system. You can experiment like so: -\code{.bash} -FILE_PATTERNS = *.lua - -FILTER_PATTERNS = *.lua=lua2dox_filter -\endcode - - -Either add them to the end or find the appropriate entry in Doxyfile. - -There are other lines that you might like to alter, but see further documentation for details. - -
    3. When Doxyfile is edited run "doxygen" +- 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". 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. -Therefore our lua interpreter is fairly limited, but "good enough". 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. @@ -81,40 +48,8 @@ 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. -
    - -Installation ------------- - -Here for linux or unix-like, for any other OS you need to refer to other documentation. - -This file is "lua2dox.lua". It gets called by "lua2dox_filter"(bash). -Somewhere in your path (e.g. "~/bin" or "/usr/local/bin") put a link to "lua2dox_filter". - -Documentation -------------- - -Read the external documentation that should be part of this package. -For example look for the "README" and some .PDFs. - ]] --- we won't use our library code, so this becomes more portable - --- require 'elijah_fix_require' --- require 'elijah_class' --- ---! \brief ``declare'' as class ---! ---! use as: ---! \code{.lua} ---! TWibble = class() ---! function TWibble.init(this,Str) ---! this.str = Str ---! -- more stuff here ---! end ---! \endcode ---! function class(BaseClass, ClassInitialiser) local newClass = {} -- a new class newClass if not ClassInitialiser and type(BaseClass) == 'function' then @@ -165,8 +100,6 @@ function class(BaseClass, ClassInitialiser) return newClass end --- require 'elijah_clock' - --! \class TCore_Clock --! \brief a clock TCore_Clock = class() @@ -201,9 +134,6 @@ function TCore_Clock.getTimeStamp(this,T0) end ---require 'elijah_io' - ---! \class TCore_IO --! \brief io to console --! --! pseudo class (no methods, just to keep documentation tidy) @@ -225,8 +155,6 @@ function TCore_IO_writeln(Str) end ---require 'elijah_string' - --! \brief trims a string function string_trim(Str) return Str:match("^%s*(.-)%s*$") @@ -257,8 +185,6 @@ function string_split(Str, Pattern) end ---require 'elijah_commandline' - --! \class TCore_Commandline --! \brief reads/parses commandline TCore_Commandline = class() @@ -279,9 +205,6 @@ function TCore_Commandline.getRaw(this,Key,Default) return val end - ---require 'elijah_debug' - ------------------------------- --! \brief file buffer --! -- cgit