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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! # syncdoc
//!
//! A procedural macro crate for injecting documentation from external files.
//!
//! This crate provides macros to automatically add documentation attributes to your functions
//! by reading from external markdown files.
use TokenStream;
use TokenStream as TokenStream2;
/// Injects documentation from external files.
///
/// This macro applies documentation injection to every documentable element found within
/// the annotated module or impl block, automatically reading documentation from
/// external markdown files based on a hierarchical path structure.
///
/// # Examples
///
/// Document all functions in a module:
/// ```ignore
/// # use syncdoc::omnidoc;
/// #[omnidoc(path = "docs")]
/// mod my_module {
/// pub fn function_one(x: i32) {
/// // Docs from ../docs/my_module/function_one.md
/// println!("Function one called with {}", x);
/// }
///
/// pub fn function_two() {
/// // Docs from ../docs/my_module/function_two.md
/// println!("Function two called");
/// }
/// }
/// ```
///
/// Document all methods in an impl block:
/// ```ignore
/// # use syncdoc::omnidoc;
/// struct MyStruct;
///
/// #[omnidoc(path = "docs")]
/// impl MyStruct {
/// pub fn method_one(&self, value: String) {
/// // Docs from ../docs/MyStruct/method_one.md
/// println!("Method called with {}", value);
/// }
///
/// pub fn method_two(&self) {
/// // Docs from ../docs/MyStruct/method_two.md
/// println!("Another method called");
/// }
/// }
/// ```
/// Generates a path to the module's documentation file.
///
/// This is specifically designed for module-level (inner) documentation attributes.
/// It automatically calculates the path based on the module hierarchy and the
/// `docs-path` configured in your `Cargo.toml`.
///
/// # Usage
///
/// ```ignore
/// #![doc = syncdoc::module_doc!(path = "docs")]
///
/// pub struct MyStruct;
/// ```
///
/// This will resolve to something like:
/// ```ignore
/// #![doc = include_str!("../docs/my_module.md")]
/// ```
///
/// But without requiring you to manually calculate the `../` prefix or
/// track your module hierarchy.
///
/// # Configuration
///
/// Add to your `Cargo.toml`:
/// ```toml
/// [package.metadata.syncdoc]
/// docs-path = "docs"
/// ```