Skip to content

Commit 7afb9c8

Browse files
committed
0.6.3 release; support for .esdocrc and esdoc.json
1 parent a57e5ea commit 7afb9c8

4 files changed

Lines changed: 42 additions & 17 deletions

File tree

File renamed without changes.

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 0.6.1 (2016-03-07)
1+
## 0.6.3 (2016-03-10)
2+
- Changed `esdoc.json` to `.esdocrc`. All TyphonJS repos are standardizing on using `.esdocrc`, but all ESDoc
3+
plugins including esdoc-plugin-jspm supports `.esdocrc` or `esdoc.json` where applicable.
4+
5+
## 0.6.1 / 0.6.2 (2016-03-07)
26
- No new features. Removed dependence on `jspm`. Converted to ES6 and integrated `typhonjs-npm-build-test`. Please
37
note that Node > 5.0 / NPM > 3.0 may be a hard dependency in order to take advantage of the flat package structure.
48

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esdoc-plugin-jspm",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"homepage": "https://github.com/typhonjs-node-esdoc/esdoc-plugin-jspm/",
55
"description": "A plugin for ESDoc making it SystemJS / JSPM aware.",
66
"license": "MPL-2.0",
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"dependencies": {
21-
"typhonjs-config-jspm-parse": "^0.4.1"
21+
"typhonjs-config-jspm-parse": "^0.4.0"
2222
},
2323
"devDependencies": {
2424
"jspm": "^0.16.0",
@@ -30,7 +30,7 @@
3030
},
3131
"scripts": {
3232
"build": "babel-node ./node_modules/typhonjs-npm-scripts-build-babel/scripts/build.js",
33-
"esdoc": "esdoc -c esdoc.json",
33+
"esdoc": "esdoc -c .esdocrc",
3434
"eslint": "eslint .",
3535
"prepublish": "babel-node ./node_modules/typhonjs-npm-scripts-publish/scripts/prepublish.js",
3636
"test": "babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/test.js",

src/plugin.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* esdoc-plugin-jspm -- Provides support for JSPM packages adding them to ESDoc based on path substitution allowing
33
* end to end documentation when using SystemJS / JSPM. This plugin automatically parses the top level `package.json`
4-
* file for a `jspm.dependencies` entry and resolves any packages that contain a valid `esdoc.json` file.
4+
* file for a `jspm.dependencies` entry and resolves any packages that contain a valid `.esdocrc` or `esdoc.json` file.
55
*
66
* Please refer to this repo that is using this plugin to generate documentation:
77
* https://github.com/typhonjs/backbone-parse-es6-demo
88
*
9-
* This is the esdoc.json configuration file for the above repo:
9+
* This is the .esdocrc configuration file for the above repo:
1010
* {
1111
* "title": "backbone-parse-es6-demo",
1212
* "source": "src",
@@ -32,16 +32,16 @@
3232
* ]
3333
* }
3434
*
35-
* Each JSPM managed package must also have a valid esdoc.json file at it's root that at minimum has a `source` entry
36-
* so that these sources may be included.
35+
* Each JSPM managed package must also have a valid `.esdocrc` or `esdoc.json` file at it's root that at minimum has a
36+
* `source` entry so that these sources may be included.
3737
*
3838
* Since ESDoc only works with one source root this plugin rewrites in `onHandleConfig` the source root to the parent
3939
* directory to `.` and builds an `includes` array that includes the original "source" value in addition to normalized
40-
* paths to the linked JSPM packages. Therefore be aware that you can not use "includes" in your esdoc.json
41-
* configuration.
40+
* paths to the linked JSPM packages. Therefore be aware that you can not use "includes" in your esdoc configuration
41+
* file.
4242
*
43-
* An optional top level entry, `jspmRootPath` to `esdoc.json` may define the JSPM root path; often this is added
44-
* programmatically IE `typhonjs-core-gulptasks` for instance. If `jspmRootPath` is not defined
43+
* An optional top level entry, `jspmRootPath` to the esdoc configuration file may define the JSPM root path; often this
44+
* is added programmatically IE `typhonjs-core-gulptasks` for instance. If `jspmRootPath` is not defined
4545
* `JSPMParser.getRootPath()` locates the root execution path. The root path is where the JSPM `package.json` is
4646
* located.
4747
*
@@ -419,6 +419,12 @@ export function onComplete()
419419

420420
// Utility functions ------------------------------------------------------------------------------------------------
421421

422+
/**
423+
* Defines the supported file names for ESDoc configuration file names.
424+
* @type {string[]}
425+
*/
426+
const s_ESDOC_CONFIG_NAMES = ['.esdocrc', 'esdoc.json'];
427+
422428
/**
423429
* Provides an additional parser for ESDoc JSPM packages when using `JSPMParser.normalizePackage`.
424430
*
@@ -430,15 +436,30 @@ export function onComplete()
430436
const s_PARSE_ESDOC_PACKAGE = (result, silent, logTitle) =>
431437
{
432438
let packageESDocConfig;
439+
let esdocFilename;
440+
441+
// Lookup JSPM package ESDoc config file to pull out the source location.
442+
for (let cntr = 0; cntr < s_ESDOC_CONFIG_NAMES.length; cntr++)
443+
{
444+
esdocFilename = s_ESDOC_CONFIG_NAMES[cntr];
445+
try
446+
{
447+
packageESDocConfig = require(`${result.fullPath}${path.sep}${esdocFilename}`);
448+
break;
449+
}
450+
catch (err) { /* ... */ }
451+
}
433452

434-
// Lookup JSPM package esdoc.json to pull out the source location. If not found then return null result.
435-
try { packageESDocConfig = require(`${result.fullPath}${path.sep}esdoc.json`); }
436-
catch (err) { return null; }
453+
// Verify that the JSPM package esdoc configuration file has loaded otherwise return null to skip this package.
454+
if (typeof packageESDocConfig !== 'object')
455+
{
456+
return null;
457+
}
437458

438-
// Verify that the JSPM package esdoc.json has a source entry.
459+
// Verify that the JSPM package esdoc configuration file has a source entry.
439460
if (typeof packageESDocConfig.source !== 'string')
440461
{
441-
throw new Error("'esdoc.json' does not have a valid 'source' entry");
462+
throw new Error(`'${esdocFilename}' does not have a valid 'source' entry`);
442463
}
443464

444465
// Remove an leading local directory string

0 commit comments

Comments
 (0)