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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// devela::code::util::include
//
//! Defines the [`include_from!`], [`mod_from!`] and [`mod_path!`] macros.
//
// TOC
// - include_from!
// - mod_from!
// - mod_path!
//
// WAIT [include! fails with top-level attributes](https://github.com/rust-lang/rfcs/issues/752)
// WAIT [include! should allow inner attributes](https://github.com/rust-lang/rust/issues/66920)
// WAIT [inner attributes with include!](https://github.com/rust-lang/rust/issues/117464)
/// Includes a Rust source file relative to the project's directory.
///
/// The contents of the specified file are inserted into the current file
/// at the location of the macro invocation. This allows you to reuse code
/// from other files without creating separate modules.
///
/// # Usage
///
/// - To include a file relative to the project's directory:
/// ```ignore
/// include_from!("src/helper.rs");
/// ```
///
/// - To include a file using its module name (relative to the project's directory):
/// ```ignore
/// include_from!(helper); // Resolves to "helper.rs" in the project's root.
/// ```
///
/// - When using [`cargo-script`], the path is relative to the script's directory:
/// ```ignore
/// #!/usr/bin/env -S cargo +nightly -Zscript
/// include_from!(utils);
/// ```
/// [`cargo-script`]: https://github.com/rust-lang/cargo/issues/12207
///
/// See also [`mod_from!`].
///
/// # Issues
/// The `include!` macro fails if included file has top-level inner attributes.
/// See [#752](https://github.com/rust-lang/rfcs/issues/752).
pub use _include_from as include_from;
/// Declares a module by including a Rust source file relative to the project's directory.
///
/// The macro generates a `mod` declaration and inserts the contents of the specified file
/// into the module. This is a more ergonomic alternative to manually wrapping `include!`
/// within a module declaration.
///
/// # Usage
///
/// - To declare a module using its name:
/// ```ignore
/// // Declares `pub(super) mod helper` with contents from "helper.rs":
/// mod_from!(pub(super) helper);
/// ```
///
/// - To declare a module with a specific path:
/// ```ignore
/// // Declares `mod helper` with contents from "src/helper.rs":
/// mod_from!(helper, "src/helper.rs");
/// ```
///
/// See also [`include_from!`], [`mod_path!`]
///
/// # Issues
/// The `include!` macro fails if included file has top-level inner attributes.
/// See [#752](https://github.com/rust-lang/rfcs/issues/752).
pub use _mod_from as mod_from;
/// A macro helper to define a module name and path.
///
/// This is used to include files re-exported by lower-level workspace crates,
/// which add documentation on top of the original one. But there's an [issue][0]
/// where cross-crate import chains mises docs from middle crates.
///
// WAIT: missing cross-crate docs:
/// [0]: https://github.com/rust-lang/rust/issues/120927
///
/// There's another [issue][1] with the `include!` macro not supporting module-level attributes.
///
// WAIT: include! fails with top-level attributes:
/// [1]: https://github.com/rust-lang/rfcs/issues/752
///
/// so we have to resort to hardcoding the `path` attribute for the module.
/// (hardcoding is necessary since it only supports a whole literal. See [issue][2].
///
// WAIT: Module path attribute override with nested macros doesn't work:
/// [2]: https://github.com/rust-lang/rust/issues/87681
//
// Once the main issue (120927) is fixed, then this:
// mod_path!(alloc "../base/alloc/src/reexports.rs", _ia);
//
// Could be replaced with this:
// #[cfg(feature = "alloc")] #[doc(inline)] #[rustfmt::skip]
// pub use devela_base_alloc::{String, ToString};
///
/// See also [`mod_from!`].
pub use _mod_path as mod_path;