Skip to content

Commit 3fb9832

Browse files
committed
improve doc comment for generated_code macro
1 parent f98175a commit 3fb9832

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

capnp/src/lib.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,22 @@ pub mod text;
6464
pub mod text_list;
6565
pub mod traits;
6666

67-
/// Macro for importing a Rust file generated by a `build.rs` file using
68-
/// `capnpc::CompilerCommand`.
67+
/// Macro for importing Rust code that has been generated by `capnpc::CompilerCommand`.
6968
///
70-
/// Typically, a schema file named `foo.capnp` should have a `mod_name`
71-
/// of `foo_capnp` and a `file_name` of `"foo_capnp.rs"`.
69+
/// For example:
70+
/// ```ignore
71+
/// generated_code!(pub mod foo_capnp);
72+
/// ```
73+
/// pulls in the generated code for `foo.capnp` into a module named `foo_capnp`.
74+
/// It expects to find the generated code in a file `$OUT_DIR/foo_capnp.rs`,
75+
/// where `OUT_DIR` is Cargo's standard environment variable giving the
76+
/// location of the output of `build.rs`.
77+
///
78+
/// If the generated code lives in a nonstandard location—perhaps in a subdirectory
79+
/// of `OUT_DIR`—you can specify its path as a second argument:
80+
/// ```ignore
81+
/// generated_code!(pub mod foo_capnp, "some_directory/foo_capnp.rs");
82+
/// ```
7283
#[macro_export]
7384
macro_rules! generated_code {
7485
($vis:vis mod $mod_name:ident, $file_name:expr) => {

0 commit comments

Comments
 (0)