komment-parser-rs

Crates.iokomment-parser-rs
lib.rskomment-parser-rs
version0.1.0
sourcesrc
created_at2023-11-04 16:02:24.627298
updated_at2023-11-04 16:02:24.627298
descriptionExtract dependencies list from comment and create Cargo.toml
homepage
repositoryhttps://github.com/Nactore/komment-parser-rs
max_upload_size
id1025250
size48,520
Harshil Jani (Harshil-Jani)

documentation

README

komment-parser-rs

Extract dependencies list from comment and create Cargo.toml out of it. This is utility which we shall be using into crab-playground-pro

Refer this Example to know the capability of the crate.

use komment_parser_rs::parse::{get_comment_with_deps, parse_block_comments};

fn main() {
    // Getting the list of block comments from the code.
    let source_code_string = r#"
        // This is a line comment
        /* This is a block comment */
        /* [dependencies] 
           rand = "0.1.0"
        */
        // Another line comment 
        fn main() {
            /* This is another block comment */
            println!("Hello World");
        }"#;

    let block_comments =
        parse_block_comments(source_code_string).expect("Failed to get the comment from file");

    println!("\nList of all block comments : \n{:#?}", block_comments);

    let deps_comment = get_comment_with_deps(source_code_string).unwrap();
    println!("\nComment with dependency : \n{}", deps_comment);
}
Commit count: 0

cargo fmt