-
Notifications
You must be signed in to change notification settings - Fork 0
API v1
- Modules
- Classes
- Constants
- Functions
- Typedefs
- pkg2md
LogWrapper- MdWriter
- Md
- PkgReader
- PkgToMd
- UTF8 :
string - DEFAULT_MD_FILE :
string - DEFAULT_PKG_FILE :
string - DEFAULT_REGISTRY :
string - DEPENDENCY_TYPE_PROD :
string - DEPENDENCY_TYPE_DEV :
string - DEPENDENCY_TYPE_BUNDLED :
string - DEPENDENCY_TYPE_BUNDLE :
string - DEPENDENCY_TYPE_OPTIONAL :
string - DEPENDENCY_TYPE_PEER :
string - NAME_REG_EXP :
RegExp - EMAIL_REG_EXP :
RegExp - URL_REG_EXP :
RegExp - createHeadlinePrefix(headlineDepth) ⇒
Promise.<string>℗ - personSort(person1, person2) ⇒
number℗ - loadPackageSchema() ⇒
object℗ - Person :
object - Options :
object
LogWrapper-
Class which defines a
loggerwrapper usable in this module.NOTE: This class is not to be intended to be called from outside this module!
- MdWriter
-
Class which writes Markdown file.
- Md
-
Utility class which wraps a Markdown string and provides useful operations on this string.
- PkgReader
-
Class which reads an validates (by JSON schema) a package.json file.
- PkgToMd
-
Class which converts a package.json to a MD file.
-
UTF8 :
string -
The 'utf8' constant.
-
DEFAULT_MD_FILE :
string -
The default Markdown file: 'README.md'.
-
DEFAULT_PKG_FILE :
string -
The default package file: 'package.json'.
-
DEFAULT_REGISTRY :
string -
The default registry: 'https://registry.npmjs.org/'.
-
DEPENDENCY_TYPE_PROD :
string -
The production dependency type: ''.
-
DEPENDENCY_TYPE_DEV :
string -
The development dependency type: 'dev'.
-
DEPENDENCY_TYPE_BUNDLED :
string -
The bundled dependency type: 'bundled'.
-
DEPENDENCY_TYPE_BUNDLE :
string -
The alternative bundled dependency type: 'bundle'.
-
DEPENDENCY_TYPE_OPTIONAL :
string -
The optional dependency type: 'optional'.
-
DEPENDENCY_TYPE_PEER :
string -
The peer dependency type: 'peer'.
-
NAME_REG_EXP :
RegExp -
A RegExp to parse a name in "flat" person strings, e.g.
Barney RubbleinBarney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/) -
EMAIL_REG_EXP :
RegExp -
A RegExp to parse an email in "flat" person strings, e.g.
b@rubble.cominBarney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/) -
URL_REG_EXP :
RegExp -
A RegExp to parse a URL in "flat" person strings, e.g.
http://barnyrubble.tumblr.com/inBarney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)
-
createHeadlinePrefix(headlineDepth) ⇒
Promise.<string>℗ -
Creates a headline prefix from given depth number.
-
personSort(person1, person2) ⇒
number℗ -
Does a lower case person name sort.
-
loadPackageSchema() ⇒
object℗ -
Loads the schema for package.json.
Deprecated
Class which defines a logger wrapper usable in this module.
NOTE: This class is not to be intended to be called from outside this module!
Kind: global class
Access: protected
-
LogWrapper- new LogWrapper([logger])
-
.logInstance :
logger|cli|console℗ - .info(msg)
- .debug(msg)
- .trace(msg)
- .error(msg)
- .verboseOptions(options) ⇒
Constructs the LogWrapper.
Returns: LogWrapper - - The instance.
| Param | Type | Default | Description |
|---|---|---|---|
| [logger] |
logger | cli | console
|
console |
Logger object. |
Example
var logger = ...;
var logWrapper = new LogWrapper(logger);The logger instance.
Kind: instance property of LogWrapper
Access: private
Log the options with INFO level.
Kind: instance method of LogWrapper
Access: public
| Param | Type | Description |
|---|---|---|
| msg | string |
The message to log. |
Example
var logger = ...;
var logWrapper = new LogWrapper(logger);
var msg = '...';
logWrapper.info(msg);Log the options with DEBUG level (if logger supports it, else with INFO).
Kind: instance method of LogWrapper
Access: public
| Param | Type | Description |
|---|---|---|
| msg | string |
The message to log. |
Example
var logger = ...;
var logWrapper = new LogWrapper(logger);
var msg = '...';
logWrapper.debug(msg);Log the options with TRACE level (if logger supports it, else with DEBUG).
Kind: instance method of LogWrapper
Access: public
See: #debug
| Param | Type | Description |
|---|---|---|
| msg | string |
The message to log. |
Example
var logger = ...;
var logWrapper = new LogWrapper(logger);
var msg = '...';
logWrapper.trace(msg);Log the options with ERROR level.
Kind: instance method of LogWrapper
Access: public
| Param | Type | Description |
|---|---|---|
| msg | string |
The message to log. |
Example
var logger = ...;
var logWrapper = new LogWrapper(logger);
var msg = '...';
logWrapper.error(msg);Log the options with INFO level.
Kind: instance method of LogWrapper
Returns: A Promise containing the passed options object.
Access: public
| Param | Type | Description |
|---|---|---|
| options | Options |
The properties to log with INFO. |
Example
var logger = ...;
var logWrapper = new LogWrapper(logger);
var options = {
...
};
logWrapper.verboseOptions(options)
.then(function (options) {
...
});Class which writes Markdown file.
Kind: global class
-
MdWriter
- new MdWriter()
-
.writeToFile(md, options, resolve, reject) ⇒
Promise.<string>℗ -
.write(md, options) ⇒
Promise.<string>
Constructs the writer.
Returns: MdWriter - - The instance.
Writes a serialized object to file. Forces overwriting the destination file if options.force true.
Kind: instance method of MdWriter
Returns: Promise.<string> - - Containing the write success message to handle by caller (e.g. for logging).
Throws:
-
Error- If serialized JSON file could not be written due to any reason.
Access: private
| Param | Type | Description |
|---|---|---|
| md | Md |
The object holding markdown to write into file. |
| options | Options |
The write options. |
| resolve | function |
The Promise resolve callback. |
| reject | function |
The Promise reject callback. |
Ensures that all dirs exists for dest and writes the file.
Kind: inner method of writeToFile
Access: private
Kind: instance method of MdWriter
Access: public
| Param |
|---|
| md |
| options |
Utility class which wraps a Markdown string and provides useful operations on this string.
Kind: global class
-
Md
- new Md(pkg, options, logger)
-
.append(content, [amount]) ⇒
Md -
.appendCodeBlock(content, [amount], [language]) ⇒
Promise.<Md> -
.nl([amount]) ⇒
Promise.<Md> -
.headline(content, headlineDepth) ⇒
Promise.<Md> -
.title() ⇒
Promise.<Md> -
.description() ⇒
Promise.<Md> -
.parseStringifiedPerson(person) ⇒
Promise.<Person> -
.repository([headline]) ⇒
Promise.<Md> -
.staff([headline]) ⇒
Promise.<Md> -
.installation([headline]) ⇒
Promise.<Md> -
.tests([headline]) ⇒
Promise.<Md> -
.dependencies(depType) ⇒
Promise.<Md> -
.bin([headline]) ⇒
Promise.<Md> -
.main([headline]) ⇒
Promise.<Md> -
.config([headline]) ⇒
Promise.<Md> -
.scripts([headline]) ⇒
Promise.<Md> -
.engines([headline]) ⇒
Promise.<Md> -
.keywords([headline]) ⇒
Promise.<Md> -
.os([headline]) ⇒
Promise.<Md> -
.cpu([headline]) ⇒
Promise.<Md> -
.license([headline]) ⇒
Promise.<Md> -
.end([amount]) ⇒
string
Constructs the Markdown string from given package object.
Returns: Md - - The instance.
| Param | Type | Description |
|---|---|---|
| pkg | object |
The package.json representation as object. |
| options | Options |
The |
| logger | logger |
The logger to use. |
md.append(content, [amount]) ⇒ Md
Appends the given content to the Markdown string and adds newlines.
Kind: instance method of Md
Returns: Md - - This instance for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| content | string |
The content to append. | |
| [amount] | number |
2 |
The amount of newlines to add. |
md.appendCodeBlock(content, [amount], [language]) ⇒ Promise.<Md>
Appends the given content to the Markdown string as code block and adds newlines.
Kind: instance method of Md
Returns: Promise.<Md> - - This instance for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| content | string |
The content to append as code block. | |
| [amount] | number |
2 |
The amount of newlines to add. |
| [language] | string |
The language of the code. |
md.nl([amount]) ⇒ Promise.<Md>
Adds newlines of the given amount.
Kind: instance method of Md
Returns: Promise.<Md> - - This instance for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [amount] | number |
2 |
The amount of newlines to add. |
md.headline(content, headlineDepth) ⇒ Promise.<Md>
Kind: instance method of Md
Returns: Promise.<Md> - - This instance for concatenated calls.
Access: public
| Param | Type | Description |
|---|---|---|
| content | string |
The content used as headline. |
| headlineDepth | number |
The depth of the headline. |
md.title() ⇒ Promise.<Md>
Creates a title for the target document. A title is either applied from:
-
options.title(if exists) or -
pkg.name(from package.json) Ifpkg.homepageis set, the title will be turned into a link to its URL value automatically.
Kind: instance method of Md
Returns: Promise.<Md> - - This instance for concatenated calls.
Access: public
md.description() ⇒ Promise.<Md>
Writes a description if options.desc is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - The Promise resolving with this.
Access: public
md.parseStringifiedPerson(person) ⇒ Promise.<Person>
Parses a "flat" person info string, e.g. which has such a pattern:
Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)
Kind: instance method of Md
Returns: Promise.<Person> - - A Promise resolving the person object.
Access: public
| Param | Type | Description |
|---|---|---|
| person | string |
The person's string to parse. |
md.repository([headline]) ⇒ Promise.<Md>
Writes the repository section (a table overview about configured repositories).
Kind: instance method of Md
Returns: Promise.<Md> - - The Promise resolving with this for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Repository" |
The headline for this section. |
md.staff([headline]) ⇒ Promise.<Md>
Writes the collaborators section (a table overview about configured persons) including their roles:
- The author
- Contributors
- Maintainers The first column is the role, the second the name linked by the URL and the last contains the email link.
Kind: instance method of Md
Returns: Promise.<Md> - - The Promise resolving with this for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Collaborators" |
The headline for this section. |
md.installation([headline]) ⇒ Promise.<Md>
Writes the installation section.
Kind: instance method of Md
Returns: Promise.<Md> - - The Promise resolving with this for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Installation" |
The headline for this section. |
md.tests([headline]) ⇒ Promise.<Md>
Writes the tests section.
Kind: instance method of Md
Returns: Promise.<Md> - - The Promise resolving with this for concatenated calls.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Installation" |
The headline for this section. |
md.dependencies(depType) ⇒ Promise.<Md>
Writes the dependencies info for given dependency type if options.deps is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
Access: public
| Param | Type | Description |
|---|---|---|
| depType | string |
The type of dependencies. |
md.bin([headline]) ⇒ Promise.<Md>
Writes the binary mappings if options.bin is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Binary Mappings" |
A headline for the section. |
md.main([headline]) ⇒ Promise.<Md>
Writes the main executable if options.main is set to true.
Writes the main executable if options.main is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Main File" |
A headline for the section. |
md.config([headline]) ⇒ Promise.<Md>
Writes the NPM configuration mappings if options.config is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"NPM Configuration" |
A headline for the section. |
md.scripts([headline]) ⇒ Promise.<Md>
Writes the NPM scripts mappings if options.scripts is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"NPM Scripts" |
A headline for the section. |
md.engines([headline]) ⇒ Promise.<Md>
Writes the engines info if options.engines is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Engine Support" |
A headline for the section. |
md.keywords([headline]) ⇒ Promise.<Md>
Writes the keywords if options.keywords is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"Keywords" |
A headline for the section. |
md.os([headline]) ⇒ Promise.<Md>
Writes the OS support if options.os is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"OS Support" |
A headline for the section. |
md.cpu([headline]) ⇒ Promise.<Md>
Writes the CPU support if options.cpu is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"CPU Support" |
A headline for the section. |
md.license([headline]) ⇒ Promise.<Md>
Writes the License(s) if options.lic is set to true.
Kind: instance method of Md
Returns: Promise.<Md> - - A Promise resolving with this.
| Param | Type | Default | Description |
|---|---|---|---|
| [headline] | string |
"License |
Licenses" |
Returns the Markdown string (optionally adds newlines), ususally after creation has finished.
Kind: instance method of Md
Returns: string - - The Markdown created.
| Param | Type | Description |
|---|---|---|
| [amount] | number |
The final amount of newlines. |
Class which reads an validates (by JSON schema) a package.json file.
Kind: global class
-
PkgReader
- new PkgReader()
-
.validate(pkg, options) ⇒
Promise℗ -
.read(options) ⇒
Promise.<T>
Constructs the constants.
Returns: PkgReader - - The instance.
If pkg is invalid it rejects with a proper validation error, else it
resolves with pkg object.
Kind: instance method of PkgReader
Returns: Promise - - Resolves with the pkg object.
Access: private
| Param | Type | Description |
|---|---|---|
| pkg | object |
The package object to validate. |
| options | object |
The validate/read options. |
Kind: instance method of PkgReader
| Param |
|---|
| options |
Class which converts a package.json to a MD file.
Kind: global class
-
PkgToMd
- new PkgToMd()
-
.writeMarkdown(options) ⇒
Promise
Constructs the ....
Returns: PkgToMd - - The instance.
Kind: instance method of PkgToMd
Returns: Promise - -
| Param |
|---|
| options |
The 'utf8' constant.
Kind: global constant
Access: public
The default Markdown file: 'README.md'.
Kind: global constant
Access: public
The default package file: 'package.json'.
Kind: global constant
Access: public
The default registry: 'https://registry.npmjs.org/'.
Kind: global constant
Access: public
The production dependency type: ''.
Kind: global constant
Access: public
The development dependency type: 'dev'.
Kind: global constant
Access: public
The bundled dependency type: 'bundled'.
Kind: global constant
Access: public
The alternative bundled dependency type: 'bundle'.
Kind: global constant
Access: public
The optional dependency type: 'optional'.
Kind: global constant
Access: public
The peer dependency type: 'peer'.
Kind: global constant
Access: public
A RegExp to parse a name in "flat" person strings, e.g. Barney Rubble in
Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)
Kind: global constant
Access: public
A RegExp to parse an email in "flat" person strings, e.g. b@rubble.com in
Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)
Kind: global constant
Access: public
A RegExp to parse a URL in "flat" person strings, e.g.
http://barnyrubble.tumblr.com/ in
Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)
Kind: global constant
Access: public
Creates a headline prefix from given depth number.
Kind: global function
Returns: Promise.<string> - - A Promise resolving the created prefix.
Access: private
| Param | Type | Description |
|---|---|---|
| headlineDepth | number |
The amount of hash-signs forprefix. |
Does a lower case person name sort.
Kind: global function
Access: private
| Param | Type | Description |
|---|---|---|
| person1 |
Person | string
|
The one person to sort against person2, if type is Object then person1.name is used for sorting! |
| person2 |
Person | string
|
The one person to sort against person1, if type is Object then person2.name is used for sorting! |
Loads the schema for package.json.
Kind: global function
Returns: object - - The JSON schema.
Access: private
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| name | string |
The name of the person. |
string |
The email of the person. | |
| url | string |
The URL of the person's page. |
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| origin | string |
"yaml" |
The origin type. |
| target | string |
"js" |
The target type. |
| src |
string | Readable | object
|
The source. | |
| dest |
string | Writable | object
|
The destination. | |
| indent | number |
4 |
The indention in files. |
| imports | string |
The exports name for reading from JS source file or objects only. | |
| exports | string |
The exports name for usage in JS destination files only. |