Docstring Generator & Python Docstring Updater (Google, NumPy, Sphinx, JSDoc)

Docstring Generator & Python Docstring Updater (Google, NumPy, Sphinx, JSDoc), a VS Code extension by Zovo

Free docstring generator for Python: type """ under a def or class and press Enter. Google, NumPy, Sphinx (reST) and Epytext styles or your own template, filled from the signature: type hints, defaults, *args, **kwargs, positional-only and keyword-only parameters, return type, yield, raise, dataclass fields and __init__ arguments. Updates a python docstring when the signature changes and keeps your text. JSDoc with TypeScript types for JS and TS. No sign-in, works offline.

Install in VS CodeOpen the Marketplace page

Free, MIT license. Needs VS Code 1.90.0 or newer. Extension ID zovo.zovo-docstring-generator, version 0.2.1.

Left: three quotes typed under a def with positional-only, keyword-only and typed parameters, and the "Generate Docstring" suggestion with its preview. Right: after Enter, the Google-style docstring with Args, Returns and Raises

Free, no sign-in, works offline. No network calls, no telemetry, no Python install needed.

Type """ on the line under a def or class and press Enter. The docstring is filled from the signature: parameters, type hints, defaults, return type, what the function yields and what it raises. When you change the signature later, Update Docstring fixes the docstring and keeps the text you wrote.

Questions people ask

Is Docstring Generator & Python Docstring Updater (Google, NumPy, Sphinx, JSDoc) free?

Yes. Docstring Generator & Python Docstring Updater (Google, NumPy, Sphinx, JSDoc) is free and MIT licensed.

How do I install Docstring Generator & Python Docstring Updater (Google, NumPy, Sphinx, JSDoc)?

Click "Install in VS Code" above, or search for zovo.zovo-docstring-generator in the Extensions view.

What you get

Why this one

The most installed Python docstring extension on the Marketplace has had no release since February 2022. Its open issues ask for these things. Each row is checked in this extension's tests and in the real VS Code gate:

What users reportWhereHere
No way to update a docstring after the signature changed#28 "Update docstring" (40 reactions), #255, #177 (renamed parameter), #179 (on save)Update Docstring, Update All Docstrings in File and update on save. Renamed parameters keep their text, removed ones with text are kept and marked.
@dataclass classes get no fields#170 (28 reactions)Fields become Attributes, with type and default. ClassVar is left out.
Class docstring lists the base classes as arguments#246The __init__ arguments are listed, not the base classes.
No positional-only or keyword-only parameters#262/ and * are read; the parameters around them are all listed.
A triple-quoted string in the body (an SQL query) stops the docstring#311, #68Works: the parser knows where strings start and end.
Docstring indented by a guess, which breaks the code after a signature with aligned continuation lines#315The indent comes from the function body (or the line you typed on).
Module docstring gets an indent#152No indent at the top of the file.
Non-ASCII names break the parameter list#183, #308größe, café and Optional[Gerät] come out right.

This extension is not made by, and does not replace, any other publisher's extension. If you used a custom template there, the common Mustache tags ({{summaryPlaceholder}}, {{#args}}, {{#kwargs}}, {{var}}, {{typePlaceholder}}, {{descriptionPlaceholder}}, {{#returns}}, {{#exceptions}}, {{#yields}}) work here too.

Update keeps your text

Left: a docstring that no longer matches the signature. Right: after Update Docstring, order_id keeps the hand-written text of order, insured and notify are added, signature is kept and marked as removed, the return type follows the hint and KeyError is added to Raises

The four styles

The same function documented in Google, NumPy, Sphinx and Epytext style

Commands

CommandWhat it does
Docstring: Generate Docstring (Cmd+Shift+2 / Ctrl+Shift+2)Docstring for the def or class at the cursor, or JSDoc in JS and TS
Docstring: Update Docstring (Signature Changed)Brings the docstring (or JSDoc) at the cursor in line with the signature
Docstring: Update All Docstrings in FileThe same for every docstring in the file
Docstring: Add Missing Docstrings in FileA docstring for every public function and class that has none
Docstring: Generate JSDocJSDoc with types for the function at the cursor
Docstring: Docstring Coverage Report (Workspace)Which functions and classes have no docstring, or a stale one, in every Python file
Docstring: Choose Docstring StyleGoogle, NumPy, Sphinx, Epytext or custom

Settings

SettingDefault
zovoDoc.stylegooglegoogle, numpy, sphinx, epytext, custom
zovoDoc.customTemplatePathMustache template. Relative to the workspace; ~, ${workspaceFolder}, ${userHome} and ${env:NAME} work
zovoDoc.includeTypesalwaysalways (hint or placeholder), hinted (only from hints), never
zovoDoc.includeDefaultstrueMention default values
zovoDoc.optionalMarkertrue, optional after the type when there is a default
zovoDoc.quoteStyle"""Or '''
zovoDoc.summaryOnNewLinefalseSummary on the line after the quotes (pydocstyle D213)
zovoDoc.blankLineAfterLastSectionfalseBlank line before the closing quotes (D413)
zovoDoc.includeExtendedSummaryfalseAdd a placeholder for a longer description
zovoDoc.classInitArgumentsclassDocument __init__ arguments in the class docstring, or leave them to __init__
zovoDoc.update.removedParametersmarkmark or delete removed parameters that have your text
zovoDoc.updateOnSavefalseUpdate docstrings when you save a Python file
zovoDoc.generateOnTripleQuote / generateOnEntertrueThe """ suggestion, and Enter when the suggestion was not picked
zovoDoc.jsdoc.typesInTypeScripttrue{types} in JSDoc in TypeScript files

Custom template

Set zovoDoc.style to custom and point zovoDoc.customTemplatePath to a file like this:

{{summaryPlaceholder}}

{{#parametersExist}}
Args:
{{#params}}
    {{var}} ({{typePlaceholder}}): {{descriptionPlaceholder}}
{{/params}}
{{/parametersExist}}
{{#returnsExist}}

Returns:
{{#returns}}
    {{typePlaceholder}}: {{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}

Lists: params (all), args (no default), kwargs (with default), attributes, exceptions, returns, yields. In a list: var (with * or **), name, type, typePlaceholder, default, descriptionPlaceholder. Flags: parametersExist, argsExist, kwargsExist, attributesExist, exceptionsExist, returnsExist, yieldsExist. Also {{^flag}} (when not), {{! comments}} and {{&default}}.

Privacy

The extension never opens a network connection. The parser is bundled (tree-sitter, MIT). Nothing is collected. In Restricted Mode, a template path from the workspace settings is ignored.

Works in

VS Code 1.90 or newer, so it also installs in Cursor, Windsurf, VSCodium and other editors built on VS Code. Tested in VS Code 1.142 with Pylance on and off, and in the Python cells of a Jupyter notebook.

Guides

Install Docstring Generator & Python Docstring Updater (Google, NumPy, Sphinx, JSDoc)

Click the button to open VS Code and install it, or press Ctrl+P (Cmd+P on macOS) in VS Code and run ext install zovo.zovo-docstring-generator.

Free, MIT license. Needs VS Code 1.90.0 or newer. Extension ID zovo.zovo-docstring-generator, version 0.2.1.

Source code and issues are on GitHub.

All our VS Code extensions

Zovo Pro and support

Zovo Pro: USD 19 once, every Zovo viewer. It turns on the Pro tools in this extension and in the other Zovo extensions you use. The free features stay free.

After a card payment your license key shows on the next page. Paste it with the command "Zovo Pro: Enter a key".

You can also support the work with no Pro:

Need your format supported?

Open a format request with a sample file, and I reply there whether it can be done. For USD 299 once, through this GitHub Sponsors tier, I add your file format or a missing feature to this extension, with tests, within 7 days.