Skip to content

Conversation

@numToStr
Copy link
Owner

@numToStr numToStr commented Oct 21, 2022

If this flag is provided, then ? (optional) will expand to nil|type. As ? is only allowed for ---@field and ---@param, thus this will only affect the vimdoc rendering of classes and functions.

local M = {}

---@class HelloWorld
---@field message? string First message to the world
---@field private opts? table
---@field secret table Sauce

---Prints given value
---@param message string
---@param opts? table
function M.echo(message, opts)
    return print(message)
end

return M
  • Without --expand-opt
HelloWorld                                                          *HelloWorld*

    Fields: ~
        {message?}  (string)  First message to the world
        {secret}    (table)   Sauce


M.echo({message}, {opts?})                                              *M.echo*
    Prints given value

    Parameters: ~
        {message}  (string)
        {opts?}    (table)
  • With --expand-opt (notice the nil)
HelloWorld                                                          *HelloWorld*

    Fields: ~
        {message}  (nil|string)  First message to the world
        {secret}   (table)       Sauce


M.echo({message}, {opts?})                                              *M.echo*
    Prints given value

    Parameters: ~
        {message}  (string)
        {opts}     (nil|table)

Resolves #44

@numToStr numToStr linked an issue Oct 21, 2022 that may be closed by this pull request
If this flag is provided, then `?` (optional) will expand to `nil|type`.
As `?` is only allowed for `---@field` and `---@param`, thus this will
only affect the vimdoc rendering of classes and functions.
@numToStr numToStr merged commit 3bd37b5 into master Oct 25, 2022
@numToStr numToStr deleted the expand-nil branch October 25, 2022 14:24
numToStr added a commit that referenced this pull request Oct 27, 2022
Also fixed a bug that slipped through in #56 :p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand ? to nil in vimdoc

2 participants