Auto-Generate Visual Studio VsDoc for JavaScript library -



Auto-Generate Visual Studio VsDoc for JavaScript library -

i'm in process of refactoring javascript library utilize single namespace. have ~200 modules, registered jquery plugins or on global object (bad). in past dispensation, intellisense working, added module references each module (from wanted intellisense)

/// <reference path="" />

to top of every module file.

everything previous dispensation flawed, fragile , inelegant.

i hope prepare in new dispensation. 1 of primary goals of refactoring create easy new developers started working in library, , intellisense of great benefit.

currently, i'm concatenating of *.js files single namespace-vsdoc.js file. every method of every class documented using vsdoc syntax. every module uses that, single vsdoc reference. works ok, it's clumsy. intellisense works 300% improve before, it's still not accurate enough. misses lots of xml documentation , doesn't recurse methods/classes homecoming complicated objects.

yui doc offers way build documentation jsdoc syntax, doesn't help intellisense. deep soul-googling has failed reveal 3rd party solutions.

are there tools generate vsdocs in more intellisense-intelligent way?

update:

after extensive thought, testing , incremental refactorings, have basic namespace looks jsfiddle.

this enables me write loosely couple modules in self-executing functions, register desired methods on namespace. of modules begin with:

/// <reference path="~/js/namespace-vsdoc.js" />

i generate vsdoc simple perl script, i've attached vs 2010 build event:

use strict; $dir = $argv[0]; $destfile = "$dir\\js\\namespace-vsdoc.js"; unlink($destfile); $js = ""; $js .= extractfile("$dir\\js\\_first-vsdoc.js"); $js .= extractfile("$dir\\js\\namespace.js"); $js .= extract("$dir\\js\\modules"); #add additional directories needed $js .= extractfile("$dir\\js\\_last-vsdoc.js"); open(vsdoc, "> $destfile") or die("cannot open vsdoc file: $destfile ; $!"); print vsdoc $js; close(vsdoc); sub extract { $ret = ""; $path = $_[0]; opendir(jsdir, $path) or die("cannot open js directory: $path ; $!"); while((my $filename = readdir(jsdir))) { if($filename =~ /.*\.js$/ && $filename !~ /-vsdoc/ && $filename !~ /_first/ && $filename !~ /_last/ && $filename !~ /.min\.js/) { $ret .= extractfile("$path\\$filename"); } } closedir(jsdir); homecoming $ret; } sub extractfile { $ret = ""; $filename = $_[0]; open(jsfile, "$filename") or die("cannot open js file: $filename ; $!"); while((my $line = <jsfile>)) { if($line !~ m/-vsdoc\.js/ ) { $ret .= $line; } } close(jsfile); homecoming $ret; } printf("finished generating namespace vsdoc.\n");

the _first-vsdoc.js , _last-vsdoc.js files wrap entire contents in self-executing function. pass resulting vsdoc closure compiler, yui compressor , uglify needed/appropriate.

this process works much improve before, still not without flaws.

starting scratch, in newmodule.js references namespace-vsdoc.js, proper intellisense:

ns.register() //visible ns.controls.register() //visible ns.actions.register() //visible

however, when define newmodule.js (and compile):

(function _alertclosure() { ns.register('alert', function alert(sometext) { ///insert proper vsdoc style comment }); }());

i not proper intellisense for:

ns.alert() //no intellisense help

which perplexing, because works on sub-namespaces. i'm forced this:

ns.alert = ns.alert || ns.register('alert', function ....

compile, , (obviously) intellisense works expected.

intellisense works chained methods using jquery's vsdoc (which have studied closely in constructing process) , jquery doesn't resort y.x = y.x || new x() trickery create happen.

so here revised question: structural standpoint, discernible difference can perceive between jquery's vsdoc , own jquery assembles entire namespace within same closure. namespace , each of modules wrapped in individual closures. in comparison, vsdoc looks long string of self-executing functions.

there much risk associated forgoing closure/module pattern; , it's hard test hypothesis in isolation. intellisense works when library little , hence unable generate thousands of "javascript intellisense message: c:\\js\namespace-vsdoc.js(40:16) : object required" errors.

ideas?

i agree @ilya volodin. resharper great tool visual studio. utilize month , can not without.

this not reply question useful you.

here summary can found on official website:

"resharper renowned productivité tool makes microsoft visual studio ide much better. thousands of. net developers worldwide wonder how 've ever lived without resharper's code inspections, automated refactorings, blazing fast shipping, , coding assistance."

javascript visual-studio documentation intellisense vsdoc

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -