Skip to content

docs(api): migrating the AppConfig utility to mkdocstrings #6008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aws_lambda_powertools/utilities/feature_flags/appconfig.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""Advanced feature flags utility
!!! abstract "Usage Documentation"
[`Feature Flags`](../../utilities/feature_flags.md)
"""
from __future__ import annotations

import logging
3 changes: 2 additions & 1 deletion aws_lambda_powertools/utilities/feature_flags/base.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@ def get_configuration(self) -> dict[str, Any]:
dict[str, Any]
parsed JSON dictionary
**Example**
Example
-------
```python
{
Original file line number Diff line number Diff line change
@@ -56,6 +56,8 @@ def compare_time_range(context_value: Any, condition_value: dict) -> bool:
end_time = current_time.replace(hour=int(end_hour), minute=int(end_min))

if int(end_hour) < int(start_hour):
# In normal circumstances, we need to assert **both** conditions
"""
# When the end hour is smaller than start hour, it means we are crossing a day's boundary.
# In this case we need to assert that current_time is **either** on one side or the other side of the boundary
#
@@ -69,10 +71,9 @@ def compare_time_range(context_value: Any, condition_value: dict) -> bool:
# │ │ │
# └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
# │

"""
return (start_time <= current_time) or (current_time <= end_time)
else:
# In normal circumstances, we need to assert **both** conditions
return start_time <= current_time <= end_time


12 changes: 7 additions & 5 deletions aws_lambda_powertools/utilities/feature_flags/feature_flags.py
Original file line number Diff line number Diff line change
@@ -179,7 +179,8 @@ def get_configuration(self) -> dict:
dict[str, dict]
parsed JSON dictionary
**Example**
Example
-------
```python
{
@@ -251,7 +252,7 @@ def evaluate(self, *, name: str, context: dict[str, Any] | None = None, default:
Can be boolean or any JSON values for non-boolean features.
Examples
Example
--------
```python
@@ -343,7 +344,8 @@ def get_enabled_features(self, *, context: dict[str, Any] | None = None) -> list
list[str]
list of all feature names that either matches context or have True as default
**Example**
Example
-------
```python
["premium_features", "my_feature_two", "always_true_feature"]
@@ -400,8 +402,8 @@ def validation_exception_handler(self, exc_class: Exception | list[Exception]):
exc_class : Exception | list[Exception]
One or more exceptions to catch
Examples
--------
Example
-------
```python
feature_flags = FeatureFlags(store=app_config)
2 changes: 2 additions & 0 deletions docs/api_doc/feature_flags/appconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- markdownlint-disable MD043 MD041 -->
::: aws_lambda_powertools.utilities.feature_flags.appconfig
2 changes: 2 additions & 0 deletions docs/api_doc/feature_flags/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- markdownlint-disable MD043 MD041 -->
::: aws_lambda_powertools.utilities.feature_flags.base
2 changes: 2 additions & 0 deletions docs/api_doc/feature_flags/comparators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- markdownlint-disable MD043 MD041 -->
::: aws_lambda_powertools.utilities.feature_flags.comparators
2 changes: 2 additions & 0 deletions docs/api_doc/feature_flags/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- markdownlint-disable MD043 MD041 -->
::: aws_lambda_powertools.utilities.feature_flags.exceptions
2 changes: 2 additions & 0 deletions docs/api_doc/feature_flags/feature_flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- markdownlint-disable MD043 MD041 -->
::: aws_lambda_powertools.utilities.feature_flags.feature_flags
2 changes: 2 additions & 0 deletions docs/api_doc/feature_flags/schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- markdownlint-disable MD043 MD041 -->
::: aws_lambda_powertools.utilities.feature_flags.schema
7 changes: 7 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -63,6 +63,13 @@ nav:
# - Casual to regular contributor: contributing/tracks/casual_regular_contributor.md
# - Customer to advocate: contributing/tracks/customer_advocate.md
- API Documentation:
- Feature Flags:
- AppConfig: api_doc/feature_flags/appconfig.md
- Base: api_doc/feature_flags/base.md
- Comparators: api_doc/feature_flags/comparators.md
- Exceptions: api_doc/feature_flags/exceptions.md
- Feature flags: api_doc/feature_flags/feature_flags.md
- Schema: api_doc/feature_flags/schema.md
- Idempotency:
- Base: api_doc/idempotency/base.md
- Config: api_doc/idempotency/config.md