Skip to content

Commit

Permalink
Documentation: Put examples for config to the start of the section (#…
Browse files Browse the repository at this point in the history
…2615)

* Put examples to the start of the section

I think this is where they belong, they were in the middle of the list of config options somewhere near the end.

* Add "options" in table of contents

* tweak

Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
  • Loading branch information
2 people authored and MihanixA committed Apr 5, 2021
1 parent 6b3cdc3 commit 88337a3
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions docs/usage/model_config.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Behaviour of _pydantic_ can be controlled via the `Config` class on a model or a _pydantic_ dataclass.

Options:
```py
{!.tmp_examples/model_config_main.py!}
```
_(This script is complete, it should run "as is")_

Also, you can specify config options as model class kwargs:
```py
{!.tmp_examples/model_config_class_kwargs.py!}
```
_(This script is complete, it should run "as is")_

Similarly, if using the `@dataclass` decorator:
```py
{!.tmp_examples/model_config_dataclass.py!}
```
_(This script is complete, it should run "as is")_

## Options

**`title`**
: the title for the generated JSON Schema
Expand Down Expand Up @@ -74,7 +91,7 @@ Options:
for use with `orm_mode`

**`alias_generator`**
: a callable that takes a field name and returns an alias for it
: a callable that takes a field name and returns an alias for it (see [the dedicated section](#alias-generator))

**`keep_untouched`**
: a tuple of types (e.g. descriptors) for a model's default values that should not be changed during model creation and will
Expand All @@ -92,24 +109,6 @@ not be included in the model schemas. **Note**: this means that attributes on th
**`json_encoders`**
: a `dict` used to customise the way types are encoded to JSON; see [JSON Serialisation](exporting_models.md#modeljson)

```py
{!.tmp_examples/model_config_main.py!}
```
_(This script is complete, it should run "as is")_

Also, you can specify config options as model class kwargs:
```py
{!.tmp_examples/model_config_class_kwargs.py!}
```
_(This script is complete, it should run "as is")_

Similarly, if using the `@dataclass` decorator:
```py
{!.tmp_examples/model_config_dataclass.py!}
```
_(This script is complete, it should run "as is")_


**`underscore_attrs_are_private`**
: whether to treat any underscore non-class var attrs as private, or leave them as is; See [Private model attributes](models.md#private-model-attributes)

Expand Down

0 comments on commit 88337a3

Please sign in to comment.