summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-12-12 16:31:09 +0000
committerAndy Williams <andy@andywilliams.me>2017-12-12 16:35:20 +0000
commit33a40500488f0a4be602901cbb58895ea6ddbbd6 (patch)
tree1f8ce1a03c69a9d9fec23494827dcbec23b01554
parent7fa99824a0c9858f0bdd41405471f54b335930f5 (diff)
docs: Keep description at the top and code snippets at the bottom
-rw-r--r--src/scripts/elua/apps/gendoc.lua83
1 files changed, 42 insertions, 41 deletions
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 2f2f4cad9c..e4c0be8b35 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -1063,8 +1063,6 @@ local build_alias = function(tp)
1063 local f = writer.Writer(ns, fulln) 1063 local f = writer.Writer(ns, fulln)
1064 printgen("Generating alias: " .. fulln) 1064 printgen("Generating alias: " .. fulln)
1065 1065
1066 write_tsigs(f, tp, ns)
1067
1068 f:write_h("Description", 2) 1066 f:write_h("Description", 2)
1069 f:write_raw(tp:doc_get():full_get(nil, true)) 1067 f:write_raw(tp:doc_get():full_get(nil, true))
1070 f:write_nl(2) 1068 f:write_nl(2)
@@ -1072,6 +1070,8 @@ local build_alias = function(tp)
1072 f:write_editable(ns, "description") 1070 f:write_editable(ns, "description")
1073 f:write_nl() 1071 f:write_nl()
1074 1072
1073 write_tsigs(f, tp, ns)
1074
1075 f:finish() 1075 f:finish()
1076end 1076end
1077 1077
@@ -1081,8 +1081,6 @@ local build_struct = function(tp)
1081 local f = writer.Writer(ns, fulln) 1081 local f = writer.Writer(ns, fulln)
1082 printgen("Generating struct: " .. fulln) 1082 printgen("Generating struct: " .. fulln)
1083 1083
1084 write_tsigs(f, tp, ns)
1085
1086 f:write_h("Description", 2) 1084 f:write_h("Description", 2)
1087 f:write_raw(tp:doc_get():full_get(nil, true)) 1085 f:write_raw(tp:doc_get():full_get(nil, true))
1088 f:write_nl(2) 1086 f:write_nl(2)
@@ -1105,6 +1103,8 @@ local build_struct = function(tp)
1105 f:write_list(arr) 1103 f:write_list(arr)
1106 f:write_nl() 1104 f:write_nl()
1107 1105
1106 write_tsigs(f, tp, ns)
1107
1108 f:finish() 1108 f:finish()
1109end 1109end
1110 1110
@@ -1114,8 +1114,6 @@ local build_enum = function(tp)
1114 local f = writer.Writer(ns, fulln) 1114 local f = writer.Writer(ns, fulln)
1115 printgen("Generating enum: " .. fulln) 1115 printgen("Generating enum: " .. fulln)
1116 1116
1117 write_tsigs(f, tp, ns)
1118
1119 f:write_h("Description", 2) 1117 f:write_h("Description", 2)
1120 f:write_raw(tp:doc_get():full_get(nil, true)) 1118 f:write_raw(tp:doc_get():full_get(nil, true))
1121 f:write_nl(2) 1119 f:write_nl(2)
@@ -1138,6 +1136,8 @@ local build_enum = function(tp)
1138 f:write_list(arr) 1136 f:write_list(arr)
1139 f:write_nl() 1137 f:write_nl()
1140 1138
1139 write_tsigs(f, tp, ns)
1140
1141 f:finish() 1141 f:finish()
1142end 1142end
1143 1143
@@ -1147,8 +1147,6 @@ local build_variable = function(v, constant)
1147 local f = writer.Writer(ns, fulln) 1147 local f = writer.Writer(ns, fulln)
1148 printgen("Generating variable: " .. fulln) 1148 printgen("Generating variable: " .. fulln)
1149 1149
1150 write_tsigs(f, v, ns)
1151
1152 f:write_h("Description", 2) 1150 f:write_h("Description", 2)
1153 f:write_raw(v:doc_get():full_get(nil, true)) 1151 f:write_raw(v:doc_get():full_get(nil, true))
1154 f:write_nl(2) 1152 f:write_nl(2)
@@ -1156,6 +1154,8 @@ local build_variable = function(v, constant)
1156 f:write_editable(ns, "description") 1154 f:write_editable(ns, "description")
1157 f:write_nl() 1155 f:write_nl()
1158 1156
1157 write_tsigs(f, v, ns)
1158
1159 f:finish() 1159 f:finish()
1160end 1160end
1161 1161
@@ -1325,13 +1325,20 @@ build_method = function(impl, cl)
1325 local f = writer.Writer(mns, methn) 1325 local f = writer.Writer(mns, methn)
1326 printgen("Generating method: " .. methn) 1326 printgen("Generating method: " .. methn)
1327 1327
1328 write_inherited_from(f, impl, cl, over, false)
1329
1330 local doc = impl:doc_get(fn.METHOD) 1328 local doc = impl:doc_get(fn.METHOD)
1331 if over and not doc:exists() then 1329 if over and not doc:exists() then
1332 doc = find_parent_doc(impl:full_name_get(), cl, fn.METHOD) 1330 doc = find_parent_doc(impl:full_name_get(), cl, fn.METHOD)
1333 end 1331 end
1334 1332
1333 f:write_h("Description", 2)
1334 f:write_raw(doc:full_get(nil, true))
1335 f:write_nl()
1336
1337 f:write_editable(mns, "description")
1338 f:write_nl()
1339
1340 write_inherited_from(f, impl, cl, over, false)
1341
1335 f:write_h("Signature", 2) 1342 f:write_h("Signature", 2)
1336 f:write_code(gen_method_sig(fn, cl)) 1343 f:write_code(gen_method_sig(fn, cl))
1337 f:write_nl() 1344 f:write_nl()
@@ -1347,13 +1354,6 @@ build_method = function(impl, cl)
1347 f:write_nl() 1354 f:write_nl()
1348 end 1355 end
1349 1356
1350 f:write_h("Description", 2)
1351 f:write_raw(doc:full_get(nil, true))
1352 f:write_nl()
1353
1354 f:write_editable(mns, "description")
1355 f:write_nl()
1356
1357 write_ilist(f, impl, cl) 1357 write_ilist(f, impl, cl)
1358 f:write_nl() 1358 f:write_nl()
1359 1359
@@ -1368,8 +1368,6 @@ build_property = function(impl, cl)
1368 local f = writer.Writer(pns, propn) 1368 local f = writer.Writer(pns, propn)
1369 printgen("Generating property: " .. propn) 1369 printgen("Generating property: " .. propn)
1370 1370
1371 write_inherited_from(f, impl, cl, over, true)
1372
1373 local pimp = fn:implement_get() 1371 local pimp = fn:implement_get()
1374 1372
1375 local isget = pimp:is_prop_get() 1373 local isget = pimp:is_prop_get()
@@ -1391,21 +1389,6 @@ build_property = function(impl, cl)
1391 end 1389 end
1392 end 1390 end
1393 1391
1394 f:write_h("Signature", 2)
1395 f:write_code(gen_prop_sig(fn, cl))
1396 f:write_nl()
1397
1398 f:write_h("C signature", 2)
1399 local codes = {}
1400 if isget then
1401 codes[#codes + 1] = gen_func_csig(fn, fn.PROP_GET)
1402 end
1403 if isset then
1404 codes[#codes + 1] = gen_func_csig(fn, fn.PROP_SET)
1405 end
1406 f:write_code(table.concat(codes, "\n"), "c")
1407 f:write_nl()
1408
1409 local pgkeys = isget and fn:property_keys_get(fn.PROP_GET) or {} 1392 local pgkeys = isget and fn:property_keys_get(fn.PROP_GET) or {}
1410 local pskeys = isset and fn:property_keys_get(fn.PROP_SET) or {} 1393 local pskeys = isset and fn:property_keys_get(fn.PROP_SET) or {}
1411 build_vallist(f, pgkeys, pskeys, "Keys") 1394 build_vallist(f, pgkeys, pskeys, "Keys")
@@ -1461,10 +1444,28 @@ build_property = function(impl, cl)
1461 f:write_nl() 1444 f:write_nl()
1462 if not isget or not isset then 1445 if not isget or not isset then
1463 f:write_nl() 1446 f:write_nl()
1447 f:write_br()
1464 f:write_editable(pns, "description") 1448 f:write_editable(pns, "description")
1465 f:write_nl() 1449 f:write_nl()
1466 end 1450 end
1467 1451
1452 write_inherited_from(f, impl, cl, over, true)
1453
1454 f:write_h("Signature", 2)
1455 f:write_code(gen_prop_sig(fn, cl))
1456 f:write_nl()
1457
1458 f:write_h("C signature", 2)
1459 local codes = {}
1460 if isget then
1461 codes[#codes + 1] = gen_func_csig(fn, fn.PROP_GET)
1462 end
1463 if isset then
1464 codes[#codes + 1] = gen_func_csig(fn, fn.PROP_SET)
1465 end
1466 f:write_code(table.concat(codes, "\n"), "c")
1467 f:write_nl()
1468
1468 write_ilist(f, impl, cl) 1469 write_ilist(f, impl, cl)
1469 f:write_nl() 1470 f:write_nl()
1470 1471
@@ -1503,6 +1504,13 @@ build_event = function(ev, cl)
1503 local f = writer.Writer(evn, evnm) 1504 local f = writer.Writer(evn, evnm)
1504 printgen("Generating event: " .. evnm) 1505 printgen("Generating event: " .. evnm)
1505 1506
1507 f:write_h("Description", 2)
1508 f:write_raw(ev:doc_get():full_get(nil, true))
1509 f:write_nl()
1510
1511 f:write_editable(evn, "description")
1512 f:write_nl()
1513
1506 f:write_h("Signature", 2) 1514 f:write_h("Signature", 2)
1507 local buf = { ev:name_get() } 1515 local buf = { ev:name_get() }
1508 1516
@@ -1540,13 +1548,6 @@ build_event = function(ev, cl)
1540 f:write_code(build_event_example(ev), "c") 1548 f:write_code(build_event_example(ev), "c")
1541 f:write_nl() 1549 f:write_nl()
1542 1550
1543 f:write_h("Description", 2)
1544 f:write_raw(ev:doc_get():full_get(nil, true))
1545 f:write_nl()
1546
1547 f:write_editable(evn, "description")
1548 f:write_nl()
1549
1550 f:finish() 1551 f:finish()
1551end 1552end
1552 1553