diff --git a/docs/api.rst b/docs/api.rst index 2ab620deb..285c6e6f8 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -85,11 +85,14 @@ Core .. doctest:: - >>> C1 = attr.make_class("C1", ["x", "y"]) + >>> import attrs + >>> C1 = attrs.make_class("C1", ["x", "y"]) >>> C1(1, 2) C1(x=1, y=2) - >>> C2 = attr.make_class("C2", {"x": attr.ib(default=42), - ... "y": attr.ib(default=attr.Factory(list))}) + >>> C2 = attrs.make_class("C2", { + ... "x": attrs.field(default=42), + ... "y": attrs.field(factory=list) + ... }) >>> C2() C2(x=42, y=[]) diff --git a/src/attr/_make.py b/src/attr/_make.py index 9ee22005b..1a06504e2 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -2818,13 +2818,13 @@ def __setstate__(self, state): def make_class(name, attrs, bases=(object,), **attributes_arguments): - """ + r""" A quick way to create a new class called *name* with *attrs*. :param str name: The name for the new class. :param attrs: A list of names or a dictionary of mappings of names to - attributes. + `attr.ib`\ s / `attrs.field`\ s. The order is deduced from the order of the names or attributes inside *attrs*. Otherwise the order of the definition of the attributes is