This small script generates Tern definition files from Appcelerator Titanium API documentation YAML files. Tern is code-analysis engine for JavaScript which adds intellisense capabilities to text editors, it uses definition files to autocomplete object model member names and infer their types.
You should have tern already installed and text editor configured. Refer to tern docs.
Clone tern-titanium repository:
$ git clone git@github.com:x-cray/tern-titanium.git
Then you'll need Titanium Mobile source code which can be obtained from titanium_mobile repository:
$ git clone git@github.com:appcelerator/titanium_mobile.git
Optionally, you may want to checkout specific titanium_mobile release:
$ cd titanium_mobile
$ git checkout 3_1_2_GA
$ cd ..
Run generate.py
supplying path to source API documentation and output file:
$ tern-titanium/generate.py titanium_mobile/apidoc titanium.json
Copy generated titanium.json
file to your project directory. Then create .tern-project
file in project directory (refer to tern documentation) with the following contents:
{
"libs": [
"titanium",
"ecma5"
],
"plugins": {
"requirejs": {
"baseURL": "./app",
"paths": {}
}
}
}
Libs entry titanium
tells tern to look for titanium.json
in project directory first and then in tern distribution defs/
directory.
That's it. Now Titanium Mobile API autocomplete should work in your text editor.
Pull requests and ideas are welcome.