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

crystal docs: use shard.yml version when no git tag present #11232

Conversation

superhawk610
Copy link
Contributor

When generating project documentation with crystal docs, the project version may be inferred from either the latest git tag or the version key in shard.yml. However, the version in shard.yml will only be used if the project is not a git repository. This requirement is counter-intuitive, and means that a project created with

$ crystal init app my_app

won't generate documentation out of the box without explicitly specifying --project-version:

$ crystal docs
Couldn't determine version from git or shard.yml, please provide --project-version option

This PR allows the version in shard.yml to be used regardless of whether or not a project is contained in a git repository; the latest git tag will still be used (if present), so I think this preserves the intention of the original implementation, while also improving the out-of-the-box DX for new projects.

If the `version` key is set in `shard.yml`, use it by default
when running `crystal docs` from a git repository, instead of
requiring `--project-version` to be set explicitly. If a git
tag is present, it will still take precedence.
@straight-shoota
Copy link
Member

For reference, the original discussion of this feature was in #8792 and #4754.

The shard.yml fallback was added for the use case of non git-based distribution. But I suppose it should be good when not at a git tag as well.

Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

Thanks @superhawk610 !

@beta-ziliani beta-ziliani added this to the 1.3.0 milestone Dec 15, 2021
@straight-shoota straight-shoota merged commit df3214a into crystal-lang:master Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants