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

--doc CLI argument does not work #2954

Open
rhys-vdw opened this issue Nov 14, 2024 · 8 comments
Open

--doc CLI argument does not work #2954

rhys-vdw opened this issue Nov 14, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@rhys-vdw
Copy link

How are you using the lua-language-server?

Command Line

Which OS are you using?

Windows WSL

What is the issue affecting?

Other

Expected Behaviour

Document generation, as documented here:

https://luals.github.io/wiki/usage/#--doc

Actual Behaviour

rhys@RhysDesktop:~/example-lua$ ~/lua-language-server/bin/lua-language-server --doc ~/example-lua/
root uri = file:///home/rhys/example-lua/
script/cli/doc/export.lua:304: attempt to concatenate a nil value (local 'outputDir')
stack traceback:
        script/cli/doc/export.lua:304: in field 'serializeAndExport'
        script/cli/doc/init.lua:235: in upvalue 'callback'
        script/lclient.lua:129: in function <script/lclient.lua:128>
stack traceback:
        script/lclient.lua:123: in function 'await.errorHandle'
        script/await.lua:35: in function 'await.checkResult'
        (...tail calls...)
        [C]: in function 'xpcall'
        script/timer.lua:52: in upvalue 'mWakeup'
        script/timer.lua:93: in upvalue 'onTick'
        script/timer.lua:236: in function 'timer.update'
        script/lclient.lua:139: in method 'start'
        script/cli/doc/init.lua:201: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        /home/rhys/lua-language-server/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?
script/lclient.lua:124: [19:48:24.474][error][#0:script/lclient.lua:123]: script/cli/doc/export.lua:304: attempt to concatenate a nil value (local 'outputDir')
stack traceback:
        script/cli/doc/export.lua:304: in field 'serializeAndExport'
        script/cli/doc/init.lua:235: in upvalue 'callback'
        script/lclient.lua:129: in function <script/lclient.lua:128>
stack traceback:
        script/lclient.lua:123: in function 'await.errorHandle'
        script/await.lua:35: in function 'await.checkResult'
        (...tail calls...)
        [C]: in function 'xpcall'
        script/timer.lua:52: in upvalue 'mWakeup'
        script/timer.lua:93: in upvalue 'onTick'
        script/timer.lua:236: in function 'timer.update'
        script/lclient.lua:139: in method 'start'
        script/cli/doc/init.lua:201: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        /home/rhys/lua-language-server/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?

stack traceback:
        [C]: in function 'error'
        script/lclient.lua:124: in function 'await.errorHandle'
        script/await.lua:35: in function 'await.checkResult'
        (...tail calls...)
        [C]: in function 'xpcall'
        script/timer.lua:52: in upvalue 'mWakeup'
        script/timer.lua:93: in upvalue 'onTick'
        script/timer.lua:236: in function 'timer.update'
        script/lclient.lua:139: in method 'start'
        script/cli/doc/init.lua:201: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        /home/rhys/lua-language-server/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?
/home/rhys/lua-language-server/bin/lua-language-server: script/lclient.lua:149: two hours later ...
====== C -> S ======
====== S -> C ======
====================
stack traceback:
        [C]: in function 'error'
        script/lclient.lua:149: in method 'start'
        script/cli/doc/init.lua:201: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        /home/rhys/lua-language-server/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?

Reproduction steps

  1. Create a new folder
  2. Add any documented lua file, I used this:
---@param x number
function foo(x) end
  1. Run lua-language-server --doc <path-to-folder>

Additional Notes

I tried this on both Windows and WSL with the same result.

Log File

No response

@rhys-vdw
Copy link
Author

I have discovered that this error goes away if I provide --doc_out_path! 🤦

I feel like the wiki would greatly benefit from an example!

@carsakiller carsakiller added the bug Something isn't working label Nov 14, 2024
@carsakiller
Copy link
Collaborator

I believe this is supposed to output to the log path if no --doc_out_path is provided.

@rhys-vdw
Copy link
Author

rhys-vdw commented Nov 14, 2024

I believe this is supposed to output to the log path if no --doc_out_path is provided.

Yeah, it's hard to decypher. But it fails with the same error on both windows and WSL for me.

On WSL I built from master, on Windows I downloaded latest release exe.

@tomlau10
Copy link
Contributor

I remembered there was a heavy refactor on the doc generation code, don't know if it has broken anything 🤔
related PR: #2821, the outputDir variable seems to be introduced in it

@rhys-vdw
Copy link
Author

This would benefit greatly from a default output dir, or an error log that catches that the param was not added and logs an error and example use.

@Mc-GrowlR
Copy link

Mc-GrowlR commented Nov 15, 2024

I mentioned this issue in my previous issue, and I need to provide two options:
#2927
The reason for this error is because the directory address of the --doc_out_path option is not provided in the options. However, depending on the wiki, when the option is empty, it will be exported to the log folder by default, but I don't see my exported documents in the log folder. According to the error prompt, I finally found that the outputDir variable is nil. This is inconsistent with what the documentation says is the default address of the log directory.
In addition, due to this reason, the document export function of the luals plugin of vscode is disabled, and the error message displayed in the log file is shown in this issue. Because the value of the '--doc_out_path' option is missing, the 'outputDir' variable is nil.

@rhys-vdw
Copy link
Author

I'm surprised that this file isn't using the type annotations that lua language server provides to alert the developer that the CLI arguments might be nil and force them to handle it. This all seems possible!

@Mc-GrowlR
Copy link

I'm surprised that this file isn't using the type annotations that lua language server provides to alert the developer that the CLI arguments might be nil and force them to handle it. This all seems possible!我很惊讶这个文件没有使用 lua 语言服务器提供的类型注释来提醒开发人员 CLI 参数可能为 nil 并强制他们处理它。这一切似乎都是可能的!

I looked at the source code of this file, and the error point was that the outputDir variable was concatenated with the string when the nil value was valued. I don't know when the default log folder path described in the documentation was given this parameter, perhaps the developers have their own considerations.
Also, not only that, there are also a lot of type conversion functions in the doc export function that are not commented, but I saw the doc.lua file when I first read this project, so I had a hard time reading it, and I wanted to serialize the output content, and I ended up with a burst stack.
Once again, my path to understanding has stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants