Codebase list lua-ldoc / e38a1b1
Better section naming, some hints for C code JonasT 10 years ago
1 changed file(s) with 16 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7575
7676 The first important tag to know is the module tag:
7777
78 #### The module tag, naming and describing your API module
78 #### Modules: naming and describing your API module
7979
8080 The first thing in your API module should be a name and a description.
8181 This is how a module is commonly done in Lua 5.2 with a @module tag at the top
9696
9797 This sets up a module named 'test' with the description 'a test module'.
9898
99 #### Describing functions with tags:
99 #### Functions:
100100
101101 The next thing to describe are the functions your module has.
102102 This is a simple example of a documented function:
109109 ....
110110 end
111111
112 You can also give the function name itself as an explicit tag,
113 which is especially useful when documenting a Lua api exported by C code:
114 /// A C function which is exported to Lua with another name,
115 // because the ways of C can be mysterious!
116 // @function our_nice_function
117 int _some_function_for_lua(lua_State* l) {
118 ....
119 }
120
112121 The tags basically add all the detail that cannot be derived from the source code
113122 automatically.
114123
115 #### Most common tags: param, return, tparam, treturn
124 #### Function parameters and return values
116125
117126 Common tags are the 'param' tag which takes a parameter name followed by a parameter
118127 description separated by a space, and the 'return' tag which is simply followed by
150159 ...
151160 Of course there is also the 'module' tag which you have already seen.
152161
153 #### Describing tables and constants: field, table
162 #### Tables and constant values (fields)
154163
155164 Modules can of course export tables and other values. The classic way to document a table
156165 looks like this:
196205 function my_function()
197206 ...
198207 end
208 As mentioned before, this is often especially useful in C where things
209 may look different in the C code than they will in the final Lua api which
210 you want to document.
199211
200212 ### Doing modules the Lua 5.1 way
201213