Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 29, 2024
1 parent 3ddd6c4 commit 049d2ee
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
15 changes: 15 additions & 0 deletions fastn-resolved/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ pub type Map<T> = std::collections::BTreeMap<String, T>;

#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum Definition {
SymbolAlias {
symbol: String,
alias: String,
line_number: usize,
},
ModuleAlias {
module: String,
alias: String,
line_number: usize,
},
Record(fastn_resolved::Record),
OrType(fastn_resolved::OrType),
OrTypeWithVariant {
Expand Down Expand Up @@ -63,6 +73,9 @@ impl Definition {
fastn_resolved::Definition::Function(f) => f.name.to_string(),
fastn_resolved::Definition::WebComponent(w) => w.name.to_string(),
fastn_resolved::Definition::Export { to, .. } => to.to_string(),
// TODO: check if the following two are valid
Definition::SymbolAlias { alias, .. } => alias.to_string(),
Definition::ModuleAlias { alias, .. } => alias.to_string(),
}
}

Expand All @@ -76,6 +89,8 @@ impl Definition {
Definition::OrTypeWithVariant { variant, .. } => variant.line_number(),
Definition::WebComponent(w) => w.line_number,
Definition::Export { line_number, .. } => *line_number,
Definition::SymbolAlias { line_number, .. } => *line_number,
Definition::ModuleAlias { line_number, .. } => *line_number,
}
}

Expand Down
2 changes: 1 addition & 1 deletion fastn-runtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ fn main() {

std::fs::write(std::path::PathBuf::from("output.html"), h.to_test_html()).unwrap();

// this main should create a HTML file, and store it in current folder as index.html etc.
// this main should create an HTML file, and store it in the current folder as index.html etc.
}
18 changes: 17 additions & 1 deletion v0.5/fastn-core/src/config/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@ impl fastn_core::Config {
pub async fn read(_fastn_ftd: fastn_section::Document) -> Result<Self, ReadError> {
Ok(fastn_core::Config {
sitemap: fastn_core::Sitemap {},
auto_imports: vec![],
auto_imports: vec![
// fastn_unresolved::UR::UnResolved(
// fastn_unresolved::Definition {
// // symbol requires us to know the module, which we do not know right now, so
// // we add empty values here, only the name.
// symbol: Some(fastn_unresolved::Symbol::new()),
// doc: None,
// name: fastn_unresolved::UR::UnResolved(fastn_section::Identifier::new(
// "ftd".to_string(),
// )),
// visibility: fastn_section::Visibility::Public,
// inner: fastn_unresolved::InnerDefinition::ModuleAlias(
// fastn_unresolved::Module::new("ftd", ""),
// ),
// },
// )
],
redirects: vec![],
dynamic_routes: vec![],
})
Expand Down
2 changes: 1 addition & 1 deletion v0.5/fastn-unresolved/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct Definition {
#[derive(Debug, Clone)]
pub enum InnerDefinition {
SymbolAlias(fastn_unresolved::Symbol),
ModuleAlias(fastn_unresolved::Symbol),
ModuleAlias(fastn_unresolved::Module),
Component {
arguments: Vec<UR<Argument, fastn_resolved::Argument>>,
body: Vec<URCI>,
Expand Down
1 change: 1 addition & 0 deletions v0.5/fastn-unresolved/src/resolver/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/// with the innermost block as the last entry.
pub fn resolve(
_module: &fastn_unresolved::Module,
// parent: Option<fastn_unresolved::Symbol>,
name: &mut fastn_unresolved::URIS,
_definitions: &std::collections::HashMap<fastn_unresolved::Symbol, fastn_unresolved::URD>,
interner: &mut string_interner::DefaultStringInterner,
Expand Down
1 change: 1 addition & 0 deletions v0.5/fastn/index.ftd
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-- ftd#text: hello
-- ftd.text: hello

0 comments on commit 049d2ee

Please sign in to comment.