@@ -26,17 +26,26 @@ def get_connection(
2626 config : dict | None = None
2727) -> Connection | DockerRunner | Context :
2828 """
29- Return a connection object based on environment variables or config .
29+ Resolve the appropriate connection object for the site .
3030
31- Priority:
32- 1. Environment variables: DEPLOYER_HOST, USER, PORT
33- 2. Docker runner if configured.
34- 3. Host/port from config.
35- 4. Fallback connection or local.
31+ Selects the correct runner based on environment variables,
32+ Docker settings, or host definitions. Priority order:
3633
37- :param fallback_connection: Local context or default connection
38- :param config: Optional site configuration dictionary
39- :return: Fabric Connection, DockerRunner, or Context
34+ 1. Environment variables: ``DEPLOYER_HOST``, ``DEPLOYER_USER``,
35+ ``DEPLOYER_PORT``
36+ 2. Docker runner (if ``runner: docker`` is set in config)
37+ 3. SSH host/port defined in config
38+ 4. Fallback connection
39+ 5. Default to local context
40+
41+ :param fallback_connection: Default local or remote runner.
42+ :type fallback_connection: Union[Connection, DockerRunner, Context]
43+
44+ :param config: Optional site config loaded from YAML.
45+ :type config: dict or None
46+
47+ :return: A connection object suitable for deployment.
48+ :rtype: Union[Connection, DockerRunner, Context]
4049 """
4150 # 1. If environment variable is set, override all
4251 host = os .getenv ("DEPLOYER_HOST" )
@@ -82,8 +91,14 @@ def deploy(c: Connection | DockerRunner | Context, site: str) -> None:
8291 """
8392 Deploy a single site defined in the configuration file.
8493
85- :param c: Fabric connection object.
86- :param site: Name of the site defined in sites.yml.
94+ Loads site-specific configuration, resolves the proper connection
95+ (local, Docker, or SSH), and runs the full deployment process.
96+
97+ :param c: Fabric connection or context object.
98+ :type c: Union[Connection, DockerRunner, Context]
99+
100+ :param site: Name of the site as defined in ``sites.yml``.
101+ :type site: str
87102 """
88103 # Load all site definitions from the YAML config
89104 sites = load_sites ()
@@ -108,9 +123,13 @@ def deploy(c: Connection | DockerRunner | Context, site: str) -> None:
108123@task
109124def deploy_all (c : Connection | DockerRunner | Context ) -> None :
110125 """
111- Deploy all sites listed in sites.yml.
126+ Deploy all sites listed in the configuration file.
127+
128+ Iterates through all entries in ``sites.yml`` and runs the
129+ deployment pipeline for each one sequentially.
112130
113- :param c: Fabric connection object.
131+ :param c: Fabric connection or context object.
132+ :type c: Union[Connection, DockerRunner, Context]
114133 """
115134 # Load all site definitions
116135 sites = load_sites ()
@@ -127,20 +146,29 @@ def deploy_all(c: Connection | DockerRunner | Context) -> None:
127146@task
128147def list_sites (c : Connection | DockerRunner | Context ) -> None :
129148 """
130- Display all available site configurations.
149+ Display all configured sites and their repository URLs.
150+
151+ Loads site data from ``sites.yml`` and prints the site name
152+ alongside its associated Git repository.
131153
132- :param c: Fabric connection object.
154+ :param c: Fabric connection or context object.
155+ :type c: Union[Connection, DockerRunner, Context]
133156 """
134157 # Print table of available site names
135158 print_site_list ()
136159
137160@task (help = {"site" : "Name of the site to rollback" })
138161def rollback (c : Connection | DockerRunner | Context , site : str ) -> None :
139162 """
140- Rollback a site to its previous release.
163+ Rollback a site to the previous release.
164+
165+ Identifies the most recent backup release and reverts to it.
166+
167+ :param c: Fabric connection or context object.
168+ :type c: Union[Connection, DockerRunner, Context]
141169
142- :param c: Fabric connection object.
143170 :param site: Name of the site to rollback.
171+ :type site: str
144172 """
145173 # Initialize logger
146174 logger = get_logger (site )
@@ -166,9 +194,13 @@ def rollback(c: Connection | DockerRunner | Context, site: str) -> None:
166194@task
167195def rollback_all (c : Connection | DockerRunner | Context ) -> None :
168196 """
169- Rollback all sites to their previous release.
197+ Rollback all sites to their previous releases.
198+
199+ Iterates through all configured sites and performs a rollback
200+ to their last known good deployment.
170201
171- :param c: Fabric connection object.
202+ :param c: Fabric connection or context object.
203+ :type c: Union[Connection, DockerRunner, Context]
172204 """
173205 # Load all site configs
174206 sites = load_sites ()
@@ -185,10 +217,16 @@ def rollback_all(c: Connection | DockerRunner | Context) -> None:
185217@task (help = {"site" : "Name of the site to unlock" })
186218def unlock (c : Connection | DockerRunner | Context , site : str ) -> None :
187219 """
188- Remove the lock file for a specific site.
220+ Force-remove the deployment lock for a specific site.
221+
222+ Useful when a previous deployment was interrupted and the
223+ lock wasn't released.
224+
225+ :param c: Fabric connection or context object.
226+ :type c: Union[Connection, DockerRunner, Context]
189227
190- :param c: Fabric connection object.
191228 :param site: Name of the site to unlock.
229+ :type site: str
192230 """
193231 # Initialize logger
194232 logger = get_logger (site )
@@ -214,9 +252,12 @@ def unlock(c: Connection | DockerRunner | Context, site: str) -> None:
214252@task
215253def unlock_all (c : Connection | DockerRunner | Context ) -> None :
216254 """
217- Unlock all sites by removing their lock files.
255+ Remove lock files for all sites defined in ``sites.yml``.
256+
257+ Useful when recovering from interrupted deploys or rollbacks.
218258
219- :param c: Fabric connection object.
259+ :param c: Fabric connection or context object.
260+ :type c: Union[Connection, DockerRunner, Context]
220261 """
221262 # Load site configurations
222263 sites = load_sites ()
0 commit comments