Soup objects

This file defines soup objects. PySoup derives soup objects from their ast equivalents and stores them in its objects attribute. These are designed to be relatively easy to compile in a markdown file.

docstr_md.python.Expr

class docstr_md.python.Expr(obj, parser='sklearn') [source]

Stores an expression.

Parameters: obj : ast.Expr

Expression object from which this is derived.

parser : callable or str, default='sklearn'

If input as a string, PySoup uses it as a key to look up a built-in parser. The parser takes a raw docstring and returns a docstr dictionary.

Attributes: ast : ast.Expr

Original ast.Expr object from which this is derived.

docstr : dict

Parsed docstring dictionary, output by the parser.

docstr_md.python.FunctionDef

class docstr_md.python.FunctionDef(obj, parser='sklearn') [source]

Stores a function.

Parameters: obj : ast.FunctionDef

Function object from which this is derived.

parser : callable or str, default='sklearn'

If input as a string, PySoup uses it as a key to look up a built-in parser. The parser takes a raw docstring and returns a docstr dictionary.

Attributes: ast : ast.FunctionDef

Original ast.FunctionDef object from which this is derived.

name : str

Name of the function.

docstr : dict

Parsed docstring dictionary, output by the parser.

import_path : str

Python formatted import path, e.g. 'path.to.file.'.

src_path : str

Path to file in the source code. e.g. 'path/to/file.py'.

src_href : callable

Takes self and outputs a link to the this object in the source code repository.

Methods

is_property(self) [source]

Indicates that this function is a getter, setter, or deleter.

i.e. This function is a method of a class decorated with @property, @x.setter, or @x.deleter.

Returns: is_property : bool

Indicator that this function is a property.

docstr_md.python.ClassDef

class docstr_md.python.ClassDef(obj, parser='sklearn') [source]

Stores a class.

Parameters: obj : ast.ClassDef

Class object from which this is derived.

parser : callable or str, default='sklearn'

If input as a string, PySoup uses it as a key to look up a built-in parser. The parser takes a raw docstring and returns a docstr dictionary.

Attributes: ast : ast.ClassDef

Original ast.ClassDef object from which this is derived.

name : str

Name of the class.

docstr : dict

Parsed docstring dictionary, output by the parser.

import_path : str

Python formatted import path, e.g. 'path.to.file.'.

src_path : str

Path to file in the source code. e.g. 'path/to/file.py'.

src_href : callable

Takes self and outputs a link to the this object in the source code repository. Setting the src_href for self automatically sets the src_href attributes for its methods.

methods : list

List of class methods as FunctionDef objects.

init : docstr_md.python.soup_objects.FunctionDef

Class constructor.

Methods

rm_properties(self) [source]

Remove methods with getter, setter, and deleter decorators.

Returns: self : docstr_md.python.soup_objects.ClassDef

rm_methods(self, *names) [source]

Remove methods by name.

Parameters: *names : str

Method names to remove.

Returns: self : docstr_md.python.ClassDef

keep_methods(self, *names) [source]

Keep methods by name.

Parameters: *names : str

Method names to keep.

Returns: self : docstr_md.python.ClassDef