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

Add ability to infer default values when compiling #304

Open
ben-eb opened this Issue Jan 1, 2015 · 6 comments

Comments

Projects
None yet
5 participants
@ben-eb
Copy link

ben-eb commented Jan 1, 2015

If I have some map, or mixin, with a documented property, it might be nice to try to parse the SCSS following the comment to try and infer its default value. Such that writing this SCSS:

// Main colour palette.
// @prop {Color} main-background - Deep, blueish gray
// @see {function} colour
// @type Map
$colours: (
    "main-background": rgb(61, 75, 92)
);

Should be parsed exactly the same as if we were to explicitly write the default value:

// Main colour palette.
// @prop {Color} main-background (rgb(61, 75, 92)) - Deep, blueish gray
// @see {function} colour
// @type Map
$colours: (
    "main-background": rgb(61, 75, 92)
);

The benefits of doing this - well, having documentation that is up to date is pretty important. I can see a few cases where an author will update their SCSS files, and forget to change a variable in the doclet. Would be a nice feature to have!

@valeriangalliat

This comment has been minimized.

Copy link
Member

valeriangalliat commented Jan 1, 2015

I like this idea. We can do this by adding a resolve function to src/annotation/annotations/property.js, parsing item.context.value for each item in given data:

// ...

  resolve(data) {
    data.filter(i => 'property' in i).forEach(item => {
      let props = someMagicWith(item.context.value);

      item.property = item.property.map(prop => {
        if (!('default' in prop)) {
          prop.default = props[prop.name];
        }

        return prop;
      });
    });
  },

// ...

Though SassDoc's purpose is not to be a proper SCSS parser (it's already having difficulties parsing annotations as you could point out in #303 😄), so if we end up implementing this, it will probably be a fairly dumb parser, that will fail in complex cases.

@ben-eb

This comment has been minimized.

Copy link
Author

ben-eb commented Jan 1, 2015

Indeed. You might like to have a look at gonzales-pe for this, instead of rolling your own. 😃

@FWeinb

This comment has been minimized.

Copy link
Member

FWeinb commented Jan 1, 2015

The last time I check Gonzales-pe it could not handle most of scss, so that isn't an option.

@HugoGiraudel

This comment has been minimized.

Copy link
Member

HugoGiraudel commented Jan 2, 2015

We already tried gonzales-pe. It does not suit our needs. Also I'd like to avoid making SassDoc a full Sass parser.

@HugoGiraudel HugoGiraudel added this to the 2.1 milestone Jan 2, 2015

@ben-eb

This comment has been minimized.

Copy link
Author

ben-eb commented Jan 2, 2015

Alright, fair enough. 😄

@HugoGiraudel HugoGiraudel modified the milestones: 2.1, 2.2 Jan 30, 2015

@HugoGiraudel

This comment has been minimized.

Copy link
Member

HugoGiraudel commented Feb 27, 2015

Who takes it and how do we tackle this?

@pascalduez pascalduez referenced this issue Jun 21, 2015

Closed

[Meta] 2.2 #415

1 of 1 task complete

@HugoGiraudel HugoGiraudel changed the title Try to infer default values when compiling Add ability to infer default values when compiling Nov 6, 2015

@pascalduez pascalduez referenced this issue Feb 18, 2017

Open

[Meta] 2.4 #484

5 of 9 tasks complete

@pascalduez pascalduez modified the milestones: 2.2, 2.3 Feb 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.