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

Show "supported since version x" for functions in API documentation #3713

Closed
watson opened this issue Nov 8, 2015 · 21 comments
Closed

Show "supported since version x" for functions in API documentation #3713

watson opened this issue Nov 8, 2015 · 21 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@watson
Copy link
Member

watson commented Nov 8, 2015

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.

@Fishrock123 Fishrock123 added the doc Issues and PRs related to the documentations. label Nov 8, 2015
@ChALkeR ChALkeR added feature request Issues that request new features to be added to Node.js. and removed feature request Issues that request new features to be added to Node.js. labels Nov 8, 2015
@evanlucas
Copy link
Contributor

FWIW I think this is a great idea

@Qard
Copy link
Member

Qard commented 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
Copy link
Member Author

watson commented 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:

screen shot 2015-11-09 at 10 19 46

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.php

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.

@targos
Copy link
Member

targos commented 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
Copy link
Contributor

r-52 commented 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
Copy link
Member Author

watson commented 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
Copy link
Contributor

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
Copy link
Contributor

How would this look in the markdown? Can get started on the generate.js tool once this has consensus.

@jwueller
Copy link
Contributor

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 [...]

buf.indexOf(value[, byteOffset]) since v5.4

  • value String, Buffer or Number
  • byteOffset Number, Optional, Default: 0
  • Return: Number

Operates similar to [...]

@watson
Copy link
Member Author

watson commented Nov 13, 2015

@jwueller looks good!

@tflanagan what does the generate.js tool do?

@Fishrock123
Copy link
Contributor

@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
Copy link
Member Author

watson commented Nov 13, 2015

@Fishrock123 thanks for explaining 😃

So if I understand it correctly, the process would have to look something like this(?):

  1. The generate.js tool needs to be updated to understand the new syntax
  2. 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?

@tflanagan
Copy link
Contributor

Yea, I was going to couple this change with the fix for #1545 (not the same commit, just same "work session")

@watson That's a "Go for no. 2" ;)

I'll work on no. 1 when the consensus is made.

@jwueller
Copy link
Contributor

@watson If we were only ever using a generator script that compiles to HTML, there would be no need to do more than a single element (like <sup/>). It's just some element to add the CSS to.

However, I would ideally like to have this be readable in non-generate.js scenarios as well (e.g. the GitHub Markdown renderer). That is why I proposed emphasis in addition to <sup/>. We have free choice of styles in the generate.js scenario, but the options are limited for standard Markdown viewers. <sup/> plus emphasis seems to be a good compromise between markup complexity and readability in the final non-generate.js output.

@tflanagan
Copy link
Contributor

Just as a side note, @jwueller, GitHub markdown does support the superscript tag.

@watson
Copy link
Member Author

watson commented Nov 14, 2015

@jwueller yeah, it would be really nice if the markdown files are readable on GitHub as well. But I'm ok with the "since"-text being bold on GitHub. Most people are going to look at the docs on nodejs.org, so as long as we can tweak the the CSS there I think we're good 😃

@jwueller
Copy link
Contributor

@tflanagan Is there any special markup for it? I cannot seem to find anything. My original example used the <sup/> HTML tag, since Markdown permits custom HTML.

@watson The emphasis in my example was only added to improve readability on GitHub. There is no way that I am aware of to un-bold text using Markdown syntax alone, so that is how it'll have to be. The CSS for the documentation pages can obviously improve this even more.

@tflanagan
Copy link
Contributor

@jwueller, I've finished modifying the generation tool. See #3867.

@jmm
Copy link
Contributor

jmm commented Nov 19, 2015

+1 for this. People love to knock PHP, but its documentation has done a better job of communicating this information than any similar documentation I can think of.

@targos @watson mentioned that they display some broad version information at the top of each page (it's not always just the major version number), but (as applicable) pages also include a Changelog section that logs changes down to patch level and includes things like changes to function signatures.

Example:

Top of page:

(PHP 5 >= 5.2.0, PECL json >= 1.2.0, PHP 7)

Changelog:

Version Description
5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.
5.5.0 depth parameter was added.
5.4.0 JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, and JSON_UNESCAPED_UNICODE options were added.
5.3.3 JSON_NUMERIC_CHECK option was added.
5.3.0 The options parameter was added.

@kzc
Copy link

kzc commented Dec 17, 2015

@jmm +1. Tracking changes to function arguments across node releases would have been very useful to me for #4317

addaleax pushed a commit to addaleax/node that referenced this issue May 4, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: nodejs#3713
Ref: nodejs#6470
addaleax pushed a commit that referenced this issue May 4, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: #3867
Ref: #3713
Ref: #6470
PR-URL: #6495
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
evanlucas pushed a commit that referenced this issue May 17, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: #3867
Ref: #3713
Ref: #6470
PR-URL: #6495
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
@evanlucas
Copy link
Contributor

Closing in favor of #6578. That issue is a duplicate of this. There is great progress being made on this front. Thanks!

addaleax pushed a commit to addaleax/node that referenced this issue Jul 12, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: nodejs#3867
Ref: nodejs#3713
Ref: nodejs#6470
PR-URL: nodejs#6495
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
MylesBorins pushed a commit that referenced this issue Jul 12, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: #3867
Ref: #3713
Ref: #6470
PR-URL: #6495
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
MylesBorins pushed a commit that referenced this issue Jul 14, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: #3867
Ref: #3713
Ref: #6470
PR-URL: #6495
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
MylesBorins pushed a commit that referenced this issue Jul 14, 2016
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: #3867
Ref: #3713
Ref: #6470
PR-URL: #6495
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

No branches or pull requests