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

Allow the version token to be a link #21

Open
FRodrigues-BrandenPT opened this issue Apr 6, 2021 · 2 comments
Open

Allow the version token to be a link #21

FRodrigues-BrandenPT opened this issue Apr 6, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@FRodrigues-BrandenPT
Copy link

FRodrigues-BrandenPT commented Apr 6, 2021

Hello,
In my project instead of using a simple [1.0.0] - 2021-04-06 we use [1.0.0](#100---2021-04-06) - 2021-04-06 (to quickly focus on the paragraph version and to be more pretty).
But because you only check for "] - " to end the parsing of the version then in my changelogs the changelogCheck is going to always throw the error below:

Preconditions.checkArgument(line.startsWith(VERSION_BEGIN));
int versionEnd = line.indexOf("] - ");
if (versionEnd == -1) {
parser.addError(line.baseLineNumberStart(), "'] - ' is missing from the expected '## [x.y.z] - yyyy-mm-dd'");
return null;
}

What do you think?

@nedtwigg nedtwigg added the enhancement New feature or request label Apr 6, 2021
@nedtwigg
Copy link
Member

nedtwigg commented Apr 6, 2021

Right now the model is this:

  • ## [x.y.z] - yyyy-mm-dd {optionalHeaderMisc}

In order to work, spotless-changelog needs to parse a changelog and modify it. So to handle your case, we need to:

  • add more modes/resilience into the parser (including error messages)
  • need to change this method:

PoolString toStringUnix() {
if (version == null) {
// {{beforeUnreleased includes '## [Unreleased]'}}{{misc}}
return PoolString.concat(Changelog.UNRELEASED, headerMisc, changes);
} else if (headerMisc == null) {
return PoolString.concat("\n## [", version, "] - ", date, changes);
} else {
return PoolString.concat("\n## [", version, "] - ", date, " ", headerMisc, changes);
}
}

One of the simple features we have already is that you can replace the versionSchema function. It would also be easy to replace the headerMisc with a specific computed value (link to javadoc, usage stats, etc.)

I think it would reasonable to do something like this:

  • add @Nullable String versionLink field to Changelog.VersionEntry
  • add interface VersionLink { String compute(String version, String date, @Nullable String headerMisc) }, which is used to specify these links for new entries
  • figuring out how to / whether to change these links for existing entries is tricky

I would be happy to merge a PR along these lines. However, I insist that the PR author starts by writing the documentation first, and getting a round of feedback on that part. Adding this versionLink feature, imo, is useful but not very useful. So if it doubles the complexity for users who are okay with the standard keepachangelog format, then it's not worth it. The burden on making this flexibility unobtrusive is on the PR author, but I am confident it can be done.

@nedtwigg nedtwigg changed the title Allow other types of version ends Allow the version token to be a link Apr 6, 2021
@FRodrigues-BrandenPT
Copy link
Author

Thank you for your reply.

Now I'm occupied with another project. When I get spare time I'm going to see what I can do.

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

No branches or pull requests

2 participants