Skip to content

angelozerr/tern.jsduck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 :

  • with the ExtJS Tern plugin

ExtJS

  • with the CKEditor Tern plugin

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:

  • install grunt client:
npm install -g grunt-cli
  • go at tern.jsduck folder and do
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:

  • api/ JSDuck api.json of ExtJS, CKEditor generated from their sources with JSDuck.
  • demos/ demos with ExtJS, CKEditor tern plugin which use CodeMirror.
  • generator/ lib to transform JSDuck api.json to tern def, generates JSDuck from api.json by using HTML pages.
  • plugin/ ExtJS, CKEditor tern plugin where defs was generated with lib JSDuck tern plugin.
  • test/ contains test of JSDuck tern plugin.

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:

  • at once using grunt test
  • in a watched mode (i.e. it reruns whenever a file changed) using grunt autotest

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.

About

Tern Plugin for ExtJS, CKEditor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published