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

Proposal: codeExample should compile Sass even when not showing the CSS output #834

Open
Goodwine opened this issue Sep 14, 2023 · 0 comments

Comments

@Goodwine
Copy link
Member

Currently codeExample accepts an autogenCSS boolean argument for whether to compile the Sass inputs and render the outputs. Many examples set this value to false because the examples want to focus on the Sass inputs without showing the CSS output. However, this is error prone because we can (and have) published broken examples such as list.separator(1, 2) because there was no compilation, and therefore no validation. codeExample should compile Sass regardless even when not showing the CSS output to avoid these problems.

On the other hand, it's important to have a lever that would actually disable compilation for cases where the example is intentionally broken code. Or.. better yet, if the example is intentionally broken, then show the error message instead of what would have been the CSS output.

Overall the proposal is so that instead of <% codeExample 'foo', false %> we could pass an options object:

<% codeExample 'foo', {showCssOutput: false} %>

Simpler Options object

The overall options interface can be something like this:

interface CodeExampleOptions {
  /** Whether to show the CSS output or the failure message. */
  showOutput?: boolean; // defaults true
  /** Assert whether the compilation should succeed or fail. */
  success?: boolean; // defaults true
}
Regardless of the outcome, the input will always be compiled.

Extra:

Currently codeExample doesn't seem to be able to compile multiple files, this forces having to turn off compilation entirely. If we want to compile everything we should then expand this to be able to compile multiple files.

Otherwise, another interface property skipCompilation?: boolean // defaults false may be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants