"Fossies" - the Fresh Open Source Software Archive

Member "darktable-3.6.1/tools/lua_doc/dumper.lua" (10 Sep 2021, 2968 Bytes) of package /linux/misc/darktable-3.6.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 
    3 para = function() return "\n" end
    4 node_to_string = function(node,name) 
    5     if name then
    6         return name
    7     else
    8         return node:get_name()
    9     end
   10 end
   11 
   12 code = function(text) 
   13     return "<code>"..text.."</code>"
   14 end
   15 emphasis = function(text)
   16   return "<em>"..text.."</em>"
   17 end
   18 
   19 startlist = function() return "\n" end
   20 endlist = function() return "\n" end
   21 listel = function(text) return "\n* "..text end
   22 
   23 url = function(text,content) 
   24   if content then
   25     return "<ulink url=\""..text.."\">"..content.."</ulink>"
   26   else
   27     return text
   28   end
   29 end
   30 
   31 require "content"
   32 doc = require "core"
   33 table = require "table"
   34 dump = require("darktable.debug").dump
   35 dt = require "darktable"
   36 
   37 
   38 local function sorted_pairs (t, f)
   39     local a = {}
   40     for n in pairs(t) do table.insert(a, n) end
   41     table.sort(a, f)
   42     local i = 0      -- iterator variable
   43     local iter = function ()   -- iterator function
   44         i = i + 1
   45         if a[i] == nil then return nil
   46         else return a[i], t[a[i]]
   47         end
   48     end
   49     return iter
   50 end
   51 
   52 local print_node
   53 local add_table_entry
   54 
   55 local function print_content(obj,obj_name)
   56   local result 
   57   if(type(obj) == "boolean") then
   58     result = tostring(obj)
   59   elseif type(obj) == "string" then
   60     result = "[==["..obj.."]==]"
   61   elseif type(obj) == "table" and obj._luadoc_type then
   62     result = print_node(obj,obj_name)
   63   elseif type(obj) == "table" then
   64     result = "{\n"
   65     for k,v in sorted_pairs(obj) do
   66       result = result..add_table_entry(k,v,obj_name.."[\""..k.."\"]")
   67     end
   68     result = result.."}"
   69   elseif type(obj) == "number" then
   70     result = tostring(obj)
   71   elseif type(obj) == "nil" then
   72     result ="nil"
   73   else
   74     error("unhandle attribute type\n"..type(obj))
   75   end
   76 
   77   return result
   78 
   79 end
   80 
   81 
   82 local known = {}
   83 
   84 function print_node(node,node_name)
   85   local result
   86   if known[node] then
   87     table.insert(known[node],node_name)
   88     return "{} --[=["..known[node].target.."]=]"
   89     --return "{}"
   90   else
   91     known[node] = {target = node_name }
   92   end
   93   result = "{\n"
   94   result = result..add_table_entry("__text",doc.get_text(node),node_name..".__text")
   95   result = result..add_table_entry("__attributes",node._luadoc_attributes,node_name..".__attributes")
   96 
   97   for k,v in node:unskiped_children() do
   98     result = result..add_table_entry(k,v,node_name.."[\""..k.."\"]")
   99   end
  100   result=result.."}"
  101   return result
  102 end
  103 
  104 
  105 add_table_entry = function(key,object,name)
  106   return "[\""..key.."\"]".." = "..  print_content(object,name)..  ",\n"
  107 
  108 end
  109 
  110 
  111 M = {}
  112 
  113 function M.get_doc()
  114   result = "API = "..  print_node(doc.toplevel,"API").."\n"
  115   for _,known_entry in pairs(known) do
  116     for _,target in ipairs(known_entry) do
  117       result = result..target.." = "..known_entry["target"].."\n"
  118     end
  119   end
  120   return result..[==[return API
  121 --
  122 -- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
  123 ]==]
  124 
  125 end
  126 
  127 
  128 --for k, v in darktable.gui.libs:unskiped_children() do
  129 --  print(v._luadoc_attributes["position"].."aaa")
  130 --end
  131 
  132 
  133 
  134 return M;
  135 --
  136 -- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua