Google Sheets not showing custom function in autocomplete - autocomplete

I can't get the google sheets autocomplete to show my custom function even when I use Google's version (see below). I have the jsdoc info correctly formatted, but it still doesn't show up. I'm sure I'm just overlooking something stupid, but I can't find it. So what am I missing?
Google's demo code:
/**
* Multiplies the input value by 2.
*
* #param {number} input The value to multiply.
* #customfunction
*/
function double(input) {
return input * 2;
}
BTW, I'm using Chrome to develop my custom functions. Also, my function works, just no autocomplete. All the built-in functions autocomplete works.
Thanks in advance for the help!
Brad

I managed to get the custom function autocomplete working yesterday. It seems to only work with container-bound scripts, so any JSDoc info inside a script being used as a library will not come across. To verify it works, I did the following:
Create new Google Sheet
Open Script Editor
Enter the following in the script:
/**
* Returns amount multiplied by itself.
*
* #param {Number} amount The amount to be multiplied by itself.
* #return {Number} The amount multiplied by itself.
* #customfunction
*/
function test(amount) {
return amount*amount;
}
Then, when entering =test into a cell in the spreadsheet, the information above the function appears in the autocomplete hint, like any other built-in spreadsheet function.

Related

how vscode active provideInlineCompletionItems by user explicitly triggers

In vscode api, we can use provideInlineCompletionItems to implemetn inline completions whenever the user stopped typing. but how can i implement user explicitly triggers?
export interface InlineCompletionItemProvider {
/**
* Provides inline completion items for the given position and document.
* **If inline completions are enabled, this method will be called whenever the user stopped typing.**
* **It will also be called when the user explicitly triggers inline completions **or explicitly asks for the next or previous inline completion.
* In that case, all available inline completions should be returned.
* `context.triggerKind` can be used to distinguish between these scenarios.
*
* #param document The document inline completions are requested for.
* #param position The position inline completions are requested for.
* #param context A context object with additional information.
* #param token A cancellation token.
* #return An array of completion items or a thenable that resolves to an array of completion items.
*/
provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionList | InlineCompletionItem[]>;
}
i dont know how to achieve this.

In JSDoc, is there a way to define terms in a separate file and link them within function docs?

What I would like is to write something like this:
/**
* Takes a foo and {#link grokelates} it.
*/
function doSomething(foo) {
}
And have "grokelates" be a link to more detail on what "grokelate" means, but because I'm going to have functions dealing with grokelation all over my code base, I'd like to write that definition once and link to it in multiple places.
Is this possible?
To be clear, grokelates is not a function. It's just a word I want to define, but not have to define in-line everywhere I use it. I basically want to write a glossary file and be able to link to definitions from that glossary in my JSDoc.
Ideally this would also be in a way the VS Code picks it up and lets someone navigate to that definition on hover.
Yes there is. When you run jsdoc to generate your documentation, you can pass it any filetype you wish. A standard practice is to create one or more *.jsdoc files which contain doclet comments (those that begin with /**) to describe features you expect to use elsewhere in your code. For instance:
// filename: grokelation.jsdoc
/**
* #module grokelates
*/
/**
* #name Grokelate
* #memberof module:grokelates
* #description
* Here is the description of the grokelation process.
*
* #example
* var g = new Grokelate(opts);
*/
Then, when you wish to reference this new object elsewhere in your documentation, simply use its long name module:grokelates~Grokelate where you can consider the ~ glyph to mean "member of".
In your example above, you'd say {#link module:grokelates~Grokelate}.

How to get Script Parameters ( SuiteScript 2.0) using VS Code?

I would like to know if there is any way to get all the scripts parameters when you create a new script (SuiteScript 2.0) using VS Code.
I'm aware that it is possible when using Eclipse IDE but I do really would like to keep using VS Code as I'm already using for Python and JavaScript.
This is what I'm looking for:
/**
* Function definition to be triggered before record is loaded.
*
* Task #5060 : calculate PO Spent Amount and Balance in realtime
*
* #param {Object} scriptContext
* #param {Record} scriptContext.newRecord - New record
* #param {Record} scriptContext.oldRecord - Old record
* #param {string} scriptContext.type - Trigger type
* #Since 2015.2
*/
BTW, I'm already using VS Code Intelisense and NetSuite Uploader extensions.
Thanks
At the time of writing, there are no official plugins from Netsuite for VS Code, only Eclipse & Webstorm are available. However, there is an unofficial plugin from Head-in-the-Cloud that might do what you're after.

VSCode JSDoc Multiline for Intellisense

I am looking to have JSON examples in my documentation, which in turn will have JSON examples in my intellisense for VScode.
I have tried every trick in the book that I can think of, is this possible to do with line breaks and things that would make the JSON readable? I cannot get this to work in VScode no matter what I do, it takes out white space and makes one line.
I try to do:
/**
* {
* "JSONData":"not going to format like this"
* }
*/
functionToDescribe()
this of course will end up in intellisense like so...
{ "JSONData":"not going to format like this" }
This is ok with small examples, but I would like to have a bit larger (still small) simple examples. There are other reasons I really want line breaks, not just JSON, I just want my text to be cleaner in my comments in general.
I will also take different examples of how other people document it. I am really looking to make my JS code easier to know what to expect the function to accept, return and use in operation before using it.
EDIT:
I stumbled across this link: https://github.com/Microsoft/vscode/issues/30062
which now I understand that formatting works when you look at the declaration of the function or item, but not when you go to use it.
the following markup code works great when I hover over the function name, but when I use it like normal it is all on one line and worthless
/** This is a description
* with each line
* on it's own
*
* #example Test
* ```javascript
* let valueReturned = false;
* jest.fn(() => {
* if (!valueReturned) {
* valueReturned = true;
* return value;
* //no idea why it requires me to have so many spaces...
* }
* });
* ```
*/
functionTest() //When hovering over this, it looks great
functionTest( //at this point intellisense pops up and is worthless
I believe this is a bug or simply bad design, maybe I will put in a feature request, if it doesn't already exist.
I will keep this question open in case someone else has any suggestions or possible work arounds.
EDIT:
Good news, it looks like this was a bug and after searching for quite a while, it seems this was fixed just this month and will be with the September release!
https://github.com/Microsoft/vscode/issues/1920
I will close this now and leave this up for anyone else who was having troubles with this.
This was a bug for the intellisense, which has been corrected as of 4 days ago, so it should be released soon, so if you can get the "hover" to look as you want, it should translate to the intellisense when the fix drops.
https://github.com/Microsoft/vscode/issues/1920

doxygen separate interface(.h)/implemetation(.c) documentation

I'm trying to generate a doxygen document where I have two documentation instances for functions. One describes the usage(interface) of the functions that get pulled from the function header in the .h file and the other describes implementation of the function that gets pulled from the .c file. I basically want to describe the same function in two different ways based on where the file that the description came from(.h or .c). I thought this would help the usability of the document since you can easily ignore the implementation details if you only care about how to use the functions. My best attempt was to try to add the .h and the .c files to separate groups like this.
example.h
/**
* #defgroup exampleInterface Example Interface
* #{
*/
/**
* This is the header file so I describe how to use this function
* #param arg
* #returns something
*/
int someFunction(int arg);
/**
* #}
*/
example .c
/**
* #defgroup exampleImpl Example Implementation
* #{
*/
/**
* This is the .c file so I describe how this function is implemented.
*/
int someFunction(int arg)
{
... Some code ...
}
/**
* #}
*/
The result was that the function header descriptions were still combined. Is there anyway to accomplish this in doxygen? Maybe there is another way I should look at this problem.
Thanks.
A possible hack you could try is to use the #internal command for the implementation which would mean you would run doxygen twice: once without the internal (for the external definitions) and the other with the inernal which would combine them.