-
-
Notifications
You must be signed in to change notification settings - Fork 176
fix(config) :: document the real configuration defaults' #1391
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
Open
81reap
wants to merge
1
commit into
sqlpage:main
Choose a base branch
from
81reap:drift/1-config-defaults
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| use serde::Deserialize; | ||
| use serde::de::value::Error as DeError; | ||
| use serde::de::{Deserializer, Visitor}; | ||
| use sqlpage::app_config::AppConfig; | ||
| use std::collections::BTreeSet; | ||
|
|
||
| #[test] | ||
| fn configuration_md_documents_every_option() { | ||
| let documented = documented_option_names(); | ||
| let implemented = app_config_option_names(); | ||
|
|
||
| let undocumented: Vec<_> = implemented.difference(&documented).collect(); | ||
| let unimplemented: Vec<_> = documented.difference(&implemented).collect(); | ||
|
|
||
| assert!( | ||
| undocumented.is_empty() && unimplemented.is_empty(), | ||
| "configuration.md and AppConfig disagree.\n\ | ||
| Missing from configuration.md: {undocumented:?}\n\ | ||
| Documented but not in AppConfig: {unimplemented:?}" | ||
| ); | ||
| } | ||
|
|
||
| fn documented_option_names() -> BTreeSet<String> { | ||
| let table = std::fs::read_to_string("configuration.md").unwrap(); | ||
| table | ||
| .lines() | ||
| .filter_map(|line| line.strip_prefix("| `")?.split('`').next()) | ||
| .map(str::to_owned) | ||
| .collect() | ||
| } | ||
|
|
||
| fn app_config_option_names() -> BTreeSet<String> { | ||
| let mut collector = OptionNameCollector::default(); | ||
| let _ = AppConfig::deserialize(&mut collector); | ||
| collector | ||
| .names | ||
| .iter() | ||
| .map(|name| (*name).to_owned()) | ||
| .collect() | ||
| } | ||
|
|
||
| /// Serde hands the names it expects, renames included, to `deserialize_struct`. | ||
| #[derive(Default)] | ||
| struct OptionNameCollector { | ||
| names: &'static [&'static str], | ||
| } | ||
|
|
||
| impl<'de> Deserializer<'de> for &mut OptionNameCollector { | ||
| type Error = DeError; | ||
|
|
||
| fn deserialize_struct<V: Visitor<'de>>( | ||
| self, | ||
| _name: &'static str, | ||
| fields: &'static [&'static str], | ||
| _visitor: V, | ||
| ) -> Result<V::Value, Self::Error> { | ||
| self.names = fields; | ||
| Err(serde::de::Error::custom("names collected")) | ||
| } | ||
|
|
||
| fn deserialize_any<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> { | ||
| Err(serde::de::Error::custom("AppConfig is not a struct")) | ||
| } | ||
|
|
||
| serde::forward_to_deserialize_any! { | ||
| bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf | ||
| option unit unit_struct newtype_struct seq tuple tuple_struct map enum | ||
| identifier ignored_any | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| mod basic; | ||
| mod common; | ||
| mod configuration_docs; | ||
| mod core; | ||
| mod data_formats; | ||
| mod errors; | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this is true. When https_domain is set, but a port number different from 443 is set, SQLPage starts both an HTTP and an HTTPS server. This makes me suspicious about the entire PR. Is this entirely LLM generated, or are these issues you actually encountered while configuring your SQLPage instance ?