Module:ConceptTimelineRenderer

From No Subject
Jump to navigation Jump to search

Documentation for this module may be created at Module:ConceptTimelineRenderer/doc

local p={}
local getArgs=require('Module:Arguments').getArgs

function p.main(frame)
 local args=getArgs(frame)
 local out={"<mermaid>","gantt","title "..(args.title or "Concept Timeline"),"dateFormat YYYY",""}

 local concepts={}

 for i=1,100 do
  local c=args["timeline_"..i.."_concept"]
  if not c then break end
  concepts[c]=concepts[c] or {}
  local s=args["timeline_"..i.."_section"] or "General"
  concepts[c][s]=concepts[c][s] or {}
  table.insert(concepts[c][s],
   args["timeline_"..i.."_person"]..": "..args["timeline_"..i.."_event"]..
   " : t"..i..","..args["timeline_"..i.."_start"]..","..args["timeline_"..i.."_duration"].."y")
 end

 for c,secs in pairs(concepts) do
  for s,tasks in pairs(secs) do
   table.insert(out,"section "..c.." - "..s)
   for _,t in ipairs(tasks) do table.insert(out," "..t) end
  end
 end

 table.insert(out,"</mermaid>")
 return table.concat(out,"\n")
end

return p