Skip to content

feat(config): implement configuration crate - #31

Merged
mroczect merged 14 commits into
refactor/new-designfrom
config/feat/add-config-crate
Sep 7, 2026
Merged

mroczect merged 14 commits into
refactor/new-designfrom
config/feat/add-config-crate

Conversation

@mroczect

@mroczect mroczect commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

This PR implements the core configuration crate (librawssg_config) for the workspace. It defines configuration types (Config, BuildConfig, SiteConfig, ContentRule, NavItem) with validation and serialization support. Tests are added for all types. The handler crate's path dependencies are also updated to include explicit version numbers.

Motivation & Context

The configuration crate was a placeholder. This implementation provides the foundational configuration model for the static site generator, enabling parsing from YAML/JSON, validation, and programmatic manipulation. Explicit version numbers on path dependencies improve clarity and ensure compatibility.

Detailed Changes

  • Cargo.lock: Updated to include new dependencies for serde_yaml, indexmap, and unsafe-libyaml.
  • librawssg_config/Cargo.toml: Added librawssg_error, serde, serde_json, serde_yaml as dependencies, and tempfile as a dev-dependency.
  • librawssg_config/src/lib.rs: Replaced placeholder with module declarations and re-exports for BuildConfig, Config, ContentRule, NavItem, SiteConfig. Added crate-level lint allowance for multiple crate versions.
  • librawssg_handler/Cargo.toml: Added version = "1.0.0" to librawssg_error and librawssg_fs path dependencies.
  • librawssg_config/src/build.rs: Added BuildConfig struct with default directory settings and serde support.
  • librawssg_config/src/config.rs: Added Config struct with validation (site name, content rules, patterns, base_url), rule management methods, and YAML/JSON conversion helpers.
  • librawssg_config/src/content_rule.rs: Added ContentRule struct with constructor and serde support.
  • librawssg_config/src/nav.rs: Added NavItem struct with constructor and serde support.
  • librawssg_config/src/site.rs: Added SiteConfig struct with constructor and serde support.
  • librawssg_config/tests/build_tests.rs: Added tests for BuildConfig.
  • librawssg_config/tests/config_tests.rs: Added comprehensive tests for Config.
  • librawssg_config/tests/content_rule_tests.rs: Added tests for ContentRule.
  • librawssg_config/tests/nav_tests.rs: Added tests for NavItem.
  • librawssg_config/tests/site_tests.rs: Added tests for SiteConfig.

Impact & Breaking Changes

No breaking changes identified. All new types are additive and the handler crate's dependency version additions do not alter its public API.

Testing Recommendations

Run cargo test -p librawssg_config to execute the new configuration tests. Ensure the workspace builds without errors using cargo check --workspace. Also run cargo clippy --workspace --all-targets --all-features -- -D warnings to verify strict lint compliance.

Related Issues

None.

Add entries for serde_yaml and its dependencies, plus indexmap and unsafe-libyaml. Update existing entries to reflect new dependency graph.
Add librawssg_error, serde, serde_json, serde_yaml as dependencies and tempfile as dev-dependency. This enables config parsing, serialization, and testing.
Replace placeholder with module declarations for build, config, content_rule, nav, and site. Re-export public types and add crate-level lint allowance.
Add version = "1.0.0" to librawssg_error and librawssg_fs path dependencies. This clarifies compatibility requirements and aligns with workspace versioning.
Add BuildConfig with content_dir, output_dir, templates_dir, static_dir and serde defaults. Implement Default, new, and derive traits for serialization.
Add Config struct with site, build, content_rules, extra. Provide methods for rule management, validation, YAML/JSON conversion. Validation checks site name, rules, patterns, and base_url.
Add ContentRule with name, pattern, template, optional list fields, extra. Derive serde traits and provide a constructor.
Add NavItem with label, url, children and serde support. Provide a constructor and Default.
Add SiteConfig with nav, sidebar, site_name, description, language, base_url, author, repo_url, license, extra. Implement Default and a constructor.
Add tests for default values, new equality, YAML roundtrip, and deserialization with defaults.
Add comprehensive tests for Config construction, rule management, validation, YAML/JSON roundtrip, and error cases.
Add tests for constructor, default, and serialization roundtrip.
Add tests for constructor, default, child addition, and serialization roundtrip.
Add tests for constructor, default values, and serialization roundtrip.
@mroczect
mroczect merged commit acbdf43 into refactor/new-design Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant