NS2Docs
Onos Ate Me
Join Date: 2010-12-31 Member: 76072Members, NS2 Playtester, Squad Five Blue
<div class="IPBDescription">Documentation generator</div>Ns2Docs analyzes the lua code for Natural Selection 2 and produces code documentation similar to that of JavaDocs or LuaDoc
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://ns2docs.bplaced.net/" target="_blank">Generated Docs</a><!--sizec--></span><!--/sizec-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="http://dl.dropbox.com/u/53107776/ns2docs/Ns2Docs.zip" target="_blank">Download Ns2Docs</a><!--sizec--></span><!--/sizec-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="https://github.com/DamienHauta/Ns2Docs" target="_blank">GitHub</a><!--sizec--></span><!--/sizec-->
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo-->System Requirements<!--sizec--></span><!--/sizec-->
<a href="http://www.microsoft.com/en-us/download/details.aspx?id=17851" target="_blank">Microsoft .NET Framework 4</a>
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo-->Usage<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe [-generator generator name] [-out output path] [source directories]<!--c2--></div><!--ec2-->
If no source directories are supplied, Ns2Docs will try to automatically find the Natural Selection installation directory by searching the registry.
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo-->Sample Usage<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -generator Json -out "C:\Natural Selection 2\docs.json" "C:\Program Files (x86)\Steam\steamapps\common\natural selection 2" "c:\My Mod"<!--c2--></div><!--ec2-->
This will parse any files with names ending in .lua that are found in either <i>C:\Program Files (x86)\Steam\steamapps\common\natural selection 2</i> or <i>c:\My Mod</i>. The output will be a Json file that will gets written to <i>C:\Natural Selection 2\docs.json</i>.
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Generating Static Html Files<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe<!--c2--></div><!--ec2-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Changing The Output Folder<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -out "C:\Natural Selection 2\docs"<!--c2--></div><!--ec2-->
The static html files will be written to <i>C:\Natural Selection 2\docs</i> instead of the default <i>ns2docs</i>.
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Generating Json Files<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -generator Json<!--c2--></div><!--ec2-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Changing The Output File<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -out "C:\Natural Selection 2\docs.json"<!--c2--></div><!--ec2-->
The Json file will be written to <i>C:\Natural Selection 2\docs.json</i> instead of <i>out.json</i>.
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Using Multiple Source Directories<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe "C:\Program Files (x86)\Steam\steamapps\common\natural selection 2" "c:\My Mod"<!--c2--></div><!--ec2-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="http://dl.dropbox.com/u/53107776/ns2docs/Ns2Docs.zip" target="_blank">Download Ns2Docs</a><!--sizec--></span><!--/sizec-->
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://ns2docs.bplaced.net/" target="_blank">Generated Docs</a><!--sizec--></span><!--/sizec-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="http://dl.dropbox.com/u/53107776/ns2docs/Ns2Docs.zip" target="_blank">Download Ns2Docs</a><!--sizec--></span><!--/sizec-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="https://github.com/DamienHauta/Ns2Docs" target="_blank">GitHub</a><!--sizec--></span><!--/sizec-->
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo-->System Requirements<!--sizec--></span><!--/sizec-->
<a href="http://www.microsoft.com/en-us/download/details.aspx?id=17851" target="_blank">Microsoft .NET Framework 4</a>
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo-->Usage<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe [-generator generator name] [-out output path] [source directories]<!--c2--></div><!--ec2-->
If no source directories are supplied, Ns2Docs will try to automatically find the Natural Selection installation directory by searching the registry.
<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo-->Sample Usage<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -generator Json -out "C:\Natural Selection 2\docs.json" "C:\Program Files (x86)\Steam\steamapps\common\natural selection 2" "c:\My Mod"<!--c2--></div><!--ec2-->
This will parse any files with names ending in .lua that are found in either <i>C:\Program Files (x86)\Steam\steamapps\common\natural selection 2</i> or <i>c:\My Mod</i>. The output will be a Json file that will gets written to <i>C:\Natural Selection 2\docs.json</i>.
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Generating Static Html Files<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe<!--c2--></div><!--ec2-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Changing The Output Folder<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -out "C:\Natural Selection 2\docs"<!--c2--></div><!--ec2-->
The static html files will be written to <i>C:\Natural Selection 2\docs</i> instead of the default <i>ns2docs</i>.
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Generating Json Files<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -generator Json<!--c2--></div><!--ec2-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Changing The Output File<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe -out "C:\Natural Selection 2\docs.json"<!--c2--></div><!--ec2-->
The Json file will be written to <i>C:\Natural Selection 2\docs.json</i> instead of <i>out.json</i>.
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Using Multiple Source Directories<!--sizec--></span><!--/sizec-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Ns2Docs-Console.exe "C:\Program Files (x86)\Steam\steamapps\common\natural selection 2" "c:\My Mod"<!--c2--></div><!--ec2-->
<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="http://dl.dropbox.com/u/53107776/ns2docs/Ns2Docs.zip" target="_blank">Download Ns2Docs</a><!--sizec--></span><!--/sizec-->
Comments
<!--QuoteBegin-'Harimau'+--><div class='quotetop'>QUOTE ('Harimau')</div><div class='quotemain'><!--QuoteEBegin-->Very nice. Just had a look through your website; if you look at Global Variables for instance, at ns2/lua/AlienStructureEffects.lua - the code isn't displaying properly. Could just be my browser though (IE7). Edit: Works fine in firefox. Seems like part of the code is missing though.<!--QuoteEnd--></div><!--QuoteEEnd-->
It appears to only display a maximum of around 10 lines of the definition, probably to maintain readability of the document. Just follow the "ns2/lua/AlienStructureEffects.lua:#"-link for a complete definition.
update: nvm, had js disabled - great program!
The Demo was a great help and I hope to continue using this invaluable reference, so any advice on this would be appreciated.
<a href="http://damien.kodingen.com/ns2docs/ns2docs.zip" target="_blank">Download latest version</a>
Turns out the bug was caused by the leg library raising an error while making an error message and class declarations being regarded as Lua keywords preventing code such as <i>local class = {}</i> from being parsed.
<b>Note:</b> In build 184, the file <i>ns2/Build.lua</i> has a syntax error on line 21, <i>buildProgress = "float"</i> needs to end with a comma, preventing Ns2Docs from generating the documentation. Here is the fix for that:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Build.networkVars =
{
buildType = "enum kTechType",
buildTechId = "integer",
buildLocation = "vector",
buildOrientation = "float",
buildProgress = "float",
buildCompleted = "boolean"
}<!--c2--></div><!--ec2-->
DocVariable.lua:49 attempt t index local 'assignment' (a nil value).
I'm only getting this with files I've modified and not the base NS2. I don't know how to go about finding which variable, or even which file is causing this and why.
Any theories on why or ways I can figure out where the problem is?
DocVariable.lua:49 attempt t index local 'assignment' (a nil value).
I'm only getting this with files I've modified and not the base NS2. I don't know how to go about finding which variable, or even which file is causing this and why.
Any theories on why or ways I can figure out where the problem is?<!--QuoteEnd--></div><!--QuoteEEnd-->
It seems that variable assignments are being parsed with no right hand value, I tried to replicate this problem but couldn't. I've updated ns2docs to print the file location and line number of the assignment being parsed when the assignment is <i>nil</i>. This fix will help you pin-point the problem at least.
<a href="http://damien.kodingen.com/ns2docs/ns2docs-3.zip" target="_blank">NSDocs Build 3</a>
S = {}
S.Names= {}
S.Names[0] = {}
S.Names[0]['Name'] = 'Test' <----error line
or similarly
--MessageIndex and MessageIndex[6] are both tables defined in another file....
MessageIndex[6]['energy'] = {Title = 'Energy', Text = 'Your current energy.' }
Something with the way these tables are formed is causing it to come up as nil in your new build
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->S = {}
S.Names= {}
S.Names[0] = {}
S.Names[0]['Name'] = 'Test'
MessageIndex = {}
MessageIndex[6]['energy'] = {Title = 'Energy', Text = 'Your current energy.' }<!--c2--></div><!--ec2-->
<a href="http://damien.kodingen.com/ns2docs/ns2docs-4.zip" target="_blank">Download NS2Docs Build 4</a>
Yes, we will try to work something out soon.
Done.
I've update the docs with the preview of <a href="http://damien.kodingen.com/187/tables/index.html" target="_blank">Ns2Docs build 5</a>. There are lots of changes but the big ones are:
<ul><li> complete interface overhaul to reduce redundancy</li><li> <a href="http://damien.kodingen.com/187/mixins/index.html" target="_blank">mixin support</a></li><li> bugs in displaying variables should be gone</li><li> globals are store in one file instead of across many to increase search-ability</li><li> tables have a bunch of ways to search their data</li></ul>
Works with IE9, Chrome, Firefox, Safari. I haven't checked whether IE 7 or 8 render the pages properly.
<a href="http://damien.kodingen.com/187/tables/Onos/index.html" target="_blank"><img src="http://img6.imageshack.us/img6/8047/nsdy.png" border="0" class="linked-image" /></a>
and you sir are a coding ninja.
can i have your babies.
j/k
but seriously what do you actually do for a living? make games? or make software?
Amazing, fantastic and thank you :)
Docs for <a href="http://dl.dropbox.com/u/53107776/ns2docs/electric/1/tables/index.html" target="_blank">Electric Build 1</a>
Tables have a basic search function when javascript is enabled. When I'm unsure where to find the data I'm looking for I'll either use the <i>Find in Files</i> search function in Notepad++ or use <a href="http://dl.dropbox.com/u/53107776/print.lua" target="_blank">this script</a> which will add <i>print</i> to the console commands in NS2. To use the command type <i>print TABLENAME</i> into the console (e.g. <i>print Player</i> to display all the fields for the Player class). Use <i>print TABLENAME FILTER</i> to restrict results (e.g. <i>print Player health</i> to display all fields inside Player with names containing <i>health</i>. <i>print _G</i> will display all the globals currently declared in NS2.
First off, this is really helpful to me, thanks for all your hardwork.
Secondly, how difficult would it be for you to add the option to output a UML class chart?
If it's a lot of hassle, don't worry, it's just an idea I had as I'm making my own class charts at the moment and it's taking me a while :)
<a href="http://dl.dropbox.com/u/53107776/ns2docs/Ns2Docs%20Build%201.zip" target="_blank">Download Ns2Docs</a>
<a href="http://dl.dropbox.com/u/53107776/review/210/210vs209.html" target="_blank">Contextual diff with 209</a>
<a href="http://dl.dropbox.com/u/53107776/review/210/210vs208.html" target="_blank">Contextual diff with 208</a>