[Tools] Force clang-format version to 3.9
[platform/core/api/webapi-plugins.git] / doc / src / tools.md
1 ## Tools
2
3 ### Generate stub code
4
5 #### <span style="color:red">**The generator is no longer maintained.**</span>
6
7 To generate stub files from the widl you can use stub generator located in
8 ```tools/skeleton_generator/``` directory and run the python command:
9
10 ```sh
11 $ python WAPIOven.py -d <stub code destination directory name> <widl directory/pluginname>.widl
12 ```
13
14 If tizen.widl is needed, add tizen.widl
15 ```
16 $ python WAPIOven.py -d <stub code destination directory name> <widl directory/pluginname>.widl <widl directory/>tizen.widl
17 ```
18 Path to WAPIOven.py:
19 ```sh
20 $ tools/skeleton_generator/WAPIOven.py
21 ```
22
23 You need to install jinja2 for WAPIOven.py:
24 ```sh
25 $ sudo apt-get install python-jinja2
26 ```
27
28 Example:
29 ```sh
30 $ sudo apt-get install python-jinja2
31 $ cd tools/skeleton_generator/
32 $ python WAPIOven.py -d ../../src/notification/ /web-device-api/web/widl/tizen/notification.widl
33 ```
34
35 WIDL files can be found in the project repository:
36
37 ```sh
38 $ git clone ssh://<username>@168.219.209.56:29418/doc/web-device-api
39 ```
40
41 The widl files are placed in: ```web-device-api/web/widl/tizen/``` directory.
42
43 Stub files generated by above command:
44
45 ```sh
46 <pluginname>_api.js
47 <pluginname>_extension.h
48 <pluginname>_extension.cc
49 <pluginname>_instance.h
50 <pluginname>_instance.cc
51 ```
52
53 What should be done when skeleton code was generated?
54 - ```<pluginname>.gyp``` file should be added
55 - entry points should be checked in ```<pluginname>_extension.cc``` file
56 - each method should be implemented in ```<pluginname>_instance.cc``` file
57
58 ### Using multiple JavaScript files
59
60 To use multiple JavaScript files in one plugin create ```js/``` directory inside
61 plugin directory and place JavaScript files.
62
63 Inside ```<pluginname>_api.js``` required JavaScript files should be added:
64 ```sh
65 //= require('common.js');
66 //= require('calendar_item.js');
67 //= require('calendar.js');
68 //= require('calendar_manager.js');
69 //= require('calendar_attendee.js');
70 //= require('calendar_alarm.js');
71 //= require('calendar_recurrence_rule.js');
72 ```
73
74 To merge all JavaScript files ```tools/mergejs.py``` file is used.
75 This script merge all files mentioned in ```<pluginname>_api.js``` file into one
76 file before build process.
77
78
79 ### Format code
80
81 To format code use scripts provided in the ``tools/codestyle`` directory.
82
83 ``cpplint`` is used to validate C++ and ``eslint`` for JavaScript files.
84
85 **Currently, the JavaScript validator and formatter seems to be a little buggy,
86 thus it is not recommended to use.**
87
88 The developer needs to have ``python``, ``node.js``, ``eslint``, ``Closure Linter`` and ``clang-format-3.9`` installed.
89
90 For convenience, in the root of the project links were provided for easier access:
91 - ``code_format -> tools/codestyle/code_formatter.sh``
92 - ``code_validate -> tools/codestyle/code_validation.sh``
93
94 Those scripts consist of configuration for rules regarding the Google style guides, with few exceptions.
95
96 To format and validate C++ and JavaScript code run in the root of the project:
97 ```sh
98 ./code_validate -a # -a for all, -c for C++, -js for JavaScript files
99 ./code_format -a   # use -h or --help for help
100 ```
101 The scripts also accept a path to module's directory.
102 By default every directory module in the ``src`` directory is used.
103
104 For more details, please see ``tools/codestyle/README`` file.
105
106 This rule concerns to branches ``tizen_3.0`` and above.