Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --expand-opt flag #56

Merged
merged 1 commit into from
Oct 25, 2022
Merged

feat: add --expand-opt flag #56

merged 1 commit into from
Oct 25, 2022

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
1 participant