Skip to content

Commit 2ed5f13

Browse files
author
Brian Kohan
committed
docs tweaks
1 parent 5160a97 commit 2ed5f13

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

doc/source/extensions.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ changing or extending the behavior of commands. :class:`~django_typer.TyperComma
1414
or add additional commands to a command implemented elsewhere. You can then use Django's built in
1515
command override precedence (INSTALLED_APPS) to ensure your command is used instead of the upstream
1616
command or give it a different name if you would like the upstream command to still be available.
17-
The :ref:`composition pattern <composition>` allows commands and groups to be added or overridden
17+
The :ref:`plugin pattern <plugin>` allows commands and groups to be added or overridden
1818
directly on upstream commands without inheritance. This mechanism is useful when you might expect
1919
other apps to also modify the original command. Conflicts are resolved in INSTALLED_APPS order.
2020

@@ -139,15 +139,15 @@ expect other apps to also modify the same command. It's also a good choice when
139139
a different flavor of a command under a different name.
140140

141141
What if other apps want to alter the same command and we don't know about them, but they may end up
142-
installed along with our app? This is where the composition pattern will serve us better.
142+
installed along with our app? This is where the plugin pattern will serve us better.
143143

144144

145-
.. _composition:
145+
.. _plugin:
146146

147-
Composition
147+
Plugins
148148
-----------
149149

150-
**The composition pattern allows us to add or override commands and groups on an upstream command
150+
**The plugin pattern allows us to add or override commands and groups on an upstream command
151151
directly without overriding it or changing its name. This allows downstream apps that know
152152
nothing about each other to add their own behavior to the same command. If there are conflicts
153153
they are resolved in INSTALLED_APPS order.**
@@ -159,7 +159,7 @@ Because we're now mostly working at the level of our particular site we may want
159159
backup logic. For instance, lets say we know our site will always run on sqlite and we prefer
160160
to just copy the file to backup our database. Lets also pretend that it is useful for us to backup
161161
the python stack (e.g. requirements.txt) running on our server. To do that we can use the
162-
composition pattern to add our environment backup routine and override the database routine from
162+
plugin pattern to add our environment backup routine and override the database routine from
163163
the upstream backup app. Our app tree now might look like this:
164164

165165
.. code-block:: text
@@ -218,7 +218,7 @@ this:
218218
do this inside ready() because conflicts are resolved in the order in which the extension
219219
modules are registered and ready() methods are called in INSTALLED_APPS order.
220220

221-
For composition to work, we'll need to re-mplement media from above as a composed extension
221+
For plugins to work, we'll need to re-mplement media from above as a composed extension
222222
and that would look like this:
223223

224224
.. literalinclude:: ../../django_typer/tests/apps/examples/extensions/media2/management/extensions/backup.py
@@ -310,18 +310,18 @@ You may even override the initializer of a predefined group:
310310
and groups.
311311
"""
312312
313-
When Does Composition Make Sense?
313+
When Do Plugins Make Sense?
314314
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315315

316-
Composition can be used to group like behavior together under a common root command. This can be
316+
Plugins can be used to group like behavior together under a common root command. This can be
317317
thought of as a way to namespace CLI tools or easily share significant code between tools that have
318318
common initialization logic. Moreover it allows you to do this safely and in a way that can be
319319
deterministically controlled in settings. Most use cases are not this complex and even our backup
320320
example could probably better be implemented as a batch of commands.
321321

322322
Django apps are great for forcing separation of concerns on your code base. In large self contained
323323
projects its often a good idea to break your code into apps that are as self contained as possible.
324-
Composition can be a good way to organize commands in a code base that follows this pattern. It
324+
Plugins can be a good way to organize commands in a code base that follows this pattern. It
325325
also allows for deployments that install a subset of those apps and is therefore a good way to
326326
organize commands in code bases that serve as a framework for a particular kind of site or that
327327
support selecting the features to install.

doc/source/reference.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ django_typer
1717
:show-inheritance:
1818

1919
.. autoclass:: django_typer.Typer
20-
:members: callback, initialize, command, add_typer
20+
:members: callback, initialize, command, group, add_typer
2121

2222
.. autoclass:: django_typer.TyperCommand
2323
:members: initialize, callback, command, group, echo, secho, print_help, get_subcommand
@@ -27,10 +27,6 @@ django_typer
2727

2828
.. autoclass:: django_typer.TyperCommandMeta
2929

30-
.. autoclass:: django_typer.CommandGroup
31-
:members: callback, initialize, group, command
32-
33-
3430
.. _types:
3531

3632
types

0 commit comments

Comments
 (0)