Comments (4)
It's indeed possible to get the output you want - look at how the [opt] and [optchain] options are used in this example:
--- options.lua
-- optional arguments
module 'options'
--- Function with an optional arg.
-- @param a
-- @param[opt] b
function fun(a, b, c)
end
--- Function with two optional args.
-- This returns one of our own types
-- @param a
-- @param[opt] b
-- @param[optchain] c
-- @return @{mytype}
function fun(a, b, c)
end
--- a custom table
-- @field x
-- @field y
-- @table mytype
The difference between opt and optchain is that you then get (a,[ b [,c]])
instead of (a[,b\[,c])
.
That also has a reference to a table in the same module - it becomes a link. Of course, you can make a link to a type or function in another module and then things get interesting!
As for param[opt], I am not entirely satisfied with this syntax. It feels a little hard on the fingers and the eyes!
from ldoc.
I just tried, and it worked flawlessly. Thanks!
I missed that feature, as I just went through the md file (docs/md), and the param[opt] feature isn't described there. Maybe it should incuded ?
Anyway, it remains a last point. Something in the output is odd, to me.
--- Function with an optional arg.
-- @param a
-- @param[opt] b
-- @param c
function fun(a, b, c)
end
Will produce this (html)
fun (a[, b], c)
which seems perfect, but it wouldn't it be a bit more clean to have a space character right before the "[" character ?
fun (a [, b], c)
That's the exact way how functions are described in the all Lua Reference Manuals, and it looks really nice, this way.
from ldoc.
Yes, let me document this feature now before I forget.
I agree with you that there should be a space there; it becomes more readable!
from ldoc.
This seems to have been addressed already.
from ldoc.
Related Issues (20)
- Part after dot is ignored HOT 2
- How to add description of example script HOT 1
- @type changes behavior when used in @submodule HOT 5
- LuaRocks module: broken link to project homepage HOT 2
- How to use @script tag? HOT 2
- Filename case issues for cross-platform document generation HOT 5
- --fatalwarnings returns 0 exit code with invalid Markdown references
- Error message on invalid tag somewhat obtuse and doesn't point out the issue being the undefined tag HOT 10
- LDoc breaks when loading config file. HOT 2
- [Meta] Is this repo dead? HOT 2
- How do I ignore certain files/directories? HOT 2
- `hxx` extension support HOT 2
- multiple raise statements cause error HOT 6
- Support nested subparams HOT 2
- Question: is there a way to generate document from lua-language-server type annotations?
- Add LuaCATS as alternative tag handling scheme HOT 4
- document nested tables? HOT 2
- Non user friendly error message
- Feature: Run ldoc on a single target file with same behavior as targeting a directory HOT 3
- Feature: Only update docs for modified files HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ldoc.