View Single Post
06-15-17, 06:18 AM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Okay team, the package is ready for your help.

Most work lies in the API Reference folder:

1. Pick an API from API Reference (parameterless).
2. Parameter it with arguments then move the snippet to API Reference, and delete it from API Reference (parameterless). (Would be nice to keep stuff alphabetically.)
4. If you find a function which should not be on the autocomplete list, Global Blizzard FrameXML/AddOn/GlueXML or any other Interface files, then move it to API Reference (blizzard) and delete it from API Reference (parameterless) (This file will be reviewed, saved and removed later.)
5. (If you would like to add stuff to the Widget References, just add them into the files directly. (Widget API, Widget Handlers))

How to parameter an API?

This is how a raw API will look like:
Code:
{
	"trigger": "AbbreviateLargeNumbers\t(...)",
	"contents": "AbbreviateLargeNumbers($1)$0",
},
The trigger thats triggering the autocomplete while you typing it then there is a \t in between anything after that is the description.

The contents is what the autocomplete will print out $1 is where the cursor will land first, $2 for second, $3 for third...$0 is the last cursor position.

If you want to highlight a whole words then it should looks like this: ${1:unit}, ${2:value}, \"${3:stringWithNoQuotationMark}\", ${4:\"stringWithQuotationMark\"}, ${5:[\"stringWithQuotationMarkInsideBrackets\"]}

So after we search for AbbreviateLargeNumbers in the Blizzard Interface code, we will see it accepts a single string value, and returns a formatted string. So we modify the code like this:

Code:
{
	"trigger": "AbbreviateLargeNumbers\t(\"value\")",
	"contents": "AbbreviateLargeNumbers(\"${1:value}\")$0",
},
Notes:
1. " needs to be escaped to \".
2. Tabs and new lines needs to be escaped like \t and \n.
3. Space, (, ), [, ], and , does not need escaping.

Since AbbreviateLargeNumbers has a return value that means we also want to make another snippet with _ added in front of it, which autocompletes it with the return value like this:

Code:
{
	"trigger": "_AbbreviateLargeNumbers\t(\"value\")",
	"contents": "${1:formattedValue} = AbbreviateLargeNumbers(\"${2:value}\")$0",
},
Notice that we had to change ${1:value} to: ${2:value}

It's very-very important to keep in mind if you make any typo in the .sublime-completions file than the whole file will not get loaded! Also you have to reopen Sublime sometimes after you made some changes in the completions files else you won't see the effect of the changes you made.

I plan to do 10-20 API functions per day myself. Would be nice to have some other volunteers too. The best would be if everyone could take care a whole letter of APIs, then there wouln't be any collisions.

You can fork/pull request, upload files, post here, send me a mail, send me a mail ingame, send me a pidgeon, i don't care as long as it's copyable/accessible.

Last edited by Resike : 06-15-17 at 06:29 AM.
  Reply With Quote