Skip to content

Commit

Permalink
#780: add --format param to generic document methods
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Mar 4, 2023
1 parent e945676 commit 37ef034
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 6 additions & 4 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ main class
* [.initProject([credentialsName])](#Mcdev.initProject) ⇒ <code>Promise.&lt;void&gt;</code>
* [.joinProject()](#Mcdev.joinProject) ⇒ <code>Promise.&lt;void&gt;</code>
* [.findBUs(credentialsName)](#Mcdev.findBUs) ⇒ <code>Promise.&lt;void&gt;</code>
* [.document(businessUnit, type)](#Mcdev.document) ⇒ <code>Promise.&lt;void&gt;</code>
* [.document(businessUnit, type, [format])](#Mcdev.document) ⇒ <code>Promise.&lt;void&gt;</code>
* [.deleteByKey(businessUnit, type, customerKey)](#Mcdev.deleteByKey) ⇒ <code>Promise.&lt;void&gt;</code>
* [.refresh(businessUnit, type, [keyArr])](#Mcdev.refresh) ⇒ <code>Promise.&lt;void&gt;</code>
* [.badKeys(businessUnit)](#Mcdev.badKeys) ⇒ <code>Promise.&lt;void&gt;</code>
Expand Down Expand Up @@ -609,7 +609,7 @@ Refreshes BU names and ID's from MC instance

<a name="Mcdev.document"></a>

### Mcdev.document(businessUnit, type) ⇒ <code>Promise.&lt;void&gt;</code>
### Mcdev.document(businessUnit, type, [format]) ⇒ <code>Promise.&lt;void&gt;</code>
Creates docs for supported metadata types in Markdown and/or HTML format

**Kind**: static method of [<code>Mcdev</code>](#Mcdev)
Expand All @@ -619,6 +619,7 @@ Creates docs for supported metadata types in Markdown and/or HTML format
| --- | --- | --- |
| businessUnit | <code>string</code> | references credentials from properties.json |
| type | <code>string</code> | metadata type |
| [format] | <code>&#x27;md&#x27;</code> \| <code>&#x27;html&#x27;</code> \| <code>&#x27;csv&#x27;</code> | output format |

<a name="Mcdev.deleteByKey"></a>

Expand Down Expand Up @@ -3276,7 +3277,7 @@ Provides default functionality that can be overwritten by child metadata type cl
* [.readSecondaryFolder(templateDir, typeDirArr, templateName, fileName, ex)](#MetadataType.readSecondaryFolder) ⇒ <code>object</code>
* [.buildDefinition(templateDir, targetDir, templateName, variables)](#MetadataType.buildDefinition) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.checkForErrors(ex)](#MetadataType.checkForErrors) ⇒ <code>Array.&lt;string&gt;</code> \| <code>void</code>
* [.document([metadata], [isDeploy])](#MetadataType.document) ⇒ <code>void</code>
* [.document([metadata], [isDeploy], [format])](#MetadataType.document) ⇒ <code>void</code>
* [.deleteByKey(customerKey)](#MetadataType.deleteByKey) ⇒ <code>boolean</code>
* [.postDeleteTasks(customerKey, [additionalExtensions])](#MetadataType.postDeleteTasks) ⇒ <code>Promise.&lt;void&gt;</code>
* [.deleteByKeySOAP(customerKey, [overrideKeyField], [handleOutside])](#MetadataType.deleteByKeySOAP) ⇒ <code>boolean</code>
Expand Down Expand Up @@ -3906,7 +3907,7 @@ Standardizes a check for multiple messages

<a name="MetadataType.document"></a>

### MetadataType.document([metadata], [isDeploy]) ⇒ <code>void</code>
### MetadataType.document([metadata], [isDeploy], [format]) ⇒ <code>void</code>
Gets metadata cache with limited fields and does not store value to disk

**Kind**: static method of [<code>MetadataType</code>](#MetadataType)
Expand All @@ -3915,6 +3916,7 @@ Gets metadata cache with limited fields and does not store value to disk
| --- | --- | --- |
| [metadata] | <code>TYPE.MetadataTypeMap</code> | a list of type definitions |
| [isDeploy] | <code>boolean</code> | used to skip non-supported message during deploy |
| [format] | <code>&#x27;md&#x27;</code> \| <code>&#x27;html&#x27;</code> \| <code>&#x27;csv&#x27;</code> | output format |

<a name="MetadataType.deleteByKey"></a>

Expand Down
8 changes: 6 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ yargs
},
})
.command({
command: 'document <BU> <TYPE>',
command: 'document <BU> <TYPE> [--format]',
aliases: ['doc'],
desc: 'Creates Markdown or HTML documentation for the selected type',
builder: (yargs) => {
Expand All @@ -139,12 +139,16 @@ yargs
type: 'string',
describe:
'metadata type to generate docs for; currently supported: dataExtension, role',
})
.option('format', {
type: 'string',
describe: 'md, html, csv: defaults to md if not specified',
});
},
handler: (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.document(argv.BU, argv.TYPE);
Mcdev.document(argv.BU, argv.TYPE, argv.format);
},
})
.command({
Expand Down
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,10 @@ class Mcdev {
*
* @param {string} businessUnit references credentials from properties.json
* @param {string} type metadata type
* @param {'md'|'html'|'csv'} [format] output format
* @returns {Promise.<void>} -
*/
static async document(businessUnit, type) {
static async document(businessUnit, type, format) {
Util.logger.info('mcdev:: Document');
const properties = await config.getProperties();
if (!(await config.checkProperties(properties))) {
Expand All @@ -353,7 +354,7 @@ class Mcdev {
if (buObject !== null) {
MetadataTypeInfo[type].properties = properties;
MetadataTypeInfo[type].buObject = buObject;
MetadataTypeInfo[type].document();
MetadataTypeInfo[type].document(null, null, format);
}
} catch (ex) {
Util.logger.error('mcdev.document ' + ex.message);
Expand Down
3 changes: 2 additions & 1 deletion lib/metadataTypes/MetadataType.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,9 +1572,10 @@ class MetadataType {
*
* @param {TYPE.MetadataTypeMap} [metadata] a list of type definitions
* @param {boolean} [isDeploy] used to skip non-supported message during deploy
* @param {'md'|'html'|'csv'} [format] output format
* @returns {void}
*/
static document(metadata, isDeploy) {
static document(metadata, isDeploy, format) {
if (!isDeploy) {
Util.logger.error(`Documenting type ${this.definition.type} is not supported.`);
}
Expand Down

0 comments on commit 37ef034

Please sign in to comment.