Code Documentation Generator

Paste a source file in JavaScript, TypeScript, PHP, Python, Java, C# or Go. Every public function, method and class with no doc comment gets a draft in the format your language expects, with parameters, defaults, return values and thrown errors read from the code. Comments you already wrote stay as they are, and the ledger under the editor names the ones missing a parameter.

Documentation drafting bench


Docblock ledger

No symbols yet
0symbols
0documented
0with gaps
0missing
LineSymbolKindStatusNote

Functions, methods and classes from your paste get listed here with their line number and docblock status.

What gets written, language by language

Each language has its own comment syntax and its own rules about what belongs inside. The drafts follow the convention read by the documentation tool of each language, so the syntax works with that tool as it stands. Your job is the wording.

One Python function, three docstring styles

The docstring setting changes layout, never content. Here is a finished docstring for one retry helper in each style, written by hand so you see the target rather than the draft.

Google
def retry_delay(attempt: int, base: float = 0.5) -> float:
    """Return the wait before the next retry.

    Args:
        attempt (int): Retry number, from 1.
        base (float, optional): First delay in
            seconds. Defaults to 0.5.

    Returns:
        float: Seconds to sleep, capped at 30.

    Raises:
        ValueError: If attempt is below 1.
    """
NumPy
def retry_delay(attempt: int, base: float = 0.5) -> float:
    """Return the wait before the next retry.

    Parameters
    ----------
    attempt : int
        Retry number, from 1.
    base : float, default 0.5
        First delay in seconds.

    Returns
    -------
    float
        Seconds to sleep, capped at 30.

    Raises
    ------
    ValueError
        If attempt is below 1.
    """
reST (Sphinx)
def retry_delay(attempt: int, base: float = 0.5) -> float:
    """Return the wait before the next retry.

    :param attempt: Retry number, from 1.
    :type attempt: int
    :param base: First delay in seconds.
    :type base: float
    :returns: Seconds to sleep, capped at 30.
    :rtype: float
    :raises ValueError: If attempt is below 1.
    """

Match whatever the project uses already. With no convention in place, Google style reads best in plain source and suits most application code. NumPy style gives long parameter lists room to breathe and is the standard in SciPy, pandas and scikit-learn. reST field lists render in stock Sphinx with no extension, at the price of being the hardest of the three to scan in an editor. Sphinx reads Google and NumPy through its napoleon extension, so the choice comes down to who reads the source, not to tooling.

Facts from the code, sentences from you

Half of a good docblock sits in the source already. The other half lives in the head of whoever wrote the function, and no parser reaches it.

Read from the source

  • Parameter names, order, and rest or variadic markers
  • Types from annotations and type hints, or from a default value when no annotation exists
  • Default values, copied as written
  • Whether a value comes back, from return statements and declared return types
  • Error classes, from throw and raise statements and Java throws clauses
  • Generators and async functions

Only you know

  • Units: seconds or milliseconds, cents or dollars
  • What null, an empty list or minus one means as a result
  • Side effects: a database write, a network call, a mutated argument
  • Valid ranges, and what happens outside them
  • Who owns a returned handle and closes it
  • Why this function exists next to the obvious alternative

The summary line comes from the name, so parseRetryAfter turns into "Parse retry after." The sentence restates the name and adds nothing. Below is the draft for the JavaScript sample next to a version worth committing.

Draft from this page
/**
 * Parse retry after.
 *
 * @param {*} header - TODO.
 * @param {number} [now=Date.now()] - TODO.
 * @returns {*} TODO.
 */
After a human pass
/**
 * Turn a Retry-After header into an epoch time.
 *
 * @param {string} header - Seconds ("120") or an
 *   HTTP date, as sent by the upstream API.
 * @param {number} [now=Date.now()] - Clock in epoch
 *   ms, injectable for tests.
 * @returns {?number} Epoch ms to wait until, or
 *   null when the header is unreadable.
 */

Three things changed. Every description now says something the signature hides: the two header formats, the unit, the null case. The type of header went from a star to string, since a parameter with no default and no annotation gives the parser nothing to go on. The return type gained a question mark for the null branch, which inference missed because the other branch returns an expression with no literal type.

Reading the ledger

Documented
A docblock sits directly above the symbol, or a docstring opens its body, and every parameter has an entry. A function returning a value also needs a return entry.
Gaps
A docblock exists but skips something, and the note names each missing parameter or return entry. In Go, the note flags a comment opening with a word other than the function name, the rule linters such as revive enforce. The generator never edits these. Rewriting a half-finished docblock would throw away the half someone wrote.
Missing
Nothing above the symbol, or only a plain /* */ comment. Documentation tools skip plain comments, so those count as missing as well. Every Missing row gets a draft in the source view.

The percentage counts symbols with any docblock, gaps included. Use it to track a file between commits, not as a quality score. A file at 100% where every description reads TODO documents nothing.

The ledger expects a docblock on the line directly above the declaration, with decorators, annotations and attributes allowed in between. A blank line between comment and code reads as Missing, so close the gap before trusting the count.

From docblocks to a published reference

The Markdown view suits a README section or a wiki page. For a full docs site, run the generator your language ships with over the commented files.

LanguageToolStarting command
JavaScriptJSDocnpx jsdoc src -r -d docs
TypeScriptTypeDocnpx typedoc src/index.ts
PHPphpDocumentorphpDocumentor -d src -t docs
PythonSphinx with autodoc and napoleonsphinx-apidoc -o docs src
Javajavadocjavadoc -d docs -sourcepath src -subpackages com.toolexe
C#Compiler XML output, then DocFX<GenerateDocumentationFile>true</GenerateDocumentationFile>
Gogo doc, pkg.go.devgo doc -all ./redirects

Each tool reads only the formats it supports. Sphinx without napoleon prints Google and NumPy sections as plain text, and TypeDoc ignores types written in JSDoc braces, so pick the style setting for the tool at the end of the pipeline.

When another tool fits better

Nothing you paste leaves the browser. Parsing, drafting and the Markdown export run in JavaScript on this page, with no request to a server after load, so private repositories and files holding credentials stay on your machine.

Questions about generated docblocks

Existing comments, summary lines, docstring styles and language conventions.

Does the generator overwrite docblocks I already wrote?

No. A symbol with any docblock above it stays untouched in the source view, even when the docblock misses a parameter. The ledger marks those rows as Gaps and names the missing entries, so you add them by hand and keep your wording. Only symbols with no docblock at all get a draft.

Where does the summary line come from?

From the name. createUser becomes "Create user." and isExpired becomes "Check whether expired." in the imperative form PEP 257 asks for, which the JavaScript, TypeScript and PHP drafts share. Java, C# and Go get the third person form their style guides ask for, as in "Returns the paths." Treat the sentence as a placeholder and replace it with what the function does for the caller.

Which Python docstring style should I pick?

Whatever the project uses already, since a mix of styles in one package reads worse than any single style. For a new project, Google style is the easiest to read in source. NumPy style suits scientific code with long parameter lists. reST works with Sphinx out of the box but is the hardest to read in an editor.

Why do TypeScript drafts have no types in braces?

The compiler already knows the types from the signature. Repeating them in the comment gives you two places to update after every refactor, and the comment goes stale first. Plain JavaScript keeps the braces because there the comment is the only place a type exists, and editors read JSDoc types for autocomplete and for type checking with checkJs.

Why does a Go function get one comment line and no parameter list?

Go documentation has no tags. The convention from Effective Go is a full sentence opening with the name of the thing documented, such as "Resolve looks up the rule for a path." Linters such as revive flag exported names whose comment opens any other way, which is why the ledger reports those as Gaps.

Is my source code uploaded anywhere?

No. Parsing and drafting run in JavaScript inside this page, and no request goes to a server after the page loads. Nothing is stored between visits either, so closing the tab clears the editor.