goodbyte

Sublime Text autocomplete

Recommended Posts

I've used the SublimeCodeIntel package as the base. To extract all the keys and function names from Overwolf, I've used the following code:

function find(obj) {
	var result = '';
	for (var k in obj) {
		switch (typeof obj[k]) {
			case 'object':
				result += '<variable name="' + k + '">' + find(obj[k]) + '</variable>';
				break;
			case 'function':
				result += '<scope ilk="function" name="' + k +  '"></scope>\n';
				break;
		}
	}
	return result;
}

console.log('<scope classrefs="Object" ilk="class" name="overwolf">' + find(overwolf) + '</scope>');

then I've appended the result to %appdata%\Sublime Text 3\Packages\SublimeCodeIntel\libs\codeintel2\stdlibs\javascript.cix and voila. I've attached the file in case someone wants to use it.
There's still work to do, like adding all the respective parameters to every function, but it's a tedious manual work, and really difficult to maintain in the long run.

javascript.cix

Edited by goodbyte

Share this post


Link to post
Share on other sites

Im generally using a jetbrains IDE for projects but like to resort to sublime for small changes / snippets.

Since im starting to work more with typescript im starting to update the TS definitions from danpantry

I guess sublime has some plugins to work with TS definition files, so feel free to use the d.ts or to contribute.

Not sure when im going to start restructuring, but will definetly update lots of stuff as I go with migrating my app to angular2 / Typescript

Share this post


Link to post
Share on other sites
On 9/15/2016 at 11:13 PM, goodbyte said:

Does anyone here develop in sublime text? I was messing around the other day, trying to make an autocomplete function to work with overwolf, this is what I have so far.
First I've downloaded the SublimeCodeIntel package, then I executed the following piece of code in the Overwolf's chrome console ( to obtain all the respective objects and functions without any typing error ).


function find(obj) {
	var result = '';
	for (var k in obj) {
		switch (typeof obj[k]) {
			case 'object':
				result += '<variable name="' + k + '">' + find(obj[k]) + '</variable>';
				break;
			case 'function':
				result += '<scope ilk="function" name="' + k +  '"></scope>\n';
				break;
		}
	}
	return result;
}

console.log('<scope classrefs="Object" ilk="class" name="overwolf">' + find(overwolf) + '</scope>');

Then appended the result to %appdata%\Sublime Text 3\Packages\SublimeCodeIntel\libs\codeintel2\stdlibs\javascript.cix and voila. I've attached the file if someone wants to use it.
There is still work to do, like adding all the respective parameters to every function, but is a tedious manual work, and really difficult to maintain in the long run.

javascript.cix

Have you considered a similar approach against the overwolf documentation pages? You would then be able to extract the parameters for the functions.

 

For example:

<section id="changevolume" class="api-endpoint api-method">
	<h3 title="overwolf.streaming.changeVolume()"><a href="#changevolume">changeVolume(streamId, audioOptions, callback)</a></h3>
		<div class="description">
		<p>Changes the volume of the stream.</p>
	</div>
		<ul class="arguments">
				<li>
			<h4>
				Parameter:
				streamId				<span class="type">&lt;int&gt;</span>							</h4>
			The id of the stream on which the volume is changed.		</li>
				<li>
			<h4>
				Parameter:
				audioOptions				<span class="type">&lt;<a href="http://developers.overwolf.com/documentation/sdk/overwolf/streaming/streamsettings/streamparams/streamaudiooptions/">StreamAudioOptions</a>&gt;</span>							</h4>
			The new volumes encapsulated in an object.		</li>
				<li>
			<h4>
				Parameter:
				callback				<span class="type">&lt;function&gt;</span>							</h4>
			A function that will be called with success or error status.		</li>
			</ul>
		</section>

 

from the <a> content you could probably get all you need, and maybe even use the ul items as a tool tip somehow?

 

Edited by rads17

Share this post


Link to post
Share on other sites

I have, but the documentation it's incomplete, poorly maintained, and prone to have typing errors.

You would need to extract the data from both sources ( web and Overwolf ), compare them and merge them, with an admin panel to tell you what functions have being added, removed, aren't documented, etc. That's the only way it could work...

Share this post


Link to post
Share on other sites
39 minutes ago, goodbyte said:

I have, but the documentation it's incomplete, poorly maintained, and prone to have typing errors.

You would need to extract the data from both sources ( web and Overwolf ), compare them and merge them, with an admin panel to tell you what functions have being added, removed, aren't documented, etc. That's the only way it could work...


thelexoplexx [3:40 PM]  
I need to convert the entire Overwolf Docs into a JSON-File, any ideas? Or what base do you use, is it accessible, can I have it?

itay [4:03 PM]  
@thelexoplexx: I can help you with that, ping me on Sunday

 

my suggestion would be to also ping him haha.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now