Skip to content

Commit

Permalink
feat(html): add experimental-html feature flag to enable html file …
Browse files Browse the repository at this point in the history
…handler
  • Loading branch information
dyc3 committed Sep 18, 2024
1 parent 2c8ff7f commit 18742af
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions crates/biome_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ tokio = { workspace = true, features = ["io-util"] }

[features]
docgen = ["bpaf/docgen"]
experimental-html = ["biome_service/experimental-html"]

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/biome_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ schema = [
"biome_css_syntax/schema",
"biome_graphql_syntax/schema",
]
experimental-html = []

[dev-dependencies]
insta = { workspace = true }
Expand Down
14 changes: 9 additions & 5 deletions crates/biome_service/src/file_handlers/html.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use biome_analyze::{AnalyzerConfiguration, AnalyzerOptions};
use biome_formatter::Printed;
use biome_fs::BiomePath;
use biome_html_formatter::{format_node, HtmlFormatOptions};
Expand Down Expand Up @@ -25,9 +26,9 @@ impl ServiceLanguage for HtmlLanguage {
type EnvironmentSettings = ();

fn lookup_settings(
_languages: &crate::settings::LanguageListSettings,
languages: &crate::settings::LanguageListSettings,
) -> &crate::settings::LanguageSettings<Self> {
todo!()
&languages.html
}

fn resolve_format_options(
Expand All @@ -46,10 +47,13 @@ impl ServiceLanguage for HtmlLanguage {
_linter: Option<&crate::settings::LinterSettings>,
_overrides: Option<&crate::settings::OverrideSettings>,
_language: Option<&Self::LinterSettings>,
_path: &biome_fs::BiomePath,
path: &biome_fs::BiomePath,
_file_source: &super::DocumentFileSource,
) -> biome_analyze::AnalyzerOptions {
todo!()
) -> AnalyzerOptions {
AnalyzerOptions {
configuration: AnalyzerConfiguration::default(),
file_path: path.to_path_buf(),
}
}
}

Expand Down
17 changes: 11 additions & 6 deletions crates/biome_service/src/file_handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ impl DocumentFileSource {
if let Ok(file_source) = GraphqlFileSource::try_from_extension(extension) {
return Ok(file_source.into());
}
//if let Ok(file_source) = HtmlFileSource::try_from_extension(extension) {
// return Ok(file_source.into());
//}
#[cfg(feature = "experimental-html")]
if let Ok(file_source) = HtmlFileSource::try_from_extension(extension) {
return Ok(file_source.into());
}
Err(FileSourceError::UnknownExtension)
}

Expand All @@ -170,9 +171,10 @@ impl DocumentFileSource {
if let Ok(file_source) = GraphqlFileSource::try_from_language_id(language_id) {
return Ok(file_source.into());
}
//if let Ok(file_source) = HtmlFileSource::try_from_language_id(language_id) {
// return Ok(file_source.into());
//}
#[cfg(feature = "experimental-html")]
if let Ok(file_source) = HtmlFileSource::try_from_language_id(language_id) {
return Ok(file_source.into());
}
Err(FileSourceError::UnknownLanguageId)
}

Expand Down Expand Up @@ -314,7 +316,10 @@ impl DocumentFileSource {
DocumentFileSource::Css(_)
| DocumentFileSource::Graphql(_)
| DocumentFileSource::Json(_) => true,
#[cfg(not(feature = "experimental-html"))]
DocumentFileSource::Html(_) => false,
#[cfg(feature = "experimental-html")]
DocumentFileSource::Html(_) => true,
DocumentFileSource::Unknown => false,
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_service/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use biome_formatter::{
use biome_fs::BiomePath;
use biome_graphql_formatter::context::GraphqlFormatOptions;
use biome_graphql_syntax::GraphqlLanguage;
use biome_html_syntax::HtmlLanguage;
use biome_js_formatter::context::JsFormatOptions;
use biome_js_parser::JsParserOptions;
use biome_js_syntax::{JsFileSource, JsLanguage};
Expand Down Expand Up @@ -560,6 +561,7 @@ pub struct LanguageListSettings {
pub json: LanguageSettings<JsonLanguage>,
pub css: LanguageSettings<CssLanguage>,
pub graphql: LanguageSettings<GraphqlLanguage>,
pub html: LanguageSettings<HtmlLanguage>,
}

impl From<JavascriptConfiguration> for LanguageSettings<JsLanguage> {
Expand Down

0 comments on commit 18742af

Please sign in to comment.