-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add project name and version to API docs #8792
Add project name and version to API docs #8792
Conversation
05847ae
to
194ce68
Compare
194ce68
to
76b684b
Compare
@crystal-lang/crystallers Any feedback on this? I'd like to move on with this 💪 Regarding the version problem, it might be best to use a generic version identifier like |
I think this is great |
56e80ed
to
637191b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like this to not introduce more errors, it's not that important. Worst case should be that the info just doesn't generate.
I've considered simply ignoring missing data. But my train of thought was that the doc generator would often be used in automatic build scripts which generate and deploy the documentation. If anything goes wrong - for whatever reason - but the generator just proceeds with a default value, the error will go unnoticed. But I'd like a CI script to fail if it can't determine the values it needs. And not publish docs for |
Erroring on not finding the project name is acceptable. Erroring if it's not a git repo is not. I think a fallback to |
Also, I would avoid making git a hard requirement in the compiler. Surely it will most likely be there, but either way. Other that than and what @RX14 said, LGTM. |
b5695ae
to
c606904
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have improved the defaults detection. Examples for specific use cases are in project_info_spec.cr.
e12c7ff
to
bfbc2eb
Compare
5ef17e5
to
72f798e
Compare
I've added some improvements. Ready for final review. |
This is now live on nightly: https://crystal-lang.org/api/master/ |
FYI for contributors of std-lib this PR force them to compile the compiler before been able to run
It will only be for one release. Until then, is changing a bit the workflow. |
Introduces Crystal::Docs::ProjectInfo as container for doc generator configuration
Just as a reference, encountered the issue mentioned by bcardiff while trying to build 0.35.1
Will investigate |
Judging from the error message it seems bin/crystal points to the previous release 0.34.0 which doesn't know the CLI options added in 0.35.0. Docs should be build with the same (i.e. newly built) compiler version. |
Yeah, it seems to be the case though trough reading the makefile I am wondering if |
For the time being I think I will add a patch for |
That's probably a bad idea. It would force everyone to build the compiler when you just want to build the docs. But that's usually completely unnecessary. It's only relevant when there are significant differences between the version of the compiler binary and the source code which is rarely the case. Most package builder workflows build the compiler first and then use that fresh compiler to build the docs. Does this not work for your use case? (I'm not familiar with nix build process, except that everythings pretty much isolated; but you should be able to somehow use the matching compiler version for dependend tasks?) |
It should be safe to apply that patch to the nix build, this only came up because it is attempting to do a |
MVP implementation of #4754
This PR adds a new section in the API docs sidebar which contains the name and version of the project.
The values can be set using the new
--project-name
and--project-version
CLI arguments.name
When
--project-name
is missing the doc generator currently errors. This should be changed to provide a good default, so thatcrystal docs
continues to just work and not require any configuration for most shards.The optimal solution would be to use the
name
property fromshard.yml
. Properly reading that file depends onlibyaml
which is not an option. Alternatively we could use a naive text-based extraction (such as grep for/^name:\s+(.*)/
) or call theshards
binary to get the information. The latter seems like a good solution to me, but needs to be implemented inshards
first (shards info --name
, cf crystal-lang/shards#86).Another alternative could be using the repository name (which has so far been used as the title) or directory name. Both are not ideal though, because shard names sometimes differ from repo names and we really want to show the shard name.
version
version
currently defaults tomaster
when--project-version
is missing. IMO we could leave it like that because that's what you usually have. When building docs for a specific commit, it should be easy to notice and fix (by supplying--project-version
explicitly).An alternative would be reading the tag from git. Using the last tag from the commit history (i.e.
git describe --abbrev=0 --tags
) doesn't take into account that the repo might have advanced since then. Only when directly at a tagged commit (i.e.git tag --points-to HEAD
) it would work reliably (ideally workdir and index need to be clean, too).This is essentially the reason why we have
src/VERSION
in the crystal repository and it gets updated on every tag for the plain tag and afterwards-dev
is added.We could try to do this automatically, first checking for
git tag --points-to HEAD
and if there's no result usegit describe --abbrev=0 --tags
with-dev
appended.I'm not sure if there would be any issues with that? We didn't choose this approach for the compiler because it's supposed to work when distributed as a tarball without git.