Description
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.