Skip to content

Commit

Permalink
chore: code style and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
amyXia1994 committed Sep 11, 2023
1 parent 9d0901d commit 2021b34
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions kclvm/api/src/service/ty.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::gpyrpc::{Decorator, KclType, Example};
use crate::gpyrpc::{Decorator, Example, KclType};
use indexmap::IndexSet;
use kclvm_runtime::SCHEMA_SETTINGS_ATTR_NAME;
use kclvm_sema::ty::{DictType, SchemaType, Type};
Expand Down Expand Up @@ -62,7 +62,7 @@ fn get_schema_ty_examples(schema_ty: &SchemaType) -> HashMap<String, Example> {
let exa = Example {
summary: example.summary.clone(),
description: example.description.clone(),
value: example.value.clone()
value: example.value.clone(),
};
examples.insert(key.clone(), exa);
}
Expand Down
31 changes: 25 additions & 6 deletions kclvm/sema/src/resolver/doc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pcre2::bytes::Regex;
use std::collections::{HashSet, HashMap};
use std::collections::{HashMap, HashSet};
use std::iter::Iterator;
use std::str;

Expand Down Expand Up @@ -281,7 +281,10 @@ pub(crate) fn parse_doc_string(ori: &String) -> Doc {
0 | 1 | 2 => "".to_string(),
_ => example_section[2..].join("\n"),
};
examples.insert("Default example".to_string(), Example::new("".to_string(), "".to_string(), default_example_content));
examples.insert(
"Default example".to_string(),
Example::new("".to_string(), "".to_string(), default_example_content),
);
}
Doc::new(summary, attrs, examples)
}
Expand All @@ -296,7 +299,11 @@ pub(crate) struct Doc {

impl Doc {
fn new(summary: String, attrs: Vec<Attribute>, examples: HashMap<String, Example>) -> Self {
Self { summary, attrs, examples: examples }
Self {
summary,
attrs,
examples,
}
}
}

Expand All @@ -323,7 +330,11 @@ pub struct Example {

impl Example {
fn new(summary: String, description: String, value: String) -> Self {
Self { summary, description, value }
Self {
summary,
description,
value,
}
}
}

Expand Down Expand Up @@ -611,8 +622,16 @@ unindented line
]
);
assert!(doc.examples.contains_key("Default example"));
assert_eq!(doc.examples.get("Default example"), Some(&Example::new("".to_string(), "".to_string(), "myCustomApp = AppConfiguration {
assert_eq!(
doc.examples.get("Default example"),
Some(&Example::new(
"".to_string(),
"".to_string(),
"myCustomApp = AppConfiguration {
name = \"componentName\"
}".to_string())));
}"
.to_string()
))
);
}
}
2 changes: 1 addition & 1 deletion kclvm/sema/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use crate::lint::{CombinedLintPass, Linter};
use crate::pre_process::pre_process_program;
use crate::resolver::scope::ScopeObject;
use crate::resolver::ty_alias::process_program_type_alias;
use crate::ty::TypeContext;
use crate::{resolver::scope::Scope, ty::SchemaType};
use kclvm_ast::ast::Program;
use kclvm_error::*;
use crate::ty::TypeContext;

use self::scope::{builtin_scope, ProgramScope};

Expand Down
2 changes: 1 addition & 1 deletion kclvm/sema/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub struct SchemaType {
/// The schema definition document string.
pub doc: String,
/// The code snippets of the schema usage examples
pub examples: HashMap<String, Example>,
pub examples: HashMap<String, Example>,
/// Indicates whether the schema is a type of a instance or
/// a type (value). Besides, it is necessary to distinguish
/// between a type instance and a type value, such as the following code:
Expand Down

0 comments on commit 2021b34

Please sign in to comment.