summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-12-22 17:30:52 +0000
committerAndy Williams <andy@andywilliams.me>2017-12-22 17:30:52 +0000
commit46fbbef13a0cc7d5612720f96ff23e0bb1d52cc5 (patch)
tree88da91a71b0a91e34af65dcf188a5941d0252c0a
parent7b4441e2b8d9d32d0d362560a64a6dcc716ee544 (diff)
docs: Group our API landing page by namespace
-rw-r--r--src/scripts/elua/apps/gendoc.lua95
1 files changed, 70 insertions, 25 deletions
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 842df515d8..55a380633c 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -305,13 +305,32 @@ end
305 305
306-- builders 306-- builders
307 307
308local nspaces_group = function(ns)
309 if ns[1] == "efl" and (ns[2] ~= "class" and ns[2] ~= "interface" and ns[2] ~= "object" and ns[2] ~= "promise") then
310 return ns[1] .. "." .. ns[2]
311 end
312
313 return ns[1]
314end
315
316local nspaces_filter = function(items, ns)
317 local out = {}
318
319 for _, item in ipairs(items) do
320 local group = nspaces_group(item:nspaces_get())
321 if group == ns then out[#out + 1] = item end
322 end
323
324 return out
325end
326
308local build_method, build_property, build_event 327local build_method, build_property, build_event
309 328
310local build_reftable = function(f, title, ctitle, ctype, t, iscl) 329local build_reftable = function(f, title, ctype, t, iscl)
311 if not t or #t == 0 then 330 if not t or #t == 0 then
312 return 331 return
313 end 332 end
314 f:write_h(title, 2) 333
315 local nt = {} 334 local nt = {}
316 for i, v in ipairs(t) do 335 for i, v in ipairs(t) do
317 nt[#nt + 1] = { 336 nt[#nt + 1] = {
@@ -324,22 +343,15 @@ local build_reftable = function(f, title, ctitle, ctype, t, iscl)
324 } 343 }
325 end 344 end
326 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end) 345 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
327 f:write_table({ ctitle, "Brief description" }, nt) 346 f:write_table({ title, "Brief description" }, nt)
328 f:write_nl()
329end 347end
330 348
331local build_ref = function() 349local build_ref_group = function(f, ns, classlist, aliases, structs, enums, consts, globals)
332 local f = writer.Writer("start", "EFL Reference")
333 printgen("Generating reference...")
334
335 f:write_editable({ "reference" }, "general")
336 f:write_nl()
337
338 local classes = {} 350 local classes = {}
339 local ifaces = {} 351 local ifaces = {}
340 local mixins = {} 352 local mixins = {}
341 353
342 for i, cl in ipairs(dtree.Class.all_get()) do 354 for i, cl in ipairs(classlist) do
343 local tp = cl:type_get() 355 local tp = cl:type_get()
344 if tp == dtree.Class.REGULAR or tp == dtree.Class.ABSTRACT then 356 if tp == dtree.Class.REGULAR or tp == dtree.Class.ABSTRACT then
345 classes[#classes + 1] = cl 357 classes[#classes + 1] = cl
@@ -350,24 +362,57 @@ local build_ref = function()
350 end 362 end
351 end 363 end
352 364
353 build_reftable(f, "Classes", "Class name", "class", classes, true) 365 local title = ns:gsub("(%l)(%w*)", function(a,b) return a:upper()..b end) --string.sub(ns, 1, 1):upper() .. string.sub(ns, 2):lower()
354 build_reftable(f, "Interfaces", "Interface name", "interface", ifaces, true) 366 f:write_h(title, 2)
355 build_reftable(f, "Mixins", "Mixin name", "mixin", mixins, true) 367
368 build_reftable(f, "Classes", "class", classes, true)
369 build_reftable(f, "Interfaces", "interface", ifaces, true)
370 build_reftable(f, "Mixins", "mixin", mixins, true)
371
372 build_reftable(f, "Aliases", "alias", aliases)
373 build_reftable(f, "Structures", "struct", structs)
374 build_reftable(f, "Enums", "enum", enums)
375 build_reftable(f, "Constants", "constant", consts)
376 build_reftable(f, "Globals", "global", globals)
377
378 f:write_nl()
379end
380
381local build_ref = function()
382 local f = writer.Writer("start", "EFL Reference")
383 printgen("Generating reference...")
356 384
357 build_reftable(f, "Aliases", "Alias name", "alias", 385 f:write_editable({ "reference" }, "general")
358 dtree.Typedecl.all_aliases_get()) 386 f:write_nl()
359 387
360 build_reftable(f, "Structures", "Struct name", "struct", 388 local classlist = dtree.Class.all_get()
361 dtree.Typedecl.all_structs_get()) 389 local aliases = dtree.Typedecl.all_aliases_get()
390 local structs = dtree.Typedecl.all_structs_get()
391 local enums = dtree.Typedecl.all_enums_get()
392 local consts = dtree.Variable.all_constants_get()
393 local globals = dtree.Variable.all_globals_get()
362 394
363 build_reftable(f, "Enums", "Enum name", "enum", 395 grouped = {}
364 dtree.Typedecl.all_enums_get()) 396 groups = {}
397 for i, cl in ipairs(classlist) do
398 local ns = cl:nspaces_get()
399 local name = nspaces_group(cl:nspaces_get())
365 400
366 build_reftable(f, "Constants", "Constant name", "constant", 401 local group = grouped[name]
367 dtree.Variable.all_constants_get()) 402 if not group then
403 group = {}
404 grouped[name] = group
405 groups[#groups + 1] = name
406 end
368 407
369 build_reftable(f, "Globals", "Global name", "global", 408 group[#group + 1] = cl
370 dtree.Variable.all_globals_get()) 409 end
410 table.sort(groups)
411
412 for _, ns in ipairs(groups) do
413 build_ref_group(f, ns, grouped[ns], nspaces_filter(aliases, ns), nspaces_filter(structs, ns),
414 nspaces_filter(enums, ns), nspaces_filter(consts, ns), nspaces_filter(globals, ns))
415 end
371 416
372 f:finish() 417 f:finish()
373end 418end