I'm using angularJS and doxygen for my project.
In my angular controller, I've some functions defined like this:
function MyCtrl($scope) {
/**
* #param page String Page name
* #ingroup API
* #author Sylvain
*/
$scope.prev = function(page) {
...
}
... other functions
}
I would like that doxygen understand this code as a function declaration.
I have tried to use the #fn command, but then doxygen concatenate all angular functions comments inside the documentation of MyCtrl function without creating a new function block.
Do you have an idea?
Thanks!
Perhaps the $scope argument is confusing Doxygen. If I change the name to just "scope" and I replace "page" with "scope" in your #param comment, then Doxygen works fine. It produces a function declaration document section, with appropriate content.
Doxygen does not claim to support JavaScript, but it does work if the JavaScript does not look like PHP thanks to the $ symbol.
Maybe this link will help, too: http://blog.coherent-labs.com/2012/10/documenting-javascript-with-doxygen.html
Related
I am using WebStorm to write SuiteScript code and the netsuite N/record module (I defined the module as record). I have a function I wrote that will return a record (below is a simplified form of it)
/**
*
* #returns {record.Record} record.Record
*/
function getRecord() {
return rrecord.load({type: 'customrecordtc_login', id: recordId})
}
I am trying to use the JS doc so that it knows that this return is a Record object, i.e. if I called something like
r = getRecord()
I was hoping intelisence would know that I can use something such as
r.getText({...})
etc. But currently I can't get the JSDoc to do that.
Is that something possible and if so how?
The JSDoc that I put doesn't seem to direct it to Record object.
Is there an additional addon (I added in the suitecloud SDK plugin from NetSuite)?
Below is a screen shot of how my IDE looks in a given place and I wondered if there was a way to JSDoc to do something kind of similar with my own utils scripts (or their returns). (to add or change something so the IDE knows to treat a return from a utility function as a specific thing and let it auto complete. For example if I called x=utils.getSomeRecord(). and the IDE would be able to give tips for x. ** display .getField etc. like above screen shot)
(function(aLeftPane) { ... }) ("History").
The complete function is here: pastebin.com
I haven't been able to get my head round how the contents of the seconds set of brackets gets passed into the functions in the first set.
I want to make the hard-coded "History" into a variable. I've tried wrapping the whole thing in a more regular function, but I haven't been able to pass parameters to it successfully.
The XUL that calls the function currently looks like this: oncommand="madeUpWrapperName('history');"
(function(aLeftPane) { ... }) ("History")
Is not an unusually structured function, it's a common pattern to encapsulate code in JS. What it does is declare an anonymous function and then immediately call it. It is used very often by libraries to create the lib entry point and cleanly separate private from public code without polluting the global namespace.
In your case, you actually want to unwrap the function :
function unwrapped(aLeftPane)
{
/**
* Select left panel in Library.
*
* #param aBrowser Browser object in selected tab.
...
}
then, in your xul or somewhere else:
oncommand="unwrapped('History');"
Example:
There are several .js files with couple functions like:
/**
* TestFunction - doing something.
* #param {String} strTest Test string.
* #return {Boolean} bRes Returned value.
*/
function TestFunction(strTest) {
//code ...
return bRes;
}
After JsDuck.exe created help file - no parameters of function in function description is present, only return value bRes with description.
Version: SDuck 5.0.0.beta2 also tried on earlier version and same result.
Does anyone used JSduck for functional frameworks and got success. or are there any workaround to get this work properly?
Same .js files work correctly with JSDoc toolkit and all data is shown, but JSDuck is still preferable to make it work.
Thanks in advance for reply.
Answered your question in bug-tracker: https://github.com/senchalabs/jsduck/issues/358
A js/css template is provided to me.
It is very talented in interactive event handling, but i am not talented on js/jquery.
In its js library, there is a .js file,
and the file has some code like:
(function ($) {
...
})(jQuery);
most of thing happens in it.
There are some "little independent functions" in this upper function.
And some lines in this upper/wrapper/non-named function, call these "little-independent functions".
Also, i want to call these "little independent functions" BUT i could not find out how.
Because in the lines in "(function ($) {...})(jQuery);" those call these "little independent functions" there are some local variables.
I think some code help me to tell:
(function ($) {
if(...){
var items;
addItem(items)
}
function addItem(funcitems){}
...
})(jQuery);
My question is that, how can i call additem, how can i pass "items" into it?
I want to call it in a custom part of my page after a custom event.
Since they're not exposed in any way, it's impossible without some crazy js hacks or editing the code. If you're sure the library doesn't expose an equivalent method, then the only real solution is to edit it.
You have two options to achieve this:
1) Add your code into this anonymous function, so that your code is in the same scope like these encapsulated functions. (Not so good since you are compromising the library)
2) Make a variable assignment and add a return-statement with the functions you need: (better, since you dont mix the library code with your own and just expose a few of the functions)
var extLib = (function ($) {
...
return{
/* return the functions you need - written in object literal notation */
addItem : addItem
/*[,exposedName : internalName] */
}
})(jQuery);
Now you can access the addItem function by calling extLib.addItem(item).
I've been at this one for a while now:
I'm using both jQuery and Prototype within Redmine, a RoR webapp. They play along well thanks to jQuery's noConflict.
I've got jqGrid working fine too.
Now here's my problem: I'm trying to use the Table Filter plugin by PicNet
but I get the following js error:
this.each is not a function
# line 862 of prototype.js
function collect(iterator, context) {
iterator = iterator || Prototype.K;
var results = [];
this.each(function(value, index) {
results.push(iterator.call(context, value, index));
});
return results;
}
It's obviously calling a prototype function while it should not, but the plugin code is minimized, and actually compiled with python, so there's no un-minimized version...
I'm not very good with js to start with, and I'm stumped as to why it calls the wrong function...
P.S: I'm using
jQuery 1.4.4
Prototype 1.7
Firebug 1.8.4 for debugging
Update: found the answer myself, see below!
I found the solution in the 'closure' lib, a dependency for Table Filter:
/**
* #define {boolean} NATIVE_ARRAY_PROTOTYPES indicates whether the code should
* rely on Array.prototype functions, if available.
*
* The Array.prototype functions can be defined by external libraries like
* Prototype and setting this flag to false forces closure to use its own
* goog.array implementation.
*
* If your javascript can be loaded by a third party site and you are wary about
* relying on the prototype functions, specify
* "--define goog.NATIVE_ARRAY_PROTOTYPES=false" to the JSCompiler.
*/
So I downloaded the necessary things (python, closure compiler, ... ) and built the Table Filter code myself with this parameter set to false, and it works.
Now I've got another problem, but I should be ok. If not I'll come back here and ask!
Try wrap the plugin in:
;(function($) {
// This way you secure that $ in this local scope is referring to jQuery and not prototype.
// Original plugin goes here....
})(jQuery);