remove treehouse-format crate and collapse everything into src

This commit is contained in:
りき萌 2025-07-10 16:50:41 +02:00
parent ca127a9411
commit b792688776
66 changed files with 145 additions and 112 deletions

37
Cargo.lock generated
View file

@ -724,7 +724,7 @@ dependencies = [
"pest_derive", "pest_derive",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror 1.0.69",
] ]
[[package]] [[package]]
@ -1409,7 +1409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442"
dependencies = [ dependencies = [
"memchr", "memchr",
"thiserror", "thiserror 1.0.69",
"ucd-trie", "ucd-trie",
] ]
@ -1599,7 +1599,7 @@ dependencies = [
"rand_chacha", "rand_chacha",
"simd_helpers", "simd_helpers",
"system-deps", "system-deps",
"thiserror", "thiserror 1.0.69",
"v_frame", "v_frame",
"wasm-bindgen", "wasm-bindgen",
] ]
@ -1931,7 +1931,16 @@ version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 1.0.69",
]
[[package]]
name = "thiserror"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [
"thiserror-impl 2.0.12",
] ]
[[package]] [[package]]
@ -1945,6 +1954,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thiserror-impl"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.8" version = "1.1.8"
@ -2176,24 +2196,17 @@ dependencies = [
"regex", "regex",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 2.0.12",
"tokio", "tokio",
"toml_edit 0.19.15", "toml_edit 0.19.15",
"tracing", "tracing",
"tracing-chrome", "tracing-chrome",
"tracing-subscriber", "tracing-subscriber",
"treehouse-format",
"ulid", "ulid",
"webp", "webp",
"xmlparser", "xmlparser",
] ]
[[package]]
name = "treehouse-format"
version = "0.1.0"
dependencies = [
"thiserror",
]
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.17.0" version = "1.17.0"

View file

@ -1,11 +1,37 @@
[workspace] [package]
members = ["crates/*"] name = "treehouse"
resolver = "2" version = "0.1.0"
edition = "2021"
[workspace.dependencies] [dependencies]
anyhow = "1.0.75"
axum = { version = "0.7.9", features = ["macros"] }
axum-macros = "0.4.2"
base64 = "0.21.7"
blake3 = "1.5.3"
chrono = { version = "0.4.35", features = ["serde"] }
clap = { version = "4.3.22", features = ["derive"] }
codespan-reporting = "0.11.1"
dashmap = "6.1.0"
git2 = { version = "0.19.0", default-features = false, features = ["vendored-libgit2"] }
handlebars = "4.3.7"
image = "0.25.5"
indexmap = { version = "2.2.6", features = ["serde"] }
jotdown = { version = "0.4.1", default-features = false }
rand = "0.8.5"
rayon = "1.10.0"
regex = "1.10.3"
serde = { version = "1.0.183", features = ["derive"] }
serde_json = "1.0.105"
thiserror = "2.0.12"
tokio = { version = "1.32.0", features = ["full"] }
toml_edit = { version = "0.19.14", features = ["serde"] }
tracing = "0.1.40" tracing = "0.1.40"
tracing-chrome = "0.7.2"
treehouse-format = { path = "crates/treehouse-format" } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
ulid = "1.0.0"
webp = "0.3.0"
xmlparser = "0.13.6"
[profile.dev] [profile.dev]
package.webp.opt-level = 3 package.webp.opt-level = 3

View file

@ -1,7 +0,0 @@
[package]
name = "treehouse-format"
version = "0.1.0"
edition = "2021"
[dependencies]
thiserror = "1.0.47"

View file

@ -1,32 +0,0 @@
use std::ops::Range;
pub mod ast;
pub mod pull;
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
pub enum ParseErrorKind {
#[error("branch kind (`+` or `-`) expected")]
BranchKindExpected,
#[error("root branches must not be indented")]
RootIndentLevel,
#[error("at least {expected} spaces of indentation were expected, but got {got}")]
InconsistentIndentation { got: usize, expected: usize },
#[error("unterminated code block")]
UnterminatedCodeBlock,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[error("{range:?}: {kind}")]
pub struct ParseError {
pub kind: ParseErrorKind,
pub range: Range<usize>,
}
impl ParseErrorKind {
pub fn at(self, range: Range<usize>) -> ParseError {
ParseError { kind: self, range }
}
}

View file

@ -1,36 +0,0 @@
[package]
name = "treehouse"
version = "0.1.0"
edition = "2021"
[dependencies]
treehouse-format = { workspace = true }
anyhow = "1.0.75"
axum = { version = "0.7.9", features = ["macros"] }
axum-macros = "0.4.2"
base64 = "0.21.7"
blake3 = "1.5.3"
chrono = { version = "0.4.35", features = ["serde"] }
clap = { version = "4.3.22", features = ["derive"] }
codespan-reporting = "0.11.1"
dashmap = "6.1.0"
git2 = { version = "0.19.0", default-features = false, features = ["vendored-libgit2"] }
handlebars = "4.3.7"
image = "0.25.5"
indexmap = { version = "2.2.6", features = ["serde"] }
jotdown = { version = "0.4.1", default-features = false }
rand = "0.8.5"
rayon = "1.10.0"
regex = "1.10.3"
serde = { version = "1.0.183", features = ["derive"] }
serde_json = "1.0.105"
tokio = { version = "1.32.0", features = ["full"] }
toml_edit = { version = "0.19.14", features = ["serde"] }
tracing.workspace = true
tracing-chrome = "0.7.2"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
ulid = "1.0.0"
webp = "0.3.0"
xmlparser = "0.13.6"

View file

@ -3,11 +3,11 @@ use std::ops::{ControlFlow, Range};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use codespan_reporting::diagnostic::Diagnostic; use codespan_reporting::diagnostic::Diagnostic;
use tracing::{error, info}; use tracing::{error, info};
use treehouse_format::ast::Branch;
use crate::{ use crate::{
parse::{self, parse_toml_with_diagnostics, parse_tree_with_diagnostics}, parse::{self, parse_toml_with_diagnostics, parse_tree_with_diagnostics},
state::{report_diagnostics, FileId, Source, Treehouse}, state::{report_diagnostics, FileId, Source, Treehouse},
tree::ast::Branch,
vfs::{self, Content, Dir, Edit, EditPath, VPath}, vfs::{self, Content, Dir, Edit, EditPath, VPath},
}; };

View file

@ -1,10 +1,9 @@
use std::ops::ControlFlow; use std::ops::ControlFlow;
use treehouse_format::ast::{Branch, Roots};
use crate::{ use crate::{
parse::parse_tree_with_diagnostics, parse::parse_tree_with_diagnostics,
state::{report_diagnostics, Source, Treehouse}, state::{report_diagnostics, Source, Treehouse},
tree::ast::{Branch, Roots},
vfs::{self, Content, Dir, VPath}, vfs::{self, Content, Dir, VPath},
}; };

View file

@ -1,7 +1,6 @@
use std::fmt::Write; use std::fmt::Write;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use treehouse_format::pull::BranchKind;
use crate::{ use crate::{
config::Config, config::Config,
@ -11,7 +10,9 @@ use crate::{
state::{FileId, Treehouse}, state::{FileId, Treehouse},
tree::{ tree::{
attributes::{Content, Stage, Visibility}, attributes::{Content, Stage, Visibility},
mini_template, SemaBranchId, mini_template,
pull::BranchKind,
SemaBranchId,
}, },
vfs::{self, VPath, VPathBuf}, vfs::{self, VPath, VPathBuf},
}; };

View file

@ -2,9 +2,11 @@ use std::{ops::Range, str::FromStr};
use codespan_reporting::diagnostic::{Diagnostic, Label, LabelStyle, Severity}; use codespan_reporting::diagnostic::{Diagnostic, Label, LabelStyle, Severity};
use tracing::instrument; use tracing::instrument;
use treehouse_format::ast::Roots;
use crate::state::{toml_error_to_diagnostic, FileId, TomlError, Treehouse}; use crate::{
state::{toml_error_to_diagnostic, FileId, TomlError, Treehouse},
tree::{self, ast::Roots},
};
pub struct ErrorsEmitted; pub struct ErrorsEmitted;
@ -13,7 +15,7 @@ pub fn parse_tree_with_diagnostics(
file_id: FileId, file_id: FileId,
input: &str, input: &str,
) -> Result<Roots, Vec<Diagnostic<FileId>>> { ) -> Result<Roots, Vec<Diagnostic<FileId>>> {
Roots::parse(&mut treehouse_format::pull::Parser { input, position: 0 }).map_err(|error| { Roots::parse(&mut tree::pull::Parser { input, position: 0 }).map_err(|error| {
vec![Diagnostic { vec![Diagnostic {
severity: Severity::Error, severity: Severity::Error,
code: Some("tree".into()), code: Some("tree".into()),

View file

@ -1,20 +1,22 @@
pub mod ast;
pub mod attributes; pub mod attributes;
pub mod mini_template; pub mod mini_template;
pub mod pull;
use std::ops::Range; use std::ops::Range;
use attributes::Timestamps; use attributes::Timestamps;
use codespan_reporting::diagnostic::{Diagnostic, Label, LabelStyle, Severity}; use codespan_reporting::diagnostic::{Diagnostic, Label, LabelStyle, Severity};
use tracing::instrument; use tracing::instrument;
use treehouse_format::{
ast::{Branch, Roots},
pull::BranchKind,
};
use crate::{ use crate::{
config::Config, config::Config,
state::{toml_error_to_diagnostic, FileId, Source, TomlError, Treehouse}, state::{toml_error_to_diagnostic, FileId, Source, TomlError, Treehouse},
tree::attributes::{Attributes, Content}, tree::{
ast::{Branch, Roots},
attributes::{Attributes, Content},
pull::BranchKind,
},
}; };
use self::attributes::RootAttributes; use self::attributes::RootAttributes;
@ -409,3 +411,31 @@ impl SemaBranch {
attributes attributes
} }
} }
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
pub enum ParseErrorKind {
#[error("branch kind (`+` or `-`) expected")]
BranchKindExpected,
#[error("root branches must not be indented")]
RootIndentLevel,
#[error("at least {expected} spaces of indentation were expected, but got {got}")]
InconsistentIndentation { got: usize, expected: usize },
#[error("unterminated code block")]
UnterminatedCodeBlock,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[error("{range:?}: {kind}")]
pub struct ParseError {
pub kind: ParseErrorKind,
pub range: Range<usize>,
}
impl ParseErrorKind {
pub fn at(self, range: Range<usize>) -> ParseError {
ParseError { kind: self, range }
}
}

View file

@ -1,6 +1,6 @@
use std::ops::Range; use std::ops::Range;
use crate::{ use super::{
pull::{Attributes, BranchEvent, BranchKind, Parser}, pull::{Attributes, BranchEvent, BranchKind, Parser},
ParseError, ParseErrorKind, ParseError, ParseErrorKind,
}; };

1
src/tree/lib.rs Normal file
View file

@ -0,0 +1 @@

View file

@ -1,6 +1,6 @@
use std::{convert::identity, ops::Range}; use std::{convert::identity, ops::Range};
use crate::{ParseError, ParseErrorKind}; use super::{ParseError, ParseErrorKind};
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BranchKind { pub enum BranchKind {

View file

@ -147,7 +147,7 @@ html {
} }
body { body {
font-size: 1.4rem; font-size: 1.6rem;
} }
pre, pre,
@ -183,9 +183,10 @@ input {
"slnt" var(--recursive-slnt), "slnt" var(--recursive-slnt),
"CRSV" var(--recursive-crsv); "CRSV" var(--recursive-crsv);
font-feature-settings: var(--recursive-simplified-f), font-feature-settings:
var(--recursive-simplified-g), var(--recursive-simplified-l), var(--recursive-simplified-f), var(--recursive-simplified-g),
var(--recursive-simplified-r), var(--recursive-no-serif-L-Z); var(--recursive-simplified-l), var(--recursive-simplified-r),
var(--recursive-no-serif-L-Z);
} }
h1 { h1 {

35
template/_doc.hbs Normal file
View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en-US" prefix="og: https://ogp.me/ns#">
<head>
{{> components/_head.hbs }}
</head>
<body>
<!-- Empty span to push noscript over to the next grid cell.
Browsers turn <noscript> tags into <span style="display: inline !important;"> with no
additional classes, and we can't easily select that in CSS. -->
<span></span>
{{> components/_noscript.hbs }}
{{> components/_nav.hbs }}
{{> components/_header.hbs }}
{{!--
NOTE: ~ because components/_tree.hbs must not include any extra indentation, because it may
contain pre elements which shouldn't be indented.
--}}
{{~> components/_tree.hbs }}
{{!-- For all pages except the one linked from the footer, include the footer icon. --}}
{{#if (ne page.tree_path "treehouse")}}
{{> components/_footer.hbs }}
{{/if}}
<th-overlays></th-overlays>
<th-command-line></th-command-line>
</body>
</html>