From: John L. <jr...@us...> - 2007-06-17 17:18:11
|
Update of /cvsroot/wxlua/wxLua/bindings In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14496/wxLua/bindings Modified Files: Makefile genidocs.lua Added Files: genidocs_rules.lua Log Message: Cleanup in the bindings file, make comments more uniform for wxluaref.html Make the genidocs.lua nicer, better colors and have it use it's own rules file. It can be used to generate a generic ref manual for any bindings now. Index: Makefile =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile 14 Jun 2007 01:23:07 -0000 1.3 --- Makefile 17 Jun 2007 17:17:36 -0000 1.4 *************** *** 40,44 **** genidocs: ! @($(LUA) -e"rulesFilename=\"wxwidgets/wx_rules.lua\"" genidocs.lua) --- 40,44 ---- genidocs: ! @($(LUA) -e"rulesFilename=\"genidocs_rules.lua\"" genidocs.lua) --- NEW FILE: genidocs_rules.lua --- ------------------------------------------------------------------------------- -- Rules to build the wxWidgets reference for wxLua -- load using : $lua -e"rulesFilename=\"rules.lua\"" genidocs.lua ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Set the root directory of the wxLua distribution, used only in this file wxlua_dir = "../" --============================================================================= -- Set the output filename for the generated html output_filename = wxlua_dir.."/docs/wxluaref.html" --============================================================================= -- A list of interface files to use to make the bindings. These files will be -- converted into a html file and placed in the output_filepath directory. -- The files are loaded from the file_path. interface_fileTable = { { ["namespace"] = "wx", ["file_path"] = "wxwidgets", ["prepend_name"] = "wxwidgets/", ["datatypes_filename"] = "wx_datatypes.lua", ["files"] = { "appframe.i", "clipdrag.i", "config.i", "controls.i", "data.i", "datetime.i", "defsutil.i", "dialogs.i", "event.i", "file.i", "gdi.i", "geometry.i", "grid.i", "help.i", "html.i", "image.i", "mdi.i", "menutool.i", "print.i", "regex.i", "sizer.i", "socket.i", "thread.i", "wave.i", "windows.i", "wxlua.i", "xml.i" } }, { ["namespace"] = "wxstc", ["file_path"] = "wxstc", ["prepend_name"] = "wxstc/", ["datatypes_filename"] = "wxstc_datatypes.lua", ["files"] = { "stc.i" } }, { ["namespace"] = "wxlua", ["file_path"] = "wxlua", ["prepend_name"] = "wxlua/", ["datatypes_filename"] = "wxlua_datatypes.lua", ["files"] = { "wxlua.i" } }, { ["namespace"] = "wxlua", ["file_path"] = "wxluasocket", ["prepend_name"] = "wxluasocket/", ["datatypes_filename"] = "wxluasocket_datatypes.lua", ["files"] = { "wxluasocket.i" } } } --============================================================================= -- A list of files that contain class names only that should be a complete -- list of all classes that could be wrapped. -- This will be mixed in with the classes in the interface files to explicitly -- show what is and isn't wrapped. completeClassRefFileTable = { "wxwidgets/wxclassref.txt" } -- If you specify the complete list above, name the col that will be checked -- if the class wrapped by lua in in the complete list completeClassRefColLabel = "In wxWidgets Manual" -- A message to append to the class name in the index for classes. msgForClassInIndex = { ["wxArray"] = "Not a real class, see implementations (wxArrayInt)", ["wxArrayInt"] = "Interchangeable with a numeric indexed lua table", ["wxArrayString"] = "Interchangeable with a numeric indexed lua table", ["wxCmdLineParser"] = "Easier to implement in lua", ["wxCSConv"] = "Lua uses ANSI 8-bit strings", ["wxDirTraverser"] = "Use wxDir::GetFirst() and GetNext()", ["wxHashMap"] = "Lua tables are hash tables", ["wxHashSet"] = "Lua tables are hash tables", ["wxHashTable"] = "Lua tables are hash tables", ["wxMBConv"] = "Lua uses ANSI 8-bit strings", ["wxMBConvFile"] = "Lua uses ANSI 8-bit strings", ["wxMBConvUTF16"] = "Lua uses ANSI 8-bit strings", ["wxMBConvUTF32"] = "Lua uses ANSI 8-bit strings", ["wxMBConvUTF7"] = "Lua uses ANSI 8-bit strings", ["wxMBConvUTF8"] = "Lua uses ANSI 8-bit strings", ["wxModule"] = "Useable in C++ only", ["wxRealPoint"] = "Not used anywhere in wxWidgets", ["wxRecursionGuard"] = "Easier to implement in lua", ["wxRecursionGuardFlag"]= "Easier to implement in lua", ["wxScopedArray"] = "Useable in C++ only (unnecessary in lua)", ["wxScopedPtr"] = "Useable in C++ only (unnecessary in lua)", ["wxScopedTiedPtr"] = "Useable in C++ only (unnecessary in lua)", ["wxSortedArrayString"] = "Interchangeable with a numeric indexed lua table", ["wxString"] = "Interchangeable with a lua string", ["wxStringBuffer"] = "Useable in C++ only (unnecessary in lua)", ["wxStringBufferLength"]= "Useable in C++ only (unnecessary in lua)", ["wxVariant"] = "Unnecessary in lua", ["wxVariantData"] = "Unnecessary in lua", } --============================================================================= -- The HTML header for the generated file. htmlHeader = [[ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>wxLua Reference Manual</title> <meta content="John Labenski" name="author"> </head> <body> <h1>wxLua 2.8.4.0 Reference Manual for wxWidgets 2.8.4</h1> ]] Index: genidocs.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genidocs.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** genidocs.lua 14 Jun 2007 01:23:07 -0000 1.6 --- genidocs.lua 17 Jun 2007 17:17:36 -0000 1.7 *************** *** 8,12 **** ------------------------------------------------------------------------------- ! wxWidgetsClassRefTable = {} -- a list of wx classes from the alphabetical class list typedefTable = {} -- filled from the data cache files --- 8,16 ---- ------------------------------------------------------------------------------- ! completeClassRefTable = nil -- a table of names that is a complete list of classes ! -- from a library the wrapper are for ! -- For wxWidgets this is taken from the alphabetical ! -- list of classes in the wxWidgets reference manual ! -- This is used to print if a class is wrapped or not. typedefTable = {} -- filled from the data cache files *************** *** 16,31 **** colours = {} ! colours.class = "AA0000" ! colours.prop = "000077" ! colours.member = "005577" ! colours.rename = "CC0033" ! colours.override = "CC3300" ! colours.overload = "CC3333" ! colours.operator = "550077" ! colours.enum = "007700" ! colours.define = "007755" ! colours.event = "557700" -- ---------------------------------------------------------------------------- --- 20,36 ---- colours = {} ! colours.class = "DD0000" -- red ! colours.member = "CC6600" -- orange ! colours.rename = "990099" -- dark pink ! colours.override = "BB0055" -- reddish pink ! colours.operator = "663300" -- brown ! colours.enum = "0066CC" -- blue ! colours.define = "006666" -- turquoise ! colours.event = "660033" -- purple ! colours.func = "AA0000" -- dark red + colours.comment = "009900" -- green + colours.blkcomment = "888888" -- grey -- ---------------------------------------------------------------------------- *************** *** 42,55 **** table.insert(fileTable, "<h2>Colours used to denote types</h2>") table.insert(fileTable, MakeColour("Enums - %enum", colours.enum).."<br>") ! table.insert(fileTable, MakeColour("Defines - %define [%string] [%object] [%pointer]", colours.define).."<br>") ! table.insert(fileTable, MakeColour("Events - %define %event", colours.event).."<br>") table.insert(fileTable, MakeColour("Classes - %class", colours.class).."<br>") - table.insert(fileTable, MakeColour("Class Properties - %property", colours.prop).."<br>") table.insert(fileTable, MakeColour("Class Members - %member", colours.member).."<br>") table.insert(fileTable, MakeColour("Renamed Functions - %rename", colours.rename).."<br>") table.insert(fileTable, MakeColour("Overridden Functions - %override", colours.override).."<br>") - table.insert(fileTable, MakeColour("Overloaded Functions - %overload", colours.overload).."<br>") table.insert(fileTable, MakeColour("Operator Functions - %operator", colours.operator).."<br><br>") end --- 47,62 ---- table.insert(fileTable, "<h2>Colours used to denote types</h2>") + table.insert(fileTable, MakeColour("Comments - //", colours.comment).."<br>") + table.insert(fileTable, MakeColour("Block Comments - /* ... */", colours.blkcomment).."<br>") + table.insert(fileTable, MakeColour("Enums - %enum", colours.enum).."<br>") ! table.insert(fileTable, MakeColour("Defines - %define [_string] [_object] [_pointer]", colours.define).."<br>") ! table.insert(fileTable, MakeColour("Events - %define_event", colours.event).."<br>") ! table.insert(fileTable, MakeColour("Functions - %function", colours.func).."<br>") table.insert(fileTable, MakeColour("Classes - %class", colours.class).."<br>") table.insert(fileTable, MakeColour("Class Members - %member", colours.member).."<br>") table.insert(fileTable, MakeColour("Renamed Functions - %rename", colours.rename).."<br>") table.insert(fileTable, MakeColour("Overridden Functions - %override", colours.override).."<br>") table.insert(fileTable, MakeColour("Operator Functions - %operator", colours.operator).."<br><br>") end *************** *** 60,98 **** -- ---------------------------------------------------------------------------- ! function MakeColour(name, color) -- color is "RRGGBB" in hex ! return "<font color=#"..color..">"..name.."</font>" end ! function MakeBold(name) ! return "<b>"..name.."</b>" end ! function MakeItalic(name) ! return "<i>"..name.."</i>" end ! function MakeLink(name) --<a href="#papers">papers</a> ! return "<a href=\"#"..name.."\">"..name.."</a>" end ! function MakeTag(name) --<a name="papers">Papers</a> ! return "<b><a name=\""..name.."\">"..name.."</a></b>" end ! -- ---------------------------------------------------------------------------- ! -- Make the HTML header ! -- ---------------------------------------------------------------------------- ! ! function GenerateHeader(fileTable) ! table.insert(fileTable, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">") ! table.insert(fileTable, "<html>") ! table.insert(fileTable, "<head>") ! table.insert(fileTable, "<meta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\">") ! table.insert(fileTable, "<title>wxLua Class Reference</title>") ! table.insert(fileTable, "<meta content=\"John Labenski\" name=\"author\">") ! table.insert(fileTable, "</head>") ! table.insert(fileTable, "<body>") ! ! table.insert(fileTable, "<h1>wxLua 2.8.4.0 Class Reference for wxWidgets 2.8.4</h1>") ! return fileTable end --- 67,109 ---- -- ---------------------------------------------------------------------------- ! -- color is "RRGGBB" in hex ! function MakeColour(str, color, size) ! if size then ! return "<font size=+"..size.." color=#"..color..">"..str.."</font>" ! end ! ! return "<font color=#"..color..">"..str.."</font>" end ! function MakeBold(str) ! return "<b>"..str.."</b>" end ! function MakeItalic(str) ! return "<i>"..str.."</i>" end ! function MakeLink(link_name, str) --<a href="#papers">papers</a> ! return "<a href=\"#"..link_name.."\">"..(str or link_name).."</a>" end ! function MakeTag(link_name, str) --<a name="papers">Papers</a> ! return "<a name=\""..link_name.."\">"..(str or link_name).."</a>" end ! -- convert invalid chars to something valid for use in <a name=... ! function MakeTagName(name) ! local s = string.lower(name) ! s = string.gsub(s, "%/", "_") ! s = string.gsub(s, "% ", "_") ! s = string.gsub(s, "%(", "_") ! s = string.gsub(s, "%)", "_") ! return s ! end ! -- replace any chars as necessary before adding our own code ! function MakeHTML(str) ! local s = string.gsub(str, "&", "&") ! s = string.gsub(s, ">", ">") ! s = string.gsub(s, "<", "<") ! return s end *************** *** 115,124 **** local names = {} ! table.insert(fileTable, "<h2>wxWidgets Classes</h2>") local allClasses = {} ! for k, v in pairs(wxWidgetsClassRefTable) do ! allClasses[k] = false -- wxWidgets classes end for k, v in pairs(dataTypeTable) do --- 126,137 ---- local names = {} ! table.insert(fileTable, "<h2>Classes</h2>") local allClasses = {} ! if completeClassRefTable then ! for k, v in pairs(completeClassRefTable) do ! allClasses[k] = false -- for example ALL wxWidgets classes ! end end for k, v in pairs(dataTypeTable) do *************** *** 133,147 **** end table.sort(names) - for n = 1, #names do - local cname = names[n] ! if allClasses[cname] then ! if wxWidgetsClassRefTable[cname] then ! table.insert(fileTable, MakeLink(cname).."<br>") else ! table.insert(fileTable, MakeLink(cname).." - (Not in wxWidgets reference manual)<br>") end ! else ! table.insert(fileTable, cname.." - (Not wrapped)<br>") end end --- 146,198 ---- end table.sort(names) ! --[[ ! <table border="1"> ! <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> ! <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr> ! </table> ! ]] ! ! if completeClassRefTable then ! ! table.insert(fileTable, "<table border=\"1\">") ! table.insert(fileTable, " <tr><th>Class Name</th> <th>"..completeClassRefColLabel.."</th> <th>Wrapped by wxLua</th> <th>Notes</th></tr>") ! ! for n = 1, #names do ! local cname = names[n] ! ! table.insert(fileTable, "<tr>") ! ! if allClasses[cname] then ! table.insert(fileTable, "<td>"..MakeLink(cname)) -- optional </td> else ! table.insert(fileTable, "<td>"..cname) end ! ! if completeClassRefTable and completeClassRefTable[cname] then ! table.insert(fileTable, "<td align=\"center\">X") ! else ! table.insert(fileTable, "<td> ") ! end ! ! if allClasses[cname] then ! table.insert(fileTable, "<td align=\"center\">X") ! else ! table.insert(fileTable, "<td> ") ! end ! ! if msgForClassInIndex and msgForClassInIndex[cname] then ! table.insert(fileTable, "<td>"..msgForClassInIndex[cname]) ! else ! table.insert(fileTable, "<td> ") ! end ! ! -- table.insert(fileTable, "</tr>") -- optional </tr> ! end ! ! table.insert(fileTable, "</table><br>") ! else ! for n = 1, #names do ! table.insert(fileTable, MakeLink(names[n]).."<br>") end end *************** *** 159,163 **** local names = {} ! table.insert(fileTable, "<h2>wxWidgets Enums</h2>") for k, v in pairs(dataTypeTable) do --- 210,214 ---- local names = {} ! table.insert(fileTable, "<h2>Enums</h2>") for k, v in pairs(dataTypeTable) do *************** *** 189,199 **** function GetPreviousWord(str, pos) local start_pos = 0 for n = pos, 0, -1 do if not nameChars[string.byte(str, n)] then ! start_pos = n+1 ! break end end ! return string.sub(str, start_pos, pos), start_pos end --- 240,255 ---- function GetPreviousWord(str, pos) local start_pos = 0 + local end_pos = 0 for n = pos, 0, -1 do if not nameChars[string.byte(str, n)] then ! if end_pos ~= 0 then ! start_pos = n+1 ! break ! end ! elseif end_pos == 0 then ! end_pos = n end end ! return string.sub(str, start_pos, end_pos), start_pos end *************** *** 207,260 **** end - -- ---------------------------------------------------------------------------- - -- Read the .i files and convert them to HTML - -- ---------------------------------------------------------------------------- ! function InterfaceFileNameToTag(name) ! local s = name ! s = string.gsub(s, "%.%./wxstc/", "wxstc_") ! s = string.gsub(s, "%.%./wxlua/", "wxlua_") ! s = string.gsub(s, "%.%./wxluasocket/", "wxluasocket_") ! if not string.find(s, "_", 1, 1) then s = "wxwidgets_"..s end ! s = string.gsub(s, "%.", "_") ! return s end function ReadInterfaceFiles(fileTable) table.insert(fileTable, "<h2>Interface files</h2>") ! local idx = 0 ! while interface_fileTable[idx+1] do ! idx = idx + 1 ! local s = InterfaceFileNameToTag(interface_fileTable[idx]) ! ! table.insert(fileTable, MakeLink(s).."<br>") ! end local strSp = string.byte(" ") ! local idx = 0 ! while interface_fileTable[idx+1] do ! idx = idx + 1 table.insert(fileTable, "<br><HR>\n") ! table.insert(fileTable, "<h2>"..MakeTag(InterfaceFileNameToTag(interface_fileTable[idx])).."</h2>") - local filename = interface_filepath.."/"..interface_fileTable[idx] for line in io.lines(filename) do local cname = "" ! local out_line = line local comment_pos = string.find(line, "//", 1, 1) or 1E6 - local class_pos = string.find(line, "%class", 1, 1) - local enum_pos = string.find(line, "%enum", 1, 1) ! local start_block = false ! local end_block = false ! if (class_pos and class_pos < comment_pos) or (enum_pos and enum_pos < comment_pos) then start_block = true --- 263,351 ---- end ! function GetAllComments(str) ! local function FindAllStrings(str, find_txt, tbl) ! local s, e = string.find(str, find_txt, 1, 1) ! while s do ! table.insert(tbl, { ["s"] = s, ["e"] = e, ["txt"] = find_txt }) ! s, e = string.find(str, find_txt, e+1, 1) ! end ! end ! local t = {} ! FindAllStrings(str, "//", t) ! FindAllStrings(str, "/*", t) ! FindAllStrings(str, "*/", t) ! ! table.sort(t, function(t1, t2) return t1.s < t2.s end) ! ! return t end + -- ---------------------------------------------------------------------------- + -- Read the .i files and convert them to HTML + -- ---------------------------------------------------------------------------- + function ReadInterfaceFiles(fileTable) table.insert(fileTable, "<h2>Interface files</h2>") ! for i = 1, #interface_fileTable do ! for j = 1, #interface_fileTable[i].files do ! local s = interface_fileTable[i].prepend_name..interface_fileTable[i].files[j] ! table.insert(fileTable, MakeLink(MakeTagName(s), s).."<br>") ! end end local strSp = string.byte(" ") ! for i = 1, #interface_fileTable do ! for j = 1, #interface_fileTable[i].files do table.insert(fileTable, "<br><HR>\n") ! local filename = interface_fileTable[i].prepend_name..interface_fileTable[i].files[j] ! table.insert(fileTable, "<h2>"..MakeTag(MakeTagName(filename), filename).."</h2>") ! table.insert(fileTable, "<HR>\n") ! ! local in_blk_comment = false ! ! local line_n = 0 for line in io.lines(filename) do + line_n = line_n + 1 local cname = "" ! local out_line = MakeHTML(line) local comment_pos = string.find(line, "//", 1, 1) or 1E6 ! -- handle all comments in the order they appear ! local t = GetAllComments(out_line) ! for n = 1, #t do ! if t[n].txt == "//" then ! out_line = string.sub(out_line, 1, t[n].s-1)..MakeColour(string.sub(out_line, t[n].s), colours.comment) ! break ! elseif t[n].txt == "/*" then ! if in_blk_comment then print("ERROR mismatched /* */ in :", filename, line_n, line) end ! in_blk_comment = true ! out_line = string.sub(out_line, 1, t[n].s-1).."<font color=#"..colours.blkcomment..">"..string.sub(out_line, t[n].s) ! elseif t[n].txt == "*/" then ! if not in_blk_comment then print("ERROR mismatched /* */ in :", filename, line_n, line) end ! in_blk_comment = false ! out_line = string.sub(out_line, 1, t[n].s-1).."</font>"..string.sub(out_line, t[n].s) ! end ! end ! ! local class_pos, class_pos2 = string.find(line, "%class", 1, 1) ! local enum_pos, enum_pos2 = string.find(line, "%enum", 1, 1) ! ! if not class_pos then ! class_pos, class_pos2 = string.find(line, "%struct", 1, 1) ! end ! ! local start_block = nil ! local end_block = nil ! ! if (class_pos and (class_pos < comment_pos)) or (enum_pos and (enum_pos < comment_pos)) then start_block = true *************** *** 262,275 **** local comma = string.find(line, ",", 1, 1) local start_pos = 0 ! if comma then cname, start_pos = GetPreviousWord(line, comma-1) else cname, start_pos = GetPreviousWord(line, string.len(line)) end ! out_line = "<font size=+1>"..string.sub(out_line, 1, start_pos-1)..MakeTag(cname)..string.sub(out_line, start_pos+string.len(cname)).."</font>" ! if class_pos then out_line = MakeColour(out_line, colours.class) end ! if enum_pos then out_line = "<font color=#"..colours.enum..">"..out_line end else -- priortize the colouring so we don't have to check for every single case --- 353,378 ---- local comma = string.find(line, ",", 1, 1) local start_pos = 0 ! if class_pos and comma then cname, start_pos = GetPreviousWord(line, comma-1) + elseif comment_pos < 1E6 then + cname, start_pos = GetPreviousWord(line, comment_pos-1) else cname, start_pos = GetPreviousWord(line, string.len(line)) end ! if cname == "enum" then ! out_line = string.sub(out_line, 1, start_pos-1)..cname..string.sub(out_line, start_pos+string.len(cname)) ! else ! out_line = string.sub(out_line, 1, start_pos-1)..MakeTag(cname)..string.sub(out_line, start_pos+string.len(cname)) ! end ! if class_pos then ! out_line = MakeColour(out_line, colours.class, 1) ! end ! if enum_pos then ! out_line = MakeColour(out_line, colours.enum, 1) ! end ! ! out_line = MakeBold(out_line) else -- priortize the colouring so we don't have to check for every single case *************** *** 278,290 **** out_line = MakeColour(out_line, colours.class) end_block = true elseif TagIsBefore(line, "%endenum", comment_pos) then - out_line = out_line.."</font>" end_block = true ! elseif TagIsBefore(line, "%property", comment_pos) then ! out_line = MakeColour(out_line, colours.prop) elseif TagIsBefore(line, "%member", comment_pos) then out_line = MakeColour(out_line, colours.member) - elseif TagIsBefore(line, "%overload", comment_pos) then - out_line = MakeColour(out_line, colours.overload) elseif TagIsBefore(line, "%rename", comment_pos) then out_line = MakeColour(out_line, colours.rename) --- 381,394 ---- out_line = MakeColour(out_line, colours.class) end_block = true + class_pos = string.find(line, "%endclass", 1, 1) + elseif TagIsBefore(line, "%endstruct", comment_pos) then + out_line = MakeColour(out_line, colours.class) + end_block = true + class_pos = string.find(line, "%endstruct", 1, 1) elseif TagIsBefore(line, "%endenum", comment_pos) then end_block = true ! enum_pos = string.find(line, "%endenum", 1, 1) elseif TagIsBefore(line, "%member", comment_pos) then out_line = MakeColour(out_line, colours.member) elseif TagIsBefore(line, "%rename", comment_pos) then out_line = MakeColour(out_line, colours.rename) *************** *** 295,298 **** --- 399,404 ---- elseif TagIsBefore(line, "%define", comment_pos) then out_line = MakeColour(out_line, colours.define) + elseif TagIsBefore(line, "%function", comment_pos) then + out_line = MakeColour(out_line, colours.func) end end *************** *** 306,310 **** --- 412,418 ---- dataTypeTable[w] and (dataTypeTable[w].DefType ~= "number") and (dataTypeTable[w].DefType ~= "wxtypedef") and (dataTypeTable[w].DefType ~= "special") then + used[w] = true + -- replace the classname with a link, but not if it's part of a name --out_line = string.gsub(out_line, w, MakeLink(w)) *************** *** 323,327 **** out_line = string.gsub(out_line, "(%%[%w_]+)", function(s) return "<i>"..s.."</i>" end) ! --[[ -- alternate to blockquote, just force the spaces local start_spaces = 0 --- 431,436 ---- out_line = string.gsub(out_line, "(%%[%w_]+)", function(s) return "<i>"..s.."</i>" end) ! --[[ ! -- alternate to blockquote, just force the spaces local start_spaces = 0 *************** *** 341,354 **** if start_block then ! tail = "" -- don't add extra space ! out_line = out_line.."<blockquote>" elseif end_block then ! out_line = "</blockquote>"..out_line end table.insert(fileTable, out_line..tail) - end ! end end --- 450,486 ---- if start_block then ! tail = "" -- don't add extra space since blockquote already gives a linebreak ! ! if in_blk_comment then ! out_line = out_line.."</font>" ! end ! ! out_line = out_line.."\n<blockquote>" ! ! -- need to restart font color after blockquote for "tidy" ! if enum_pos then ! out_line = out_line.."<font color=#"..colours.enum..">" ! end ! -- restart the block comment after blockquote, overrides enum colour ! if in_blk_comment then ! out_line = out_line.."<font color=#"..colours.blkcomment..">" ! end elseif end_block then ! -- need to restart font color after blockquote for "tidy" ! if class_pos then ! out_line = "</blockquote>"..MakeColour(out_line, colours.class) ! end ! if enum_pos then ! out_line = "</font>\n</blockquote>"..MakeColour(out_line, colours.enum) ! end ! -- restart the block comment after blockquote ! if in_blk_comment then ! out_line = "</font>"..out_line.."<font color=#"..colours.blkcomment..">" ! end end table.insert(fileTable, out_line..tail) end ! end end end *************** *** 358,369 **** -- ---------------------------------------------------------------------------- ! function LoadwxClassRef() ! for line in io.lines(interface_filepath.."/".."wxclassref.txt") do ! for w in string.gmatch(line, "([%w_]+)") do ! wxWidgetsClassRefTable[w] = true end end end -- ---------------------------------------------------------------------------- -- main() --- 490,548 ---- -- ---------------------------------------------------------------------------- ! function LoadCompleteClassRef(filePath) ! for line in io.lines(filePath) do ! -- only create this if necessary ! if not completeClassRefTable then completeClassRefTable = {} end ! ! for w in string.gmatch(line, "([%w_]+)") do -- strip spaces if any ! completeClassRefTable[w] = true end end end + -- --------------------------------------------------------------------------- + -- Do the contents of the file match the strings in the fileData table? + -- the table may contain any number of \n per index + -- returns true for a match or false if not + -- --------------------------------------------------------------------------- + function FileDataIsTableData(filename, fileData) + local file_handle = io.open(filename) + if not file_handle then return false end -- ok if it doesn't exist + + local f = file_handle:read("*a") + local is_same = (f == table.concat(fileData, "\n")) + io.close(file_handle) + return is_same + end + + -- --------------------------------------------------------------------------- + -- Write the contents of the table fileData (indexes 1.. are line numbers) + -- to the filename, but only write to the file if FileDataIsTableData returns + -- false. If overwrite_always is true then always overwrite the file. + -- returns true if the file was overwritten + -- --------------------------------------------------------------------------- + function WriteTableToFile(filename, fileData, overwrite_always) + assert(filename and fileData, "Invalid filename or fileData in WriteTableToFile") + + if (not overwrite_always) and FileDataIsTableData(filename, fileData) then + print("No changes to file : '"..filename.."'") + return false + end + + print("Updating file : '"..filename.."'") + + local outfile = io.open(filename, "w+") + if not outfile then + print("Unable to open file for writing '"..filename.."'.") + return + end + + outfile:write(table.concat(fileData, "\n")) + + outfile:flush() + outfile:close() + return true + end + -- ---------------------------------------------------------------------------- -- main() *************** *** 377,416 **** end ! local rules = loadfile(rulesFilename) if rules then rules() ! --print("loaded rules file: "..rulesFilename) end ! -- FIXME - hack to add wxSTC and other bindings ! table.insert(interface_fileTable, "../wxstc/stc.i") ! table.insert(interface_fileTable, "../wxlua/wxlua.i") ! table.insert(interface_fileTable, "../wxluasocket/wxluasocket.i") ! ! local datatypes_file = loadfile(interface_filepath.."/"..datatypes_cache_output_filename) ! if datatypes_file then ! datatypes_file() ! --print("loaded data types file: "..datatypes_cache_output_filename) end dataTypeTable["wxString"].DefType = "class" -- FIXME hack for wxString DefType as "special" ! -- load any cached settings from other wrappers ! if datatype_cache_input_fileTable then ! for key, filename in pairs(datatype_cache_input_fileTable) do ! if FileExists(filename) then ! local cache = loadfile(filename) ! cache() -- run loaded file ! else ! assert(false, "unable to load datatypes cache file: "..filename) ! end end end ! ! LoadwxClassRef() ! ! fileTable = {} ! GenerateHeader(fileTable) GenerateClassReference(fileTable) table.insert(fileTable, "<HR>") --- 556,590 ---- end ! local rules = loadfile("./"..rulesFilename) if rules then rules() ! print("Loaded rules file: "..rulesFilename) ! else ! print("ERROR : unable to load rules file: "..rulesFilename) ! print("This could mean that either the file cannot be found or there is an error in it.") ! print("The rules file should be valid lua code, try running it with lua directly.") end ! for n = 1, #interface_fileTable do ! local datatypes_filename = interface_fileTable[n].file_path.."/"..interface_fileTable[n].datatypes_filename ! local datatypes_file = loadfile(datatypes_filename) ! if datatypes_file then ! datatypes_file() ! print("Loaded data types file: "..datatypes_filename) ! else ! print("WARNING: unable to load data types file: "..datatypes_filename) ! end end dataTypeTable["wxString"].DefType = "class" -- FIXME hack for wxString DefType as "special" ! if completeClassRefFileTable then ! for n = 1, #completeClassRefFileTable do ! LoadCompleteClassRef(completeClassRefFileTable[n]) ! print("Loaded complete class reference : "..completeClassRefFileTable[n]) end end ! fileTable = { htmlHeader } GenerateClassReference(fileTable) table.insert(fileTable, "<HR>") *************** *** 422,428 **** GenerateFooter(fileTable) ! for n = 1, #fileTable do ! print(fileTable[n]) ! end end --- 596,602 ---- GenerateFooter(fileTable) ! ! WriteTableToFile(output_filename , fileTable) ! --for n = 1, #fileTable do print(fileTable[n]) end end |