mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:26:23 -04:00
feat: generate schema in tree-sitter.json
This commit is contained in:
parent
05b2f443ba
commit
78e5144f3f
|
|
@ -140,6 +140,8 @@ pub struct LanguageConfigurationJSON {
|
|||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct TreeSitterJSON {
|
||||
#[serde(rename = "$schema")]
|
||||
pub schema: Option<String>,
|
||||
pub grammars: Vec<Grammar>,
|
||||
pub metadata: Metadata,
|
||||
#[serde(default)]
|
||||
|
|
|
|||
|
|
@ -93,6 +93,9 @@ const TEST_BINDING_PY_TEMPLATE: &str = include_str!("./templates/test_binding.py
|
|||
const PACKAGE_SWIFT_TEMPLATE: &str = include_str!("./templates/package.swift");
|
||||
const TESTS_SWIFT_TEMPLATE: &str = include_str!("./templates/tests.swift");
|
||||
|
||||
const TREE_SITTER_JSON_SCHEMA: &str =
|
||||
"https://tree-sitter.github.io/tree-sitter/assets/schemas/config.schema.json";
|
||||
|
||||
#[must_use]
|
||||
pub fn path_in_ignore(repo_path: &Path) -> bool {
|
||||
[
|
||||
|
|
@ -133,6 +136,7 @@ impl JsonConfigOpts {
|
|||
#[must_use]
|
||||
pub fn to_tree_sitter_json(self) -> TreeSitterJSON {
|
||||
TreeSitterJSON {
|
||||
schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()),
|
||||
grammars: vec![Grammar {
|
||||
name: self.name.clone(),
|
||||
camelcase: Some(self.camelcase),
|
||||
|
|
@ -226,6 +230,7 @@ pub fn migrate_package_json(repo_path: &Path) -> Result<bool> {
|
|||
let name = old_config.name.replace("tree-sitter-", "");
|
||||
|
||||
let new_config = TreeSitterJSON {
|
||||
schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()),
|
||||
grammars: old_config
|
||||
.tree_sitter
|
||||
.unwrap()
|
||||
|
|
|
|||
Loading…
Reference in a new issue