Fix documentation errors

Add more links to external docs where appropriate
Fix readme links hardcoded to github and 1.0.0 tag
Clarify intended usage of the calc_batch_size function
This commit is contained in:
Ethan Paul 2023-04-13 13:34:37 -04:00
parent 5520faef88
commit 6f97ff74e0
2 changed files with 23 additions and 19 deletions

View File

@ -22,7 +22,7 @@ release history.
## Installing ## Installing
Peewee+ is [available on PyPI](https://pypi.org/project/peewee-plus/) and can be installed peewee+ is [available on PyPI](https://pypi.org/project/peewee-plus/) and can be installed
using Poetry, Pipenv, or Pip: using Poetry, Pipenv, or Pip:
```bash ```bash
@ -57,30 +57,29 @@ when using SQLite
### Functions ### Functions
[`calc_batch_size`](https://github.com/enpaul/peewee-plus/blob/1.0.0/peewee_plus.py#L71) - [`calc_batch_size`](blob/devel/peewee_plus.py#L75) - Helper function for writing
Helper function for determining how to batch a create/update query with SQLite backend-agnostic batch queries while accounting for the
[SQLite max variable limit](https://www.sqlite.org/limits.html#max_variable_number).
[`flat_transaction`](https://github.com/enpaul/peewee-plus/blob/devel/peewee_plus.py#L137) [`flat_transaction`](blob/devel/peewee_plus.py#L141) - Decorator function for wrapping
\- Decorator function for wrapping callables in a database transaction without creating callables in a database transaction without creating nested transactions
nested transactions
### Classes ### Classes
[`PathField`](https://github.com/enpaul/peewee-plus/blob/1.0.0/peewee_plus.py#179) - A [`PathField`](blob/devel/peewee_plus.py#186) - A Peewee database field for storing
Peewee database field for storing
[Pathlib](https://docs.python.org/3/library/pathlib.html) objects, optionally relative to [Pathlib](https://docs.python.org/3/library/pathlib.html) objects, optionally relative to
a runtime value. a runtime value.
[`PrecisionFloatField`](https://github.com/enpaul/peewee-plus/blob/1.0.0/peewee_plus.py#L237) [`PrecisionFloatField`](blob/devel/peewee_plus.py#L244) - A Peewee database field for
\- A Peewee database field for storing floats while specifying the storing floats while specifying the
[MySQL precision parameters](https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html) [MySQL precision parameters](https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html)
`M` and `D` `M` and `D`
[`JSONField`](https://github.com/enpaul/peewee-plus/blob/1.0.0/peewee_plus.py#L267) - A [`JSONField`](blob/devel/peewee_plus.py#L275) - A Peewee database field for storing
Peewee database field for storing arbitrary JSON-serializable data arbitrary JSON-serializable data
[`EnumField`](https://github.com/enpaul/peewee-plus/blob/1.0.0/peewee_plus.py#L322) - A [`EnumField`](blob/devel/peewee_plus.py#L330) - A Peewee database field for storing Enums
Peewee database field for storing Enums by name by name
## For Developers ## For Developers

View File

@ -1,4 +1,6 @@
"""Peewee+ """peewee+
Various extensions, helpers, and utilities for `Peewee`_
:constant SQLITE_DEFAULT_VARIABLE_LIMIT: The default number of variables that a single SQL query :constant SQLITE_DEFAULT_VARIABLE_LIMIT: The default number of variables that a single SQL query
can contain when interfacing with SQLite. The actual can contain when interfacing with SQLite. The actual
@ -10,7 +12,9 @@
SQLite database connection. The value for this constant is taken SQLite database connection. The value for this constant is taken
directly from the `Peewee documentation`_ directly from the `Peewee documentation`_
.. _`Peewee documentation`: http://docs.peewee-orm.com/en/latest/peewee/database.html#recommended-settings .. _`Peewee`: https://docs.peewee-orm.com/en/latest/
.. _`Peewee documentation`: https://docs.peewee-orm.com/en/latest/peewee/database.html#recommended-settings
""" """
import contextlib import contextlib
import enum import enum
@ -254,8 +258,9 @@ class PrecisionFloatField(peewee.FloatField): # pylint: disable=abstract-method
.. _here: https://stackoverflow.com/a/67476045/5361209 .. _here: https://stackoverflow.com/a/67476045/5361209
:param max_digits: Maximum number of digits, combined from left and right of the decimal place, :param max_digits: Maximum number of digits, combined from left and right of the decimal place,
to store for the value. to store for the value; corresponds to the ``M`` MySQL precision parameter.
:param decimal_places: Maximum number of digits that will be stored after the decimal place :param decimal_places: Maximum number of digits that will be stored after the decimal place;
corresponds to the ``D`` MySQL precision parameter.
""" """
def __init__(self, *args, max_digits: int = 10, decimal_places: int = 4, **kwargs): def __init__(self, *args, max_digits: int = 10, decimal_places: int = 4, **kwargs):
@ -270,7 +275,7 @@ class PrecisionFloatField(peewee.FloatField): # pylint: disable=abstract-method
class JSONField(peewee.TextField): # pylint: disable=abstract-method class JSONField(peewee.TextField): # pylint: disable=abstract-method
"""Field class for storing JSON-serializable data """Field class for storing JSON-serializable data
This field can be used to store a dictionary of data directly in the database without needing This field can be used to store a dictionary of data directly in the database
without needing to call :func:`json.dumps` and :func:`json.loads` directly. without needing to call :func:`json.dumps` and :func:`json.loads` directly.
:: ::