Crates.io | strinject |
lib.rs | strinject |
version | 0.1.1 |
source | src |
created_at | 2024-11-21 16:05:42.71259 |
updated_at | 2024-11-21 16:08:39.040413 |
description | Inject text from somewhere else into given text |
homepage | |
repository | https://github.com/Vrixyz/strinject |
max_upload_size | |
id | 1456336 |
size | 26,977 |
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='test/to_inject1.txt' marker='ToInject1_1' />
will load the file test/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.
We advise to setup your own diff tooling to verify no unintended modifications were introduced after the injection took place.
rustdoc
checks the whole inlined code, and allows to hide specific lines
strinject
is context agnostic.