{ "ast": { "items": [ { "mod": { "attrs": [ { "meta": { "name_value": { "path": { "segments": [ { "ident": "doc" } ] }, "value": { "lit": { "str": "\" Processes a single markdown file and extracts all information.\"" } } } }, "style": "outer" }, { "meta": { "list": { "delimiter": "paren", "path": { "segments": [ { "ident": "cfg" } ] }, "tokens": [ { "ident": "test" } ] } }, "style": "outer" } ], "content": [ { "use": { "tree": { "path": { "ident": "super", "tree": "*" } } } }, { "use": { "tree": { "path": { "ident": "std", "tree": { "path": { "ident": "path", "tree": { "ident": "PathBuf" } } } } } } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_clean_html", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Hello World\"" } } }, "pat": { "ident": { "ident": "raw_text" } } } }, { "let": { "init": { "expr": { "call": { "args": [ { "path": { "segments": [ { "ident": "raw_text" } ] } } ], "func": { "path": { "segments": [ { "ident": "clean_html" } ] } } } } }, "pat": { "ident": { "ident": "cleaned" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "cleaned" }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "\"Hello World\"" } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_create_content_hash", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"fn main() { println!(\\\"Hello, world!\\\"); }\"" } } }, "pat": { "ident": { "ident": "content" } } } }, { "let": { "init": { "expr": { "call": { "args": [ { "path": { "segments": [ { "ident": "content" } ] } } ], "func": { "path": { "segments": [ { "ident": "create_content_hash" } ] } } } } }, "pat": { "ident": { "ident": "hash1" } } } }, { "let": { "init": { "expr": { "call": { "args": [ { "path": { "segments": [ { "ident": "content" } ] } } ], "func": { "path": { "segments": [ { "ident": "create_content_hash" } ] } } } } }, "pat": { "ident": { "ident": "hash2" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "hash1" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "hash2" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "hash1" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "len" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "64" } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_code_snippets", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"\\r\\n Here\\'s some Rust code:\\r\\n ```rust\\r\\n fn main() {\\r\\n println!(\\\"Hello, world!\\\");\\r\\n }\\r\\n ```\\r\\n And some JavaScript:\\r\\n ```javascript\\r\\n function hello() {\\r\\n console.log(\\\"Hello, world!\\\");\\r\\n }\\r\\n ```\\r\\n \"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"{:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "text" } ] } }, { "expr": [ { "for_loop": { "body": [ { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"SNIP {} {:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "i" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "m" } ] } } ], "expr": { "method_call": { "args": [], "method": "enumerate", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } }, "pat": { "tuple": { "elems": [ { "ident": { "ident": "i" } }, { "ident": { "ident": "m" } } ] } } } }, false ] }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"{:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "snippets" } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_estimate_token_count", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"fn main() { println!(\\\"Hello, world!\\\"); }\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "estimate_token_count" } ] } } } } }, "pat": { "ident": { "ident": "count" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "count" }, { "punct": { "op": ">", "spacing": "alone" } }, { "lit": "0" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "count" }, { "punct": { "op": "<", "spacing": "alone" } }, { "lit": "50" } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" }, { "meta": { "path": { "segments": [ { "ident": "ignore" } ] } }, "style": "outer" } ], "ident": "test_process_prelude_file", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "call": { "args": [ { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "env" } ] }, "tokens": [ { "lit": "\"CARGO_MANIFEST_DIR\"" } ] } } ], "func": { "path": { "segments": [ { "ident": "PathBuf" }, { "ident": "from" } ] } } } } }, "pat": { "ident": { "ident": "path", "mut": true } } } }, { "expr": [ { "method_call": { "args": [ { "lit": { "str": "\"founding_documents/prelude1-aaa.md\"" } } ], "method": "push", "receiver": { "path": { "segments": [ { "ident": "path" } ] } } } }, true ] }, { "let": { "init": { "expr": { "call": { "args": [ { "reference": { "expr": { "path": { "segments": [ { "ident": "path" } ] } } } } ], "func": { "path": { "segments": [ { "ident": "process_file" } ] } } } } }, "pat": { "ident": { "ident": "result" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "result" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "is_ok" }, { "group": { "delimiter": "parenthesis", "stream": [] } } ] } }, { "let": { "init": { "expr": { "method_call": { "args": [], "method": "unwrap", "receiver": { "path": { "segments": [ { "ident": "result" } ] } } } } }, "pat": { "ident": { "ident": "summary" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "total_turns" }, { "punct": { "op": ">", "spacing": "alone" } }, { "lit": "0" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "total_tokens" }, { "punct": { "op": ">", "spacing": "alone" } }, { "lit": "0" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"Document Summary:\"" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"Total turns: {}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "total_turns" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"Total code snippets: {}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "total_code_snippets" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"Total tokens: {}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "total_tokens" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"Languages found: {:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "languages_found" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"Content hashes: {:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "summary" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content_hashes" } ] } } ] } } ], "ident": "tests" } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_code_snippets", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Here\\'s some Rust code:\\r\\n```rust\\r\\nfn main() {\\r\\n println!(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\nAnd some JavaScript:\\r\\n```javascript\\r\\nfunction hello() {\\r\\n console.log(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\n\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"{:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "text" } ] } }, { "expr": [ { "for_loop": { "body": [ { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"SNIP {} {:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "i" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "m" } ] } } ], "expr": { "method_call": { "args": [], "method": "enumerate", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } }, "pat": { "tuple": { "elems": [ { "ident": { "ident": "i" } }, { "ident": { "ident": "m" } } ] } } } }, false ] }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"{:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "snippets" } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_code_snippets_with_inline", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Here\\'s some code: `let x = 42; println!(\\\"{}\\\", x);` and more text.\\r\\nAlso a code block:\\r\\n```python\\r\\ndef hello():\\r\\n print(\\\"Hello!\\\")\\r\\n```\\r\\n\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "method_call": { "args": [], "method": "unwrap", "receiver": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "len" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ">", "spacing": "joint" } }, { "punct": { "op": "=", "spacing": "alone" } }, { "lit": "2" } ] } }, { "let": { "init": { "expr": { "method_call": { "args": [ { "closure": { "body": { "binary": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "s" } ] } }, "ident": "language" } }, "op": "==", "right": { "lit": { "str": "\"python\"" } } } }, "inputs": [ { "ident": { "ident": "s" } } ], "output": null } } ], "method": "find", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "python_snippet" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "python_snippet" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "is_some" }, { "group": { "delimiter": "parenthesis", "stream": [] } } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "python_snippet" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "unwrap" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"def hello\"" } ] } } ] } }, { "let": { "init": { "expr": { "method_call": { "args": [ { "closure": { "body": { "binary": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "s" } ] } }, "ident": "language" } }, "op": "==", "right": { "lit": { "str": "\"inline\"" } } } }, "inputs": [ { "ident": { "ident": "s" } } ], "output": null } } ], "method": "find", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "inline_snippet" } } } }, { "expr": [ { "if": { "cond": { "method_call": { "args": [], "method": "is_some", "receiver": { "path": { "segments": [ { "ident": "inline_snippet" } ] } } } }, "then_branch": [ { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "inline_snippet" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "unwrap" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"let x = 42\"" } ] } } ] } } ] } }, false ] } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_empty_code_blocks", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Empty block:\\r\\n```rust\\r\\n```\\r\\nNon-empty block:\\r\\n```javascript\\r\\nconsole.log(\\\"test\\\");\\r\\n```\\r\\n\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "method_call": { "args": [], "method": "unwrap", "receiver": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "len" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "1" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "0" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "language" }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "\"javascript\"" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "0" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"console.log\"" } ] } } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "name_value": { "path": { "segments": [ { "ident": "doc" } ] }, "value": { "lit": { "str": "\" newest\"" } } } }, "style": "outer" }, { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_code_snippets_new", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Here\\'s some Rust code:\\r\\n```rust\\r\\nfn main() {\\r\\n println!(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\nAnd some JavaScript:\\r\\n```javascript\\r\\nfunction hello() {\\r\\n console.log(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\n\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "method_call": { "args": [], "method": "unwrap", "receiver": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"{:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "text" } ] } }, { "expr": [ { "for_loop": { "body": [ { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"SNIP {} {:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "i" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "m" } ] } } ], "expr": { "method_call": { "args": [], "method": "enumerate", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } }, "pat": { "tuple": { "elems": [ { "ident": { "ident": "i" } }, { "ident": { "ident": "m" } } ] } } } }, false ] }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "println" } ] }, "semi_token": true, "tokens": [ { "lit": "\"{:?}\"" }, { "punct": { "op": ",", "spacing": "alone" } }, { "ident": "snippets" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "len" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "2" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "0" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "language" }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "\"rust\"" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "1" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "language" }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "\"javascript\"" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "0" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"fn main\"" } ] } } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "1" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"function hello\"" } ] } } ] } } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_code_snippets_with_inline2", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Here\\'s some code: `let x = 42; println!(\\\"{}\\\", x);` and more text.\\r\\nAlso a code block:\\r\\n```python\\r\\ndef hello():\\r\\n print(\\\"Hello!\\\")\\r\\n```\\r\\n\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "method_call": { "args": [], "method": "unwrap", "receiver": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "len" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ">", "spacing": "joint" } }, { "punct": { "op": "=", "spacing": "alone" } }, { "lit": "2" } ] } }, { "let": { "init": { "expr": { "method_call": { "args": [ { "closure": { "body": { "binary": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "s" } ] } }, "ident": "language" } }, "op": "==", "right": { "lit": { "str": "\"python\"" } } } }, "inputs": [ { "ident": { "ident": "s" } } ], "output": null } } ], "method": "find", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "python_snippet" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "python_snippet" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "is_some" }, { "group": { "delimiter": "parenthesis", "stream": [] } } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "python_snippet" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "unwrap" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"def hello\"" } ] } } ] } }, { "let": { "init": { "expr": { "method_call": { "args": [ { "closure": { "body": { "binary": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "s" } ] } }, "ident": "language" } }, "op": "==", "right": { "lit": { "str": "\"inline\"" } } } }, "inputs": [ { "ident": { "ident": "s" } } ], "output": null } } ], "method": "find", "receiver": { "method_call": { "args": [], "method": "iter", "receiver": { "path": { "segments": [ { "ident": "snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "inline_snippet" } } } }, { "expr": [ { "if": { "cond": { "method_call": { "args": [], "method": "is_some", "receiver": { "path": { "segments": [ { "ident": "inline_snippet" } ] } } } }, "then_branch": [ { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "inline_snippet" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "unwrap" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"let x = 42\"" } ] } } ] } } ] } }, false ] } ] } }, { "fn": { "attrs": [ { "meta": { "path": { "segments": [ { "ident": "test" } ] } }, "style": "outer" } ], "ident": "test_extract_empty_code_blocks2", "inputs": [], "output": null, "stmts": [ { "let": { "init": { "expr": { "lit": { "str": "\"Empty block:\\r\\n```rust\\r\\n```\\r\\nNon-empty block:\\r\\n```javascript\\r\\nconsole.log(\\\"test\\\");\\r\\n```\\r\\n\"" } } }, "pat": { "ident": { "ident": "text" } } } }, { "let": { "init": { "expr": { "method_call": { "args": [], "method": "unwrap", "receiver": { "call": { "args": [ { "path": { "segments": [ { "ident": "text" } ] } } ], "func": { "path": { "segments": [ { "ident": "extract_code_snippets" } ] } } } } } } }, "pat": { "ident": { "ident": "snippets" } } } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "len" }, { "group": { "delimiter": "parenthesis", "stream": [] } }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "1" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert_eq" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "0" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "language" }, { "punct": { "op": ",", "spacing": "alone" } }, { "lit": "\"javascript\"" } ] } }, { "macro": { "delimiter": "paren", "path": { "segments": [ { "ident": "assert" } ] }, "semi_token": true, "tokens": [ { "ident": "snippets" }, { "group": { "delimiter": "bracket", "stream": [ { "lit": "0" } ] } }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "content" }, { "punct": { "op": ".", "spacing": "alone" } }, { "ident": "contains" }, { "group": { "delimiter": "parenthesis", "stream": [ { "lit": "\"console.log\"" } ] } } ] } } ] } }, { "fn": { "ident": "test_code_snippet", "inputs": [ { "typed": { "pat": { "ident": { "ident": "snippet" } }, "ty": { "reference": { "elem": { "path": { "segments": [ { "ident": "CodeSnippet" } ] } }, "mut": true } } } } ], "output": null, "stmts": [ { "let": { "init": { "expr": { "call": { "args": [], "func": { "path": { "segments": [ { "ident": "std" }, { "ident": "time" }, { "ident": "Instant" }, { "ident": "now" } ] } } } } }, "pat": { "ident": { "ident": "start_time" } } } }, { "expr": [ { "match": { "arms": [ { "body": { "block": { "stmts": [ { "expr": [ { "if": { "cond": { "binary": { "left": { "method_call": { "args": [ { "lit": { "str": "\"fn \"" } } ], "method": "contains", "receiver": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "content" } } } }, "op": "||", "right": { "method_call": { "args": [ { "lit": { "str": "\"let \"" } } ], "method": "contains", "receiver": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "content" } } } } } }, "else_branch": { "block": { "stmts": [ { "expr": [ { "assign": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "test_result" } }, "right": { "call": { "args": [ { "struct": { "fields": [ { "colon_token": true, "expr": { "lit": { "bool": false } }, "ident": "success" }, { "colon_token": true, "expr": { "call": { "args": [ { "method_call": { "args": [], "method": "to_string", "receiver": { "lit": { "str": "\"No function or variable declarations found\"" } } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } }, "ident": "error_message" }, { "colon_token": true, "expr": { "cast": { "expr": { "method_call": { "args": [], "method": "as_millis", "receiver": { "method_call": { "args": [], "method": "elapsed", "receiver": { "path": { "segments": [ { "ident": "start_time" } ] } } } } } }, "ty": { "path": { "segments": [ { "ident": "u64" } ] } } } }, "ident": "execution_time_ms" } ], "path": { "segments": [ { "ident": "TestResult" } ] } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } } } }, true ] } ] } }, "then_branch": [ { "expr": [ { "assign": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "test_result" } }, "right": { "call": { "args": [ { "struct": { "fields": [ { "colon_token": true, "expr": { "lit": { "bool": true } }, "ident": "success" }, { "colon_token": true, "expr": { "path": { "segments": [ { "ident": "None" } ] } }, "ident": "error_message" }, { "colon_token": true, "expr": { "cast": { "expr": { "method_call": { "args": [], "method": "as_millis", "receiver": { "method_call": { "args": [], "method": "elapsed", "receiver": { "path": { "segments": [ { "ident": "start_time" } ] } } } } } }, "ty": { "path": { "segments": [ { "ident": "u64" } ] } } } }, "ident": "execution_time_ms" } ], "path": { "segments": [ { "ident": "TestResult" } ] } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } } } }, true ] } ] } }, false ] } ] } }, "pat": { "lit": { "str": "\"rust\"" } } }, { "body": { "block": { "stmts": [ { "expr": [ { "if": { "cond": { "binary": { "left": { "binary": { "left": { "method_call": { "args": [ { "lit": { "str": "\"function\"" } } ], "method": "contains", "receiver": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "content" } } } }, "op": "||", "right": { "method_call": { "args": [ { "lit": { "str": "\"const \"" } } ], "method": "contains", "receiver": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "content" } } } } } }, "op": "||", "right": { "method_call": { "args": [ { "lit": { "str": "\"let \"" } } ], "method": "contains", "receiver": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "content" } } } } } }, "else_branch": { "block": { "stmts": [ { "expr": [ { "assign": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "test_result" } }, "right": { "call": { "args": [ { "struct": { "fields": [ { "colon_token": true, "expr": { "lit": { "bool": false } }, "ident": "success" }, { "colon_token": true, "expr": { "call": { "args": [ { "method_call": { "args": [], "method": "to_string", "receiver": { "lit": { "str": "\"No function or variable declarations found\"" } } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } }, "ident": "error_message" }, { "colon_token": true, "expr": { "cast": { "expr": { "method_call": { "args": [], "method": "as_millis", "receiver": { "method_call": { "args": [], "method": "elapsed", "receiver": { "path": { "segments": [ { "ident": "start_time" } ] } } } } } }, "ty": { "path": { "segments": [ { "ident": "u64" } ] } } } }, "ident": "execution_time_ms" } ], "path": { "segments": [ { "ident": "TestResult" } ] } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } } } }, true ] } ] } }, "then_branch": [ { "expr": [ { "assign": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "test_result" } }, "right": { "call": { "args": [ { "struct": { "fields": [ { "colon_token": true, "expr": { "lit": { "bool": true } }, "ident": "success" }, { "colon_token": true, "expr": { "path": { "segments": [ { "ident": "None" } ] } }, "ident": "error_message" }, { "colon_token": true, "expr": { "cast": { "expr": { "method_call": { "args": [], "method": "as_millis", "receiver": { "method_call": { "args": [], "method": "elapsed", "receiver": { "path": { "segments": [ { "ident": "start_time" } ] } } } } } }, "ty": { "path": { "segments": [ { "ident": "u64" } ] } } } }, "ident": "execution_time_ms" } ], "path": { "segments": [ { "ident": "TestResult" } ] } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } } } }, true ] } ] } }, false ] } ] } }, "pat": { "or": { "cases": [ { "lit": { "str": "\"javascript\"" } }, { "lit": { "str": "\"js\"" } } ] } } }, { "body": { "block": { "stmts": [ { "expr": [ { "assign": { "left": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "test_result" } }, "right": { "call": { "args": [ { "struct": { "fields": [ { "colon_token": true, "expr": { "lit": { "bool": false } }, "ident": "success" }, { "colon_token": true, "expr": { "call": { "args": [ { "method_call": { "args": [], "method": "to_string", "receiver": { "lit": { "str": "\"Language not supported for testing\"" } } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } }, "ident": "error_message" }, { "colon_token": true, "expr": { "cast": { "expr": { "method_call": { "args": [], "method": "as_millis", "receiver": { "method_call": { "args": [], "method": "elapsed", "receiver": { "path": { "segments": [ { "ident": "start_time" } ] } } } } } }, "ty": { "path": { "segments": [ { "ident": "u64" } ] } } } }, "ident": "execution_time_ms" } ], "path": { "segments": [ { "ident": "TestResult" } ] } } } ], "func": { "path": { "segments": [ { "ident": "Some" } ] } } } } } }, true ] } ] } }, "pat": { "_": {} } } ], "expr": { "method_call": { "args": [], "method": "as_str", "receiver": { "field": { "base": { "path": { "segments": [ { "ident": "snippet" } ] } }, "ident": "language" } } } } } }, false ] } ], "vis": "pub" } } ] }, "file_path": "src\\extractor\\tests.rs", "summary": { "emoji_counts_in_strings": {}, "string_literals": [ "\" Processes a single markdown file and extracts all information.\"", "\"Hello World\"", "\"Hello World\"", "\"fn main() { println!(\\\"Hello, world!\\\"); }\"", "64", "\"\\r\\n Here\\'s some Rust code:\\r\\n ```rust\\r\\n fn main() {\\r\\n println!(\\\"Hello, world!\\\");\\r\\n }\\r\\n ```\\r\\n And some JavaScript:\\r\\n ```javascript\\r\\n function hello() {\\r\\n console.log(\\\"Hello, world!\\\");\\r\\n }\\r\\n ```\\r\\n \"", "\"{:?}\"", "\"SNIP {} {:?}\"", "\"{:?}\"", "\"fn main() { println!(\\\"Hello, world!\\\"); }\"", "0", "50", "\"CARGO_MANIFEST_DIR\"", "\"founding_documents/prelude1-aaa.md\"", "0", "0", "\"Document Summary:\"", "\"Total turns: {}\"", "\"Total code snippets: {}\"", "\"Total tokens: {}\"", "\"Languages found: {:?}\"", "\"Content hashes: {:?}\"", "\"Here\\'s some Rust code:\\r\\n```rust\\r\\nfn main() {\\r\\n println!(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\nAnd some JavaScript:\\r\\n```javascript\\r\\nfunction hello() {\\r\\n console.log(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\n\"", "\"{:?}\"", "\"SNIP {} {:?}\"", "\"{:?}\"", "\"Here\\'s some code: `let x = 42; println!(\\\"{}\\\", x);` and more text.\\r\\nAlso a code block:\\r\\n```python\\r\\ndef hello():\\r\\n print(\\\"Hello!\\\")\\r\\n```\\r\\n\"", "2", "\"python\"", "\"def hello\"", "\"inline\"", "\"let x = 42\"", "\"Empty block:\\r\\n```rust\\r\\n```\\r\\nNon-empty block:\\r\\n```javascript\\r\\nconsole.log(\\\"test\\\");\\r\\n```\\r\\n\"", "1", "0", "\"javascript\"", "0", "\"console.log\"", "\" newest\"", "\"Here\\'s some Rust code:\\r\\n```rust\\r\\nfn main() {\\r\\n println!(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\nAnd some JavaScript:\\r\\n```javascript\\r\\nfunction hello() {\\r\\n console.log(\\\"Hello, world!\\\");\\r\\n}\\r\\n```\\r\\n\"", "\"{:?}\"", "\"SNIP {} {:?}\"", "\"{:?}\"", "2", "0", "\"rust\"", "1", "\"javascript\"", "0", "\"fn main\"", "1", "\"function hello\"", "\"Here\\'s some code: `let x = 42; println!(\\\"{}\\\", x);` and more text.\\r\\nAlso a code block:\\r\\n```python\\r\\ndef hello():\\r\\n print(\\\"Hello!\\\")\\r\\n```\\r\\n\"", "2", "\"python\"", "\"def hello\"", "\"inline\"", "\"let x = 42\"", "\"Empty block:\\r\\n```rust\\r\\n```\\r\\nNon-empty block:\\r\\n```javascript\\r\\nconsole.log(\\\"test\\\");\\r\\n```\\r\\n\"", "1", "0", "\"javascript\"", "0", "\"console.log\"", "\"fn \"", "\"let \"", "\"No function or variable declarations found\"", "\"rust\"", "\"function\"", "\"const \"", "\"let \"", "\"No function or variable declarations found\"", "\"javascript\"", "\"js\"", "\"Language not supported for testing\"" ], "top_level_nodes": 1, "total_nodes": 1364, "type_counts": { "_": 1, "args": 64, "arms": 1, "assign": 5, "attrs": 12, "base": 15, "binary": 7, "block": 5, "body": 10, "bool": 5, "call": 22, "cases": 1, "cast": 5, "closure": 4, "colon_token": 15, "cond": 4, "content": 1, "delimiter": 73, "elem": 1, "elems": 3, "else_branch": 2, "expr": 68, "field": 15, "fields": 5, "fn": 12, "for_loop": 3, "func": 22, "group": 29, "ident": 353, "if": 4, "init": 29, "inputs": 16, "items": 1, "left": 12, "let": 29, "list": 1, "lit": 80, "macro": 43, "match": 1, "meta": 15, "method": 42, "method_call": 42, "mod": 1, "mut": 2, "name_value": 2, "op": 82, "or": 1, "output": 16, "pat": 36, "path": 139, "punct": 75, "receiver": 42, "reference": 2, "right": 12, "segments": 136, "semi_token": 42, "spacing": 75, "stmts": 17, "str": 28, "stream": 29, "struct": 5, "style": 15, "then_branch": 4, "tokens": 44, "tree": 5, "tuple": 3, "ty": 6, "typed": 1, "use": 2, "value": 2, "vis": 1 }, "word_counts": { "0": 9, "1": 4, "2": 3, "42": 4, "50": 1, "64": 1, "a": 3, "aaa": 1, "all": 1, "also": 2, "and": 6, "block": 6, "cargo_manifest_dir": 1, "class": 1, "code": 8, "console": 5, "const": 1, "content": 1, "declarations": 2, "def": 2, "document": 1, "empty": 4, "extracts": 1, "file": 1, "fn": 5, "for": 1, "found": 3, "founding_documents": 1, "function": 5, "hashes": 1, "hello": 20, "here": 5, "information": 1, "inline": 2, "java": 3, "javascript": 9, "js": 1, "language": 1, "languages": 1, "let": 6, "log": 7, "main": 6, "markdown": 1, "md": 1, "more": 2, "n": 55, "nconsole": 2, "ndef": 2, "newest": 1, "nfn": 2, "nfunction": 2, "no": 2, "non": 2, "not": 1, "or": 2, "prelude1": 1, "print": 2, "println": 7, "processes": 1, "python": 4, "r": 63, "rust": 10, "s": 5, "script": 3, "single": 1, "snip": 3, "snippets": 1, "some": 8, "span": 2, "summary": 1, "supported": 1, "test": 3, "testing": 1, "text": 2, "tokens": 1, "total": 3, "turns": 1, "variable": 2, "world": 10, "x": 6 }, "word_emoji_counts": { "0️⃣": 9, "1️⃣": 4, "2️⃣": 3, "⏱️": 5, "🎟️": 1, "📌": 6, "📦": 1, "🔀": 2, "🔒": 1, "🦀⚙️": 5, "🧱": 6 } }, "timestamp": 1751588209 }