| Crates.io | strinject |
| lib.rs | strinject |
| version | 0.2.0 |
| created_at | 2024-11-21 16:05:42.71259+00 |
| updated_at | 2024-12-16 09:11:25.995008+00 |
| description | Inject text from somewhere else into given text |
| homepage | |
| repository | https://github.com/Vrixyz/strinject |
| max_upload_size | |
| id | 1456336 |
| size | 66,967 |
When writing documentation, it's useful to reference and inline code snippets.
strinject helps you do that.
Replace text in a file, taking content from another file.
A simple API:
pub fn inject(source_text: &str) -> Result<String, InjectError>;
Any occurrence of the tag <load path='tests/to_inject1.txt' marker='ToInject1_1' />
will load the file tests/to_inject1.txt, search for the text between // DOCUSAURUS: ToInject1_1: start
and the next // DOCUSAURUS: ToInject1_1: stop, and replace the tag with the text between those markers.
Useful code is sometimes indented, strinject removes out-of-context indentation.
Download external files pointed to by path with the feature download.
We advise to setup your own diff tooling to verify no unintended modifications were introduced after the injection took place.
See parry.rs CI for an example of such tool.
rustdoc checks the whole inlined code, and allows to hide specific lines
strinject is context agnostic.