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

Change to underscore delimiter for Windows-friendly snippet names #117

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ By default, variants will be stacked. If you wish to view variants side by side,

_TODO:_ [Simplify Technique for Including Notes](https://github.com/chrislopresto/ember-freestyle/issues/61)

Use the `freestyle-note` component to add a markdown note for a specific `freestyle-usage`. Note that the `freestyle-note` slug must match the `freestyle-usage` slug followed by `:notes`.
Use the `freestyle-note` component to add a markdown note for a specific `freestyle-usage`. Note that the `freestyle-note` slug must match the `freestyle-usage` slug followed by `_notes`.

```hbs
{{#freestyle-usage "globally-unique-slug" title="Title To Display In Style Guide"}}
{{x-foo propa="aaa" propb="bbb"}}
{{/freestyle-usage}}
{{#freestyle-note "globally-unique-slug:notes"}}
{{#freestyle-note "globally-unique-slug_notes"}}
# Contextual Markdown Note for x-foo

You can write helpful _markdown_ notes explaining how the
Expand Down
2 changes: 1 addition & 1 deletion addon/components/freestyle-snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default Ember.Component.extend({
},

language: computed('name', function() {
if (this.get('name').indexOf(':notes') >= 0) {
if (this.get('name').indexOf('_notes') >= 0) {
return 'markdown';
}

Expand Down
2 changes: 1 addition & 1 deletion addon/styles/components/freestyle-palette-item.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BEGIN-FREESTYLE-USAGE fpi:notes
/* BEGIN-FREESTYLE-USAGE fpi_notes
# Markdown Notes In SCSS!

Hey look... these are `markdown` notes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { inject } = Ember;
export default FreestyleController.extend({
emberFreestyle: inject.service(),

/* BEGIN-FREESTYLE-USAGE fp:notes
/* BEGIN-FREESTYLE-USAGE fp_notes
### A few notes regarding freestyle-palette

- Accepts a colorPalette POJO like the one found in the freestyle.js blueprint controller
Expand Down
9 changes: 4 additions & 5 deletions freestyle-usage-snippet-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ function extractHbsComponentSnippets(fileContent, componentName, ui) {
inside = m[0].indexOf('}}') >= 0; // curlies closed }}
name = m[1];
// TODO: Cleanup freestyle-notes vs freestyle-usage disambiguation here
if (name.indexOf(':notes') >= 0) {
if (name.indexOf('_notes') >= 0) {
if (output[name]) {
ui.writeLine('ember-freestyle detected multiple instances of the freestyle-note slug "' + name +'"');
}
} else {
if (output[name + ':usage']) {
if (output[name + '_usage']) {
ui.writeLine('ember-freestyle detected multiple instances of the freestyle-usage slug "' + name +'"');
}
name += ':usage';
name += '_usage';
}
}
}
Expand Down Expand Up @@ -117,8 +117,7 @@ SnippetFinder.prototype.write = function (readTree, destDir) {
var commentSnippets = extractCommentSnippets(fs.readFileSync(filename, 'utf-8'));
var snippets = naiveMerge(componentSnippets, commentSnippets);
for (var name in snippets){
var windowsFriendlyName = name.replace(":notes", "_notes").replace(":usage", "_usage"); // replace : in order to have windows friendly filenames
fs.writeFileSync(path.join(destDir, windowsFriendlyName)+path.extname(filename),
fs.writeFileSync(path.join(destDir, name)+path.extname(filename),
snippets[name]);
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default FreestyleController.extend({
emberFreestyle: inject.service(),
showCode: computed.alias('emberFreestyle.showCode'),

/* BEGIN-FREESTYLE-USAGE fpi:notes
/* BEGIN-FREESTYLE-USAGE fpi_notes
### A few notes regarding freestyle-palette-item

- Accepts a color object
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
component to write notes in html.
</p>
{{/freestyle-annotation}}
{{#freestyle-note 'foo-normal:notes'}}
{{#freestyle-note 'foo-normal_notes'}}
#### Another Note About Normal

This comment is coming from a `freestyle-note` component. Use the `freestyle-note` component
Expand Down