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

Feature request: Types of arguments in documentation #12580

Closed
Itee opened this issue Nov 4, 2017 · 11 comments
Closed

Feature request: Types of arguments in documentation #12580

Itee opened this issue Nov 4, 2017 · 11 comments

Comments

@Itee
Copy link
Contributor

Itee commented Nov 4, 2017

Next to #12574 part 1

Currently we was have access to the variable type using hovering in the documentation. But it is maybe unusable on mobile. And is not guess to know !

The proposal is to add the type and when possible the range of the parameters.

Example:

fooParam - The fooParam of the bar class. A Floating point number, in the range 0.0 - 1.0 with default to null

instead of

fooParam - The fooParam of the bar class. Default to null

@Itee
Copy link
Contributor Author

Itee commented Nov 12, 2017

/ping @mrdoob So what is your opinion ?

@haroldiedema
Copy link
Contributor

haroldiedema commented Nov 20, 2017

"Currently we was have access to the variable type using hovering in the documentation."

I've been using THREE for a few years now and find myself going to the docs for reference on a regular basis. Just to prove the usefulness of this, I've never known this "feature" was there.

While we're on the subject of documentation, I find it personally frustrating that the source code of the library itself is extremely poorly documented.

Why don't we use a JSDoc standard in the code and generate documentation based on that?

So something that looks like this:

class PointLight extends Light
{
    /**
     * Constructs a PointLight.
     *
     * @constructor
     * @param {Color|String|Number} color - (optional) hexadecimal color of the light. Default is 0xffffff (white)
     * @param {Float} intensity           - (optional) numeric value of the light's strength/intensity. Default is 1.
     * @param {Number} distance           - The distance from the light where the intensity is 0. When set to 0, then the light never stops. Default is 0.
     * @param {Number} decay              - The amount the light dims along the distance of the light. Default is 1. For physically correct lighting, set this to 2.
     */
    constructor (color, intensity, distance, decay)
    {
        // ...
    }
}

Would produce an automatically generated readable documentation. So when the code gets updated, the documentation is updated automatically as well.

I've build a similar system for a level editor for a game I'm working on, and I have to say that it works wonders:

Screenshot of the code:

  • don't mind the bug in the code in this screenshot. It's an old image I had on discord :p

Screenshot of the automatically generated API reference in-editor:

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2017

Why don't we use a JSDoc standard in the code and generate documentation based on that?

This was already discussed a number of times: #2869, #4725, #11550

I think the approach of the project is clear: #3445 (comment)

@haroldiedema
Copy link
Contributor

Ah my apologies, I wasn't aware.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 20, 2017

No problem

@WestLangley
Copy link
Collaborator

@haroldiedema Thanks for your suggestion, anyway.

@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2017

Another issue of JSDocs I've recently realised is that it doesn't scale to docs localisation (not that our docs have been localised yet anyway... 😛)

@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2017

@Itee can you point me to a docs page were that change is applicable?

@Itee
Copy link
Contributor Author

Itee commented Dec 21, 2017

@mrdoob Almost everywhere in the doc ?!

But if you want some listing:

  • timeScale: A value of 0 causes the animation to pause. Negative values cause the animation to play backwards. Default is 1. We got a 0, a 1, and negative values... So are we in a range like: -1 -> 1, -1.0 -> +1.0, or -Inf -> +Inf ?
  • weight: The degree of influence of this action (in the interval [0, 1]). Values between 0 (no impact) and 1 (full impact) can be used to blend between several actions. Default is 1. This one is perfectly clear !
  • PropertyMixer: ...
  • far: Camera frustum far plane. Default is 2000. The valid range is between the current value of the near plane and infinity. Could i use negative values ?
  • zoom Gets or sets the zoom factor of the camera. Default is 1. Zoom range is ?
  • etc... etc...

Maybe this could be normalized during doc generation ?

@looeee
Copy link
Collaborator

looeee commented Dec 21, 2017

far: Camera frustum far plane. Default is 2000. The valid range is between the current value of the near plane and infinity.

near: Camera frustum near plane. Default is 0.1. The valid range is greater than 0 and less than the current value of the far plane.

I don't see how this one could be much clearer.

Agreed that some of the others need work though.

Maybe this could be normalized during doc generation ?

Docs are written by hand, not generated.

Automatically generated docs tend to be pretty horrible to read.

@Itee
Copy link
Contributor Author

Itee commented Dec 21, 2017

@looeee

Docs are written by hand, not generated.

Ok I thought there was some helpers or templates somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants