Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: "SFDX: Open Documentation" (on web) #4414

Merged
merged 13 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha! that explains the 26 files...I was like 👀

*/
export const messages = {
command_error_help_text: 'コマンドは次のエラーを返しました。',
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-apex-debugger/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
command_error_help_text: 'Command returned the following error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
session_language_server_error_text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
session_language_server_error_text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
faux_generation_cancelled_text: '疑似クラスの作成がキャンセルされました',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
faux_generation_cancelled_text: 'Faux class generation canceled',
Expand Down
11 changes: 6 additions & 5 deletions packages/salesforcedx-utils-vscode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ export {
SFDX_CORE_CONFIGURATION_NAME,
SFDX_CORE_EXTENSION_NAME
} from './constants';
export { OrgInfo, WorkspaceContextUtil, getLogDirPath } from './context/workspaceContextUtil';
export {
OrgInfo,
WorkspaceContextUtil,
getLogDirPath
} from './context/workspaceContextUtil';
export {
TelemetryService,
TelemetryBuilder,
TelemetryData,
Properties,
Measurements
} from './telemetry/telemetry';
export {
getRelativeProjectPath,
fileExtensionsMatch
} from './helpers';
export { getRelativeProjectPath, fileExtensionsMatch } from './helpers';
export { TraceFlags } from './helpers/traceFlags';
export { TelemetryReporter } from './telemetry/telemetryReporter';
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
sfdx_cli_not_found:
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-utils-vscode/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
sfdx_cli_not_found:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
config_name_text: 'Apex デバッガを起動',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
config_name_text: 'Launch Apex Debugger',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
config_name_text: 'Apex Replay Debugger を起動',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
config_name_text: 'Launch Apex Replay Debugger',
Expand All @@ -22,7 +22,7 @@ export const messages = {
up_to_five_checkpoints:
'You have %s of the maximum 5 enabled checkpoints. Remove or disable checkpoints until 5 or fewer are active.',
no_enabled_checkpoints:
'You don\'t have any checkpoints enabled. Enable a checkpoint and try again.',
"You don't have any checkpoints enabled. Enable a checkpoint and try again.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was auto-made when I saved.

checkpoints_can_only_be_on_valid_apex_source:
'Checkpoints can be set on a valid line of Apex source. Invalid checkpoint location: URI=%s, Line=%s',
local_source_is_out_of_sync_with_the_server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
apex_execute_compile_success: '正常にコンパイルされました。',
Expand Down
8 changes: 8 additions & 0 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@
"command": "sfdx.force.auth.logout.default",
"when": "sfdx:project_opened && sfdx:has_default_username"
},
{
"command": "sfdx.force.open.documentation",
"when": "sfdx:project_opened"
},
{
"command": "sfdx.force.org.create",
"when": "sfdx:project_opened"
Expand Down Expand Up @@ -643,6 +647,10 @@
"command": "sfdx.force.auth.logout.default",
"title": "%force_auth_logout_default_text%"
},
{
"command": "sfdx.force.open.documentation",
"title": "%force_open_documentation_text%"
},
{
"command": "sfdx.force.org.create",
"title": "%force_org_create_default_scratch_org_text%"
Expand Down
1 change: 1 addition & 0 deletions packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"force_auth_access_token_authorize_org_text": "SFDX: Authorize an Org using Session ID",
"force_auth_logout_all_text": "SFDX: Log Out from All Authorized Orgs",
"force_auth_logout_default_text": "SFDX: Log Out from Default Org",
"force_open_documentation_text": "SFDX: Open Documentation",
"force_org_create_default_scratch_org_text": "SFDX: Create a Default Scratch Org...",
"force_org_open_default_scratch_org_text": "SFDX: Open Default Org",
"force_source_pull_default_scratch_org_text": "SFDX: Pull Source from Default Scratch Org",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as path from 'path';
import * as vscode from 'vscode';
import {
APEX_CLASSES_PATH,
APEX_FILE_NAME_EXTENSION,
AURA_PATH,
FUNCTIONS_PATH,
LWC_PATH,
SOQL_FILE_NAME_EXTENSION
} from '../constants';
import { nls } from '../messages';

export async function forceOpenDocumentation() {
let docUrl = '';
const editor = vscode.window.activeTextEditor;
if (editor) {
const filePath = editor.document.fileName;
const extension = path.extname(filePath);

if (filePath.includes(AURA_PATH)) {
docUrl = nls.localize('aura_doc_url');
} else if (
filePath.includes(APEX_CLASSES_PATH) ||
extension === APEX_FILE_NAME_EXTENSION
) {
docUrl = nls.localize('apex_doc_url');
} else if (extension === SOQL_FILE_NAME_EXTENSION) {
docUrl = nls.localize('soql_doc_url');
} else if (filePath.includes(LWC_PATH)) {
docUrl = nls.localize('lwc_doc_url');
} else if (filePath.includes(FUNCTIONS_PATH)) {
docUrl = nls.localize('functions_doc_url');
}
}

if (docUrl === '') {
docUrl = nls.localize('default_doc_url');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job handling the case where it doesn't get an active editor.


await vscode.env.openExternal(vscode.Uri.parse(docUrl));
}
1 change: 1 addition & 0 deletions packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export {
ForceAuthDevHubContainerExecutor
} from './auth/forceAuthDevHub';
export { forceDataSoqlQuery } from './forceDataSoqlQuery';
export { forceOpenDocumentation } from './forceOpenDocumentation';
export {
forceOrgCreate,
AliasGatherer,
Expand Down
6 changes: 6 additions & 0 deletions packages/salesforcedx-vscode-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ export const CLI = {
AUTH_DEVICE_LOGIN: 'force:auth:device:login',
AUTH_WEB_LOGIN: 'force:auth:web:login'
};
export const APEX_FILE_NAME_EXTENSION = '.apex';
export const SOQL_FILE_NAME_EXTENSION = '.soql';
export const AURA_PATH = '/force-app/main/default/aura/';
export const APEX_CLASSES_PATH = '/force-app/main/default/classes/';
export const LWC_PATH = '/force-app/main/default/lwc/';
export const FUNCTIONS_PATH = '/functions/';
6 changes: 6 additions & 0 deletions packages/salesforcedx-vscode-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
forceLightningInterfaceCreate,
forceLightningLwcCreate,
forceLightningLwcTestCreate,
forceOpenDocumentation,
forceOrgCreate,
forceOrgDelete,
forceOrgDisplay,
Expand Down Expand Up @@ -149,6 +150,10 @@ function registerCommands(
'sfdx.force.auth.logout.default',
forceAuthLogoutDefault
);
const forceOpenDocumentationCmd = vscode.commands.registerCommand(
'sfdx.force.open.documentation',
forceOpenDocumentation
);
const forceOrgCreateCmd = vscode.commands.registerCommand(
'sfdx.force.org.create',
forceOrgCreate
Expand Down Expand Up @@ -447,6 +452,7 @@ function registerCommands(
forceFunctionStartCmd,
forceFunctionContainerStartCmd,
forceFunctionStopCmd,
forceOpenDocumentationCmd,
forceOrgCreateCmd,
forceOrgOpenCmd,
forceOrgDeleteDefaultCmd,
Expand Down
12 changes: 10 additions & 2 deletions packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not
* be localized
*
* If ommitted, we will assume _message.
* If omitted, we will assume _message.
*/
export const messages = {
channel_name: 'Salesforce CLI',
Expand Down Expand Up @@ -516,5 +516,13 @@ export const messages = {
force_source_diff_title: '%s//%s ↔ ローカル //%s',
package_id_validation_error:
'Package ID should be a 15 or 18 character Id that starts with 04t',
package_id_gatherer_placeholder: '04t...'
package_id_gatherer_placeholder: '04t...',
aura_doc_url: 'https://developer.salesforce.com/tools/vscode/ja/aura/writing',
apex_doc_url: 'https://developer.salesforce.com/tools/vscode/ja/apex/writing',
soql_doc_url:
'https://developer.salesforce.com/tools/vscode/ja/soql/soql-builder',
lwc_doc_url: 'https://developer.salesforce.com/tools/vscode/ja/lwc/writing',
functions_doc_url:
'https://developer.salesforce.com/tools/vscode/ja/functions/overview',
default_doc_url: 'https://developer.salesforce.com/tools/vscode/ja'
};
10 changes: 9 additions & 1 deletion packages/salesforcedx-vscode-core/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,5 +650,13 @@ export const messages = {
pending_org_expiration_notification_message:
'Warning: One or more of your orgs expire in the next %s days. For more details, review the Output panel.',
pending_org_expiration_output_channel_message:
'Warning: The following orgs expire in the next %s days:\n\n%s\n\nIf these orgs contain critical data or settings, back them up before the org expires.'
'Warning: The following orgs expire in the next %s days:\n\n%s\n\nIf these orgs contain critical data or settings, back them up before the org expires.',
aura_doc_url: 'https://developer.salesforce.com/tools/vscode/en/aura/writing',
apex_doc_url: 'https://developer.salesforce.com/tools/vscode/en/apex/writing',
soql_doc_url:
'https://developer.salesforce.com/tools/vscode/en/soql/soql-builder',
lwc_doc_url: 'https://developer.salesforce.com/tools/vscode/en/lwc/writing',
functions_doc_url:
'https://developer.salesforce.com/tools/vscode/en/functions/overview',
default_doc_url: 'https://developer.salesforce.com/tools/vscode'
};
Loading