Testing and maintaining example codes in documentation

Hello, I would like to know if there is any tool to test the codes inserted in the example section of the documentation in an agile way.

You can do this with the cargo test command.

1 Like

cargo test will compile and run all code found in library documentation. For more details, see:

https://doc.rust-lang.org/rustdoc/documentation-tests.html

Note that there are some limitations to doctests because of how they work. Most importantly, they can only use your library's public API. They can't directly call private code, or code within binary (non-library) crates.

1 Like

That's amazing, thanks for the link.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.