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

Missing documentation for fabric.util.object.clone #309

Closed
Serene47 opened this issue Jul 17, 2021 · 4 comments
Closed

Missing documentation for fabric.util.object.clone #309

Serene47 opened this issue Jul 17, 2021 · 4 comments

Comments

@Serene47
Copy link
Contributor

Please add documentation for the method clone(object,deep) in file /docs/fabric.util.object.html.

The source code for the function is in https://github.com/fabricjs/fabric.js/blob/master/src/util/lang_object.js

The absence of the documentation misleads people to think that this function is for cloning fabric objects.

Feel free to assign me the task, if you are busy with other tasks.

@asturur
Copy link
Member

asturur commented Jul 17, 2021

hi @Serene47 you can look at the fabricjs repo and a jsdoc there if missing

@Serene47
Copy link
Contributor Author

Serene47 commented Jul 18, 2021

hi @asturur, Yeah I am fine with js doc,

But my point is people who are new with fabric js, assume util.object.clone for cloning fabric objects, use it and break their code at some point.

Some posts justifying my point

I also ran into that kind of problem and had to put some effort to find the repo and look into it.

I assume if we provide documentation on the official page, people are more likely to read that.

@asturur
Copy link
Member

asturur commented Jul 20, 2021

I have nothing against an explanation of that jsdoc on the website. But how would you frame it?
the only place i can think of is the fabricjs-gotchas.

This is what we say in the fabricJS docs for extend:

  /**
   * Copies all enumerable properties of one js object to another
   * this does not and cannot compete with generic utils.
   * Does not clone or extend fabric.Object subclasses.
   * This is mostly for internal use and has extra handling for fabricJS objects
   * it skips the canvas and group properties in deep cloning.
   * @memberOf fabric.util.object
   * @param {Object} destination Where to copy to
   * @param {Object} source Where to copy from
   * @return {Object}
   */

and this is what we say for clone:

  /**
   * Creates an empty object and copies all enumerable properties of another object to it
   * @memberOf fabric.util.object
   * TODO: this function return an empty object if you try to clone null
   * @param {Object} object Object to clone
   * @return {Object}
   */

Now the main issue is that the clone jsdoc needs to be updated with the content of the extend one.
That is 100% useful and quick to do. If you want to add a specific part in the docs, make a proposal with a PR on this repo.

@Serene47
Copy link
Contributor Author

Hi, thanks for your suggestion

I have added pull requests in fabricjs/fabric.js and fabricjs/fabricjs.com

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

3 participants