Skip to content

Can parse CSS rule code contexts, too. #21

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 28, 2015

Conversation

carljm
Copy link
Contributor

@carljm carljm commented Nov 19, 2015

Hi! We'd like to use SassDoc as part of a "living styleguide" system for our projects, and for this to work it needs to have the capability to annotate CSS rule blocks as well as functions/variables/mixins/placeholders. This pull request adds that capability to the comments context parser.

I see that the broad concept has been rejected before, on "do just one thing" grounds (e.g. see SassDoc/sassdoc#268), but I'd like to request re-consideration. Accepting this small PR does not mean changing the primary supported purpose of SassDoc in any way, it just adds a bit more flexibility for those of us who want to experiment with extending SassDoc in "off the beaten path" ways, without harming or impacting the existing uses at all.

Thoughts? Thanks for considering.

@KittyGiraudel
Copy link
Member

For some reason, I didn’t get notified for this PR so I’ll ping other core contributors as well: @valeriangalliat @FWeinb @pascalduez. I will reply to this tomorrow as soon as I get to work. :)

assert.deepEqual(context, {
type: 'css',
name: '.foo',
value: 'font-weight: bold;\n color: red;\n .bar {\n color: blue;\n }'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing leading {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also maybe makes more sense to call it code instead of value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I debated about the names. I chose name and value for consistency with all the other types, but if that consistency doesn't matter it would probably be better to use selector and body.

And the leading { and trailing } of the body are both removed, but if you think it's better to include them I can certainly do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It looks like the trailing } is there, but it's not -- that's actually part of a nested rule.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, indeed, just the fact that the code was ending with a } and not beginning with one was bugging me.

And the {} are removed for other annotations so you're right that's the right way to do. 👍

The mixin uses name and code so it's still consistent to use code for CSS rules too, though selector and body also really make sense... let's see @SassDoc/owners's opinion.

@pascalduez
Copy link
Member

Conceptually I'm in favor of this, I feel like it's time to let people be able to hack around SassDoc, so they can build custom themes that fits their needs, new directions, etc...
At the time of PostCSS, CSS modules, and all possible new concepts to come, it might be wise not to lock SassDoc evolution capabilities.
Which doesn't mean SassDoc core (default theme) have to change guidance, if we still want to focus on Sass libraries, we can.

I'll have a look at the code later on.

@KittyGiraudel
Copy link
Member

Ohai.

Thanks again for bringing this on the table @carljm (and @ericam).

On the code side, it looks simple and clever enough to be merged without worrying too much, so I’d go with a yes. It looks like a nice addition that does not introduce any backward incompatibility, therefore I do not see any reason to prevent this or decline this pull request.

Now, on the documentation side I am wondering whether / how we should document this. I would be in favor of not promoting this too much if we want SassDoc to remain an API documentation tool. That being said, we could make this reply from the FAQ a bit more elaborate, perhaps including a link to this pull-request and any further work performed by the OddBird team.

On top of that, it would be interesting to document this somewhere else in the “Custom theme” section, so people know that they can use this feature if they build their own theme. Indeed, I must say I don’t really want to adapt the default theme to support CSS rules, although maybe we should. Thoughts?

@carljm
Copy link
Contributor Author

carljm commented Nov 20, 2015

Thanks for the review and discussion! I don't personally have any opinion on how or whether the SassDoc documentation, FAQ, or default theme should be updated, but if you all decide that they should be, I'm happy to submit a PR to SassDoc for that as well. Just let me know.

Regarding this PR, let me know if you want the keys updated from name and value to either name and code or selector and body. That's the only outstanding question I'm aware of.

@carljm
Copy link
Contributor Author

carljm commented Nov 25, 2015

What's the next step here? Sounds like the consensus so far is in favor of merging -- any changes needed first? Anyone else need to weigh in?

@KittyGiraudel
Copy link
Member

I would have loved to have @FWeinb but I don’t think it’s gonna happen. @pascalduez, @valeriangalliat, all good?

@valeriangalliat
Copy link
Member

Looks good to me

@pascalduez
Copy link
Member

👍

@pascalduez
Copy link
Member

Let's see this as a shy hello sign to future evolutions and theme hackers.
But feels like we would need a serious planning at some point if we want to do things right.
Especially the data interface naming.

pascalduez added a commit that referenced this pull request Nov 28, 2015
Can parse CSS rule code contexts, too.
@pascalduez pascalduez merged commit e0e6e71 into SassDoc:master Nov 28, 2015
@pascalduez
Copy link
Member

Thanks for the PR @carljm !

Available as of scss-comment-parser@0.8.0 and sassdoc@2.1.16

@carljm
Copy link
Contributor Author

carljm commented Nov 28, 2015

Thanks @pascalduez !

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants