-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Automatically add links to API-docs in examples #3551
Automatically add links to API-docs in examples #3551
Conversation
*/ | ||
function getLinkToApiHtml(googRequires) { | ||
var lis = googRequires.map(function(symb) { | ||
var href = 'http://openlayers.org/en/master/apidoc/' + symb + '.html'; |
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.
Or should we use relative links?
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.
And then there are things like this: http://openlayers.org/en/master/apidoc/ol.html#Coordinate
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.
Relative links would be better IMHO.
Do we have a chance of detecting the cornercases? I'd love to get rid of that remaining 5% 404s. |
var lis = googRequires.map(function(symb) { | ||
var href = 'http://openlayers.org/en/master/apidoc/' + symb + '.html'; | ||
return '<li><a href="' + href + '" title="API documentation for ' + | ||
symb +'"><code>' + symb + '</code></a></li>'; |
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.
Maybe remove the <code>
tag - it makes the symbols look very big.
You could send an XHR to the generated URL and remove the |
I'll think about this... |
This is now using relative links. I also added some lines to TIA for any review. |
This PR assumes jQuery is used in the examples. I'll update this so it does no longer depend on jQuery. |
@@ -34,6 +34,7 @@ <h4 id="title">{{ title }}</h4> | |||
<p id="shortdesc">{{ shortdesc }}</p> | |||
<div id="docs">{{ md docs }}</div> | |||
<div id="tags">{{ tags }}</div> | |||
<div id="api-links">Used in this example: {{{ js.apiHtml }}}</div> |
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.
Maybe this could read "Related API documentation: " instead.
No worries, @tschaub, I know you aren't picky 😉 I'll adress all your comments and thank you for giving them. |
And now you'll have to deal with a few conflicts when you rebase this on master. As mentioned in #3558 (comment), jQuery is safe to use in the You'll notice I also removed the use of the comma operator for long sequences of variable declarations and assignments (this can be enforced in the future with the |
I'll try to rebase this on master this evening. |
When we create the examples, we know exactly which specific `ol.…` symbols we `goog.require(…)`. We can create links to the API documentation of these symbols automatically.
Rebased. I'd be grateful for another review. |
This is really nice @marcjansen. I think this goes a long way toward making our examples and API docs usable. All we need now is a common template for API docs, the website, and the examples, and we'll finally have a proper project website (well, that plus some serious design attention - I'm hoping I can rope in one of our designers for that). Please merge. |
Cheers for the review, Tim. |
Automatically add links to API-docs in examples
One final comment about something that can be handled later. I think it would be nice to improve things when running the examples locally (it's annoying to have the links flash up and then disappear). I actually think the best solution is to try to avoid the |
Actually I did not notice any dead links. But there were unreliable names of HTML outputs in the past. The logic could be switched of course: initially hide alle the lis and only show them once we are sure they exist. |
Ok, I'll create a pull request for discussion. I think the only thing that would not work are typedefs. For example, the URL to the See #3581. |
Take transformfunction.js for example. This file just includes a So, in general, we add a I think we're quite consistent with our use of |
I said our use of I think the only reason to |
Ok, I understand now. I had misread your comment. Sorry.
I am no longer sure that I understand this, and our use of The Manage Closure Dependencies doc states that I should probably seat down and spend some time to better understand all this. I thought it was clear at one point, but it looks like it's no longer the case… |
And, if I remember correctly, you observed that the build was larger when |
Here's what I think (I don't think that doc page is very complete). When we use For example, I have a build config that only exports So, with I said the |
Let's carry on this conversation in #3452. I think it will make a more sensible reference later. |
When we create the examples, we know exactly which specific
ol.…
symbolswe
goog.require(…)
. We can create links to the API documentation of thesesymbols automatically.
Please review.