Skip to content

Commit 22d8f18

Browse files
authored
docs: fix advanced alchemy references (litestar-org#3881)
* docs: fix advanced alchemy references * fix: correct additional AA references * fix: references * fix: docs building * fix: linting
1 parent 35a9837 commit 22d8f18

File tree

7 files changed

+32
-46
lines changed

7 files changed

+32
-46
lines changed

docs/conf.py

+8-22
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
extensions = [
3131
"sphinx.ext.intersphinx",
32-
"sphinx.ext.autosectionlabel",
3332
"sphinx.ext.autodoc",
3433
"sphinx.ext.napoleon",
34+
"sphinx.ext.autosectionlabel",
3535
"sphinx_design",
3636
"auto_pytabs.sphinx_ext",
3737
"tools.sphinx_ext",
@@ -48,6 +48,7 @@
4848
"msgspec": ("https://jcristharif.com/msgspec/", None),
4949
"anyio": ("https://anyio.readthedocs.io/en/stable/", None),
5050
"multidict": ("https://multidict.aio-libs.org/en/stable/", None),
51+
"cryptography": ("https://cryptography.io/en/latest/", None),
5152
"sqlalchemy": ("https://docs.sqlalchemy.org/en/20/", None),
5253
"alembic": ("https://alembic.sqlalchemy.org/en/latest/", None),
5354
"click": ("https://click.palletsprojects.com/en/8.1.x/", None),
@@ -60,6 +61,8 @@
6061
"advanced-alchemy": ("https://docs.advanced-alchemy.litestar.dev/latest/", None),
6162
"jinja2": ("https://jinja.palletsprojects.com/en/latest/", None),
6263
"trio": ("https://trio.readthedocs.io/en/stable/", None),
64+
"pydantic": ("https://docs.pydantic.dev/latest/", None),
65+
"typing_extensions": ("https://typing-extensions.readthedocs.io/en/stable/", None),
6366
}
6467

6568
napoleon_google_docstring = True
@@ -74,6 +77,7 @@
7477
autodoc_default_options = {"special-members": "__init__", "show-inheritance": True, "members": True}
7578
autodoc_member_order = "bysource"
7679
autodoc_typehints_format = "short"
80+
autodoc_mock_imports = []
7781

7882
nitpicky = True
7983
nitpick_ignore = [
@@ -164,27 +168,7 @@
164168
(PY_METH, "litestar.dto.factory.DTOData.create_instance"),
165169
(PY_METH, "litestar.dto.interface.DTOInterface.data_to_encodable_type"),
166170
(PY_CLASS, "MetaData"),
167-
(PY_CLASS, "advanced_alchemy.repository.typing.ModelT"),
168-
(PY_OBJ, "advanced_alchemy.config.common.SessionMakerT"),
169-
(PY_OBJ, "advanced_alchemy.config.common.ConnectionT"),
170-
(PY_CLASS, "advanced_alchemy.extensions.litestar.plugins._slots_base.SlotsBase"),
171-
(PY_CLASS, "advanced_alchemy.config.EngineConfig"),
172-
(PY_CLASS, "advanced_alchemy.config.common.GenericAlembicConfig"),
173-
(PY_CLASS, "advanced_alchemy.extensions.litestar.SQLAlchemyDTO"),
174-
(PY_CLASS, "advanced_alchemy.extensions.litestar.dto.SQLAlchemyDTO"),
175-
(PY_CLASS, "advanced_alchemy.extensions.litestar.plugins.SQLAlchemyPlugin"),
176-
(PY_CLASS, "advanced_alchemy.extensions.litestar.plugins.SQLAlchemySerializationPlugin"),
177-
(PY_CLASS, "advanced_alchemy.extensions.litestar.plugins.SQLAlchemyInitPlugin"),
178-
(PY_CLASS, "advanced_alchemy.extensions.litestar.config.SQLAlchemySyncConfig"),
179-
(PY_CLASS, "advanced_alchemy.extensions.litestar.config.SQLAlchemyAsyncConfig"),
180-
(PY_METH, "advanced_alchemy.extensions.litestar.plugins.SQLAlchemySerializationPlugin.create_dto_for_type"),
181-
(PY_CLASS, "advanced_alchemy.base.BasicAttributes"),
182-
(PY_CLASS, "advanced_alchemy.config.AsyncSessionConfig"),
183-
(PY_CLASS, "advanced_alchemy.config.SyncSessionConfig"),
184-
(PY_CLASS, "advanced_alchemy.types.JsonB"),
185-
(PY_CLASS, "advanced_alchemy.types.BigIntIdentity"),
186171
(PY_FUNC, "sqlalchemy.get_engine"),
187-
(PY_ATTR, "advanced_alchemy.repository.AbstractAsyncRepository.id_attribute"),
188172
(PY_OBJ, "litestar.template.base.T_co"),
189173
("py:exc", "RepositoryError"),
190174
("py:exc", "InternalServerError"),
@@ -204,6 +188,9 @@
204188
(PY_CLASS, "typing.Self"),
205189
(PY_CLASS, "attr.AttrsInstance"),
206190
(PY_CLASS, "typing_extensions.TypeGuard"),
191+
(PY_CLASS, "advanced_alchemy.types.BigIntIdentity"),
192+
(PY_CLASS, "advanced_alchemy.types.JsonB"),
193+
(PY_CLASS, "advanced_alchemy.repository.SQLAlchemyAsyncRepository"),
207194
]
208195

209196
nitpick_ignore_regex = [
@@ -247,7 +234,6 @@
247234
"litestar.template": {"litestar.template.base.T_co"},
248235
"litestar.openapi.OpenAPIController.security": {"SecurityRequirement"},
249236
"litestar.response.file.async_file_iterator": {"FileSystemAdapter"},
250-
"advanced_alchemy._listeners.touch_updated_timestamp": {"Session"},
251237
re.compile("litestar.response.redirect.*"): {"RedirectStatusType"},
252238
re.compile(r"litestar\.plugins.*"): re.compile(".*ModelT"),
253239
re.compile(r"litestar\.(contrib|repository)\.*"): re.compile(".*T"),

docs/examples/contrib/sqlalchemy/plugins/tutorial/full_app_with_plugin.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import AsyncGenerator, List, Optional
22

3-
from advanced_alchemy.extensions.litestar.plugins.init.config.asyncio import autocommit_before_send_handler
43
from sqlalchemy import select
54
from sqlalchemy.exc import IntegrityError, NoResultFound
65
from sqlalchemy.ext.asyncio import AsyncSession
@@ -74,7 +73,7 @@ async def update_item(item_title: str, data: TodoItem, transaction: AsyncSession
7473
connection_string="sqlite+aiosqlite:///todo.sqlite",
7574
metadata=Base.metadata,
7675
create_all=True,
77-
before_send_handler=autocommit_before_send_handler,
76+
before_send_handler="autocommit",
7877
)
7978

8079
app = Litestar(

docs/tutorials/repository-tutorial/01-modeling-and-features.rst

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Additional features provided by the built-in base models include:
7474
reverts to an ``Integer`` for unsupported variants.
7575
- A custom :class:`JsonB <advanced_alchemy.types.JsonB>` type that uses
7676
native ``JSONB`` where possible and ``Binary`` or ``Blob`` as an alternative.
77+
- A custom :class:`EncryptedString <advanced_alchemy.types.EncryptedString>` encrypted string that supports multiple cryptography backends.
7778

7879
Let's build on this as we look at the repository classes.
7980

docs/tutorials/sqlalchemy/4-final-touches-and-recap.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ engine and session lifecycle, and register our ``transaction`` dependency.
5959
.. literalinclude:: /examples/contrib/sqlalchemy/plugins/tutorial/full_app_with_plugin.py
6060
:language: python
6161
:linenos:
62-
:lines: 80-84
62+
:lines: 80-83
6363

6464
.. seealso::
6565

docs/usage/databases/sqlalchemy/plugins/sqlalchemy_init_plugin.rst

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SQLAlchemy Init Plugin
22
----------------------
33

4-
The :class:`SQLAlchemyInitPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemyInitPlugin>` adds functionality to the
4+
The :class:`SQLAlchemyInitPlugin <advanced_alchemy.extensions.litestar.SQLAlchemyInitPlugin>` adds functionality to the
55
application that supports using Litestar with `SQLAlchemy <http://www.sqlalchemy.org/>`_.
66

77
The plugin:
@@ -39,8 +39,8 @@ Renaming the dependencies
3939
#########################
4040

4141
You can change the name that the engine and session are bound to by setting the
42-
:attr:`engine_dependency_key <advanced_alchemy.extensions.litestar.plugins.init.config.asyncio.SQLAlchemyAsyncConfig.engine_dependency_key>`
43-
and :attr:`session_dependency_key <advanced_alchemy.extensions.litestar.plugins.init.config.asyncio.SQLAlchemyAsyncConfig.session_dependency_key>`
42+
:attr:`engine_dependency_key <advanced_alchemy.extensions.litestar.SQLAlchemyAsyncConfig.engine_dependency_key>`
43+
and :attr:`session_dependency_key <advanced_alchemy.extensions.litestar.SQLAlchemyAsyncConfig.session_dependency_key>`
4444
attributes on the plugin configuration.
4545

4646
Configuring the before send handler
@@ -50,7 +50,7 @@ The plugin configures a ``before_send`` handler that is called before sending a
5050
session and removes it from the connection scope.
5151

5252
You can change the handler by setting the
53-
:attr:`before_send_handler <advanced_alchemy.extensions.litestar.plugins.init.config.asyncio.SQLAlchemyAsyncConfig.before_send_handler>`
53+
:attr:`before_send_handler <advanced_alchemy.extensions.litestar.SQLAlchemyAsyncConfig.before_send_handler>`
5454
attribute on the configuration object. For example, an alternate handler is available that will also commit the session
5555
on success and rollback upon failure.
5656

@@ -73,21 +73,21 @@ on success and rollback upon failure.
7373
Configuring the plugins
7474
#######################
7575

76-
Both the :class:`SQLAlchemyAsyncConfig <advanced_alchemy.extensions.litestar.config.SQLAlchemyAsyncConfig>` and the
77-
:class:`SQLAlchemySyncConfig <advanced_alchemy.extensions.litestar.config.SQLAlchemySyncConfig>` have an ``engine_config``
76+
Both the :class:`SQLAlchemyAsyncConfig <advanced_alchemy.extensions.litestar.SQLAlchemyAsyncConfig>` and the
77+
:class:`SQLAlchemySyncConfig <advanced_alchemy.extensions.litestar.SQLAlchemySyncConfig>` have an ``engine_config``
7878
attribute that is used to configure the engine. The ``engine_config`` attribute is an instance of
79-
:class:`EngineConfig <advanced_alchemy.config.EngineConfig>` and exposes all of the configuration options
79+
:class:`EngineConfig <advanced_alchemy.extensions.litestar.EngineConfig>` and exposes all of the configuration options
8080
available to the SQLAlchemy engine.
8181

82-
The :class:`SQLAlchemyAsyncConfig <advanced_alchemy.extensions.litestar.config.SQLAlchemyAsyncConfig>` class and the
83-
:class:`SQLAlchemySyncConfig <advanced_alchemy.extensions.litestar.config.SQLAlchemySyncConfig>` class also have a
82+
The :class:`SQLAlchemyAsyncConfig <advanced_alchemy.extensions.litestar.SQLAlchemyAsyncConfig>` class and the
83+
:class:`SQLAlchemySyncConfig <advanced_alchemy.extensions.litestar.SQLAlchemySyncConfig>` class also have a
8484
``session_config`` attribute that is used to configure the session. This is either an instance of
85-
:class:`AsyncSessionConfig <advanced_alchemy.config.AsyncSessionConfig>` or
86-
:class:`SyncSessionConfig <advanced_alchemy.config.SyncSessionConfig>` depending on the type of config
85+
:class:`AsyncSessionConfig <advanced_alchemy.extensions.litestar.AsyncSessionConfig>` or
86+
:class:`SyncSessionConfig <advanced_alchemy.extensions.litestar.SyncSessionConfig>` depending on the type of config
8787
object. These classes expose all of the configuration options available to the SQLAlchemy session.
8888

89-
Finally, the :class:`SQLAlchemyAsyncConfig <advanced_alchemy.extensions.litestar.config.SQLAlchemyAsyncConfig>` class and the
90-
:class:`SQLAlchemySyncConfig <advanced_alchemy.extensions.litestar.config.SQLAlchemySyncConfig>` class expose configuration
89+
Finally, the :class:`SQLAlchemyAsyncConfig <advanced_alchemy.extensions.litestar.SQLAlchemyAsyncConfig>` class and the
90+
:class:`SQLAlchemySyncConfig <advanced_alchemy.extensions.litestar.SQLAlchemySyncConfig>` class expose configuration
9191
options to control their behavior.
9292

9393
Consult the reference documentation for more information.
@@ -98,7 +98,7 @@ Example
9898
The below example is a complete demonstration of use of the init plugin. Readers who are familiar with the prior section
9999
may note the additional complexity involved in managing the conversion to and from SQLAlchemy objects within the
100100
handlers. Read on to see how this increased complexity is efficiently handled by the
101-
:class:`SQLAlchemySerializationPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemySerializationPlugin>`.
101+
:class:`SQLAlchemySerializationPlugin <advanced_alchemy.extensions.litestar.SQLAlchemySerializationPlugin>`.
102102

103103
.. tab-set::
104104

docs/usage/databases/sqlalchemy/plugins/sqlalchemy_plugin.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
SQLAlchemy Plugin
22
-----------------
33

4-
The :class:`SQLAlchemyPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemyPlugin>` provides complete support for
4+
The :class:`SQLAlchemyPlugin <advanced_alchemy.extensions.litestar.SQLAlchemyPlugin>` provides complete support for
55
working with `SQLAlchemy <https://www.sqlalchemy.org/>`_ in Litestar applications.
66

77
.. note::
88

99
This plugin is only compatible with SQLAlchemy 2.0+.
1010

11-
The :class:`SQLAlchemyPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemyPlugin>` combines the functionality of
12-
:class:`SQLAlchemyInitPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemyInitPlugin>` and
13-
:class:`SQLAlchemySerializationPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemySerializationPlugin>`, each of
11+
The :class:`SQLAlchemyPlugin <advanced_alchemy.extensions.litestar.SQLAlchemyPlugin>` combines the functionality of
12+
:class:`SQLAlchemyInitPlugin <advanced_alchemy.extensions.litestar.SQLAlchemyInitPlugin>` and
13+
:class:`SQLAlchemySerializationPlugin <advanced_alchemy.extensions.litestar.SQLAlchemySerializationPlugin>`, each of
1414
which are examined in detail in the following sections. As such, this section describes a complete example of using the
15-
:class:`SQLAlchemyPlugin <advanced_alchemy.extensions.litestar.plugins.SQLAlchemyPlugin>` with a Litestar application and a
15+
:class:`SQLAlchemyPlugin <advanced_alchemy.extensions.litestar.SQLAlchemyPlugin>` with a Litestar application and a
1616
SQLite database.
1717

1818
Or, skip ahead to :doc:`/usage/databases/sqlalchemy/plugins/sqlalchemy_init_plugin` or

docs/usage/plugins/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ The following example shows the actual implementation of the ``SerializationPlug
9191
:language: python
9292
:caption: ``SerializationPluginProtocol`` implementation example
9393

94-
:meth:`supports_type(self, field_definition: FieldDefinition) -> bool: <advanced_alchemy.extensions.litestar.plugins.serialization.SQLAlchemySerializationPlugin.supports_type>`
94+
:meth:`supports_type(self, field_definition: FieldDefinition) -> bool: <advanced_alchemy.extensions.litestar.SQLAlchemySerializationPlugin.supports_type>`
9595
returns a :class:`bool` indicating whether the plugin supports serialization for the given type. Specifically, we return
9696
``True`` if the parsed type is either a collection of SQLAlchemy models or a single SQLAlchemy model.
9797

98-
:meth:`create_dto_for_type(self, field_definition: FieldDefinition) -> type[AbstractDTO]: <advanced_alchemy.extensions.litestar.plugins.SQLAlchemySerializationPlugin.create_dto_for_type>`
98+
:meth:`create_dto_for_type(self, field_definition: FieldDefinition) -> type[AbstractDTO]: <advanced_alchemy.extensions.litestar.SQLAlchemySerializationPlugin.create_dto_for_type>`
9999
takes a :class:`FieldDefinition <litestar.typing.FieldDefinition>` instance as an argument and returns a
100100
:class:`SQLAlchemyDTO <advanced_alchemy.extensions.litestar.dto.SQLAlchemyDTO>` subclass and includes some logic that may be
101101
interesting to potential serialization plugin authors.

0 commit comments

Comments
 (0)