Skip to content

Commit fdcc158

Browse files
committed
document public API
closes #614
1 parent 81ec3f2 commit fdcc158

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

core/lib/patternlab.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,31 @@ const patternlab_engine = function (config) {
656656
}
657657

658658
return {
659+
/**
660+
* logs current version
661+
*
662+
* @returns {void} current patternlab-node version as defined in package.json, as console output
663+
*/
659664
version: function () {
660665
return logVersion();
661666
},
667+
668+
/**
669+
* return current version
670+
*
671+
* @returns {string} current patternlab-node version as defined in package.json, as string
672+
*/
662673
v: function () {
663674
return getVersion();
664675
},
676+
677+
/**
678+
* build patterns, copy assets, and construct ui
679+
*
680+
* @param {function} callback a function invoked when build is complete
681+
* @param {object} options an object used to control build behavior
682+
* @returns {Promise} a promise fulfilled when build is complete
683+
*/
665684
build: function (callback, options) {
666685
if (patternlab && patternlab.isBusy) {
667686
console.log('Pattern Lab is busy building a previous run - returning early.');
@@ -694,9 +713,23 @@ const patternlab_engine = function (config) {
694713
callback();
695714
});
696715
},
716+
717+
/**
718+
* logs usage
719+
*
720+
* @returns {void} pattern lab API usage, as console output
721+
*/
697722
help: function () {
698723
help();
699724
},
725+
726+
/**
727+
* build patterns only, leaving existing public files intact
728+
*
729+
* @param {function} callback a function invoked when build is complete
730+
* @param {object} options an object used to control build behavior
731+
* @returns {Promise} a promise fulfilled when build is complete
732+
*/
700733
patternsonly: function (callback, options) {
701734
if (patternlab && patternlab.isBusy) {
702735
console.log('Pattern Lab is busy building a previous run - returning early.');
@@ -709,18 +742,53 @@ const patternlab_engine = function (config) {
709742
callback();
710743
});
711744
},
745+
746+
/**
747+
* fetches starterkit repos from pattern-lab github org that contain 'starterkit' in their name
748+
*
749+
* @returns {Promise} Returns an Array<{name,url}> for the starterkit repos
750+
*/
712751
liststarterkits: function () {
713752
return listStarterkits();
714753
},
754+
755+
/**
756+
* load starterkit already available via `node_modules/`
757+
*
758+
* @param {string} starterkitName name of starterkit
759+
* @param {boolean} clean whether or not to delete contents of source/ before load
760+
* @returns {void}
761+
*/
715762
loadstarterkit: function (starterkitName, clean) {
716763
loadStarterKit(starterkitName, clean);
717764
},
765+
766+
767+
/**
768+
* install plugin already available via `node_modules/`
769+
*
770+
* @param {string} pluginName name of plugin
771+
* @returns {void}
772+
*/
718773
installplugin: function (pluginName) {
719774
installPlugin(pluginName);
720775
},
776+
777+
/**
778+
* returns all file extensions supported by installed PatternEngines
779+
*
780+
* @returns {Array<string>} all supported file extensions
781+
*/
721782
getSupportedTemplateExtensions: function () {
722783
return getSupportedTemplateExtensions();
723784
},
785+
786+
/**
787+
* build patterns, copy assets, and construct ui, watch source files, and serve locally
788+
*
789+
* @param {object} options an object used to control build, copy, and serve behavior
790+
* @returns {Promise} TODO: validate
791+
*/
724792
serve: function (options) {
725793
options.watch = true;
726794
return this.build(() => {}, options).then(function () {

0 commit comments

Comments
 (0)