Updated Exports Files (markdown)
+10
-3
@@ -1,4 +1,4 @@
|
||||
## Exports files (.exports)
|
||||
## Exporting constructors, methods and functions
|
||||
|
||||
Alongside js files, the `src` directory includes "exports files" (e.g. `src/ol/map.exports`). The export files declare symbols and properties that the library exports. (See the [Closure Compiler docs](https://developers.google.com/closure/compiler/docs/api-tutorial3?hl=fr#export) to know more about _exporting_.)
|
||||
|
||||
@@ -9,10 +9,17 @@ For example the `src/ol/map.exports` file includes this:
|
||||
@exportProperty ol.Map.prototype.addLayer
|
||||
```
|
||||
|
||||
|
||||
This declares that the `ol.Map` symbol, and that the `ol.Map.prototype.addLayer` property, should be *exported*, i.e. made available to library's users.
|
||||
|
||||
Exports files are processed by the `bin/generate-exports` script, using its `--exports` switch. This script receives a list of exports files as its input, and outputs `@exportSymbol` and `@exportProperty` statements. The output of `generate-exports --exports` goes into `build/src/external/src/exports.js`, which is then used as an input file for the `ol.js` build (see `build/ol.json`).
|
||||
Exports files are processed by the `bin/generate-exports` script, using the `--exports` switch. This script receives a list of exports files as its input, and outputs JavaScript code including calls to Closure's `goog.exportSymbol` and `goog.exportProperty` functions.
|
||||
|
||||
As an example, try the following:
|
||||
|
||||
python bin/generate-exports.py --exports src/objectliterals.jsdoc src/ol/map.exports
|
||||
|
||||
The `build.py` script places the output of `generate-exports --exports` into `build/src/external/src/exports.js`, which is then used as an input file for the `ol.js` build (see `build/ol.json`).
|
||||
|
||||
## Exporting options objects
|
||||
|
||||
The `src/objectliterals.exports` file is specific. This file declares the config objects and properties for the library's single-argument constructors. These declarations are done with the `@exportObjectLiteral` and `@exportObjectLiteralProperty` directives. This file is also processed with the `bin/generate-exports` script, but using the `--externs` and `--typedef` switches.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user