Codebase list lua-ldoc / e5605a4
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
1 changed file(s) with 38 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
9090 self.fieldname = 'section'
9191 end
9292
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
10093 local ProjectMap = class(KindMap)
10194 ProjectMap.project_level = true
10295
10598 self.fieldname = 'type'
10699 end
107100
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
113102
114103 local lua, cc = lang.lua, lang.cc
115104
124113 ['.mm'] = cc,
125114 ['.moon'] = lang.moon,
126115 }
127
128116 ------- ldoc external API ------------
129117
130118 -- the ldoc table represents the API available in `config.ld`.
131119 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
132153 local add_language_extension
133154 -- hacky way for doc module to be passed options...
134155 doc.ldoc = ldoc
201222 'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape','merge_error_groups',
202223 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
203224 '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',
205226 }
206227 ldoc_contents = tablex.makeset(ldoc_contents)
207228
391412 override 'not_luadoc'
392413 override 'module_file'
393414 override 'boilerplate'
415
416 setup_kinds()
394417
395418 -- LDoc is doing plain ole C, don't want random Lua references!
396419 if ldoc.parse_extra and ldoc.parse_extra.C then
461484 quit ("file or directory does not exist: "..quote(args.file))
462485 end
463486
487
464488 -- create the function that renders text (descriptions and summaries)
465489 -- (this also will initialize the code prettifier used)
466490 override ('format','plain')