Skip to content

Commit c83e8fb

Browse files
author
minjk-bl
committed
Add helpviewer to include import codes
1 parent 64585de commit c83e8fb

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

visualpython/js/com/component/HelpViewer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,18 @@ define([
167167
return sbSelector.toString();
168168
}
169169

170-
open(content, useHelp=true) {
170+
open(content, useHelp=true, importCode='') {
171171
this.show();
172172

173173
let that = this;
174174

175175
let code = content;
176176
if (useHelp === true) {
177-
code = `print(help(${content}))`;
177+
if (importCode !== '') {
178+
code = importCode + '\n' + `print(help(${content}))`;
179+
} else {
180+
code = `print(help(${content}))`;
181+
}
178182
}
179183

180184
let loadingSpinner = new LoadingSpinner($(this.wrapSelector('.vp-popup-body')));

visualpython/js/com/component/PopupComponent.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ define([
122122
checkModules: [], // module aliases or function names
123123
docs: 'https://visual-python.gitbook.io/docs/getting-started/welcome-to-visual-python',
124124
helpInfo: {
125-
content: '', // method to show using help() ex) pd.DataFrame
126-
useHelp: true // custom text to show on help viewer
125+
content: '', // method to show using help() ex) pd.DataFrame
126+
useHelp: true, // custom text to show on help viewer
127+
importCode: '' // import code for help
127128
},
128129
...restConfig
129130
};
@@ -1227,7 +1228,7 @@ define([
12271228
openHelpView() {
12281229
this.closeHelpView();
12291230
this.helpViewer = new HelpViewer();
1230-
this.helpViewer.open(this.config.helpInfo.content, this.config.helpInfo.useHelp);
1231+
this.helpViewer.open(this.config.helpInfo.content, this.config.helpInfo.useHelp, this.config.helpInfo.importCode);
12311232
}
12321233

12331234
/**
@@ -1243,11 +1244,13 @@ define([
12431244
* Set HelpViewer content
12441245
* @param {string} content
12451246
* @param {boolean} useHelp
1247+
* @param {string} importCode
12461248
*/
1247-
setHelpContent(content, useHelp=true) {
1249+
setHelpContent(content, useHelp=true, importCode='') {
12481250
this.config.helpInfo = {
12491251
content: content,
1250-
useHelp: useHelp
1252+
useHelp: useHelp,
1253+
importCode: importCode
12511254
};
12521255
}
12531256

0 commit comments

Comments
 (0)