Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Scikit learn Scikit learn NumpyDocScrape

From Leeroopedia
Revision as of 16:36, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Scikit_learn_Scikit_learn_NumpyDocScrape.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Documentation, Utilities
Last Updated 2026-02-08 15:00 GMT

Overview

Concrete tool for extracting and parsing NumPy-style docstrings into structured data provided by scikit-learn.

Description

This module provides classes for parsing NumPy-style docstrings into an abstract structured representation. The main class NumpyDocString parses docstring sections (Parameters, Returns, Examples, etc.) into a mapping from section titles to structured data. It also includes a Reader class for line-based string reading and a FunctionDoc class that extracts documentation directly from function objects.

Usage

Use this module when you need to programmatically parse, inspect, or validate NumPy-style docstrings in Python code, particularly within the scikit-learn documentation toolchain.

Code Reference

Source Location

Signature

class Reader:
    """A line-based string reader."""
    def __init__(self, data):
        ...

class NumpyDocString(Mapping):
    """Parses a numpydoc string to an abstract representation."""
    def __init__(self, docstring, config=None):
        ...

class FunctionDoc(NumpyDocString):
    def __init__(self, func, role="func", doc=None, config=None):
        ...

Import

from sklearn.externals._numpydoc.docscrape import NumpyDocString, FunctionDoc

I/O Contract

Inputs

Name Type Required Description
docstring str Yes NumPy-style docstring text to parse
config dict No Configuration options for parsing behavior
func callable Yes (FunctionDoc) Function object to extract documentation from
role str No Role descriptor like 'func' or 'meth' (default: 'func')

Outputs

Name Type Description
NumpyDocString instance Mapping Mapping from section names to structured content
Parameters section list List of (name, type, description) tuples
Returns section list List of (name, type, description) tuples
Examples section str Raw example code text

Usage Examples

Basic Usage

from sklearn.externals._numpydoc.docscrape import NumpyDocString

doc = NumpyDocString("""
Summary line.

Parameters
----------
x : int
    The input value.
y : float, optional
    Another parameter.

Returns
-------
result : bool
    The output.
""")

print(doc['Parameters'])
print(doc['Returns'])

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment