Expand description
version-sync provides macros for keeping version numbers in sync
with your crate version.
§Library Overview
When making a release of a Rust project, you typically need to adjust some version numbers in your code and documentation. This crate gives you macros that covers some typical cases where version numbers need updating:
- 
TOML examples in the
README.mdfiles that show how to add a dependency on your crate. Seeassert_markdown_deps_updated. - 
A
Changelog.mdfile that should at least mention the current version. Seeassert_contains_regexandassert_contains_substring. - 
A
README.mdfile which should only mention the current version. Seeassert_only_contains_regex. - 
The
html_root_urlattribute that tells other crates where to find your documentation. Seeassert_html_root_url_updated. 
Except for assert_contains_substring, the macros are gated
behind individual features, as detailed below.
A typical configuration will use an integration test to verify
that all version numbers are in sync. Create a
tests/version-numbers.rs file with:
#[test]
fn test_readme_deps_updated() {
    version_sync::assert_markdown_deps_updated!("README.md");
}
#[test]
fn test_readme_mentions_version() {
    version_sync::assert_contains_substring!("README.md", "Version {version}");
}
#[test]
fn test_html_root_url() {
    version_sync::assert_html_root_url_updated!("src/lib.rs");
}
When you run cargo test, your version numbers will be
automatically checked.
§Cargo Features
In case you only need some of the macros above, you can disable them individually using Cargo features. The features are:
markdown_deps_updatedenablesassert_markdown_deps_updated.html_root_url_updatedenablesassert_html_root_url_updated.contains_regexenablesassert_contains_regexandassert_only_contains_regex.
All of these features are enabled by default. If you disable all
of them, you can still use assert_contains_substring to
quickly check that a given file contains the current crate
version.
Macros§
- assert_
contains_ regex  - Assert that versions numbers are up to date via a regex.
 - assert_
contains_ substring  - Assert that versions numbers are up to date via substring matching.
 - assert_
html_ root_ url_ updated  - Assert that the 
html_root_urlattribute is up to date. - assert_
markdown_ deps_ updated  - Assert that dependencies on the current package are up to date.
 - assert_
only_ contains_ regex  - Assert that all versions numbers are up to date via a regex.
 
Functions§
- check_
contains_ regex  - Check that 
pathcontain the regular expression given bytemplate. - check_
contains_ substring  - Check that 
pathcontain the substring given bytemplate. - check_
html_ root_ url  - Check version numbers in 
html_root_urlattributes. - check_
markdown_ deps  - Check dependencies in Markdown code blocks.
 - check_
only_ contains_ regex  - Check that 
pathonly contains matches to the regular expression given bytemplate.