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",
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()
430436const 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