Skip to content

Commit 166ec4a

Browse files
update docs (#62)
* update docs * keep line width * fix mkdocstrings warning
1 parent acfc438 commit 166ec4a

27 files changed

+157
-136
lines changed

databind.core/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
Deprecated since v4.5.0. This is a proxy for depending on [`databind`](https://pypi.org/project/databind/). Do not
3+
depend on this package directly anymore.

databind.json/README.md

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,3 @@
1-
# databind.json
21

3-
The `databind.json` package implements the de-/serialization to or from JSON payloads using
4-
the `databind.core` framework.
5-
6-
Check out the [Documentation][0] for examples.
7-
8-
[0]: https://niklasrosenstein.github.io/python-databind/
9-
10-
## Built-in converters
11-
12-
The following tables shows which types can be deserialized from / serialize to Python types with the native
13-
converters provided by the `databind.json` module:
14-
15-
| Converter name | Types | Description |
16-
| -------------- | ----- | ----------- |
17-
| `AnyConverter` | `typing.Any` | Accept any value (useful for arbitrary JSON). |
18-
| `CollectionConverter` | `typing.Collection[T]`, excl. `str`, `bytes`, `bytearray`, `memoryview` and `typing.Mapping[K, V]` | Converts between native Python collections and JSON arrays. |
19-
| `DatetimeConverter` | `datetime.date`, `datetime.datetime`, `datetime.time` | Converts between strings and date/time formats, using ISO 8601 time format by default (can be changed with the `databind.core.settings.DateFormat` setting). |
20-
| `DecimalConverter` | `decimal.Decimal` | Converts between strings (and ints/floats if strict mode is off, strict mode is on by default) and decimals. The precision can be controlled with the `databind.core.settings.Precision` setting. |
21-
| `EnumConverter` | `enum.Enum`, `enum.IntEnum` | Convert between strings and Python enumerations. The serialized form of `IntEnum` is the integer value, whereas the serialized form of `Enum` is a string (name of the enumeration value). |
22-
| `MappingConverter` | `typing.Mapping[K, V]` | Converts between Python dicts and JSON objects. (While in theory `K` can be any type, for JSON `K` always needs to be `str`). |
23-
| `OptionalConverter` | `typing.Optional[T]` | Handles optional fields in a schema. |
24-
| `PlainDatatypeConverter` | `bytes`, `str`, `int`, `float`, `bool` | Converts between plain datatypes. In non-strict mode (off by default), numeric types will also accept strings as input for the deserialization. |
25-
| `SchemaConverter` | `dataclasses.dataclass`, `typing.TypedDict` | Converts between Python dataclasses or typed dictionary and JSON objects. |
26-
| `UnionConverter` | `typing.Union[...]` | Handles union types. Unions in JSON can be expressed in a multitide of ways, e.g. using a discriminator key and flat, keyed or nested structure or "best match". Check out the examples section of the documentation for more information. |
27-
| `LiteralConverter` | `typing.Literal[...]` | Accepts or rejects a value based on whether it matches one of the values in the literal type hint. |
28-
29-
30-
The following converters are provided for convenience:
31-
32-
| Converter name | Types | Description |
33-
| -------------- | ----- | ----------- |
34-
| `StringifyConverter` | n/a | A helper that allows to easily create de/serializers from a "to string" and "from string" function. |
35-
36-
The following additional types are natively supported by `databind.json` using `StringifyConverter`:
37-
38-
| Types | Description |
39-
| ----- | ----------- |
40-
| `uuid.UUID` | Convert between strings and UUIDs. |
41-
| `pathlib.Path` | Convert between strings and paths. |
42-
| `pathlib.PurePath` | Convert between strings and paths. |
43-
| `nr.date.duration` | Deserialize from ISO 8601 duration strings or the object form, serialize to ISO 8601 strings. |
44-
45-
---
46-
47-
<p align="center">Copyright &copy; 2020 &ndash; Niklas Rosenstein</p>
2+
Deprecated since v4.5.0. This is a proxy for depending on [`databind`](https://pypi.org/project/databind/). Do not
3+
depend on this package directly anymore.

databind/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
The `databind` package provides a (de)serialization framework that understands most native Python types as well as
1212
dataclasses, as well as an implementation for serialize to/from JSON-like nested data structures.
1313

14-
Databind is intended mostly for flexible and easy to use configuration loading. It does __not__ try achieve high-performance; you should look towards e.g. [mashumaro](https://pypi.org/project/mashumaro/) for this usecase.
14+
Databind is intended mostly for flexible and easy to use configuration loading. It does __not__ try achieve
15+
high-performance; you should look towards e.g. [mashumaro](https://pypi.org/project/mashumaro/) for this usecase.
1516

1617
### Example
1718

@@ -38,10 +39,12 @@ assert dump(loaded, Config) == dict_payload
3839

3940
[typeapi]: https://github.com/NiklasRosenstein/python-typeapi
4041

41-
* Support for a plethora of builtin types, including `Enum`, `Decimal`, `UUID`, `Path`, `datetime`, `date`, `time`, `timedelta`
42+
* Support for a plethora of builtin types, including `Enum`, `Decimal`, `UUID`, `Path`, `datetime`, `date`,
43+
`time`, `timedelta`
4244
* Support for multiple union serialization modes (nested, flat, keyed, `typing.Literal`)
4345
* Support for generic types, e.g. `load([{"name": "Jane Doe"}], list[Person])`
44-
* Support for new-style type hints in older Python versions when using forward refererences (strings or `__future__.annotations`) thanks to [typeapi][]
46+
* Support for new-style type hints in older Python versions when using forward refererences (strings or
47+
`__future__.annotations`) thanks to [typeapi][]
4548
* [PEP 604 - Allow writing union types as X | Y](https://www.python.org/dev/peps/pep-0604/)
4649
* [PEP585 - Type Hinting Generics in Standard Collections](https://www.python.org/dev/peps/pep-0585/))
4750
* Support for customized serialization and deserialization of types
@@ -50,7 +53,8 @@ assert dump(loaded, Config) == dict_payload
5053
* Use "settings" to customize serialization behaviour
5154
* As global settings per `load()`/`dump()` call: `load(..., settings=[ExtraKeys(True)])`
5255
* As class-level settings using a decorator: `@Union(style=Union.FLAT)` or `@ExtraKeys(True)`
53-
* As type-hint level settings using `typing.Annotated` (or `typing_extensions.Annotated`): `full_name: Annotated[str, Alias("fullName")]` or `FullNameField = Annotated[str, Alias("fullName")]`
56+
* As type-hint level settings using `typing.Annotated` (or `typing_extensions.Annotated`):
57+
`full_name: Annotated[str, Alias("fullName")]` or `FullNameField = Annotated[str, Alias("fullName")]`
5458

5559
## Notable release notes
5660

databind/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ types-deprecated = "*"
2727
types-setuptools = "*"
2828
types-termcolor = "*"
2929

30+
[tool.poetry.group.docs]
31+
optional = true
32+
33+
[tool.poetry.group.docs.dependencies]
34+
mkdocs = "*"
35+
mkdocs-material = "*"
36+
mkdocstrings = {version = "*", extras = ["python"]}
37+
mksync = "^0.1.4"
38+
3039
[build-system]
3140
requires = ["poetry-core==1.9.0"]
3241
build-backend = "poetry.core.masonry.api"

databind/src/databind/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def format(self, dt: T_Dtype) -> str:
620620
"""Format a date/time value to a string.
621621
622622
Arguments:
623-
value: The date/time value to format (i.e. an instance of #datetime.date, #datetime.time or
623+
dt: The date/time value to format (i.e. an instance of #datetime.date, #datetime.time or
624624
#datetime.datetime).
625625
Raises:
626626
ValueError: If no date format to format the type of *value* is available.

docs/build.novella

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/content/core/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/content/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/content/json/examples/index.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/content/json/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)