summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua173
-rw-r--r--src/scripts/elua/apps/docgen/serializers.lua33
-rw-r--r--src/scripts/elua/apps/docgen/stats.lua14
-rw-r--r--src/scripts/elua/apps/gendoc.lua25
4 files changed, 205 insertions, 40 deletions
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index ff1e3309b2..32678e1fa0 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -503,6 +503,171 @@ M.Event = Node:clone {
503 end 503 end
504} 504}
505 505
506M.Typedecl = Node:clone {
507 UNKNOWN = eolian.typedecl_type.UNKNOWN,
508 STRUCT = eolian.typedecl_type.STRUCT,
509 STRUCT_OPAQUE = eolian.typedecl_type.STRUCT_OPAQUE,
510 ENUM = eolian.typedecl_type.ENUM,
511 ALIAS = eolian.typedecl_type.ALIAS,
512
513 __ctor = function(self, tp)
514 self.typedecl = tp
515 assert(self.typedecl)
516 end,
517
518 type_get = function(self)
519 return self.typedecl:type_get()
520 end,
521
522 type_str_get = function(self)
523 local strs = {
524 [eolian.typedecl_type.STRUCT] = "struct",
525 [eolian.typedecl_type.STRUCT_OPAQUE] = "struct",
526 [eolian.typedecl_type.ENUM] = "enum",
527 [eolian.typedecl_type.ALIAS] = "alias"
528 }
529 return strs[self:type_get()]
530 end,
531
532 struct_fields_get = function(self)
533 return self.typedecl:struct_fields_get():to_array()
534 end,
535
536 struct_field_get = function(self, name)
537 return self.typedecl:struct_field_get(name)
538 end,
539
540 enum_fields_get = function(self)
541 return self.typedecl:enum_fields_get():to_array()
542 end,
543
544 enum_field_get = function(self, name)
545 return self.typedecl:enum_field_get(name)
546 end,
547
548 enum_legacy_prefix_get = function(self)
549 return self.typedecl:enum_legacy_prefix_get()
550 end,
551
552 doc_get = function(self)
553 return M.Doc(self.typedecl:documentation_get())
554 end,
555
556 file_get = function(self)
557 return self.typedecl:file_get()
558 end,
559
560 base_type_get = function(self)
561 return self.typedecl:base_type_get()
562 end,
563
564 aliased_base_get = function(self)
565 return self.typedecl:aliased_base_get()
566 end,
567
568 is_extern = function(self)
569 return self.typedecl:is_extern()
570 end,
571
572 c_type_get = function(self)
573 return self.typedecl:c_type_get()
574 end,
575
576 name_get = function(self)
577 return self.typedecl:name_get()
578 end,
579
580 full_name_get = function(self)
581 return self.typedecl:full_name_get()
582 end,
583
584 namespaces_get = function(self)
585 return self.typedecl:namespaces_get():to_array()
586 end,
587
588 free_func_get = function(self)
589 return self.typedecl:free_func_get()
590 end,
591
592 nspaces_get = function(self, root)
593 return M.Node.nspaces_get(self, self:type_str_get(), root)
594 end,
595
596 -- static getters
597
598 all_aliases_get = function()
599 local ret = {}
600 for tp in eolian.typedecl_all_aliases_get() do
601 ret[#ret + 1] = M.Typedecl(tp)
602 end
603 return ret
604 end,
605
606 all_structs_get = function()
607 local ret = {}
608 for tp in eolian.typedecl_all_structs_get() do
609 ret[#ret + 1] = M.Typedecl(tp)
610 end
611 return ret
612 end,
613
614 all_enums_get = function()
615 local ret = {}
616 for tp in eolian.typedecl_all_enums_get() do
617 ret[#ret + 1] = M.Typedecl(tp)
618 end
619 return ret
620 end,
621
622 aliases_by_file_get = function(fn)
623 local ret = {}
624 for tp in eolian.typedecl_aliases_get_by_file(fn) do
625 ret[#ret + 1] = M.Typedecl(tp)
626 end
627 return ret
628 end,
629
630 structs_by_file_get = function(fn)
631 local ret = {}
632 for tp in eolian.typedecl_structs_get_by_file(fn) do
633 ret[#ret + 1] = M.Typedecl(tp)
634 end
635 return ret
636 end,
637
638 enums_by_file_get = function(fn)
639 local ret = {}
640 for tp in eolian.typedecl_enums_get_by_file(fn) do
641 ret[#ret + 1] = M.Typedecl(tp)
642 end
643 return ret
644 end,
645
646 alias_by_name_get = function(tn)
647 local v = eolian.typedecl_alias_get_by_name(tn)
648 if not v then
649 return nil
650 end
651 return M.Typedecl(v)
652 end,
653
654 struct_by_name_get = function(tn)
655 local v = eolian.typedecl_struct_get_by_name(tn)
656 if not v then
657 return nil
658 end
659 return M.Typedecl(v)
660 end,
661
662 enum_by_name_get = function(tn)
663 local v = eolian.typedecl_enum_get_by_name(tn)
664 if not v then
665 return nil
666 end
667 return M.Typedecl(v)
668 end
669}
670
506M.Variable = Node:clone { 671M.Variable = Node:clone {
507 UNKNOWN = eolian.variable_type.UNKNOWN, 672 UNKNOWN = eolian.variable_type.UNKNOWN,
508 CONSTANT = eolian.variable_type.CONSTANT, 673 CONSTANT = eolian.variable_type.CONSTANT,
@@ -566,7 +731,7 @@ M.Variable = Node:clone {
566 all_globals_get = function() 731 all_globals_get = function()
567 local ret = {} 732 local ret = {}
568 for v in eolian.variable_all_globals_get() do 733 for v in eolian.variable_all_globals_get() do
569 ret[#ret + 1] = v 734 ret[#ret + 1] = M.Variable(v)
570 end 735 end
571 return ret 736 return ret
572 end, 737 end,
@@ -574,7 +739,7 @@ M.Variable = Node:clone {
574 all_constants_get = function() 739 all_constants_get = function()
575 local ret = {} 740 local ret = {}
576 for v in eolian.variable_all_constants_get() do 741 for v in eolian.variable_all_constants_get() do
577 ret[#ret + 1] = v 742 ret[#ret + 1] = M.Variable(v)
578 end 743 end
579 return ret 744 return ret
580 end, 745 end,
@@ -582,7 +747,7 @@ M.Variable = Node:clone {
582 globals_by_file_get = function(fn) 747 globals_by_file_get = function(fn)
583 local ret = {} 748 local ret = {}
584 for v in eolian.variable_globals_get_by_file(fn) do 749 for v in eolian.variable_globals_get_by_file(fn) do
585 ret[#ret + 1] = v 750 ret[#ret + 1] = M.Variable(v)
586 end 751 end
587 return ret 752 return ret
588 end, 753 end,
@@ -590,7 +755,7 @@ M.Variable = Node:clone {
590 constants_by_file_get = function(fn) 755 constants_by_file_get = function(fn)
591 local ret = {} 756 local ret = {}
592 for v in eolian.variable_constants_get_by_file(fn) do 757 for v in eolian.variable_constants_get_by_file(fn) do
593 ret[#ret + 1] = v 758 ret[#ret + 1] = M.Variable(v)
594 end 759 end
595 return ret 760 return ret
596 end, 761 end,
diff --git a/src/scripts/elua/apps/docgen/serializers.lua b/src/scripts/elua/apps/docgen/serializers.lua
index 0e38fd93c6..e39abe769f 100644
--- a/src/scripts/elua/apps/docgen/serializers.lua
+++ b/src/scripts/elua/apps/docgen/serializers.lua
@@ -1,5 +1,6 @@
1local eolian = require("eolian") 1local eolian = require("eolian")
2local keyref = require("docgen.keyref") 2local keyref = require("docgen.keyref")
3local dtree = require("docgen.doctree")
3 4
4local M = {} 5local M = {}
5 6
@@ -84,19 +85,19 @@ local add_typedecl_attrs = function(tp, buf)
84end 85end
85 86
86M.get_typedecl_str = function(tp) 87M.get_typedecl_str = function(tp)
87 local tps = eolian.typedecl_type
88 local tpt = tp:type_get() 88 local tpt = tp:type_get()
89 if tpt == tps.UNKNOWN then 89 if tpt == dtree.Typedecl.UNKNOWN then
90 error("unknown typedecl: " .. tp:full_name_get()) 90 error("unknown typedecl: " .. tp:full_name_get())
91 elseif tpt == tps.STRUCT or tpt == tps.STRUCT_OPAQUE then 91 elseif tpt == dtree.Typedecl.STRUCT or
92 tpt == dtree.Typedecl.STRUCT_OPAQUE then
92 local buf = { "struct " } 93 local buf = { "struct " }
93 add_typedecl_attrs(tp, buf) 94 add_typedecl_attrs(tp, buf)
94 buf[#buf + 1] = tp:full_name_get() 95 buf[#buf + 1] = tp:full_name_get()
95 if tpt == tps.STRUCT_OPAQUE then 96 if tpt == dtree.Typedecl.STRUCT_OPAQUE then
96 buf[#buf + 1] = ";" 97 buf[#buf + 1] = ";"
97 return table.concat(buf) 98 return table.concat(buf)
98 end 99 end
99 local fields = tp:struct_fields_get():to_array() 100 local fields = tp:struct_fields_get()
100 if #fields == 0 then 101 if #fields == 0 then
101 buf[#buf + 1] = " {}" 102 buf[#buf + 1] = " {}"
102 return table.concat(buf) 103 return table.concat(buf)
@@ -111,11 +112,11 @@ M.get_typedecl_str = function(tp)
111 end 112 end
112 buf[#buf + 1] = "}" 113 buf[#buf + 1] = "}"
113 return table.concat(buf) 114 return table.concat(buf)
114 elseif tpt == tps.ENUM then 115 elseif tpt == dtree.Typedecl.ENUM then
115 local buf = { "enum " } 116 local buf = { "enum " }
116 add_typedecl_attrs(tp, buf) 117 add_typedecl_attrs(tp, buf)
117 buf[#buf + 1] = tp:full_name_get() 118 buf[#buf + 1] = tp:full_name_get()
118 local fields = tp:enum_fields_get():to_array() 119 local fields = tp:enum_fields_get()
119 if #fields == 0 then 120 if #fields == 0 then
120 buf[#buf + 1] = " {}" 121 buf[#buf + 1] = " {}"
121 return table.concat(buf) 122 return table.concat(buf)
@@ -137,7 +138,7 @@ M.get_typedecl_str = function(tp)
137 end 138 end
138 buf[#buf + 1] = "}" 139 buf[#buf + 1] = "}"
139 return table.concat(buf) 140 return table.concat(buf)
140 elseif tpt == tps.ALIAS then 141 elseif tpt == dtree.Typedecl.ALIAS then
141 local buf = { "type " } 142 local buf = { "type " }
142 add_typedecl_attrs(tp, buf) 143 add_typedecl_attrs(tp, buf)
143 buf[#buf + 1] = tp:full_name_get() 144 buf[#buf + 1] = tp:full_name_get()
@@ -150,20 +151,20 @@ M.get_typedecl_str = function(tp)
150end 151end
151 152
152M.get_typedecl_cstr = function(tp) 153M.get_typedecl_cstr = function(tp)
153 local tps = eolian.typedecl_type
154 local tpt = tp:type_get() 154 local tpt = tp:type_get()
155 if tpt == tps.UNKNOWN then 155 if tpt == dtree.Typedecl.UNKNOWN then
156 error("unknown typedecl: " .. tp:full_name_get()) 156 error("unknown typedecl: " .. tp:full_name_get())
157 elseif tpt == tps.STRUCT or tpt == tps.STRUCT_OPAQUE then 157 elseif tpt == dtree.Typedecl.STRUCT or
158 tpt == dtree.Typedecl.STRUCT_OPAQUE then
158 local buf = { "typedef struct " } 159 local buf = { "typedef struct " }
159 local fulln = tp:full_name_get():gsub("%.", "_"); 160 local fulln = tp:full_name_get():gsub("%.", "_");
160 keyref.add(fulln, "c") 161 keyref.add(fulln, "c")
161 buf[#buf + 1] = "_" .. fulln; 162 buf[#buf + 1] = "_" .. fulln;
162 if tpt == tps.STRUCT_OPAQUE then 163 if tpt == dtree.Typedecl.STRUCT_OPAQUE then
163 buf[#buf + 1] = " " .. fulln .. ";" 164 buf[#buf + 1] = " " .. fulln .. ";"
164 return table.concat(buf) 165 return table.concat(buf)
165 end 166 end
166 local fields = tp:struct_fields_get():to_array() 167 local fields = tp:struct_fields_get()
167 if #fields == 0 then 168 if #fields == 0 then
168 buf[#buf + 1] = " {} " .. fulln .. ";" 169 buf[#buf + 1] = " {} " .. fulln .. ";"
169 return table.concat(buf) 170 return table.concat(buf)
@@ -176,11 +177,11 @@ M.get_typedecl_cstr = function(tp)
176 end 177 end
177 buf[#buf + 1] = "} " .. fulln .. ";" 178 buf[#buf + 1] = "} " .. fulln .. ";"
178 return table.concat(buf) 179 return table.concat(buf)
179 elseif tpt == tps.ENUM then 180 elseif tpt == dtree.Typedecl.ENUM then
180 local buf = { "typedef enum" } 181 local buf = { "typedef enum" }
181 local fulln = tp:full_name_get():gsub("%.", "_"); 182 local fulln = tp:full_name_get():gsub("%.", "_");
182 keyref.add(fulln, "c") 183 keyref.add(fulln, "c")
183 local fields = tp:enum_fields_get():to_array() 184 local fields = tp:enum_fields_get()
184 if #fields == 0 then 185 if #fields == 0 then
185 buf[#buf + 1] = " {} " .. fulln .. ";" 186 buf[#buf + 1] = " {} " .. fulln .. ";"
186 return table.concat(buf) 187 return table.concat(buf)
@@ -210,7 +211,7 @@ M.get_typedecl_cstr = function(tp)
210 end 211 end
211 buf[#buf + 1] = "} " .. fulln .. ";" 212 buf[#buf + 1] = "} " .. fulln .. ";"
212 return table.concat(buf) 213 return table.concat(buf)
213 elseif tpt == tps.ALIAS then 214 elseif tpt == dtree.Typedecl.ALIAS then
214 local fulln = tp:full_name_get():gsub("%.", "_"); 215 local fulln = tp:full_name_get():gsub("%.", "_");
215 keyref.add(fulln, "c") 216 keyref.add(fulln, "c")
216 return "typedef " .. M.get_ctype_str(tp:base_type_get(), fulln) .. ";" 217 return "typedef " .. M.get_ctype_str(tp:base_type_get(), fulln) .. ";"
diff --git a/src/scripts/elua/apps/docgen/stats.lua b/src/scripts/elua/apps/docgen/stats.lua
index df5b6bca55..9d53caa055 100644
--- a/src/scripts/elua/apps/docgen/stats.lua
+++ b/src/scripts/elua/apps/docgen/stats.lua
@@ -205,7 +205,7 @@ M.check_property = function(fn, cl, ft)
205end 205end
206 206
207M.check_alias = function(v) 207M.check_alias = function(v)
208 if not v:documentation_get() then 208 if not v:doc_get():exists() then
209 print_missing(v:full_name_get(), "alias") 209 print_missing(v:full_name_get(), "alias")
210 stat_incr("alias", true) 210 stat_incr("alias", true)
211 else 211 else
@@ -214,13 +214,13 @@ M.check_alias = function(v)
214end 214end
215 215
216M.check_struct = function(v) 216M.check_struct = function(v)
217 if not v:documentation_get() then 217 if not v:doc_get():exists() then
218 print_missing(v:full_name_get(), "struct") 218 print_missing(v:full_name_get(), "struct")
219 stat_incr("struct", true) 219 stat_incr("struct", true)
220 else 220 else
221 stat_incr("struct", false) 221 stat_incr("struct", false)
222 end 222 end
223 for fl in v:struct_fields_get() do 223 for i, fl in ipairs(v:struct_fields_get()) do
224 if not fl:documentation_get() then 224 if not fl:documentation_get() then
225 print_missing(v:full_name_get() .. "." .. fl:name_get(), "struct field") 225 print_missing(v:full_name_get() .. "." .. fl:name_get(), "struct field")
226 stat_incr("sfield", true) 226 stat_incr("sfield", true)
@@ -231,13 +231,13 @@ M.check_struct = function(v)
231end 231end
232 232
233M.check_enum = function(v) 233M.check_enum = function(v)
234 if not v:documentation_get() then 234 if not v:doc_get():exists() then
235 print_missing(v:full_name_get(), "enum") 235 print_missing(v:full_name_get(), "enum")
236 stat_incr("enum", true) 236 stat_incr("enum", true)
237 else 237 else
238 stat_incr("enum", false) 238 stat_incr("enum", false)
239 end 239 end
240 for fl in v:enum_fields_get() do 240 for i, fl in ipairs(v:enum_fields_get()) do
241 if not fl:documentation_get() then 241 if not fl:documentation_get() then
242 print_missing(v:full_name_get() .. "." .. fl:name_get(), "enum field") 242 print_missing(v:full_name_get() .. "." .. fl:name_get(), "enum field")
243 stat_incr("efield", true) 243 stat_incr("efield", true)
@@ -248,7 +248,7 @@ M.check_enum = function(v)
248end 248end
249 249
250M.check_constant = function(v) 250M.check_constant = function(v)
251 if not v:documentation_get() then 251 if not v:doc_get():exists() then
252 print_missing(v:full_name_get(), "constant") 252 print_missing(v:full_name_get(), "constant")
253 stat_incr("constant", true) 253 stat_incr("constant", true)
254 else 254 else
@@ -257,7 +257,7 @@ M.check_constant = function(v)
257end 257end
258 258
259M.check_global = function(v) 259M.check_global = function(v)
260 if not v:documentation_get() then 260 if not v:doc_get():exists() then
261 print_missing(v:full_name_get(), "global") 261 print_missing(v:full_name_get(), "global")
262 stat_incr("global", true) 262 stat_incr("global", true)
263 else 263 else
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 5d4d6742bb..f8041fc726 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -1,4 +1,3 @@
1local eolian = require("eolian")
2local getopt = require("getopt") 1local getopt = require("getopt")
3 2
4local serializer = require("serializer") 3local serializer = require("serializer")
@@ -317,7 +316,7 @@ local build_reftable = function(f, title, ctitle, ctype, t, iscl)
317 iscl and v:nspaces_get() or dtree.Node.nspaces_get(v, ctype, true), 316 iscl and v:nspaces_get() or dtree.Node.nspaces_get(v, ctype, true),
318 v:full_name_get() 317 v:full_name_get()
319 ):finish(), 318 ):finish(),
320 (iscl and v:doc_get() or dtree.Doc(v:documentation_get())):brief_get() 319 v:doc_get():brief_get()
321 } 320 }
322 end 321 end
323 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end) 322 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
@@ -381,13 +380,13 @@ local build_ref = function()
381 build_reftable(f, "Mixins", "Mixin name", "mixin", mixins, true) 380 build_reftable(f, "Mixins", "Mixin name", "mixin", mixins, true)
382 381
383 build_reftable(f, "Aliases", "Alias name", "alias", 382 build_reftable(f, "Aliases", "Alias name", "alias",
384 eolian.typedecl_all_aliases_get():to_array()) 383 dtree.Typedecl.all_aliases_get())
385 384
386 build_reftable(f, "Structures", "Struct name", "struct", 385 build_reftable(f, "Structures", "Struct name", "struct",
387 eolian.typedecl_all_structs_get():to_array()) 386 dtree.Typedecl.all_structs_get())
388 387
389 build_reftable(f, "Enums", "Enum name", "enum", 388 build_reftable(f, "Enums", "Enum name", "enum",
390 eolian.typedecl_all_enums_get():to_array()) 389 dtree.Typedecl.all_enums_get())
391 390
392 build_reftable(f, "Constants", "Constant name", "constant", 391 build_reftable(f, "Constants", "Constant name", "constant",
393 dtree.Variable.all_constants_get()) 392 dtree.Variable.all_constants_get())
@@ -765,7 +764,7 @@ local build_alias = function(tp)
765 write_tsigs(f, tp) 764 write_tsigs(f, tp)
766 765
767 f:write_h("Description", 3) 766 f:write_h("Description", 3)
768 f:write_raw(dtree.Doc(tp:documentation_get()):full_get(nil, true)) 767 f:write_raw(tp:doc_get():full_get(nil, true))
769 f:write_nl(2) 768 f:write_nl(2)
770 769
771 f:finish() 770 f:finish()
@@ -778,13 +777,13 @@ local build_struct = function(tp)
778 write_tsigs(f, tp) 777 write_tsigs(f, tp)
779 778
780 f:write_h("Description", 3) 779 f:write_h("Description", 3)
781 f:write_raw(dtree.Doc(tp:documentation_get()):full_get(nil, true)) 780 f:write_raw(tp:doc_get():full_get(nil, true))
782 f:write_nl(2) 781 f:write_nl(2)
783 782
784 f:write_h("Fields", 3) 783 f:write_h("Fields", 3)
785 784
786 local arr = {} 785 local arr = {}
787 for fl in tp:struct_fields_get() do 786 for i, fl in ipairs(tp:struct_fields_get()) do
788 local buf = writer.Buffer() 787 local buf = writer.Buffer()
789 buf:write_b(fl:name_get()) 788 buf:write_b(fl:name_get())
790 buf:write_raw(" - ", dtree.Doc(fl:documentation_get()):full_get()) 789 buf:write_raw(" - ", dtree.Doc(fl:documentation_get()):full_get())
@@ -803,13 +802,13 @@ local build_enum = function(tp)
803 write_tsigs(f, tp) 802 write_tsigs(f, tp)
804 803
805 f:write_h("Description", 3) 804 f:write_h("Description", 3)
806 f:write_raw(dtree.Doc(tp:documentation_get()):full_get(nil, true)) 805 f:write_raw(tp:doc_get():full_get(nil, true))
807 f:write_nl(2) 806 f:write_nl(2)
808 807
809 f:write_h("Fields", 3) 808 f:write_h("Fields", 3)
810 809
811 local arr = {} 810 local arr = {}
812 for fl in tp:enum_fields_get() do 811 for i, fl in ipairs(tp:enum_fields_get()) do
813 local buf = writer.Buffer() 812 local buf = writer.Buffer()
814 buf:write_b(fl:name_get()) 813 buf:write_b(fl:name_get())
815 buf:write_raw(" - ", dtree.Doc(fl:documentation_get()):full_get()) 814 buf:write_raw(" - ", dtree.Doc(fl:documentation_get()):full_get())
@@ -833,15 +832,15 @@ local build_variable = function(v, constant)
833end 832end
834 833
835local build_typedecls = function() 834local build_typedecls = function()
836 for tp in eolian.typedecl_all_aliases_get() do 835 for i, tp in ipairs(dtree.Typedecl.all_aliases_get()) do
837 build_alias(tp) 836 build_alias(tp)
838 end 837 end
839 838
840 for tp in eolian.typedecl_all_structs_get() do 839 for i, tp in ipairs(dtree.Typedecl.all_structs_get()) do
841 build_struct(tp) 840 build_struct(tp)
842 end 841 end
843 842
844 for tp in eolian.typedecl_all_enums_get() do 843 for i, tp in ipairs(dtree.Typedecl.all_enums_get()) do
845 build_enum(tp) 844 build_enum(tp)
846 end 845 end
847end 846end