SassDoc / sassdoc

Release the docs!
http://sassdoc.com
MIT License
1.41k stars 56 forks source link

@requires autofill: multiple of the same dependency #294

Open DenisMir opened 9 years ago

DenisMir commented 9 years ago

I have found the error that requires dependencies are getting referenced multiple times in the rendered output when some mixin is using some function multiple times.

/**
 * Some function that gets used from other mixins
 */
@function base() {}

/**
 * Some mixin that uses the `base` function multiple times
 */
@mixin fails() {
  base();
  base();
}

/**
* Some mixin that uses the `base` function multiple times
* @requires base
*/
@mixin works() {
  base();
  base();
}

Manually adding the @requires fixes the bug in this simple case. In more complex mixins this is not enough and I'm getting multiple dependencies all over.

An example can be found right here:

https://github.com/DenisMir/sassdoc-bugs/blob/master/src/requires-autofill-bug.scss

KittyGiraudel commented 9 years ago

This one is for @FWeinb.

FWeinb commented 9 years ago

This should not happen because I am using lodash#uniq here. Will look into it.

KittyGiraudel commented 9 years ago

@FWeinb Any idea what's going on here?

FWeinb commented 9 years ago

Found the issue. And fixed it on develop a994ed5c22b487f69d6aa8eb67fdc57ec70e77f3

MiChAeLoKGB commented 7 years ago

virtualbox_2017-07-10_20-22-58

From my testing, this is still a problem both with variables and with functions. Also its counting variables/functions on lines which are commented, so if you comment out a line with a variable/function, it will still be in Requires section...

Also, if function uses a variable as default parameter, its not in Requires section. I would argue, that its still required for the mixin/function to actually work properly...

Example code (the $base-font-size is 3x in Requires section and if you remove those not needed variables using it (and the commented one), it wont be there at all, even when its a default parameter):

@function calculateEm($size, $base-size: $base-font-size) {
    $random-thing: $base-font-size;
    $why-hello-again: $base-font-size;
    // $wait-what-no-way: $base-font-size;
    @return ($size / $base-size) * 1em;
}