Skip to content

Commit 09f3d04

Browse files
committed
Generate documentation for only one cmdlet
1 parent aae7976 commit 09f3d04

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

tools/office-cmdlet-updater/controllers/cli.controller.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ class CliController {
2323

2424
this.cliServoce.addOption({
2525
option: '-c --cmdlet <cmdet>',
26-
description: 'update documentation for cmdlet in module'
26+
description: 'update documentation for cmdlet in module',
27+
action: (cli) => {
28+
const { module, cmdlet } = cli;
29+
30+
if (module === 'all' && cmdlet) {
31+
throw new Error('You must specify a module for cmdet.');
32+
}
33+
}
2734
});
2835

2936
this.cliServoce.start(argv, async (cli) => {
3037
const { module, cmdlet } = cli;
3138

32-
this.markdownController.updateMarkdown({ moduleName: module });
39+
this.markdownController.updateMarkdown({
40+
moduleName: module,
41+
cmdlet
42+
});
3343
console.log(module);
3444
console.log(cmdlet);
3545
});

tools/office-cmdlet-updater/controllers/markdown.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MarkdownController {
1919
throw new Error(powerShellErrors.DOC_PATH_DOESNT_EXIST);
2020
}
2121

22-
[, err] = await of(this.markdownService.updateMd(doc));
22+
[, err] = await of(this.markdownService.updateMd(doc, cmdlet));
2323

2424
if (err) {
2525
this.powerShellService.dispose();

tools/office-cmdlet-updater/services/markdown.service.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ class MarkdownService {
3131
this.installedDependencies = [];
3232
}
3333

34-
async updateMd(doc) {
35-
return this.addMdFilesInQueue(doc);
34+
async updateMd(doc, cmdlet) {
35+
return this.addMdFilesInQueue(doc, cmdlet);
3636
}
3737

38-
async addMdFilesInQueue(doc) {
39-
const mdFiles = await this.fsService.getModuleFiles(doc);
38+
async addMdFilesInQueue(doc, cmdlet) {
39+
const mdFiles = (await this.fsService.getModuleFiles(doc)).filter(
40+
(file) => this._filterCmdlets(file, cmdlet)
41+
);
4042

4143
mdFiles.forEach((file) => {
4244
this.queue
@@ -46,6 +48,16 @@ class MarkdownService {
4648
});
4749
}
4850

51+
_filterCmdlets(mdPath, cmdletName) {
52+
if (!cmdletName) {
53+
return true;
54+
}
55+
56+
const mdExt = '.md';
57+
58+
return mdPath.endsWith(`${cmdletName}${mdExt}`);
59+
}
60+
4961
async processQueue({ file, doc }, cb) {
5062
let result, err;
5163

0 commit comments

Comments
 (0)