Codebase list lua-ldoc / 955802e
Issue #93: can define fields/properties of objects; the 'readonly' modifier is now special. See tests/styles/type.lua steve donovan 10 years ago
4 changed file(s) with 56 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
287287 -- add the item to the module's item list
288288 if this_mod then
289289 -- new-style modules will have qualified names like 'mod.foo'
290 if item.name == nil then
291 self:error("item's name is nil")
292 end
290293 local mod,fname = split_dotted_name(item.name)
291294 -- warning for inferred unqualified names in new style modules
292295 -- (retired until we handle methods like Set:unset() properly)
420423
421424 function Item:trailing_warning (kind,tag,rest)
422425 if type(rest)=='string' and #rest > 0 then
423 Item.warning(self,kind.." tag: '"..tag..'" has trailing text; use not_luadoc=true if you want description to continue between tags\n'..rest)
426 Item.warning(self,kind.." tag: '"..tag..'" has trailing text ; use not_luadoc=true if you want description to continue between tags\n"'..rest..'"')
424427 end
425428 end
426429
824827 return opt
825828 end
826829
830 function Item:readonly(p)
831 local m = self:param_modifiers(p)
832 if not m then return nil end
833 return m.readonly
834 end
835
827836 function Item:subparam(p)
828837 local subp = rawget(self.subparams,p)
829838 if subp then
154154 $(M(ldoc.descript(item),item))
155155
156156 # if show_parms and item.params and #item.params > 0 then
157 <h3>$(module.kinds:type_of(item).subnames):</h3>
157 # local subnames = module.kinds:type_of(item).subnames
158 # if subnames then
159 <h3>$(subnames):</h3>
160 # end
158161 <ul>
159162 # for parm in iter(item.params) do
160163 # local param,sublist = item:subparam(parm)
171174 $(M(item.params[p],item))
172175 # if def then
173176 (<em>default</em> $(def))
177 # end
178 # if item:readonly(p) then
179 <em>readonly</em>
174180 # end
175181 </li>
176182 # end
363363 if is_local or tags['local'] then
364364 tags:add('local',true)
365365 end
366 -- support for standalone fields/properties of classes/modules
367 if (tags.field or tags.param) and not tags.class then
368 -- the hack is to take a subfield and pull out its name,
369 -- (see Tag:add above) but let the subfield itself go through
370 -- with any modifiers.
371 local fp = tags.field or tags.param
372 if type(fp) == 'table' then fp = fp[1] end
373 fp = tools.extract_identifier(fp)
374 tags:add('name',fp)
375 tags:add('class','field')
376 end
366377 if tags.name then
367378 current_item = F:new_item(tags,line)
368379 current_item.inferred = item_follows ~= nil
0 -----
1 -- module containing a class
2 -- @module type
3
4 ----
5 -- Our class.
6 -- @type Bonzo
7
8 ----
9 -- make a new Bonzo
10 -- @string s name of Bonzo
11 function Bonzo.new(s)
12 end
13
14 -----
15 -- get a string representation.
16 function Bonzo.__tostring()
17 end
18
19 ----
20 -- A subtable with fields.
21 -- @table Details
22 -- @string[readonly] name
23 -- @int[readonly] age
24
25 ---
26 -- This is a simple field/property of the class.
27 -- @string[opt="Bilbo",readonly] frodo direct access to text