Documenting Lua Code Like a Pro

Thanks René, here are my Sublime settings:

1.- LDoc - File

{   //create docs for the current file   "shell\_cmd": "lua ~/LDoc/ldoc.lua '$file\_path' -p '$project\_base\_name' -d '$project\_path/doc' -f 'discount' " }

2.- LDoc - Project

{   //create docs for the current project   "shell\_cmd": "lua ~/LDoc/ldoc.lua '$project\_path' -p '$project\_base\_name' -d '$project\_path/doc' -f 'discount' " }

I did a TextExpander snippet to run LDoc from Terminal easily by copying and pasting the project path and it seems to be working well, here is the output I get when I run it form Terminal, no errors so far:

lua /Users/hectorgabrielsanchezperez/Documents/CoronaSDK\ Projects/GitHub/LDoc/ldoc.lua /Users/hectorgabrielsanchezperez/Desktop/test -p hectorproject -d /Users/hectorgabrielsanchezperez/Desktop/test/docs -f discount output written to /Users/hectorgabrielsanchezperez/Desktop/test/docs

I’m sure I have a wrong setting in Sublime that doesn’t let me run it as I can from Terminal.

No big deal, I can run it fine from Terminal, it’s just that it’d be nice to run it from Sublime

Hey Hector,

I tested your build settings. At last they do build something on my machine.

In your error output I saw this

[shell\_cmd: lua ~/LDoc/ldoc.lua '' -p '' -d '/doc']

I’m not sure, but this looks like as if Sublime’s environment variables like $file_path, $file_name do not work.

Do get proper output when do something like this in the build file:

{ "shell\_cmd": "echo '$file\_path/$file\_name'" }

The file path and file name of the current active file in Sublime should be printed to console.

Best

René

hi Rene, I liked a lot LDoc from what I saw in the CoronaGeek show, and I tried to install it but I’m getting this error:

I already installed Brew, luarocks and PenLight. I also put the two sublime config files in ~/Library/Application Support/Sublime Text 3/Packages/User/LDoc

I wonder what I could be doing wrong

lua: /usr/local/share/lua/5.2/pl/dir.lua:339: attempt to index local 'p' (a nil value) stack traceback: /usr/local/share/lua/5.2/pl/dir.lua:339: in function '\_makepath' /usr/local/share/lua/5.2/pl/dir.lua:344: in function \</usr/local/share/lua/5.2/pl/dir.lua:337\> (...tail calls...) /Users/hectorgabrielsanchezperez/LDoc/ldoc/tools.lua:227: in function 'check\_directory' /Users/hectorgabrielsanchezperez/LDoc/ldoc/html.lua:324: in function 'generate\_output' /Users/hectorgabrielsanchezperez/LDoc/ldoc.lua:830: in main chunk [C]: in ? [Finished in 0.0s with exit code 1] [shell\_cmd: lua ~/LDoc/ldoc.lua '' -p '' -d '/doc'] [dir: /Users/hectorgabrielsanchezperez/Desktop/test] [path: /usr/bin:/bin:/usr/sbin:/sbin]

I was able to make LDoc work from Terminal, so most likely the problem is in the Sublime Text setup, let me keep digging into this

Hi Hector,

did you manage to make it run from Sublime?

Otherwise you can post your Sublime settings code here, I can check if the code runs in my set up.

Best

René

Thanks René, here are my Sublime settings:

1.- LDoc - File

{ &nbsp; //create docs for the current file &nbsp; "shell\_cmd": "lua ~/LDoc/ldoc.lua '$file\_path' -p '$project\_base\_name' -d '$project\_path/doc' -f 'discount' " }

2.- LDoc - Project

{ &nbsp; //create docs for the current project &nbsp; "shell\_cmd": "lua ~/LDoc/ldoc.lua '$project\_path' -p '$project\_base\_name' -d '$project\_path/doc' -f 'discount' " }

I did a TextExpander snippet to run LDoc from Terminal easily by copying and pasting the project path and it seems to be working well, here is the output I get when I run it form Terminal, no errors so far:

lua /Users/hectorgabrielsanchezperez/Documents/CoronaSDK\ Projects/GitHub/LDoc/ldoc.lua /Users/hectorgabrielsanchezperez/Desktop/test -p hectorproject -d /Users/hectorgabrielsanchezperez/Desktop/test/docs -f discount output written to /Users/hectorgabrielsanchezperez/Desktop/test/docs

I’m sure I have a wrong setting in Sublime that doesn’t let me run it as I can from Terminal.

No big deal, I can run it fine from Terminal, it’s just that it’d be nice to run it from Sublime

Hey Hector,

I tested your build settings. At last they do build something on my machine.

In your error output I saw this

[shell\_cmd: lua ~/LDoc/ldoc.lua '' -p '' -d '/doc']

I’m not sure, but this looks like as if Sublime’s environment variables like $file_path, $file_name do not work.

Do get proper output when do something like this in the build file:

{ "shell\_cmd": "echo '$file\_path/$file\_name'" }

The file path and file name of the current active file in Sublime should be printed to console.

Best

René