kind_names variable can override names used in sidebar, e.g. 'kind_names={topic='Manual'}' will override default of 'Topics'
Steve Donovan
10 years ago
90 | 90 | self.fieldname = 'section' |
91 | 91 | end |
92 | 92 | |
93 | ModuleMap:add_kind('function','Functions','Parameters') | |
94 | ModuleMap:add_kind('table','Tables','Fields') | |
95 | ModuleMap:add_kind('field','Fields') | |
96 | ModuleMap:add_kind('lfunction','Local Functions','Parameters') | |
97 | ModuleMap:add_kind('annotation','Issues') | |
98 | ||
99 | ||
100 | 93 | local ProjectMap = class(KindMap) |
101 | 94 | ProjectMap.project_level = true |
102 | 95 | |
105 | 98 | self.fieldname = 'type' |
106 | 99 | end |
107 | 100 | |
108 | ProjectMap:add_kind('module','Modules') | |
109 | ProjectMap:add_kind('script','Scripts') | |
110 | ProjectMap:add_kind('classmod','Classes') | |
111 | ProjectMap:add_kind('topic','Topics') | |
112 | ProjectMap:add_kind('example','Examples') | |
101 | ||
113 | 102 | |
114 | 103 | local lua, cc = lang.lua, lang.cc |
115 | 104 | |
124 | 113 | ['.mm'] = cc, |
125 | 114 | ['.moon'] = lang.moon, |
126 | 115 | } |
127 | ||
128 | 116 | ------- ldoc external API ------------ |
129 | 117 | |
130 | 118 | -- the ldoc table represents the API available in `config.ld`. |
131 | 119 | local ldoc = { charset = 'UTF-8' } |
120 | ||
121 | local kind_names | |
122 | ||
123 | local function lookup (itype,igroup,isubgroup) | |
124 | local kn = kind_names[itype] | |
125 | if kn then | |
126 | if type(kn) == 'string' then | |
127 | igroup = kn | |
128 | else | |
129 | igroup = kn[1] | |
130 | isubgroup = kn[2] | |
131 | end | |
132 | end | |
133 | return itype, igroup, isubgroup | |
134 | end | |
135 | ||
136 | local function setup_kinds () | |
137 | kind_names = ldoc.kind_names or {} | |
138 | ||
139 | ModuleMap:add_kind(lookup('function','Functions','Parameters')) | |
140 | ModuleMap:add_kind(lookup('table','Tables','Fields')) | |
141 | ModuleMap:add_kind(lookup('field','Fields')) | |
142 | ModuleMap:add_kind(lookup('lfunction','Local Functions','Parameters')) | |
143 | ModuleMap:add_kind(lookup('annotation','Issues')) | |
144 | ||
145 | ProjectMap:add_kind(lookup('module','Modules')) | |
146 | ProjectMap:add_kind(lookup('script','Scripts')) | |
147 | ProjectMap:add_kind(lookup('classmod','Classes')) | |
148 | ProjectMap:add_kind(lookup('topic','Topics')) | |
149 | ProjectMap:add_kind(lookup('example','Examples')) | |
150 | end | |
151 | ||
152 | ||
132 | 153 | local add_language_extension |
133 | 154 | -- hacky way for doc module to be passed options... |
134 | 155 | doc.ldoc = ldoc |
201 | 222 | 'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape','merge_error_groups', |
202 | 223 | 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler', |
203 | 224 | 'no_space_before_args','parse_extra','no_lua_ref','sort_modules','use_markdown_titles', |
204 | 'unqualified', 'custom_display_name_handler', | |
225 | 'unqualified', 'custom_display_name_handler', 'kind_names', | |
205 | 226 | } |
206 | 227 | ldoc_contents = tablex.makeset(ldoc_contents) |
207 | 228 | |
391 | 412 | override 'not_luadoc' |
392 | 413 | override 'module_file' |
393 | 414 | override 'boilerplate' |
415 | ||
416 | setup_kinds() | |
394 | 417 | |
395 | 418 | -- LDoc is doing plain ole C, don't want random Lua references! |
396 | 419 | if ldoc.parse_extra and ldoc.parse_extra.C then |
461 | 484 | quit ("file or directory does not exist: "..quote(args.file)) |
462 | 485 | end |
463 | 486 | |
487 | ||
464 | 488 | -- create the function that renders text (descriptions and summaries) |
465 | 489 | -- (this also will initialize the code prettifier used) |
466 | 490 | override ('format','plain') |