Skip to content

Commit 3079921

Browse files
committed
better docs
1 parent d9c1ac0 commit 3079921

File tree

9 files changed

+69
-36
lines changed

9 files changed

+69
-36
lines changed

docs/docs/api.md

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

docs/docs/api/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Changelogs
2+
3+
::: pum.changelog.Changelog
4+
5+
::: pum.changelog.list_changelogs
6+
7+
::: pum.changelog.last_version
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## MigrationParameterDefinition
2+
3+
::: pum.migration_parameter_definition.ParameterType
4+
::: pum.migration_parameter_definition.MigrationParameterDefintion

docs/docs/api/pum_config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## PumConfig
2+
3+
::: pum.config.PumConfig

docs/docs/api/schema_migrations.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## SchemaMigrations
2+
3+
::: pum.schema_migrations.SchemaMigrations

docs/docs/api/upgrader.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Upgrader
2+
3+
::: pum.upgrader.Upgrader

pum/changelog.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class Changelog:
1313
"""
1414

1515
def __init__(self, dir):
16+
"""
17+
Args:
18+
dir (str): The directory where the changelog is located.
19+
"""
1620
self.dir = dir
1721
self.version = parse_version(basename(dir))
1822

pum/config.py

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class PumConfig:
1212
def __init__(self, **kwargs):
1313
"""
1414
Initialize the configuration with key-value pairs.
15+
16+
Args:
17+
**kwargs: Key-value pairs representing configuration settings.
1518
"""
1619
self.pg_restore_exe: str | None = kwargs.get("pg_restore_exe") or os.getenv(
1720
"PG_RESTORE_EXE"
@@ -43,27 +46,49 @@ def __init__(self, **kwargs):
4346
"parameters must be a list of dictionaries or MigrationParameterDefintion instances"
4447
)
4548

46-
def get(self, key, default=None):
47-
"""
48-
Get a configuration value by key, with an optional default.
49-
"""
50-
return getattr(self, key, default)
49+
# def get(self, key, default=None) -> any:
50+
# """
51+
# Get a configuration value by key, with an optional default.
52+
# This method allows dynamic retrieval of attributes from the PumConfig instance.
53+
# Args:
54+
# key (str): The name of the attribute to retrieve.
55+
# default: The default value to return if the attribute does not exist.
56+
# Returns:
57+
# any: The value of the attribute, or the default value if the attribute does not exist.
58+
# """
59+
# return getattr(self, key, default)
5160

52-
def set(self, key, value):
53-
"""
54-
Set a configuration value by key.
55-
"""
56-
setattr(self, key, value)
61+
# def set(self, key, value):
62+
# """
63+
# Set a configuration value by key.
64+
# This method allows dynamic setting of attributes on the PumConfig instance.
65+
66+
# Args:
67+
# key (str): The name of the attribute to set.
68+
# value: The value to assign to the attribute.
69+
# Raises:
70+
# AttributeError: If the attribute does not exist.
71+
# """
72+
# setattr(self, key, value)
5773

58-
def parameters(self):
74+
def parameters(self) -> dict[str, MigrationParameterDefintion]:
5975
"""
60-
Get all changelogs parameters as a dictionary.
76+
Get all migration parameters as a dictionary.
77+
78+
Returns:
79+
dict[str, MigrationParameterDefintion]: A dictionary of migration parameters.
80+
The keys are parameter names, and the values are MigrationParameterDefintion instances.
6181
"""
6282
return self.parameter_definitions
6383

64-
def parameter(self, name):
84+
def parameter(self, name) -> MigrationParameterDefintion:
6585
"""
66-
Get a specific changelog parameter by name.
86+
Get a specific migration parameter by name.
87+
88+
Returns:
89+
MigrationParameterDefintion: The migration parameter definition.
90+
Raises:
91+
KeyError: If the parameter name does not exist.
6792
"""
6893
return self.parameter_definitions[name]
6994

pum/schema_migrations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626

2727

2828
class SchemaMigrations:
29+
"""
30+
This class is responsible for managing the schema migrations in the database.
31+
It provides methods to create the schema_migrations table, check its existence,
32+
set the baseline version, and retrieve migration details.
33+
"""
34+
2935
def __init__(self, config: PumConfig):
3036
"""
3137
Initialize the SchemaMigrations class with a database connection and configuration.

0 commit comments

Comments
 (0)