feat(config): implement configuration crate - #31
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
librawssg_error,serde,serde_json,serde_yamlas dependencies, andtempfileas a dev-dependency.BuildConfig,Config,ContentRule,NavItem,SiteConfig. Added crate-level lint allowance for multiple crate versions.version = "1.0.0"tolibrawssg_errorandlibrawssg_fspath dependencies.BuildConfigstruct with default directory settings and serde support.Configstruct with validation (site name, content rules, patterns, base_url), rule management methods, and YAML/JSON conversion helpers.ContentRulestruct with constructor and serde support.NavItemstruct with constructor and serde support.SiteConfigstruct with constructor and serde support.BuildConfig.Config.ContentRule.NavItem.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_configto execute the new configuration tests. Ensure the workspace builds without errors usingcargo check --workspace. Also runcargo clippy --workspace --all-targets --all-features -- -D warningsto verify strict lint compliance.Related Issues
None.