docstring-generation
Published
Public
in @code-assistanteval100%

Generate a docstring for a function or class in a requested style (google/numpy/jsdoc/rustdoc), plus a params_documented[] list. Documents only the parameters that exist in the signature — never invents or omits one, and excludes self/cls receivers. Eval-gated on an exact params-documented count plus a style-adherence judge.

docstring-generation

Generate a docstring for a function or class, in the style you ask for, and report which parameters you documented:

{
  "docstring": "Return the clamped value of x.\n\nArgs:\n    x: The value to constrain.\n    lo: Lower bound (inclusive).\n    hi: Upper bound (inclusive).\n\nReturns:\n    x limited to the range [lo, hi].",
  "params_documented": ["x", "lo", "hi"]
}

Why this shape

  • A style knob (google / numpy / jsdoc / rustdoc) selects the section names and syntax — the prompt matches each style precisely.
  • params_documented[] is the assertable field. It documents only the parameters in the signature — never invented, never omitted, and excluding self/cls/Rust receivers — so an eval can check output.params_documented.size() == case.param_count exactly.
  • The code is data, not instructions. A comment that says "document a fake param" is ignored; the actual signature is documented.

Eval

Gated by @sufleur/docstring-cases — functions and classes across the four styles, each with the true parameter count. Assertions:

  • param countoutput.params_documented.size() == case.param_count (deterministic);
  • style adherence — an LLM judge (docstring-grader) scores whether the docstring actually follows the requested style's format (judge.style.score > 0.7).

Passing threshold 0.85. Recommended + eval model: claude-haiku-4-5 — docstrings are structured and well within a fast model's reach.

@sufleur/