🌐
Sphinx
sphinx-doc.org › en › master › usage › extensions › example_numpy.html
Example NumPy Style Python Docstrings — Sphinx documentation
.. _NumPy docstring standard: https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard """ module_level_variable1 = 12345 module_level_variable2 = 98765 """int: Module level variable documented inline. The docstring may span multiple lines. The type may optionally be specified on the first line, separated by a colon. """ def function_with_types_in_docstring(param1, param2): """Example function with types documented in the docstring.
🌐
Readthedocs
sphinxcontrib-napoleon.readthedocs.io › en › latest › example_numpy.html
Example NumPy Style Python Docstrings — napoleon 0.7 documentation
.. _PEP 484: https://www.python.org/dev/peps/pep-0484/ """ def function_with_pep484_type_annotations(param1: int, param2: str) -> bool: """Example function with PEP 484 type annotations. The return type must be duplicated in the docstring to comply with the NumPy docstring style.
🌐
Readthedocs
numpydoc.readthedocs.io › en › latest › format.html
Style guide — numpydoc v1.11.1.dev1+gca74aae44 Manual
If a method has an equivalent function (which is the case for many ndarray methods for example), the function docstring should contain the detailed documentation, and the method docstring should refer to it. Only put brief summary and See Also sections in the method docstring. The method should use a Returns or Yields section, as appropriate. Instances of classes that are part of the NumPy API (for example np.r_ np.c_, np.index_exp, etc.) may require some care.
🌐
Medium
mr-amit.medium.com › numpy-docstring-explained-3d2e3b3f017a
NumPy Docstring Explained. If you think you need to spend $2,000… | by It's Amit | Medium
March 6, 2025 - As we wrap up, let’s tackle a few common questions you might have about working with NumPy docstrings. These are quick but essential points that will make your journey smoother. ... This one’s super simple. Python allows you to access any function’s docstring with the __doc__ attribute.
🌐
Readthedocs
numpydoc.readthedocs.io › en › latest › example.html
Example — numpydoc v1.11.0rc0.dev0 Manual - Read the Docs
If your docstring does extend over multiple lines, the closing three quotation marks must be on a line by itself, preferably preceded by a blank line. """ import os # standard library imports first # Do NOT import using *, e.g. from numpy import * # # Import the module using # # import numpy # # instead or import individual functions as needed, e.g # # from numpy import array, zeros # # If you prefer the use of abbreviated module names, we suggest the # convention used by NumPy itself:: import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt # These abbreviated names are not to be used in docstrings; users must # be able to paste and execute docstrings after importing only the # numpy module itself, unabbreviated.
🌐
Lsst
developer.lsst.io › python › numpydoc.html
Documenting Python APIs with docstrings — LSST DM Developer Guide main documentation
For example, the description for format references the should_plot parameter: Parameters ---------- should_plot : `bool` Plot the fit if `True`. plot_format : `str`, optional Format of the plot when ``should_plot`` is `True`. We organize Python docstrings into sections that appear in a common order. This format is based on the original Numpydoc Style Guide (used by NumPy, SciPy, and Astropy, among other scientific Python packages), though this style guide includes several DM-specific clarifications.
🌐
Python-sprints
python-sprints.github.io › pandas › guide › pandas_docstring.html
pandas docstring guide — Python documentation
Parameters ---------- num1 : int ... another Examples -------- >>> add(2, 2) 4 >>> add(25, 0) 25 >>> add(10, -10) 0 """ return num1 + num2 · Some standards exist about docstrings, so they are easier to read, and they can be exported to other formats such as html or pdf. The first conventions every Python docstring should follow are defined in PEP-257. As PEP-257 is quite open, and some other standards exist on top of it. In the case of pandas, the numpy docstring ...
🌐
NumPy
numpy.org › doc › 1.19 › docs › howto_document.html
A Guide to NumPy/SciPy Documentation — NumPy v1.19 Manual
This document describes the syntax and best practices for docstrings used with the numpydoc extension for Sphinx. ... For an accompanying example, see example.py. Some features described in this document require a recent version of numpydoc. For example, the Yields section was added in numpydoc 0.6. We mostly follow the standard Python ...
🌐
NumPy
numpy.org › doc › 1.20 › docs › howto_document.html
A Guide to NumPy Documentation — NumPy v1.20 Manual
January 31, 2021 - Using numpydoc will also avoid the reStructuredText errors produced by plain Sphinx when it encounters numpy docstring conventions like section headers (e.g. -------------) that sphinx does not expect to find in docstrings. Some features described in this document require a recent version of numpydoc. For example, the Yields section was added in numpydoc 0.6.
🌐
Pyansys
dev.docs.pyansys.com › doc-style › docstrings.html
Numpydoc docstrings — PyAnsys developer's guide
These sections should follow numpydoc style. To avoid inconsistencies between PyAnsys libraries, see Docstring formatting rules. The “Examples” section provides one or more small code samples that make usage of a method or function clear. They provide an easy place to start when trying out the API. Here is a sample “Examples” section from a Python ...
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › docstrings-python
Python Docstrings Tutorial : Examples & Format for Pydoc, Numpy, Sphinx Doc Strings | DataCamp
February 14, 2025 - See Python Docstrings. Learn about the different types of docstrings & various docstring formats like Sphinx, Numpy, and Pydoc with examples now.
🌐
GitHub
github.com › numpy › numpydoc › blob › main › doc › example.py
numpydoc/doc/example.py at main · numpy/numpydoc
If your docstring does · extend over multiple lines, the closing three quotation marks must be on · a line by itself, preferably preceded by a blank line. · """ · import os # standard library imports first · · # Do NOT import using *, e.g. from numpy import * # # Import the module using · # # import numpy · # # instead or import individual functions as needed, e.g ·
Author: numpy
🌐
GitHub
github.com › douglasdavis › numpydoc.el
GitHub - douglasdavis/numpydoc.el: Insert NumPy style docstrings in Python functions. · GitHub
;; 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) View customizations without leaving Emacs via M-x customize-group RET numpydoc ... The method used to insert components of the docstring (default is 'prompt).
Starred by 51 users
Forked by 8 users
Languages: Emacs Lisp
🌐
pyOpenSci
pyopensci.org › python-package-guide › documentation › write-user-documentation › document-your-code-api-docstrings.html
Document the code in your package’s API using docstrings — Python Packaging Guide
In the example above, you saw the use of numpy-style docstrings to describe data types that are passed into functions as parameters or into classes as attributes. In a numpy-style docstring you add those types in the Parameters section of the docstring. Below you can see that the parameter num1 and num2 should both be a Python int (integer) value.
🌐
pythontutorials
pythontutorials.net › blog › numpy-style-docstrings
Mastering NumPy Style Docstrings: A Comprehensive Guide — pythontutorials.net
For example, if functionA calls functionB, you can mention functionB in the docstring of functionA and provide a link to its documentation if possible. NumPy style docstrings are a powerful tool for documenting Python code, especially in the ...
🌐
Plain English
python.plainenglish.io › how-to-write-numpy-style-docstrings-a092121403ba
How to Write NumPy-Style Docstrings | Python in Plain English
May 25, 2022 - As so often in the Python world, there are a few best practices on how to do something, in this case how to write docstrings properly. Three main styles have evolved: the traditional style, the Google style, and the NumPy style. I advocate the NumPy style because it is very human-readable (in ...
🌐
GitHub
gist.github.com › 910512d92769b0cc382a09ae4de41771
Very Simple Example of NumPy Style Docstrings · GitHub
Save eikonomega/910512d92769b0cc382a09ae4de41771 to your computer and use it in GitHub Desktop. Download ZIP · Very Simple Example of NumPy Style Docstrings · Raw · main.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
NumPy
numpy.org › doc › 1.21 › docs › howto_document.html
A Guide to NumPy Documentation — NumPy v1.21 Manual
June 22, 2021 - When using Sphinx in combination with the numpy conventions, you should use the numpydoc extension so that your docstrings will be handled correctly. For example, Sphinx will extract the Parameters section from your docstring and convert it into a field list.
🌐
Readthedocs
numpydoc.readthedocs.io › en › v1.0.0 › format.html
numpydoc docstring guide — numpydoc v1.0 Manual
If a method has an equivalent function (which is the case for many ndarray methods for example), the function docstring should contain the detailed documentation, and the method docstring should refer to it. Only put brief summary and See Also sections in the method docstring. The method should use a Returns or Yields section, as appropriate. Instances of classes that are part of the NumPy API (for example np.r_ np.c_, np.index_exp, etc.) may require some care.
🌐
pythontutorials
pythontutorials.net › blog › numpy-docstring-format
Mastering the NumPy Docstring Format — pythontutorials.net
For NumPy, this usually means using numpy.ndarray or more specific dtypes like numpy.float64. The names of parameters and variables in the docstring should be descriptive. Avoid using single - letter names like a and b in the docstring if possible. The examples in the docstring should be easy to understand and directly related to the functionality of the function.