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)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct TreeSitterJSON {
|
pub struct TreeSitterJSON {
|
||||||
|
#[serde(rename = "$schema")]
|
||||||
|
pub schema: Option<String>,
|
||||||
pub grammars: Vec<Grammar>,
|
pub grammars: Vec<Grammar>,
|
||||||
pub metadata: Metadata,
|
pub metadata: Metadata,
|
||||||
#[serde(default)]
|
#[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 PACKAGE_SWIFT_TEMPLATE: &str = include_str!("./templates/package.swift");
|
||||||
const TESTS_SWIFT_TEMPLATE: &str = include_str!("./templates/tests.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]
|
#[must_use]
|
||||||
pub fn path_in_ignore(repo_path: &Path) -> bool {
|
pub fn path_in_ignore(repo_path: &Path) -> bool {
|
||||||
[
|
[
|
||||||
|
|
@ -133,6 +136,7 @@ impl JsonConfigOpts {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn to_tree_sitter_json(self) -> TreeSitterJSON {
|
pub fn to_tree_sitter_json(self) -> TreeSitterJSON {
|
||||||
TreeSitterJSON {
|
TreeSitterJSON {
|
||||||
|
schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()),
|
||||||
grammars: vec![Grammar {
|
grammars: vec![Grammar {
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
camelcase: Some(self.camelcase),
|
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 name = old_config.name.replace("tree-sitter-", "");
|
||||||
|
|
||||||
let new_config = TreeSitterJSON {
|
let new_config = TreeSitterJSON {
|
||||||
|
schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()),
|
||||||
grammars: old_config
|
grammars: old_config
|
||||||
.tree_sitter
|
.tree_sitter
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue