Skip to content

Commit 952cb05

Browse files
committed
docs: add @remarks JSDoc sections to EnvironmentManager interface methods (Refs #378)
1 parent 4e46444 commit 952cb05

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

pythonEnvironmentsApi/src/main.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,27 +396,46 @@ export interface EnvironmentManager {
396396
* @param scope - The scope within which to create the environment.
397397
* @param options - Optional parameters for creating the Python environment.
398398
* @returns A promise that resolves to the created Python environment, or undefined if creation failed.
399+
*
400+
* @remarks
401+
* Called when the user:
402+
* - Runs the "Python: Create Environment" command (which prompts for a manager to use).
403+
* - Clicks the "+" button on an environment manager in the Python Environments view.
404+
* - Creates a new environment as part of the new Python package project creation wizard.
399405
*/
400406
create?(scope: CreateEnvironmentScope, options?: CreateEnvironmentOptions): Promise<PythonEnvironment | undefined>;
401407

402408
/**
403409
* Removes the specified Python environment.
404410
* @param environment - The Python environment to remove.
405411
* @returns A promise that resolves when the environment is removed.
412+
*
413+
* @remarks
414+
* Called when the user right-clicks an environment in the Python Environments tree view and selects
415+
* "Delete Environment".
406416
*/
407417
remove?(environment: PythonEnvironment): Promise<void>;
408418

409419
/**
410420
* Refreshes the list of Python environments within the specified scope.
411421
* @param scope - The scope within which to refresh environments.
412422
* @returns A promise that resolves when the refresh is complete.
423+
*
424+
* @remarks
425+
* Called when the user clicks the refresh button in the Python Environments view title bar.
413426
*/
414427
refresh(scope: RefreshEnvironmentsScope): Promise<void>;
415428

416429
/**
417430
* Retrieves a list of Python environments within the specified scope.
418431
* @param scope - The scope within which to retrieve environments.
419432
* @returns A promise that resolves to an array of Python environments.
433+
*
434+
* @remarks
435+
* Called when:
436+
* - The user expands an environment manager node in the Python Environments tree view.
437+
* - The user opens the environment picker to select an interpreter.
438+
* - Internally after {@link EnvironmentManager.refresh} completes, to count discovered environments.
420439
*/
421440
getEnvironments(scope: GetEnvironmentsScope): Promise<PythonEnvironment[]>;
422441

@@ -430,13 +449,30 @@ export interface EnvironmentManager {
430449
* @param scope - The scope within which to set the environment.
431450
* @param environment - The Python environment to set. If undefined, the environment is unset.
432451
* @returns A promise that resolves when the environment is set.
452+
*
453+
* @remarks
454+
* Called when the user:
455+
* - Selects an environment in the environment picker or clicks the checkmark button in the tree view.
456+
* - Creates a new environment and the extension auto-selects it.
457+
*
458+
* Also called at extension startup during initial environment selection to cache the active
459+
* environment, and when a Python project is removed (with `environment` set to `undefined`).
433460
*/
434461
set(scope: SetEnvironmentScope, environment?: PythonEnvironment): Promise<void>;
435462

436463
/**
437464
* Retrieves the current Python environment within the specified scope.
438465
* @param scope - The scope within which to retrieve the environment.
439466
* @returns A promise that resolves to the current Python environment, or undefined if none is set.
467+
*
468+
* @remarks
469+
* Called when:
470+
* - The extension starts up, during initial environment selection for each workspace folder and global scope.
471+
* - After {@link EnvironmentManager.set}, to confirm the new active environment and fire change events.
472+
* - A terminal is opened or a command is run, to determine which Python environment to activate.
473+
* - The user runs a Python file ("Run in Terminal", "Run as Task"), to get the interpreter.
474+
* - The environment picker needs to display the currently selected (recommended) environment.
475+
* - Auto-discovery checks if a local venv already exists for a workspace folder.
440476
*/
441477
get(scope: GetEnvironmentScope): Promise<PythonEnvironment | undefined>;
442478

@@ -456,13 +492,22 @@ export interface EnvironmentManager {
456492
*
457493
* @param context - The context for resolving the environment, which can be a {@link PythonEnvironment} or a {@link Uri}.
458494
* @returns A promise that resolves to the fully detailed {@link PythonEnvironment}, or `undefined` if the environment cannot be resolved.
495+
*
496+
* @remarks
497+
* Called when:
498+
* - The user browses for and selects a Python interpreter path via the file picker.
499+
* - The user has `python.defaultInterpreterPath` configured and the extension resolves it at startup.
500+
* - Before running a Python script ("Run in Terminal", "Run as Task"), to obtain full execution info.
459501
*/
460502
resolve(context: ResolveEnvironmentContext): Promise<PythonEnvironment | undefined>;
461503

462504
/**
463505
* Clears the environment manager's cache.
464506
*
465507
* @returns A promise that resolves when the cache is cleared.
508+
*
509+
* @remarks
510+
* Called when the user runs the "Python: Clear Cache" command from the Command Palette.
466511
*/
467512
clearCache?(): Promise<void>;
468513
}

src/api.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,27 +390,46 @@ export interface EnvironmentManager {
390390
* @param scope - The scope within which to create the environment.
391391
* @param options - Optional parameters for creating the Python environment.
392392
* @returns A promise that resolves to the created Python environment, or undefined if creation failed.
393+
*
394+
* @remarks
395+
* Called when the user:
396+
* - Runs the "Python: Create Environment" command (which prompts for a manager to use).
397+
* - Clicks the "+" button on an environment manager in the Python Environments view.
398+
* - Creates a new environment as part of the new Python package project creation wizard.
393399
*/
394400
create?(scope: CreateEnvironmentScope, options?: CreateEnvironmentOptions): Promise<PythonEnvironment | undefined>;
395401

396402
/**
397403
* Removes the specified Python environment.
398404
* @param environment - The Python environment to remove.
399405
* @returns A promise that resolves when the environment is removed.
406+
*
407+
* @remarks
408+
* Called when the user right-clicks an environment in the Python Environments tree view and selects
409+
* "Delete Environment".
400410
*/
401411
remove?(environment: PythonEnvironment): Promise<void>;
402412

403413
/**
404414
* Refreshes the list of Python environments within the specified scope.
405415
* @param scope - The scope within which to refresh environments.
406416
* @returns A promise that resolves when the refresh is complete.
417+
*
418+
* @remarks
419+
* Called when the user clicks the refresh button in the Python Environments view title bar.
407420
*/
408421
refresh(scope: RefreshEnvironmentsScope): Promise<void>;
409422

410423
/**
411424
* Retrieves a list of Python environments within the specified scope.
412425
* @param scope - The scope within which to retrieve environments.
413426
* @returns A promise that resolves to an array of Python environments.
427+
*
428+
* @remarks
429+
* Called when:
430+
* - The user expands an environment manager node in the Python Environments tree view.
431+
* - The user opens the environment picker to select an interpreter.
432+
* - Internally after {@link EnvironmentManager.refresh} completes, to count discovered environments.
414433
*/
415434
getEnvironments(scope: GetEnvironmentsScope): Promise<PythonEnvironment[]>;
416435

@@ -424,13 +443,30 @@ export interface EnvironmentManager {
424443
* @param scope - The scope within which to set the environment.
425444
* @param environment - The Python environment to set. If undefined, the environment is unset.
426445
* @returns A promise that resolves when the environment is set.
446+
*
447+
* @remarks
448+
* Called when the user:
449+
* - Selects an environment in the environment picker or clicks the checkmark button in the tree view.
450+
* - Creates a new environment and the extension auto-selects it.
451+
*
452+
* Also called at extension startup during initial environment selection to cache the active
453+
* environment, and when a Python project is removed (with `environment` set to `undefined`).
427454
*/
428455
set(scope: SetEnvironmentScope, environment?: PythonEnvironment): Promise<void>;
429456

430457
/**
431458
* Retrieves the current Python environment within the specified scope.
432459
* @param scope - The scope within which to retrieve the environment.
433460
* @returns A promise that resolves to the current Python environment, or undefined if none is set.
461+
*
462+
* @remarks
463+
* Called when:
464+
* - The extension starts up, during initial environment selection for each workspace folder and global scope.
465+
* - After {@link EnvironmentManager.set}, to confirm the new active environment and fire change events.
466+
* - A terminal is opened or a command is run, to determine which Python environment to activate.
467+
* - The user runs a Python file ("Run in Terminal", "Run as Task"), to get the interpreter.
468+
* - The environment picker needs to display the currently selected (recommended) environment.
469+
* - Auto-discovery checks if a local venv already exists for a workspace folder.
434470
*/
435471
get(scope: GetEnvironmentScope): Promise<PythonEnvironment | undefined>;
436472

@@ -450,13 +486,22 @@ export interface EnvironmentManager {
450486
*
451487
* @param context - The context for resolving the environment, which can be a {@link PythonEnvironment} or a {@link Uri}.
452488
* @returns A promise that resolves to the fully detailed {@link PythonEnvironment}, or `undefined` if the environment cannot be resolved.
489+
*
490+
* @remarks
491+
* Called when:
492+
* - The user browses for and selects a Python interpreter path via the file picker.
493+
* - The user has `python.defaultInterpreterPath` configured and the extension resolves it at startup.
494+
* - Before running a Python script ("Run in Terminal", "Run as Task"), to obtain full execution info.
453495
*/
454496
resolve(context: ResolveEnvironmentContext): Promise<PythonEnvironment | undefined>;
455497

456498
/**
457499
* Clears the environment manager's cache.
458500
*
459501
* @returns A promise that resolves when the cache is cleared.
502+
*
503+
* @remarks
504+
* Called when the user runs the "Python: Clear Cache" command from the Command Palette.
460505
*/
461506
clearCache?(): Promise<void>;
462507
}

0 commit comments

Comments
 (0)