Skip to content

Commit

Permalink
Flow doc & flow diff commands (#188)
Browse files Browse the repository at this point in the history
* Flow doc & flow diff commands

* [Mega-Linter] Apply linters fixes

* documentation menu

* Add commands with history

* Doc Gen + changelog

* cspell

* [Mega-Linter] Apply linters fixes

---------

Co-authored-by: nvuillam <nvuillam@users.noreply.github.com>
  • Loading branch information
nvuillam and nvuillam authored Jan 3, 2025
1 parent 07a1f68 commit 54e93ee
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/linters/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"minimumapiversion",
"missingattributes",
"mkdir",
"mkdocs",
"multiselect",
"myfolder",
"nogit",
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## [Unreleased]

- Add your updates here :)

## [5.5.0] 2024-01-03

- New Documentation menu section
- [Generate SF project documentation](https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/) (including Visual Flows)
- New command to [**Generate Flow Markdown Documentation**](https://sfdx-hardis.cloudity.com/hardis/doc/flow2markdown/)
- New command to [**Generate Flow Visual Git Diff**](https://sfdx-hardis.cloudity.com/hardis/project/generate/flow-git-diff/)
- New command to run local Web Server with Documentation HTML pages

## [5.4.0] 2024-12-16

- Add context menu to Generate Package.xml documentation
Expand Down
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@
"title": "SFDX Hardis: Generate package.xml Documentation",
"icon": "$(book)"
},
{
"command": "vscode-sfdx-hardis.generateFlowDocumentation",
"title": "SFDX Hardis: Generate Flow Documentation",
"icon": "$(book)"
},
{
"command": "vscode-sfdx-hardis.flowVisualGitDiff",
"title": "SFDX Hardis: Flow Visual Git Diff",
"icon": "$(diff)"
},
{
"command": "vscode-sfdx-hardis.openExternal",
"title": "SFDX Hardis: Open external url",
Expand Down Expand Up @@ -266,6 +276,16 @@
"command": "vscode-sfdx-hardis.generatePackageXmlDoc",
"when": "resourceExtname == '.xml'",
"group": "z_sfdxhardis@10"
},
{
"command": "vscode-sfdx-hardis.generateFlowDocumentation",
"when": "resourceExtname == '.xml'",
"group": "z_sfdxhardis@15"
},
{
"command": "vscode-sfdx-hardis.flowVisualGitDiff",
"when": "resourceExtname == '.xml'",
"group": "z_sfdxhardis@20"
}
],
"view/title": [
Expand Down Expand Up @@ -335,6 +355,16 @@
"command": "vscode-sfdx-hardis.generatePackageXmlDoc",
"when": "resourceExtname == '.xml'",
"group": "z_sfdxhardis@10"
},
{
"command": "vscode-sfdx-hardis.generateFlowDocumentation",
"when": "resourceExtname == '.xml'",
"group": "z_sfdxhardis@15"
},
{
"command": "vscode-sfdx-hardis.flowVisualGitDiff",
"when": "resourceExtname == '.xml'",
"group": "z_sfdxhardis@20"
}
],
"view/item/context": [
Expand Down
48 changes: 48 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class Commands {
this.registerSelectExtensionTheme();
this.registerSimulateDeployment();
this.registerGeneratePackageXmlDoc();
this.registerGenerateFlowDocumentation();
this.registerGenerateFlowVisualGitDiff();
}

getLatestTerminal() {
Expand Down Expand Up @@ -451,6 +453,52 @@ export class Commands {
this.disposables.push(disposable);
}

registerGenerateFlowDocumentation() {
// Open external command
const disposable = vscode.commands.registerCommand(
"vscode-sfdx-hardis.generateFlowDocumentation",
async (uri: vscode.Uri) => {
const relativePath = vscode.workspace.asRelativePath(uri);
if (!relativePath.endsWith(".flow-meta.xml")) {
vscode.window.showWarningMessage(
"This command only works with Flow files :)",
);
return;
}
const command = `sf hardis:doc:flow2markdown --inputfile "${relativePath}"`;
vscode.commands.executeCommand(
"vscode-sfdx-hardis.execute-command",
command,
);
},
);
this.disposables.push(disposable);
}

/* jscpd:ignore-start */
registerGenerateFlowVisualGitDiff() {
// Open external command
const disposable = vscode.commands.registerCommand(
"vscode-sfdx-hardis.flowVisualGitDiff",
async (uri: vscode.Uri) => {
const relativePath = vscode.workspace.asRelativePath(uri);
if (!relativePath.endsWith(".flow-meta.xml")) {
vscode.window.showWarningMessage(
"This command only works with Flow files :)",
);
return;
}
const command = `sf hardis:project:generate:flow-git-diff --flow "${relativePath}"`;
vscode.commands.executeCommand(
"vscode-sfdx-hardis.execute-command",
command,
);
},
);
this.disposables.push(disposable);
}
/* jscpd:ignore-end */

registerOpenKeyFile() {
// Open key file command
vscode.commands.registerCommand(
Expand Down
75 changes: 65 additions & 10 deletions src/hardis-commands-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,6 @@ export class HardisCommandsProvider
requiresProject: true,
helpUrl: "https://sfdx-hardis.cloudity.com/hardis/org/test/apex/",
},
{
id: "hardis:doc:project2markdown",
label: "Generate Project Documentation",
command: "sf hardis:doc:project2markdown",
tooltip:
"Generates markdown pages with SF Project content: List of metadatas, installed packages...",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/",
},
{
id: "hardis:org:monitor:limits",
label: "Check Org Limits",
Expand Down Expand Up @@ -759,6 +749,71 @@ export class HardisCommandsProvider
},
],
},
{
id: "doc",
label: "Documentation Generation",
commands: [
{
id: "hardis:doc:project2markdown",
label: "Generate Project Documentation",
command: "sf hardis:doc:project2markdown",
tooltip:
"Generates markdown pages with SF Project content: List of metadatas, installed packages...",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/",
},
{
id: "hardis:doc:project2markdown-history",
label: "Generate Project Documentation (with history)",
command: "sf hardis:doc:project2markdown --with-history",
tooltip:
"Generates markdown pages with SF Project content: List of metadatas, installed packages..., with Flow Diff History",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/",
},
{
id: "hardis:doc:flow2markdown",
label: "Generate Flow Documentation",
command: "sf hardis:doc:flow2markdown",
tooltip: "Generates Visual Documentation for a Flow",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/hardis/doc/flow2markdown/",
},
{
id: "hardis-run-doc",
label: "Run Local HTML Doc Pages",
command:
"pip install mkdocs-material mdx_truly_sane_lists && mkdocs serve",
tooltip:
"Run Documentation local web server, then open http://127.0.0.1:8000/",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/salesforce-project-documentation/",
},
{
id: "hardis:doc:flow2markdown-history",
label: "Generate Flow Documentation (with history)",
command: "sf hardis:doc:flow2markdown --with-history",
tooltip: "Generates Visual Documentation for a Flow",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/hardis/doc/flow2markdown/",
},
{
id: "hardis:project:generate:flow-git-diff",
label: "Generate Flow Visual Git Diff",
command: "sf hardis:project:generate:flow-git-diff",
tooltip:
"Generates Visual Documentation of the differences between versions of a Flow",
requiresProject: true,
helpUrl:
"https://sfdx-hardis.cloudity.com/hardis/project/generate/flow-git-diff/",
},
],
},
{
id: "nerdy-stuff",
label: "Nerdy stuff",
Expand Down
5 changes: 5 additions & 0 deletions src/hardis-websocket-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export class LocalWebSocketServer {
);
vscode.workspace.openTextDocument(openPath).then((doc) => {
vscode.window.showTextDocument(doc);
if (data.file.endsWith(".md")) {
new Promise((resolve) => setTimeout(resolve, 500)).then(() => {
vscode.commands.executeCommand("markdown.showPreview", doc);
});
}
});
}
// Request user input
Expand Down
13 changes: 13 additions & 0 deletions src/themeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ export class ThemeUtils {
hardis: "old.svg",
},
"hardis:doc:project2markdown": { vscode: "book", hardis: "doc.svg" },
"hardis:doc:project2markdown-history": {
vscode: "book",
hardis: "doc.svg",
},
"hardis:doc:flow2markdown": { vscode: "git-branch", hardis: "doc.svg" },
"hardis:doc:flow2markdown-history": {
vscode: "git-branch",
hardis: "doc.svg",
},
"hardis:project:generate:flow-git-diff": {
vscode: "diff",
hardis: "doc.svg",
},
"hardis:org:monitor:limits": { vscode: "eye-watch", hardis: "gauge.svg" },
"org:diagnose:legacyapi": { vscode: "watch", hardis: "old.svg" },
"hardis:org:diagnose:unusedusers": {
Expand Down

0 comments on commit 54e93ee

Please sign in to comment.