Module
migration_docs
migration_docs.Migration
A migration and its associated docs.
Migrations are typically loaded and accessed via the parent Migrations
object. When loaded, the Migration has access to core migration
attributes (e.g. atomic
, sql
, etc) and also has attributes
for every attribute collected in the documentation schema. For example,
if the user configured a type
attribute to be collected
in .migration-docs/migration.yaml
, it would be accessible as
a type
attribute on this object.
Source code in migration_docs/core.py
__getattribute__
Allows migration docs to be accessed as attributes on the Migration or the migration docs.
Doing this provides the ability for users to filter Migrations by any documented attribute.
Source code in migration_docs/core.py
hash
set_docs
Set docs about a migration
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt |
boolean, default=False
|
True if collecting data from a user. |
True
|
defaults |
dict, default=None
|
When prompting, use these values as defaults. |
None
|
Source code in migration_docs/core.py
sql
The raw SQL for the migration
Source code in migration_docs/core.py
migration_docs.Migrations
Migrations(
using: str = "default",
loader: Union[django_migration_loader.MigrationLoader, None] = None,
executor: Union[django_migration_executor.MigrationExecutor, None] = None,
)
Bases: FilterableUserList
A filterable and groupable list of migrations and their associated migration docs.
Source code in migration_docs/core.py
__getitem__
bootstrap_docs
filter_by_missing_docs
filter_by_stale_docs
Filter migration docs by ones that are stale
Source code in migration_docs/core.py
migration_docs.bootstrap
Bootstrap migration docs with filler values when integrating docs with a project for the first time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
Callable
|
A message printer for showing messages to the user. |
_pretty_msg
|
Raises:
Type | Description |
---|---|
RuntimeError
|
When migration docs have already been synced |
Source code in migration_docs/core.py
migration_docs.check
Check migration notes. Return False if any of the conditions hold true: - There are migrations without docs. - There are documented migrations that no longer exist. - There are stale migration docs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
Callable
|
A message printer for showing messages to the user. |
_pretty_msg
|
Returns:
Type | Description |
---|---|
bool
|
|
Source code in migration_docs/core.py
migration_docs.show
show(
app_labels: Union[List[str], None] = None,
unapplied: bool = False,
style: str = "default",
) -> str
Shows migration docs to the user
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_labels |
Union[List[str], None]
|
App labels to limit the shown migrations to. |
None
|
unapplied |
bool
|
Only show unapplied migrations. |
False
|
style |
str
|
The style to use when rendering. Corresponds to a Jinja template stored in
|
'default'
|
Returns:
Type | Description |
---|---|
str
|
The rendered migration list. |
Source code in migration_docs/core.py
migration_docs.sync
Sync new migrations with the migration docs and prune migrations that no longer exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
Callable
|
A message printer for showing messages to the user. |
_pretty_msg
|
Source code in migration_docs/core.py
migration_docs.update
Update migration docs for specific migrations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migrations |
List[str]
|
A list of migration labels to update (e.g. users.0001_initial). |
required |
msg |
Callable
|
A message printer for showing messages to the user. |
_pretty_msg
|