Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,17 @@ True
<class 'int'>
```

To give the generated class a docstring, pass `__doc__` in the `class_body` argument:

```{doctest}
>>> C = make_class("C", ["x", "y"], class_body={"__doc__": "A pair of values."})
>>> C.__doc__
'A pair of values.'
```

You can also assign to `C.__doc__` after creating the class.
Both approaches make the docstring available to `help(C)`.

You can still have power over the attributes if you pass a dictionary of name: {func}`~attrs.field` mappings and can pass the same arguments as you can to `@attrs.define`:

```{doctest}
Expand Down