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

doc attribute for docstrings #2050

Merged
merged 5 commits into from
May 25, 2024
Merged

doc attribute for docstrings #2050

merged 5 commits into from
May 25, 2024

Conversation

neunenak
Copy link
Contributor

cf. #1955 , it would be convenient if there was a way to specify a recipe documentation string with an attribute. Also this would make possible to provide a docstring that is different from actual comments in the justfile.

@casey
Copy link
Owner

casey commented May 18, 2024

I think this needs to be rebased on master, there are a bunch of extra commits in here.

@neunenak
Copy link
Contributor Author

neunenak commented May 18, 2024

I think this needs to be rebased on master, there are a bunch of extra commits in here.

The new code in this PR is on top of #1842 since that changes how attribute parsing works. I'm not sure if there's a way to tell github to omit commits from another PR in the pull request UI. In any case, eda55cc has the code that is actually new in this PR; I'm fine with not trying to get this merged until 1842 is merged.

src/recipe.rs Outdated
pub(crate) fn docstring(&self) -> Option<&str> {
for attribute in &self.attributes {
if let Attribute::Doc { docstring } = attribute {
return docstring.as_ref().map(|s| s.as_str());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.map(|s| s.as_str()) => .map(String::as_str())

@casey
Copy link
Owner

casey commented May 25, 2024

I'm going to cut a release tomorrow, which will be a monster one, since the features have piled up. I think this would be sweet, if you want to get it in. No worries if you don't have time though!

@neunenak
Copy link
Contributor Author

I'm going to cut a release tomorrow, which will be a monster one, since the features have piled up. I think this would be sweet, if you want to get it in. No worries if you don't have time though!

Yeah, it'd be great to get this in this release, although what I really care about is recipe groups so if this has to wait, not the end of the world.

@neunenak neunenak marked this pull request as ready for review May 25, 2024 08:27
@casey casey enabled auto-merge (squash) May 25, 2024 09:24
@casey casey merged commit dcbd07f into casey:master May 25, 2024
5 checks passed
@neunenak neunenak deleted the doc-attribute branch May 25, 2024 09:26
@casey
Copy link
Owner

casey commented May 25, 2024

Dope!

@kranurag7
Copy link

@neunenak Thanks for working on this, I'm looking forward to using this one.

_default:
  @just --list

[doc('this is a long line
which gives usage instruction for 
test recipe')]
test:
  echo "testing"

When I run just in this directory I get the following output:

$ just
Available recipes:
    test # this is a long line
which gives usage instruction for
test recipe

It would be great (in terms of readability) if can indent the extra lines as per indentation of the first line.

$ just
Available recipes:
    test # this is a long line
           which gives usage instruction for
           test recipe

Is there a way I can do this now?

@simonmichael
Copy link

simonmichael commented Jul 14, 2024

Is this really needed, when you can also just leave a blank line between comment and recipe ?

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

Successfully merging this pull request may close these issues.

5 participants