-
Notifications
You must be signed in to change notification settings - Fork 42
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
Suggestion: Link back to Github for github-fetched generated docs #36
Comments
It's unfortunate that we can't make this work for gems. I can't imagine how it would work, though. Maybe if there was some kind of dotfile that was in the project (maybe we can add metadata to yardopts somehow) or if the gemspec could actually specify this stuff (the gemspec can contain metadata). But users would have to opt in, and it would be hard to track / maintain. You would have to point to the tag / commit of the code in the gem, which isn't easily mappable. As I mentioned, we could not just assume master. |
Also I just made this change in yard to do better filtering on the "next()" element so that your greasemonkey style script should now work properly, and it's deployed on rubydoc.info. |
Is there even any way to identify if a gem does come from github, and In many but not all cases, but enough that it might be worth it at But prerequisite is being able to tell from the gemspec what the |
PS: If you release with the "bundle release" rake task, it adds a "semantic versioning" style tag to your repo for you. Plus many people do it intentionally. I think a great many gems (although certainly not all, esp ones whose latest release is old) will have semver-style tags in the repo. That part doesn't actually seem as hard as identifying the repo! |
I just did this kind of stuff last week, and it turns out that it's really hard to get the source code URL from rubygems.org, and even harder from a gemspec. We actually ran this across 140 gems and only got back 80. I guess that's either bad or not bad depending on your viewpoint. We could do it that way... Note however that yard doesn't follow the "vX.Y.Z" scheme, we drop the "v" (we were tagging way before this "semver" stuff existed :)), but that's an easy heuristic check. |
The problem here is two fold though:
|
You could HEAD for both (inc with the "v." dropped), or you could just say "use semver if you want auto git links (and fix yard! :) ). But the harder thing is clearly getting the github url in the first place. Now, from my perspective as a user having github links work on just over half of gems (if 80 out of 140 was representative) would still be exactly halfway better than none having links back to github! But it's whether it's worth the coding or not just to get those, is up to you. I don't know if your methods including looking at gemspec 'homepage' to see if it is set and just happens to be https://github.com/.... , but that would get some gems, which have their home pages set there. It is not surprising to me that it's hard to get it from the gemspec alone, since, sadly, there is no gemspec param for it. It is surprising to me you can't get it from rubygems.org itself, since it's a clearly specified seperate field in the gem admin interface. They don't have an api for pulling it out? Well, you told me before that one could call it 'using the DOM' instead of 'screen scraping' and just get it from the HTML representation instead then (heh, mostly kidding). Also, did I mention I really do love rubydoc.info? Also, now that I've noticed you are keeping multiple versions of auto-generated-from-gemspec docs around, of course another feature occurs to me -- apidock.com-style compare-and-contrast different versions of the api for a given gem. But that's a different issue, and a non-trivial feature to do as well as apidock does. (But now I'm stuck going to apidock when I need to compare-and-contrast rails features; going to api.rubyonrails.org when I want the links to github that it's got (yep, they've got em); and going to rubydoc.info for everything non-rails cause, well, you've got it, and in a very usable website. In my dreams, there's one site that does all that, for all gems, not just rails! ) |
I understand that is may end up a technical challenge for you, that's your call if it's not worth it of course, it's your resources.(for real, respect). And yeah, I agree that success would need to be reasonably predictable to keep gem authors from complaining. But it'd probably be okay if it entirley predictable based on gem authors following reasonable and documented conventions:
You do both these things, you get github links! If not, not! I think that would keep gem authors satisfied. But if there's no good way to get the repo from rubygems.org metadata, forget it, yeah. And again, I can respect if there aren't the resources to do it now. (But could just do it for new generations, not go back and re-do existing ones. But yeah, you'd need some kind of 'database', even if that's just dropping a dotfile in the filesystem somewhere, depending on how your back end filesystem works, not familiar with it. But yes, I understand this is non-trivial and may not be a priority. I'm just saying it would be sweet!) |
(It's definitely documented avail from rubygems.org api, but you probably know that better than me. http://guides.rubygems.org/rubygems-org-api/#gem Understand that many authors may not fill that out. Don't think anyone would complain if it was clearly documented 'fill that out if you want auto-generated rubydoc.info github links'. Might even lead to more people filling it out, if it was popular. ) |
hmm, this might be related rubygems/rubygems.org#724 |
thanks for looking into this stuff and working on that last 10% to making rubydocs more usable. |
I suggested (https://rubydoc.tenderapp.com/discussions/suggestions/4-suggestion-links-back-to-github) that http://rubydoc.info ought to do this.
Then lsegal suggested it would be best to do this with Javascript. That seemed an odd way to do it, but I said, okay, give it a shot.
Then I wrote this javascript that seems to work pretty darn well if it's applied to any rubydoc.info page in the github area. I just wrote/tested it 'greasemonkey' style, I didn't try running rubydoc.info locally and putting it into source myself.
https://gist.github.com/1305162
Then I realized that in fact these days the majority of my rubygems.info use is for 'gem' area not 'github' area, and this wouldn't do anything for me there, even if the gem source was in github. Then I got depressed and lost interest in spending TOO much more time on this.
Then I noticed that the JS code I wrote conflicts with your JS code for hide/show source. Only because of where it inserts the "link to github" link into the DOM I think. Either it needs to be changed to insert into the DOM somewhere else, or the hide/show source JS needs to be changed to be more precise in it's selectors instead of blindly assuming whatever's next() in the DOM after it is the source.
Now I file a ticket here with my JS code, as lsegal suggested, in case anyone else wants to run with it. I think I'm done. It is pretty cool though! I might make a little JS bookmarklet for myself to use this code, if it doesn't make it into rubydoc.info deployed.
The text was updated successfully, but these errors were encountered: