Skip to content

Commit 7359c61

Browse files
committed
code: Report Python interpreter version in sphinx process tree
1 parent 87077c2 commit 7359c61

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

code/changes/1075.enhancement.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The Python interpreter version is now included in the Sphinx process tree.

code/src/node/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export interface ClientCreatedNotification {
6666
*/
6767
config: SphinxClientConfig
6868

69+
/**
70+
* The client process id
71+
*/
72+
pid: number
6973
}
7074

7175
/**
@@ -105,6 +109,11 @@ export interface SphinxInfo {
105109
*/
106110
version: string
107111

112+
/**
113+
* The version of Python Sphinx is running under
114+
*/
115+
python: string
116+
108117
/**
109118
* The Sphinx application object's confdir
110119
*/

code/src/node/processTreeView.ts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
9999
collapsibleState: vscode.TreeItemCollapsibleState.None
100100
}
101101

102-
case 'python':
102+
case 'pythonCommand':
103103
let pyCmd: string[] = []
104104
element.command?.command.forEach(c => pyCmd.push(`- ${c}`))
105105

@@ -109,6 +109,16 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
109109
tooltip: new vscode.MarkdownString(`**Python Command**\n ${pyCmd.join('\n ')}`),
110110
resourceUri: vscode.Uri.parse('file:///test.py'), // Needed to pull in the icon for Python
111111
contextValue: element.kind,
112+
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed
113+
}
114+
115+
case 'python':
116+
return {
117+
label: `Python v${element.version}`,
118+
iconPath: vscode.ThemeIcon.File,
119+
tooltip: '',
120+
resourceUri: vscode.Uri.parse('file:///test.py'), // Needed to pull in the icon for Python
121+
contextValue: element.kind,
112122
collapsibleState: vscode.TreeItemCollapsibleState.None
113123
}
114124

@@ -169,8 +179,8 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
169179
break
170180
}
171181

172-
let pythonNode: PythonCommandNode = { kind: 'python', command: client.config.pythonCommand }
173-
result.push(pythonNode)
182+
let pythonCmdNode: PythonCommandNode = { kind: 'pythonCommand', command: client.config.pythonCommand, python: client.app?.python }
183+
result.push(pythonCmdNode)
174184

175185
let commandNode: SphinxCommandNode = { kind: 'sphinxCommand', command: client.config.buildCommand }
176186
result.push(commandNode)
@@ -205,9 +215,13 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
205215
}
206216
break
207217

218+
case 'pythonCommand':
219+
let pythonNode: PythonNode = { kind: 'python', version: element.python }
220+
result.push(pythonNode)
221+
break
222+
208223
// The following node types have no children
209224
case 'sphinxCommand':
210-
case 'python':
211225
case 'file':
212226
}
213227

@@ -220,7 +234,7 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
220234
* @param params Information about the newly created client.
221235
*/
222236
private clientCreated(params: ClientCreatedNotification) {
223-
this.logger.debug(`sphinx/clientCreated: ${JSON.stringify(params.config, undefined, 2)}`)
237+
this.logger.debug(`sphinx/clientCreated[${params.pid}]: ${JSON.stringify(params.config, undefined, 2)}`)
224238
this.sphinxClients.set(params.id, new SphinxProcess(params.config))
225239
this._onDidChangeTreeData.fire()
226240
}
@@ -272,14 +286,23 @@ export class SphinxProcessProvider implements vscode.TreeDataProvider<ProcessTre
272286
}
273287
}
274288

275-
type ProcessTreeNode = ProcessContainerNode | SphinxProcessNode | SphinxBuilderNode | SphinxCommandNode | PythonCommandNode | DirNode | FileNode
289+
type ProcessTreeNode = ProcessContainerNode | SphinxProcessNode | SphinxBuilderNode | SphinxCommandNode | PythonNode | PythonCommandNode | DirNode | FileNode
290+
291+
/**
292+
* Represents a Python node
293+
*/
294+
interface PythonNode {
295+
kind: 'python'
296+
version: string | undefined
297+
}
276298

277299
/**
278300
* Represents a Python command
279301
*/
280302
interface PythonCommandNode {
281-
kind: 'python'
303+
kind: 'pythonCommand'
282304
command: PythonCommand | undefined
305+
python: string | undefined
283306
}
284307

285308
/**

0 commit comments

Comments
 (0)