Jsdoc array with more than one different thing in array - jsdoc

I want to do jsdoc with something like the following
/**
#param {string|number[]}
*/
In the above it's an array of numbers or a string, but I want an array of numbers and/or strings. I need this to work for other things like 2 different kinds of objects. Does anyone know how to do this?

If you are using Closure Compiler, you can write:
/** #param {!Array<number|string>} x */
function f(x) {}
See this example.

Related

Is is possible to reference function's parameter in the documention text?

I woul like to reference method's parameters in the documentation text,
but have no idea how to do it.
In .NET world we use tag paramref
Just as an example:
/** Send email with the specified #paramref body to the addesses given in #paramref to.
#param body Just a plain text or teamplate-aware text.*/
def SendEmail(body: EmailBody, to: EmailAddress*) = ???
How is it done in Scala?
You can make reference in Scaladoc similarly to Javadoc. According to the documentation for javadocs:
{#code foo}
and
<code>foo</code>
But XML looks ugly and not readable, prefer to use {#code foo} instead.
I think you should find everything you need in https://docs.scala-lang.org/style/scaladoc.html. Do a string search for "param name".

Doxygen - parameterless functions

I have several functions that do not have a parameter or a return.
When I do something like this:
/*!
* #fn
*
* #brief ...
*
* #param None.
*
* #return None.
*/
I will get warnings about not knowing what parameter 'None.' is, and the resulting HTML documentation will highlight 'None.' as if it were a literal parameter name.
I would like to be able to explicitly say that I do not have parameters, without leaving the section blank/nonexistent.
How can I specify in the prolog (or the doxygen settings) to generate the Parameters section and use a message instead of specifying a literal parameter?
#param[in,out] is usually reserved to define the input parameters.
As you don't have any, explain this in the detailed description or using the \remark command.

Inline Documentation displays 'Cannot find macro' for List.head()

Inline Documentation (use Ctrl+Q to open it's pop-up) in IntelliJ IDEA (2016.3.4) is having problems when JavaDoc contains variables, like:
/** Selects the first element of this $coll.
* $orderDependent
* #return the first element of this $coll.
* #throws NoSuchElementException if the $coll is empty.
*/
Instead of parsing these variables it displays: [Cannot find macro: $coll.]. Scala API parses it correctly and changes $coll into iterable collection.
Is there a way to fix this issue in IntelliJ IDEA?
It's a known bug in IntelliJ IDEA Scala plug-in:
SCL-9720 Documentation view unreadable when #define placeholders are used

Equivalent of R's str in Matlab? [duplicate]

I'd like to be able to view the structure of objects in Matlab/GNU Octave the same way as I do in R (using the str() function). Is there a function that does this? An example task would be returning nr rows and cols in matrix, but also all the arguments for a given function.
I'm aware that I could use both size() and help() (but not for function files) separately to get this information.
There are several useful functions for displaying some information about Matlab objects (I can't say anything about Octave compatibility), but I'm not sure they'll provide the same detail as R's str(). You can display all of the methods of a class with the methods function, e.g.:
methods('MException')
which returns
Methods for class MException:
addCause getReport ne throw
eq isequal rethrow throwAsCaller
Static methods:
last
The what function will return similar results. Or methods can be used on an object of a given class:
ME = MException('Test:test','Testing');
methods(ME)
Similarly, you can view the properties with properties and the events with events.

Eclipse JSDT - declaring the type of a function argument

Using Eclipse Helios:
If I define a simple Javascript function
/**
* #returns {Number}
* #param {String} arg
*/
function test(arg)
{
return 1;
}
the tags were those automatically added by Alt-Shift0J - then the inferred type for the function is:
Number test(any arg)
Parameters:
{String} arg
#returns
{Number}
Note the "any arg", despite also Eclipse also recognising the parameter is "{String} arg" later.
Nothing I've tried get the inferred type of the arg to be anything other than "any". This means calling the function with a non-String isn't detected, which is a pity.
So, is this a bug? Not supposed to work? Something I'm doing wrong?
Actually the JsDoc annotations in JSDT/Eclipse are meant for primarily two reasons(as per my comprehension, do correct me if its not the same)
For generation of documentation and
To let eclipse-JSDT-engine help the developer with auto suggest(case-specific).
so the eclipse-developers are not just cross-checking the annotation bindings with your actual code implementation until you run the js file. And again, while you run the javascript. at run time the the javadoc annotations are overlooked as mere comments.