You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show "supported since version x" for functions in API documentation #3713
I think it would be useful to show from which version a given function in the API is supported, e.g. Buffer.prototype.indexOf() was added in v4.x, so if I'm creating a node module that should be backwards compatible with node v0.12, I shouldn't use that function.
I'll happily make pull request with this change - and please comment if you have deeper knowlege of the documentation system in case there are ways to (semi-)automate this in some way.
The docs wg has already discussed this idea before and we seemed to all agree it is a thing we want. We just haven't got to it yet. Contributions in that regard are absolutely welcome! 😄
Also, maybe we should consider supporting the few cases where the API for a given function have changed between two versions of node - e.g. fs.readFile changed it's 2nd argument from a string to a an object at v0.9.11.
Maybe it makes sense to also include a short notice about the first (soft) deprecation of a module/ function.
Right now the docs mention that it's deprecated, but not when the function was first deprecated (or even when it's expected to be removed)
I would propose to just use something like <sup/>, potentially combined with an emphasis. Markdown does not have superscript, and we need some kind of unique-ish thing that does not interfere with any function signatures. Something like only emphasizing would probably work as well, but I feel that superscript is harder to misinterpret as part of the signature.
### buf.indexOf(value[, byteOffset]) _<sup>since v5.4</sup>_
* `value` String, Buffer or Number
* `byteOffset` Number, Optional, Default: 0
* Return: Number
Operates similar to [...]
So if I understand it correctly, the process would have to look something like this(?):
The generate.js tool needs to be updated to understand the new syntax
Someone needs to add _<sup>since vx.y</sup>_ where appropriate throughout the docs
I don't mind making a PR with no 2 if we agree on the markdown format.
@jwueller In my example I added the css style font-weight: normal to ensure a bigger contrast between it and the function headline. But I guess we can tweak all that stuff in css later? Or do we need to add something special in the markdown for it to work?
Activity
evanlucas commentedon Nov 9, 2015
FWIW I think this is a great idea
Qard commentedon Nov 9, 2015
The docs wg has already discussed this idea before and we seemed to all agree it is a thing we want. We just haven't got to it yet. Contributions in that regard are absolutely welcome! 😄
watson commentedon Nov 9, 2015
There are tons of ways to visually display this. I just messed around with the dev tools and mocked this up to get the discussion going:
Any other suggestions?
As reference, the PHP docs have something similar - notice the
(PHP 4, PHP 5)at the top of this page: http://php.net/manual/en/function.setcookie.phpAlso, maybe we should consider supporting the few cases where the API for a given function have changed between two versions of node - e.g.
fs.readFilechanged it's 2nd argument from a string to a an object at v0.9.11.targos commentedon Nov 9, 2015
I think we need to be more precise about the version number. Because we are following semver, a method could be added in v5.4.
r-52 commentedon Nov 9, 2015
Maybe it makes sense to also include a short notice about the first (soft) deprecation of a module/ function.
Right now the docs mention that it's deprecated, but not when the function was first deprecated (or even when it's expected to be removed)
watson commentedon Nov 9, 2015
@targos good point 👍
@romankl does it matter from which version a function is deprecated and do we know up front in which version that function is expected to be removed?
jwueller commentedon Nov 12, 2015
This is a great idea, I've actually had to figure it out manually several times in the past. Not fun.
@watson's mockup looks great and keeping version numbers as precise as possible is definitely the right thing to do.
Concerning deprecation versions: I do not think those are relevant information, since no functionality actually changes in those cases.
tflanagan commentedon Nov 13, 2015
How would this look in the markdown? Can get started on the generate.js tool once this has consensus.
jwueller commentedon Nov 13, 2015
I would propose to just use something like
<sup/>, potentially combined with an emphasis. Markdown does not have superscript, and we need some kind of unique-ish thing that does not interfere with any function signatures. Something like only emphasizing would probably work as well, but I feel that superscript is harder to misinterpret as part of the signature.buf.indexOf(value[, byteOffset]) since v5.4
valueString, Buffer or NumberbyteOffsetNumber, Optional, Default: 0Operates similar to [...]
watson commentedon Nov 13, 2015
@jwueller looks good!
@tflanagan what does the generate.js tool do?
Fishrock123 commentedon Nov 13, 2015
@watson generate.js is our current doc generation tool. It turn markdown into html mostly.
Note that it's pretty fragile and hasn't been touched in years. :)
watson commentedon Nov 13, 2015
@Fishrock123 thanks for explaining 😃
So if I understand it correctly, the process would have to look something like this(?):
_<sup>since vx.y</sup>_where appropriate throughout the docsI don't mind making a PR with no 2 if we agree on the markdown format.
@jwueller In my example I added the css style
font-weight: normalto ensure a bigger contrast between it and the function headline. But I guess we can tweak all that stuff in css later? Or do we need to add something special in the markdown for it to work?10 remaining items
tools: parse documentation metadata
evanlucas commentedon May 24, 2016
Closing in favor of #6578. That issue is a duplicate of this. There is great progress being made on this front. Thanks!
tools: parse documentation metadata
tools: parse documentation metadata
tools: parse documentation metadata