Skip to content

Repository files navigation

Python docstring highlighter for VSCode

Markdown syntax highlighting inside Python docstrings.

The extension recognizes actual line-leading Python docstring statements while leaving assigned and embedded triple-quoted strings alone.

Highlights

  • Headings, emphasis, links, lists, blockquotes, inline code, tables, and the other syntax supported by VS Code's built-in Markdown grammar.
  • Fenced code blocks with an explicit language, such as python, javascript, typescript, json, yaml, sql, shell, rust, and the other languages recognized by VS Code Markdown.
  • Parser-backed Python detection for unlabelled fenced and indented code blocks.
  • Syntactically valid Python—including formulas that are valid Python expressions—uses Python highlighting; rejected blocks use the theme's normal editor foreground.
  • Unformatted prose retains the active theme's Python docstring/string color.
  • Triple-quoted and single-line docstrings, raw docstrings, module docstrings, and conventionally indented nested definitions.

Install for local use

  1. Install dependencies with npm install.
  2. Build and test with npm run build && npm test.
  3. Create a VSIX with npm run package.
  4. In VS Code, run Extensions: Install from VSIX... and select the generated file.

For development, run npm run build, open this directory in VS Code, and press F5. Rebuild after changing the extension runtime or grammar generator.

Publish to the VS Code Marketplace

  1. Install the locked dependencies with npm ci.
  2. Run the checks with npm test.
  3. Build the release VSIX with npm run package. The pre-publish script rebuilds the grammar, extension bundle, and parser assets before packaging.
  4. Open Visual Studio Marketplace publisher management and select the publisher account.
  5. Choose New Extension → Visual Studio Code, then upload the generated docstring-highlighter-python-<version>.vsix file.

Before packaging a later release, update both manifest versions without creating a Git tag automatically:

npm version patch --no-git-tag-version

Notes

  • Markdown is enabled only for strings that begin a Python statement. An assigned value such as template = """...""" remains an ordinary string.
  • Conventional four-space indentation and tabs are handled exactly through 12 nesting levels. Unusual indentation uses a best-effort baseline inferred from the first non-empty content line.
  • An unlabelled fenced or indented block is parsed as a complete Python snippet. A syntax-error-free parse receives Python highlighting; otherwise the block uses the normal editor foreground without language highlighting. Explicit fence labels continue to select their corresponding installed grammar directly.

Use Developer: Inspect Editor Tokens and Scopes to inspect a token. Extension-specific scopes start with meta.docstring.docstring-highlighter-python; detected Python code uses meta.embedded.block.python.docstring-highlighter-python, while plain code uses meta.embedded.block.plaintext.docstring-highlighter-python.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages