diff --git a/doc-generator/markdown/en/docs/latest/index.md b/doc-generator/markdown/en/docs/latest/index.md index 5c4db5f..2980217 100755 --- a/doc-generator/markdown/en/docs/latest/index.md +++ b/doc-generator/markdown/en/docs/latest/index.md @@ -40,10 +40,11 @@ Num aConstant = 30 // <- `val` is optional Num var aVariable = 20 // <- `var` required // You can assign the result of many operations to a variable -val roi = +val roi = do { val income = someIncomeCalculation() val investment = 25000 income / investment // This will be the value of `roi` +} ``` ## Basic datatypes @@ -63,17 +64,18 @@ Str string = "John Doe" // // Conditionals // -if name == "John Doe" do +if name == "John Doe" { val message = "Hello John" console.log(message) -else if name == "Mark" do +} else if name == "Mark" { console.log("Hi Mark!") -else +} else { console.log("Hello there") +} // You can use conditionals as expressions -val response = if risk < 0.2 do "Go ahead" else "Don't" +val response = if risk < 0.2 { "Go ahead" } else { "Don't" } // There is no ternary conditional ``` @@ -121,16 +123,18 @@ var #(name, age, isMarried) = person // // Loops // -for key in object do - console.log("key: {key}, value: {object.[key]}") +for #(key, value) in object { + console.log("key: {key}, value: {value}") +} - -for value of array do +for value of array { console.log("value: {value}") +} -while condition do +while condition { print("while") +} ``` ## Functions @@ -147,15 +151,15 @@ add(10, 20) substring(input: "Hello, world!", start: 7, end: 12) // Funtion declaration -fun add(Num x, Num y) -> Num = +fun add(Num x, Num y) -> Num { x + y - +} // Function with default value -fun calculate(Num price, Num discount = 0.0) = +fun calculate(Num price, Num discount = 0.0) { val total = price * (1.0 - discount) console.log("Your total is {total}$") - +} calculate(100, 0.25) // "Your total is 75$" calculate(100) // "Your total is 100$" @@ -361,15 +365,32 @@ match result with ## JSX ```misti -// -// JSX -// +use Solid.{createSignal} +use Search +use Person +use Registers +use NewRegister + +pub fun 'Certs() { + val #(person, setPerson) = createSignal[Person?](None) + val #(lastUpdate, setLastUpdate) = createSignal(0) + +
+

+ Registrar certificado +

+ + + +
+} -val element = <div>This is JSX</div> -val list = items.map fun (item, count) {<li key={count}>{item}</li>} ``` - - diff --git a/doc-generator/markdown/en/docs/latest/index.yaml b/doc-generator/markdown/en/docs/latest/index.yaml index 37c6e77..63a06f4 100644 --- a/doc-generator/markdown/en/docs/latest/index.yaml +++ b/doc-generator/markdown/en/docs/latest/index.yaml @@ -3,42 +3,58 @@ name: "" has_index: true children: - path: index + name: Index - path: basics name: Basics children: - path: variables-and-constants + name: Variables and constants - path: simple-datatypes + name: Simple datatypes - path: function-calls + name: Function calls - path: operators + name: Operators - path: tuples + name: Tuples - path: indentation-rules + name: Indentation rules - path: flow-control name: Flow control children: - path: conditionals + name: Conditionals - path: arrays + name: Arrays - path: loops + name: Loops - path: functions name: Functions children: - path: definition + name: Definition - path: lambdas + name: Lambdas - path: parameters + name: Parameters - path: objects name: Objects children: - path: definition + name: Definition - path: classes name: Classes children: - path: definition + name: Definition - path: modules name: Modules children: - path: import + name: Import diff --git a/doc-generator/markdown/en/stdlib/latest/index.yaml b/doc-generator/markdown/en/stdlib/latest/index.yaml index 2ada17c..432e95b 100644 --- a/doc-generator/markdown/en/stdlib/latest/index.yaml +++ b/doc-generator/markdown/en/stdlib/latest/index.yaml @@ -5,4 +5,6 @@ children: name: Prelude children: - path: String + name: String - path: Console + name: Console diff --git a/doc-generator/src/generator/highlighter/mod.rs b/doc-generator/src/generator/highlighter/mod.rs index d621744..ce20b77 100644 --- a/doc-generator/src/generator/highlighter/mod.rs +++ b/doc-generator/src/generator/highlighter/mod.rs @@ -36,17 +36,7 @@ pub fn highlight(input: &String) -> String { TokenType::Identifier if token.value == "true" || token.value == "false" => { replace!("keyword", token, offset, output) } - TokenType::String => { - let start_pos = token.position; - let end_pos = token.get_end_position(); - - let range = (start_pos + offset)..(end_pos + offset); - let html = format!("\"{}\"", token.value); - - offset += 34; - - output.replace_range(range, html.as_str()); - } + TokenType::String => replace!("string", token, offset, output), TokenType::Comment => replace!("comment", token, offset, output), TokenType::VAL | TokenType::VAR => replace!("keyword", token, offset, output), _ => {} diff --git a/doc-generator/src/pages/md_compiler.rs b/doc-generator/src/pages/md_compiler.rs index 80d1acc..5f1d4d6 100644 --- a/doc-generator/src/pages/md_compiler.rs +++ b/doc-generator/src/pages/md_compiler.rs @@ -32,12 +32,14 @@ pub fn compile(file: &PathBuf, input_folder: &Path, output_folder: &Path, file_t output_file.set_extension("html"); // - // Compilation + // Read MD from disk // let file_content_bytes = fs::read(&input_file).unwrap(); let markdown_text = String::from_utf8(file_content_bytes).unwrap(); - // let html_text = to_html(markdown_text.as_str()); + // + // Compile MD + // let md_ast = markdown::to_mdast(&markdown_text, &markdown::ParseOptions::gfm()).unwrap(); let html_text = md_ast.to_html(); let sidebar_html = md_ast.generate_sidebar(); diff --git a/doc-generator/src/pages/mod.rs b/doc-generator/src/pages/mod.rs index 12dbc7e..b8a6a77 100644 --- a/doc-generator/src/pages/mod.rs +++ b/doc-generator/src/pages/mod.rs @@ -14,6 +14,8 @@ pub enum Node<'a> { pub struct File<'a> { /// Name of the file path: &'a String, + /// Display name of the file + name: &'a String, } pub struct Folder<'a> { @@ -42,18 +44,17 @@ pub fn parse_yaml(values: &Yaml) -> Node { let Yaml::String(path) = table.get(y_str!("path")).expect("YAML: Node MUST have a `path` key") else { panic!("YAML: `path` MUST be a String") }; + let Yaml::String(name) = table.get(y_str!("name")).expect("YAML: Node MUST have a `name` key") + else { panic!("YAML: `name` MUST be a String") }; + let input_data = ( - table.get(y_str!("name")), table.get(y_str!("has_index")), table.get(y_str!("children")), ); match input_data { - (None, None, None) => Node::File(File { path }), - (Some(name), has_index, Some(children)) => { - let Yaml::String(name) = name - else { panic!("YAML: `name` MUST be a String") }; - + (None, None) => Node::File(File { path, name }), + (has_index, Some(children)) => { let has_index = match has_index { Some(Yaml::Boolean(v)) => *v, Some(_) => panic!("YAML: if key `has_index` exists, it MUST be a Boolean"), @@ -100,7 +101,7 @@ pub fn generate_pages_html(file_tree: &Node, current_path: &Path) -> String { ", current_path.to_str().unwrap(), file.path, - file.path + file.name ) } } diff --git a/doc-generator/static/package.json b/doc-generator/static/package.json index e6b2abe..3d841d7 100644 --- a/doc-generator/static/package.json +++ b/doc-generator/static/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "watch": "concurrently -k \"tailwindcss -i ./tailwind/input.css -o ./tailwind/output.css --watch\" \"live-server . --port=3333\"", - "server": "live-server . --port=3333", + "start": "live-server . --port=3333", "styles": "tailwindcss -i ./tailwind/input.css -o ./tailwind/output.css --watch" }, "keywords": [],