Skip to content

Fred-Wu/vscode-python-help-viewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Help Viewer

A dedicated Help panel for Python in VS Code.

Inspired by the VSCode-R “Help” experience: type a help query and read docs in a separate viewer.

Type Python help syntax like help(x), ?x, or x? and get a dedicated, searchable documentation panel with navigation, safe links, runtime docs (NumPy/PyTorch-style), and math rendering.

Highlights

  • Help panel in the editor area (webview), separate from your code.
  • Works in Python files and Jupyter notebooks.
  • Supports both documentation sources:
    • Hover-based help (Pylance hover markdown)
    • Runtime help (pydoc.render_doc) for richer library docs
  • Internal navigation for doc cross-references (stays inside the help panel).
  • Back / Forward history + Find in help.
  • Safe external links: external URLs require confirmation.
  • Session cache (bounded + optional TTL) so repeated lookups are instant.
  • Theme-aware styling + configurable help panel font size.
  • Math rendering for LaTeX-style snippets (KaTeX), e.g. \sqrt{}, \frac{}{}, H_\text{in}.

Requirements

  • VS Code with the Python ecosystem enabled.
  • For hover help, you’ll typically want Pylance installed and active.
  • For runtime help, you need a Python interpreter selected (and the target libraries installed in that interpreter).

How to use

Quick usage

  1. Open a Python file (.py) or a notebook cell.
  2. Use any of these patterns (common in scientific Python workflows):
    • help(symbol)
    • ?symbol / ??symbol
    • symbol? / symbol??
  3. The extension will show a CodeLens (“Open Help Panel”) and (optionally) auto-open the help panel.

Help for symbol at cursor

Use the command:

  • Python Help: Open Help for Symbol at Cursor (Ctrl+Alt+H)

This works even without typing help syntax.

Runtime help vs hover help

Many libraries have significantly richer docs via runtime help than via hover. This extension can launch your configured interpreter and run pydoc.render_doc(...) to fetch that richer output.

Setting:

  • pythonHelp.helpSource: preferRuntime (default) | runtime | hover

Notes:

  • Runtime help uses the Python interpreter configured in VS Code (typically via the Python extension settings).
  • Runtime help may import modules based on your file’s imports (best-effort) to resolve symbols like np.array.

Notebooks: runtime help can’t see live kernel variables

Runtime help is executed in a separate Python subprocess (so it can run pydoc.render_doc(...)). That subprocess cannot access variables created in earlier notebook cells (your live kernel state).

Example:

  • Cell 1:
    • import numpy as np
    • a = np.arange(10)
  • Cell 2:
    • a.argmax?

In a notebook, the runtime subprocess does not know what a is. To keep the UX close to notebook-style help, the extension will:

  • Use hover/type info to infer the type of a (e.g. numpy.ndarray).
  • Retry runtime help for an importable target (e.g. numpy.ndarray.argmax).

When that inferred mapping is used, the help panel shows a small note explaining what it inferred.

If you want the most “kernel-accurate” behavior for dynamic values, set pythonHelp.helpSource to hover.

Navigation and search

When the help panel is focused, you can:

  • Go Back: Alt+Left
  • Go Forward: Alt+Right
  • Find in help: Ctrl+F

You can also use the editor titlebar buttons on the help panel (Back/Forward/Search).

Commands

  • pythonHelp.showHelp — Open Help Panel (used by CodeLens)
  • pythonHelp.showHelpAtCursor — Open help for symbol at cursor
  • pythonHelp.navBack — Back
  • pythonHelp.navForward — Forward
  • pythonHelp.searchInPanel — Find in help panel
  • pythonHelp.clearCache — Clear in-memory help cache

Settings

  • pythonHelp.helpSource:
    • preferRuntime (default)
    • runtime
    • hover
  • pythonHelp.autoOpenOnHelpSyntax (default: false): auto-open/update when you finish typing help(x), ?x, x?
  • pythonHelp.fontSize (default: 0): help panel font size in px (0 = use VS Code defaults)
  • pythonHelp.cache.enabled (default: true)
  • pythonHelp.cache.maxEntries (default: 200)
  • pythonHelp.cache.ttlSeconds (default: 0, meaning no expiry until reload)

Runtime-only settings:

  • pythonHelp.runtime.extraEnv (default: {})
  • pythonHelp.runtime.trace (default: false): logs when the extension spawns a runtime-help Python subprocess

pythonHelp.runtime.extraEnv

pythonHelp.runtime.extraEnv is an optional map of environment variables that are applied only to the Python subprocess used for runtime help (the process that runs pydoc.render_doc(...)).

Use this when runtime help fails to import/resolve symbols unless certain environment variables are set (for example: custom PYTHONPATH or library-specific knobs).

Notes:

  • These variables affect runtime help only. They do not affect hover help (Pylance) and do not change your notebook kernel state.
  • Values are treated as strings.
  • The extension does not expand/interpolate placeholders like ${env:PATH} inside this setting. If you need to append to PATH, include the full desired value.

Example: add a project folder to PYTHONPATH so the runtime-help subprocess can import it:

{
  "pythonHelp.runtime.extraEnv": {
    "PYTHONPATH": "C:\\my\\repo"
  }
}

Security & privacy

  • The help panel intercepts clicks and uses internal navigation for symbol references.
  • Any external URL requires explicit confirmation before opening.
  • The extension does not send your code or documentation text to any remote service.

Development note

This extension’s source code was written with assistance from GitHub Copilot (GPT-5.2). The overall feature design and logic decisions are mine; Copilot was used to generate and iterate on the implementation.

Troubleshooting

  • If runtime help keeps falling back to hover:
    • Make sure you’ve selected the correct interpreter (Command Palette → Python: Select Interpreter), and that the library is installed in that environment.
    • In notebooks, also try selecting a notebook kernel.
  • If hover help is empty:
    • Ensure Pylance is installed/enabled for the current workspace.

About

A dedicated Help panel for Python in VS Code

Resources

License

Stars

Watchers

Forks

Releases

No releases published