Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot retrieve [doc] attribute content and comment of a module at the same time with json dump #2463

Open
Retorikal opened this issue Nov 12, 2024 · 3 comments

Comments

@Retorikal
Copy link

Retorikal commented Nov 12, 2024

Given the following justfile and any random but validly formatted somemodule.justfile:

# Module comment
[doc('Module doc')]
mod somemodule

# Recipe comment
[doc('Recipe doc')]
somerecipe:
    echo "Recipe echo"
    read -p "Press any key to continue..." -n 1 -r

when running just --dump --dump-format=json, results in the following (parts omitted for brevity, full at pastebin):

{
    "modules": {
        "somemodule": {
            "doc": "Module doc",
            ...
        }
    },
    "recipes": {
        "somerecipe": {
            "attributes": [
                {
                    "doc": "Recipe doc"
                }
            ],
            "doc": "Recipe comment",
            ...
        }
    },
    ...
}

On the recipe, content of doc attribute and comment is put on different fields. But on module, content of doc attribute overwrites doc field, so "Module comment" does now show up anywhere on the output.

(Edit: The justfile snippet used to generate the output was outdated when this issue was initially made)

@casey
Copy link
Owner

casey commented Nov 12, 2024

interesting issue! It doesn't seem ideal that recipe.doc is different from the contents of the doc attribute, since the doc attribute effectively replaces the doc comment in --list. Is there a use case for having access to both?

@Retorikal
Copy link
Author

Retorikal commented Nov 12, 2024

I'm making a front-end for a set of justfiles that I have, and needed to add a user-friendly name and description for each module and recipe included in it. I'm thinking of adding the user-friendly name on the doc attribute, and the description on the doc comment.

Aside from the usecase, it does seem weird that on a module doc attribute overwrites doc comment, but on recipe it does not.

@adienakhmad
Copy link

adienakhmad commented Nov 12, 2024

I'm not sure if this is directly related but it seems like just --fmt is correctly preserving comment on recipes but removing them on module.

just --fmt --unstable --check

-# setup a CAN network
 mod cansetup
-# adjust or tune a CAN network
 mod cantweak
-# benchmark, stress test a CAN network
 mod canbench
-# monitor a CAN network
 mod canmonitor
 
 ..
 <trimmed>
 ..
 
 error: Formatted justfile differs from original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants