This document provides information for developers working on ngeo.
To build the "standalone" version of ngeo use the dist
target:
$ make dist
The resulting file is dist/ngeo.js
.
The standalone version of ngeo contains both the ngeo
code and the ol
code.
So when you use ngeo.js
in a web page you should not have a script tag for
ol.js
.
To run the examples use the serve
target:
$ make serve
and point your browser to http://localhost:3000/examples.
Run the check
target before submitting a PR:
$ make check
The check
target runs a number of checks on the code of the library and the
examples (lint, compile, …). This is the target run on Travis.
Note: this target compiles the examples' code. The examples are combined into a single file before compilation. See the following section to know how to individually compile the examples.
Each example can be individually compiled. For example:
$ make .build/examples-hosted/simple.js
Let's say you're working on a new feature in a specific branch and want to
publish examples to show others what that new feature's UI looks like. The
Makefile provides a gh-pages
target for exactly this.
To publish the current branch's examples to GitHub Pages:
$ make gh-pages GITHUB_USERNAME=<your_github_username>
The GITHUB_USERNAME
variable is used to specify the user/organization name to
publish to on GitHub.
For example
$ make gh-pages GITHUB_USERNAME=camptocamp
will publish the examples to https://camptocamp.github.io/ngeo/<branchname>/
.
The published examples use the ngeo.js
standalone build.
Example: https://camptocamp.github.io/ngeo/master/examples/simple.html.
Ngeo (and GMF) comes with an automatically built API documentation.
The current master version of this doc is available at https://camptocamp.github.io/ngeo/master/apidoc/index.html
You can build the API documentation locally on your machine in order to make sure that your changes are correctly taken into account.
To do so you can run the following command:
$ make apidoc
You can then see the result using make serve
and pointing your browser to
http://localhost:3000/.build/apidoc
You can also see it online if you use the following command:
$ make gh-pages GITHUB_USERNAME=<your_github_username>
URL will then be http://<your_github_username>.github.io/ngeo/<branchname>/apidoc
If using Windows, then please use the Windows Makefile Makefile_windows
.
Typically, to run the example, one would use the following command:
$ make -f Makefile_windows serve
Please be sure to fulfill also the requirements listed on top of the Windows Makefile
This section includes information for developers and users of ngeo.
We more or less follow the AngularJS Style Guide for Closure Users at Google.
Services that are objects (rather than numbers, strings, or functions) may need
"exports". Exports are needed for users of the ngeo.js
standalone build.
To export a symbol, the @export
annotation can be used:
/**
* Some layer.
*
* @constructor
* @extends {ol.source.WMTS}
* @param {ngeox.source.SomeLayerOptions} options Layer options.
* @export
*/
ngeo.source.SomeLayer = function(options) {
...
};
Developers often need to add goog.require(...);
statements at the top of the
files to make sure that dependency is correctly handled.
However, in some cases, specifically when adding requirements for directives, the closure compiler may complain because the directive's namespace is actually not used in the file.
To avoid such a warning, developers are invited to use the following annotation
just before a goog.require(...);
: @suppress {extraRequire}
.
To run the examples locally, just run make serve
and open your browser in
http://localhost:3000/examples/
uri.
All extern javascript includes must be defined in the example file, explicitly.
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>
To include the example code and all its dependencies through ngeo
and ol3
you have to include the following tag:
<script src="/@?main=scaleselector.js"></script>
The /@?main=scaleselector.js
will take the scaleselector.js
file in the
example folder and will load in debug mode all the dependency tree built with
the goog.require()
call.
In local examples, you will have all javascripts files in debug mode of ol3,
ngeo, contribs and goog files loaded.
The target examples-hosted
will create a folder in your .build
folder
for hosted examples, where examples are fully compiled. You can then test
them in advanced build mode.
When you execute the target gh-pages
, it pushs your examples-hosted
to your
github gh-pages, you can them test them online and share them.
During the examples-hosted
phase, some changes are made on source
files to make them work in an advanced build context:
An index.html
is created in examples/
and contribs/gmf/
to list
all examples available in the library.
For example, all links to external js files are changed from
../node_modules/angular/angular.js
to
lib/angular.min.js
in ngeo examples../../lib/angular.min.js
in gmf examples
In hosted examples, we use the standalone build of ngeo ngeo.js
for ngeo
examples, and gmf.js
for gmf examples.
<script src="../../lib/gmf.js"></script>
<script src="lib/ngeo.js"></script>
The example source is finally added in debug mode. /@?main=scaleselector.js
is
changed to
<script src="scaleselector.js"></script>
in ngeo<script src="locationchooser.js"></script>
in gmf
So both are relative to the example folder.
The GMF applications works the same way in local mode as the examples.
But it is different for the hosted examples. As we want gmf applications to be
a default instance of gmf ui, we want to build the whole application in
advanced mode.
So during make, all javascript includes are merged into one :
<script src="../../build/mobile.js"></script>
The build is done in contribs/gmf/build/
.
The unit tests are located in test/spec/
and uses the Jasmine Framework.
Please refer to the AngularJS's unit-testing guide for
how to write unit tests.
To run the unit tests on the command line, just run make test
. All the tests will be
run inside PhantomJS.
For debugging purposes it is useful to run the unit tests in an actual browser with
make test-debug
. This task starts the Karma server and opens Chrome/Chromium. Click on
Debug
to open a new page that runs all unit tests. Now you can start the debugger.
To run only a single test or test group, use fdescribe
or fit
to focus
on a test:
fdescribe('...', function() {
fit('...', function() {
git checkout <release-branch>
git fetch origin
git reset --hard origin/<release-branche>
Where <release-branch>
stand for 2.x
.
Verify that the <version>
(2.x.x
) in package.json match with the tag you'll
create. Then create a tag named the same as the version.
git tag <version>
git push <version>
Travis will create a new package on npm.
If you create a new release, bump version in the package.json file:
git checkout -b bump
vi package.json
git add package.json
git commit -m "Bump version to <version + 1>"
git push origin bump
Do the pull request on branch <release-branche>
When we create a new stabilisation branch we should also duplicate the localisation.
Go on master:
git checkout master
git pull origin master
Create the new branch:
git checkout -b x_y
Update the .travis.yml
:
- provider: script
script: make transifex-send
skip_cleanup: true
on:
repo: camptocamp/ngeo
- branch: master
+ branch: x.y
Commit and push the changes:
git add .travis.yml
git commit -m "Update the branch"
git push origin x_y
Back on master:
git checkout master
Do the merge to prepare the future merges:
git checkout merge x.y
Restore the .travis.yml
:
- provider: script
script: make transifex-send
skip_cleanup: true
on:
repo: camptocamp/ngeo
- branch: x.y
+ branch: master
Get the actual localisation:
make transifex-get
Update the Makefile
:
- TX_VERSION ?= x_y
+ TX_VERSION ?= x_y+1
Commit and push the changes:
git add Makefile .travis.yml
git commit -m "Start the version x.y+1"
git push origin master
Create the new localisation resource:
rm .tx/config
make transifex-init