Module

config.defaults

Single source of truth for all Bengal configuration defaults.

All config access should use these defaults via get_default() or specialized helpers like get_max_workers(). Provides centralized default values for all configuration options.

Key Concepts:

  • Default values: Centralized default configuration values
  • Worker configuration: Auto-detection of optimal worker count
  • Fast imports: Avoids heavy dependencies for fast import time
  • Specialized helpers: get_max_workers(), etc. for common config access

Related Modules:

  • bengal.config.loader: Configuration loading from files
  • bengal.config.env_overrides: Environment variable overrides
  • bengal.orchestration.build: Build orchestration using config

See Also:

  • bengal/config/defaults.py: get_default() for default value access
  • bengal/config/defaults.py: get_max_workers() for worker configuration

Functions

get_max_workers
Resolve max_workers with auto-detection.
1 int
def get_max_workers(config_value: int | None = None) -> int

Resolve max_workers with auto-detection.

Parameters 1

Name Type Default Description
config_value int | None None

User-configured value from site.config.get("max_workers") - None or 0 = auto-detect based on CPU count - Positive int = use that value

Returns

int

Resolved worker count (always >= 1)

get_default
Get default value for a config key.
2 Any
def get_default(key: str, nested_key: str | None = None) -> Any

Get default value for a config key.

Parameters 2

Name Type Default Description
key str

Top-level config key (e.g., "max_workers", "theme")

nested_key str | None None

Optional nested key using dot notation (e.g., "lunr.prebuilt")

Returns

Any

Default value, or None if key not found

get_pagination_per_page
Resolve pagination per_page with default.
1 int
def get_pagination_per_page(config_value: int | None = None) -> int

Resolve pagination per_page with default.

Parameters 1

Name Type Default Description
config_value int | None None

User-configured value

Returns

int

Items per page (default: 10, minimum: 1)

normalize_bool_or_dict
Normalize config values that can be bool or dict. This standardizes handling of config keys like `…
3 dict[str, Any]
def normalize_bool_or_dict(value: bool | dict[str, Any] | None, key: str, default_enabled: bool = True) -> dict[str, Any]

Normalize config values that can be bool or dict.

This standardizes handling of config keys likehealth_check,search, graph, etc. that accept both:

  • key: false(bool to disable)
  • key: { enabled: true, ... }(dict with options)

Parameters 3

Name Type Default Description
value bool | dict[str, Any] | None

The config value (bool, dict, or None)

key str

The config key name (for defaults lookup)

default_enabled bool True

Whether the feature is enabled by default

Returns

dict[str, Any]

Normalized dict with 'enabled' key and any other options

is_feature_enabled
Check if a bool/dict config feature is enabled. Convenience function for quick enable/disable chec…
3 bool
def is_feature_enabled(config: dict[str, Any], key: str, default: bool = True) -> bool

Check if a bool/dict config feature is enabled.

Convenience function for quick enable/disable checks without needing the full normalized dict.

Parameters 3

Name Type Default Description
config dict[str, Any]

The site config dictionary

key str

The config key to check (e.g., "health_check", "search")

default bool True

Default value if key not present

Returns

bool

True if feature is enabled, False otherwise

get_feature_config
Get normalized config for a bool/dict feature. This is the main entry point for accessing features…
3 dict[str, Any]
def get_feature_config(config: dict[str, Any], key: str, default_enabled: bool = True) -> dict[str, Any]

Get normalized config for a bool/dict feature.

This is the main entry point for accessing features that can be configured as either bool or dict.

Parameters 3

Name Type Default Description
config dict[str, Any]

The site config dictionary

key str

The config key (e.g., "health_check", "search", "graph")

default_enabled bool True

Whether the feature is enabled by default

Returns

dict[str, Any]

Normalized dict with 'enabled' key and feature options