1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use tool;
// This test verifies that the macro produces a compile error when a parameter
// is documented in the docstring but doesn't exist in the function signature
// VALIDATION ERROR CASES
// ======================
// These are examples of what should fail to compile with helpful error messages:
// ERROR CASE 1: Extra parameter in docstring
// This would fail with: "Parameter 'nonexistent' found in docstring but not in function parameters"
/*
#[tool]
/// Function with extra parameter in docstring
/// param1: Valid parameter
/// nonexistent: This parameter doesn't exist in function
fn function_with_extra_docstring_param(param1: String) -> String {
param1
}
*/
// ERROR CASE 2: Missing parameter description
// This would fail with: "Parameter 'param2' is missing description in docstring. Add: 'param2: description'"
/*
#[tool]
/// Function with missing parameter description
/// param1: First parameter description
/// (param2 description is missing)
fn function_with_missing_param_desc(param1: String, param2: i32) -> String {
format!("{} {}", param1, param2)
}
*/
// These validation errors ensure that:
// 1. All parameters mentioned in docstrings exist in the function signature
// 2. All function parameters have descriptions in the docstring
// 3. Users get clear, actionable error messages when validation fails