jacobrask / styledocco

Automatically generate a style guide from your stylesheets.
http://jacobrask.github.com/styledocco/
MIT License
1.07k stars 119 forks source link

Compile partial sass files #104

Open jorgenfb opened 10 years ago

jorgenfb commented 10 years ago

I have a lot of css modules defined as partials (files starting with ). Styledocco generates the documentation page, but the preview iframe contains no styling. I think this is because the filename starts with a . If I rename the files ( without leading _) then it includes the styling.

Compiling the partials and adding them to the preview would really help document my modules. I guess other have this problem as well, saving modules as partials seems to be good practice.

marrs commented 10 years ago

It sounds like a good idea. It may be a while before I can get around to this, so if you want to contribute this feature yourself, you can make a pull request against dev0.7.

jorgenfb commented 10 years ago

At first the solutions seemed clear, just remove the check for sass/scss file beginning with _ at the beginning of the preprocess-function. This will include the partials, but if other files include these partials they are included multiple times. This may or may not be a problem, depending on order of concatenation.

The same problem already exist for files not starting with underscore, they appear multiple times if included in some other file.

The only solution that I can think of is analyzing all style files, looking for import statement and only preprocess files already not imported in other files.

I'm not sure this is worth continuing. I have been thinking and come to the conclusion that a styleguide should be based on your main style file, which should include all the modules your using.

What do you think @marrs ?

marrs commented 10 years ago

I think you're right that documenting the main file is the right way to go. I wonder if this was considered by @jacobrask originally and that's why modules get ignored.

So it's probably best to leave it as is. I will need to add a spec to the tests to document this behaviour. I'm in the process of documenting all code for the 0.7 release so I'll close this ticket when that gets done.

Thanks for raising this behaviour and thinking through the problem.

highvoltag3 commented 9 years ago

I agree with most of what @jorgenfb @marrs have mentioned here, yet I'm not 100% sure the solution is on leaving the as is and documenting all in the main file, the reason behind this is that if you're including third party libraries like Bourbon you don't want those to get process, so it's easier to just pass the files you want to actually include, bringing the original problem back.

I'm currently working on a project that includes Bournon, Neat, Normalize and Animate in the main file along with all the partials for the project and having all those files pass through Styledocco makes no since, not to mention that normalize.css comes heavily commented and those get build into the final style guide.

highvoltag3 commented 9 years ago

After looking into this it's not as easy as just changing the method preprocess() though of course that would need to be done, but the real root cause of the issue is #124 since the common path between say:

/styles/sass/partials/_partial1.scss
/styles/sass/partials/_partial2.scss

is /styles/sass/partials/_ which is not a real path but fails silently.