docstring

Generate PyTorch-style docstrings for Python functions and methods.

27|10|Updated Dec 27, 2025
One-click install
npx skills add https://github.com/nilecui/SkillsBase --skill docstring-nilecui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docstring
Source: https://github.com/nilecui/SkillsBase/tree/main/.cursor/skills/docstring
Command: npx skills add https://github.com/nilecui/SkillsBase --skill docstring-nilecui

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write high-quality, consistent docstrings for PyTorch functions and methods, adhering to project conventions and best practices.

Core Features & Use Cases

  • Standardized Docstrings: Generates docstrings following PyTorch's specific format (Sphinx/reST, raw strings, mathematical formulas).
  • Comprehensive Guidance: Covers function signatures, parameter documentation, cross-references, notes, warnings, and examples.
  • Use Case: When adding a new custom layer to a PyTorch model, use this Skill to ensure its documentation is perfectly formatted and informative for other developers.

Quick Start

Write a docstring for the torch.nn.functional.conv2d function following PyTorch conventions.

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 for custom functions using Sphinx and reStructuredText?

To write PyTorch docstrings, generate standardized documentation using Sphinx and reStructuredText formatting. This ensures adherence to project conventions by covering function signatures, parameter descriptions, mathematical formulas, cross-references, and examples.

What is the best way to document mathematical formulas in Python docstrings for PyTorch projects?

Documenting mathematical formulas in Python docstrings requires using raw strings and reStructuredText syntax. This approach aligns with PyTorch project conventions, ensuring complex equations and function signatures render correctly in Sphinx-generated documentation.

How do I format function signatures and parameter descriptions for a PyTorch custom layer?

Formatting function signatures and parameter descriptions for a PyTorch custom layer involves applying specific reStructuredText patterns. This generates comprehensive guidance covering arguments, return types, notes, warnings, and examples.

Does this docstring generation approach work for both Python functions and class methods?

Yes, this docstring generation approach works for both Python functions and class methods within the PyTorch ecosystem. It applies project-specific Sphinx formatting rules to ensure consistent documentation across different code structures.

When do I need to use cross-references in reST docstrings for PyTorch development?

You need to use cross-references in reST docstrings when linking related PyTorch functions, classes, or modules. This ensures developers can navigate interconnected APIs seamlessly within the Sphinx documentation build.

Why are my PyTorch docstrings not rendering correctly in Sphinx?

PyTorch docstrings fail to render correctly in Sphinx when they deviate from expected reStructuredText conventions. Ensuring raw strings, proper parameter formatting, and PyTorch-specific patterns are used resolves generation and rendering issues.