sassdoc
sassdoc copied to clipboard
@requires autofill: multiple of the same dependency
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
This one is for @FWeinb.
This should not happen because I am using lodash#uniq here. Will look into it.
@FWeinb Any idea what's going on here?
Found the issue. And fixed it on develop a994ed5c22b487f69d6aa8eb67fdc57ec70e77f3

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;
}