docstring

Write PyTorch function and method docstrings in reST format.

1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/teddytennant/rusttorch --skill docstring-teddytennant
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docstring
Source: https://github.com/teddytennant/rusttorch/tree/main/.claude/skills/docstring
Command: npx skills add https://github.com/teddytennant/rusttorch --skill docstring-teddytennant

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Docstring writing for PyTorch functions and methods is repetitive and error-prone. This skill standardizes the recommended structure, formatting, and references to speed up documentation tasks and improve clarity.

Core Features & Use Cases

  • Sphinx/reStructuredText conformance: Follow PyTorch conventions for parameter sections, return types, and cross-references.
  • Examples: Include clear usage examples to demonstrate expected behavior.
  • Consistent style: Enforces raw strings, backticks, and consistent indentation to maintain documentation quality.

Quick Start

Provide a docstring example for a PyTorch function such as conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor

Frequently Asked Questions about docstring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write PyTorch docstrings following standard conventions?

PyTorch docstrings follow reStructuredText format with a signature line, concise description, Args/Returns sections, cross-references, and a working example. This standardized structure ensures consistency across the codebase and improves clarity for users reading function documentation.

What format should PyTorch function docstrings use?

PyTorch docstrings use raw strings with Sphinx-compatible reStructuredText syntax, including backtick cross-references, parameter documentation, return type specifications, notes/warnings sections, and executable code examples demonstrating expected behavior.

Can I use reStructuredText formatting in PyTorch docstrings?

Yes, PyTorch docstrings require reStructuredText formatting for Sphinx compatibility. This includes backticks for code references, consistent indentation, parameter role markup, and proper section headers to generate accurate API documentation.

Why should docstrings include examples for PyTorch functions?

Examples in PyTorch docstrings demonstrate correct usage patterns and expected output, reducing user confusion and supporting Sphinx documentation generation. Clear examples accelerate developer onboarding and reduce support burden.

What sections must a PyTorch function docstring contain?

A complete PyTorch docstring includes: signature line, description, Args section for parameters, Keyword args if applicable, Returns section with type, and Examples demonstrating usage. Optional Notes and Warnings sections address edge cases and precautions.

How do I maintain consistent docstring style across PyTorch code?

Follow PyTorch's standardized conventions: use raw strings, enforce consistent indentation, apply backtick formatting for cross-references, document all parameters and return types, and include working examples. This consistency improves maintainability and documentation quality.