All Projects → douglasdavis → numpydoc.el

douglasdavis / numpydoc.el

Licence: GPL-3.0 license
Insert NumPy style docstrings in Python functions.

Programming Languages

emacs lisp
2029 projects

Projects that are alternatives of or similar to numpydoc.el

Jsdoc To Markdown
Generate markdown documentation from jsdoc-annotated javascript
Stars: ✭ 1,199 (+3533.33%)
Mutual labels:  documentation-tool, documentation-generator
Naturaldocs
Natural Docs source code documentation system
Stars: ✭ 106 (+221.21%)
Mutual labels:  documentation-tool, documentation-generator
Graphdoc
Static page generator for documenting GraphQL Schema
Stars: ✭ 1,218 (+3590.91%)
Mutual labels:  documentation-tool, documentation-generator
strictdoc
Software for writing technical requirements specifications.
Stars: ✭ 80 (+142.42%)
Mutual labels:  documentation-tool, documentation-generator
Dart
DART is a test documentation tool created by the Lockheed Martin Red Team to document and report on penetration tests, especially in isolated network environments.
Stars: ✭ 207 (+527.27%)
Mutual labels:  documentation-tool, documentation-generator
App
Fast and searchable Ruby docs
Stars: ✭ 47 (+42.42%)
Mutual labels:  documentation-tool, documentation-generator
Dox
Haxe documentation generator.
Stars: ✭ 98 (+196.97%)
Mutual labels:  documentation-tool, documentation-generator
Documenter.jl
A documentation generator for Julia.
Stars: ✭ 384 (+1063.64%)
Mutual labels:  documentation-tool, documentation-generator
Redoc
📘 OpenAPI/Swagger-generated API Reference Documentation
Stars: ✭ 15,935 (+48187.88%)
Mutual labels:  documentation-tool, documentation-generator
Nbdev template
Template for nbdev projects
Stars: ✭ 161 (+387.88%)
Mutual labels:  documentation-tool, documentation-generator
Pdoc
API Documentation for Python Projects
Stars: ✭ 853 (+2484.85%)
Mutual labels:  documentation-tool, documentation-generator
Nbdev
Create delightful python projects using Jupyter Notebooks
Stars: ✭ 3,061 (+9175.76%)
Mutual labels:  documentation-tool, documentation-generator
Pdoc
🐍 ➡️ 📜 Auto-generate API documentation for Python projects
Stars: ✭ 604 (+1730.3%)
Mutual labels:  documentation-tool, documentation-generator
Toast Ui.doc
Stars: ✭ 71 (+115.15%)
Mutual labels:  documentation-tool, documentation-generator
Daux.io
Daux.io is an documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It helps you create great looking documentation in a developer friendly way.
Stars: ✭ 603 (+1727.27%)
Mutual labels:  documentation-tool, documentation-generator
Drf Autodocs
Ultimately automated DRF documentation rendering(UNMAINTAINED)
Stars: ✭ 82 (+148.48%)
Mutual labels:  documentation-tool, documentation-generator
Literate.jl
Simple package for literate programming in Julia
Stars: ✭ 272 (+724.24%)
Mutual labels:  documentation-tool, documentation-generator
Sourcedocs
Generate Markdown documentation from source code
Stars: ✭ 286 (+766.67%)
Mutual labels:  documentation-tool, documentation-generator
Documentalist
📝 A sort-of-static site generator optimized for living documentation of software projects
Stars: ✭ 130 (+293.94%)
Mutual labels:  documentation-tool, documentation-generator
Ford
Automatically generates FORtran Documentation from comments within the code.
Stars: ✭ 245 (+642.42%)
Mutual labels:  documentation-tool, documentation-generator

numpydoc.el

MELPA CI

An Emacs Lisp package to automatically insert NumPy style docstrings in Python function definitions.

Calling numpydoc-generate parses the function at point (the cursor can be anywhere in the function body). The parsing detects argument names, type hints, exceptions, and the return type hint. This information is used to generate a docstring.

The default behavior is to prompt the user (in the minibuffer) for a short & long description of the function, a description for each function argument, a description for each possible exception, and a description for the return. It's also possible to either disable the minibuffer prompt or use yasnippet insertion. See customization for more information. You'll also find a few examples below. See the NEWS file to see recent changes.

Setup

Pick your favorite method of Emacs Lisp package setup:

;; use-package with :ensure t to intall from MELPA.
(use-package numpydoc
  :ensure t)

;; use the straight.el package manager.
(straight-use-package 'numpydoc)

;; clone the git respository and require
(add-to-list 'load-path "/path/to/numpydoc.el")
(require 'numpydoc)

;; or point use-package to the local clone
(use-package numpydoc
  :load-path "/path/to/numpydoc.el")

The C-c C-n binding is vacant (not used in python.el, as of writing this), so you may want to give yourself a convenient shortcut:

;; with use-package
(use-package numpydoc
  :ensure t
  :bind (:map python-mode-map
              ("C-c C-n" . numpydoc-generate)))

;; without
(add-to-list 'load-path "/path/to/numpydoc.el")
(require 'numpydoc)
(define-key python-mode-map (kbd "C-c C-n") #'numpydoc-generate)

Customization

View customizations without leaving Emacs via M-x customize-group RET numpydoc

numpydoc-insertion-style
The method used to insert components of the docstring (default is 'prompt).
  • 'prompt will trigger a request for each description in the minibuffer.
  • 'yas (requires yasnippet to be installed) will generate a template and call yas-expand-snippet, providing an insertion method familiar to yasnippet users.
  • nil will disable any interactive insertion (template text will be inserted).
numpydoc-quote-char
Quote character to use (the default is a double quote, ?\", used throughout the numpydoc docstring guide and the black formatting tool).
numpydoc-insert-examples-block
If t (the default) an Examples block will be added to the docstring.
numpydoc-insert-parameter-types
If t (the default) type hints from the function signature will be used to add a type to each argument in the Parameters block of the docstring.
numpydoc-insert-raises-block
If t (the default) a Raises bock will be added to the docstring if exceptions are detected in the function body.
numpydoc-insert-return-without-typehint
If t a Returns block will be inserted in the absence of a return type hint.
numpydoc-template-short
Template text that will be used as the short description if numpydoc-insertion-style is nil.
numpydoc-template-long
Template text that will be used as the long description if numpydoc-insertion-style is nil.
numpydoc-template-arg-desc
Template text that will be used for each function argument description if numpydoc-insertion-style is nil.
numpydoc-template-type-desc
Template text that will be used for each function argument type description if numpydoc-insertion-style is nil.

Examples

M-x numpydoc-generate with the default configuration, numpydoc-insertion-style set to 'prompt (notice how long text is automatically paragraph-filled):

Using yasnippet (numpydoc-insertion-style set to 'yas):

With numpydoc-insertion-style set to nil; before:

def plot_histogram(
    x: np.ndarray,
    bins: int = 10,
    range: tuple[float, float] | None = None,
    weights: np.ndarray | None = None,
    flow: bool = False,
    ax: plt.Axes | None = None,
) -> tuple[plt.Figure, plt.Axes]:
    if weights is not None:
        if weights.shape != np.shape:
            raise ValueError("x and weights must have same shape.")
    pass

After M-x numpydoc-generate:

def plot_histogram(
    x: np.ndarray,
    bins: int = 10,
    range: tuple[float, float] | None = None,
    weights: np.ndarray | None = None,
    flow: bool = False,
    ax: plt.Axes | None = None,
) -> tuple[plt.Figure, plt.Axes]:
    """FIXME: Short description.

    FIXME: Long description.

    Parameters
    ----------
    x : np.ndarray
        FIXME: Add docs.
    bins : int
        FIXME: Add docs.
    range : tuple[float, float], optional
        FIXME: Add docs.
    weights : np.ndarray, optional
        FIXME: Add docs.
    flow : bool
        FIXME: Add docs.
    ax : plt.Axes | None
        FIXME: Add docs.

    Returns
    -------
    tuple[plt.Figure, plt.Axes]
        FIXME: Add docs.

    Raises
    ------
    ValueError
        FIXME: Add docs.

    Examples
    --------
    FIXME: Add docs.

    """
    if weights is not None:
        if weights.shape != np.shape:
            raise ValueError("x and weights must have same shape.")
    pass

Similar packages

  • sphinx-doc.el: Inserts sphinx-compatible docstrings (does not offer customizations or automatically formatted insertions from the minibuffer or yasnippet).
  • docstr: Docstring insertion support for any programming language, including NumPy style Python (it has a programmable interface but requires a bit more setup to get the utility provided numpydoc.el).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].