From fa2fc09ae1c299374f4e506e9762e894215f7acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 10 May 2013 04:09:42 -0700 Subject: [PATCH] Updated Exports Files (markdown) --- Exports-Files.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Exports-Files.md b/Exports-Files.md index 02e78f8..3aabaad 100644 --- a/Exports-Files.md +++ b/Exports-Files.md @@ -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.