Skip to content

[DOC] The usage example confuses me more than it actually helps #48

Description

@sassman

Describe what is/was unclear to you

I saw your talk at the rustweek, it was very cool big thanks for it!.
I thought your tool could replace a hand made one, so I gave it a try.

First on a complex workspace project then on a simple "hello-world" binary.

Both with the same result:

❯ mantra collect
[2025-05-16T09:27:21Z WARN ] No requirements were found.
No requirements found.

'2' requirements updated:
- `JIRAX-35604`
- `JIRAX-35605`

Then I looked closer to the usage example and I'm more puzzled that before.

Describe what would help you to better understand the documentaon

I would suggest the usage example(s) could take a total unbiased / unknown outsiders view, as if you hear the first time of the tool and you are not familiar with the config file or the individual .json files.

So guiding a user for a simple new hello world tool, and what are the steps to add when and to invoke what would be awesome.

A brief summary of what I did:

  1. Generated a project
cargo new --bin demo-mantra-usage
# Cargo.toml
# other stuff omitted..

[dependencies]
mantra-rust-macros = "0.2.14"
  1. Added some tracing "annotations" to the code
# src/main.rs

use mantra_rust_macros::req;

fn main() {
    foo();
}

#[req(JIRAX-35604)]
fn foo() {
    println!("foo");
}
  1. Create the requirements "database"
# .requirements.json (Note: this comment is not in the file)

{
  "requirements": [
    {
      "id": "JIRAX-35604",
      "title": "Some req added from JSON.",
      "origin": "local",
      "manual": false,
      "deprecated": false,
      "data": {
        "custom_field": "some data"
      }
    },
    {
      "id": "JIRAX-35605",
      "title": "Another req added from JSON.",
      "origin": "local",
      "manual": false,
      "deprecated": false,
      "data": {
        "custom_field": "some data"
      }
    }
  ]
}
  1. Create the minimal mantra config file
[[requirements]]
# The path to JSON files containing requirements.
files = [".requirements.json"]
  1. Collect with mantra
mantra collect
  1. Create report
mantra report --formats=html foo.html

Observations and Remarks

  • the report does not show any of the requirement annotated in code
  • it's not clear what of the files and steps are maybe optional
  • in the config file, when omitting the [package] section, I would somehow expect the report gets this infos from the Cargo.toml manifest of the scanned project (if this is too much of an expectation, it would be worth to note why that is)
  • it's unclear to me, what are the things I do wrong or I should better be doing to get the requirement collected and shown up in the report

Update: also in the readme show all ways to do things in one shot, is a bit contra helpful. I would divide this e.g. into 2 pieces

#[req(req_id)]
fn some_fn() {
  println!("This reports via the attribute macro");
}

fn bar() {
  println!("This reports via reqcov! macro call");
  reqcov!(function_like_trace);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions