angelozerr / tern.jsduck

Tern Plugin for ExtJS, CKEditor
MIT License
9 stars 3 forks source link

tern.jsduck

Build Status

Generates Tern plugin for

from their Javascript sources by using Api Ext.json, CKEDITOR.json generated with JSDuck

What is tern plugin?

Tern is a stand-alone code-analysis engine for JavaScript. It is intended to be used with a code editor plugin (WebBrowser (CodeMirror, Ace, Orion), Vim, Emacs, Sublime, Eclipse IDE (see tern.java)) to enhance the editor's support for intelligent JavaScript editing.

Here screenshot with completion inside Eclipse IDE :

ExtJS

CKEditor

Demo

You can see online demo (CodeMirror is used):

How it works?

Ext*.json

Generate Ext*.json from extjs sources by using jsduck

jsduck --verbose --output ext-5.0.0-json/ ext-5.0.0/src --ignore-global --export=full --encoding=iso-8859-1

jsduck Ext*.json -> Tern defs

Once you have generated jsduck *.json files (for instance see api/extjs/5.0.0) you can generate tern plugin:

npm install -g grunt-cli
grunt template

This command generates tern plugins:

...
Running "template:generate-tern.extjs_5.0.0" (template) task
File `plugin/extjs_5.0.0.js` created.
...

The grunt task uses template generator/extjs.js.tpl and merge it with generated JSON Type definitions.

Structure

The basic structure of the project is given in the following way:

Contributing

Debugging

If you wish to debug the generator with a browser(Chrome, FF, etc), you can open the HTML file generator/ExtJSApi2TernDef_5.0.0.html

Testing

Tests are present in test/unit/ and test/completion/. They are all name *-spec.js and use Mocha+Chai.

Tests can be run:

See also Gruntfile.js for the exhaustive list of tasks.

Unit testing

Files in test/unit/ contain unit tests for the JSDuck generator.

Completion tests

test/completion include completion test for supported libraries and versions (not every of them are covered by these tests at the moment, only ExtJS 5.1.1 and 4.2.1).

More precisely, files in test/completion/ contain tests which sends requests to a real Tern server running with a set of plugins.

A test in this folder creates a Completor instance (see test/lib/util.js) and provides it a fixture in test/completion/*/fixtures/.

Fixtures are JS files including locations to auto-complete. The locations are specified using this syntax: <complete:someName> where someName can be provided to completor.completeAt(). You may take a look at existing tests for more information.