From edf57a75b56f2e4d0aaf25ae2af934488f4ae7ca Mon Sep 17 00:00:00 2001 From: Hamish Coates Date: Fri, 1 Jun 2018 16:32:17 +0800 Subject: [PATCH 1/5] .editorconfig file create --- .editorconfig | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8d465d3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +[*] +charset = utf-8 +end_of_line = crlf +insert_final_newline = true +indent_style = space +indent_size = 2 From 5abb6d0400c416d9a71c4ace9d485650c547800b Mon Sep 17 00:00:00 2001 From: Hamish Coates Date: Fri, 1 Jun 2018 16:33:30 +0800 Subject: [PATCH 2/5] updated .gitignore to ignore .idea folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 437c59b..aa3417d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules /coverage examples/**/*.html bower_components -npm-debug.log \ No newline at end of file +npm-debug.log +.idea From 7090e224820e2c39e1fb8673b24849cbfbc68f78 Mon Sep 17 00:00:00 2001 From: Hamish Coates Date: Fri, 1 Jun 2018 16:55:09 +0800 Subject: [PATCH 3/5] namespace tag functionality created --- lib/tags.js | 15 ++++++++++++++- template/partials/polymer.hbs | 7 ++++++- template/partials/section.hbs | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/tags.js b/lib/tags.js index f7ed8ec..d791b27 100644 --- a/lib/tags.js +++ b/lib/tags.js @@ -412,9 +412,22 @@ var tags = { description += file; this.comment.description += description.trimRight(); + }, + + /** + * Apply a namespace to example code. Multiple namespaces will be applied to the same element. + * Nesting not supported. + * @example + /** + * @section + * @namespace foo + *\/ + */ + namespace: function () { + this.block.namespace = this.tag.description; } }; tags.code = tags.example; // @code and @example generate the same structure module.exports = tags; -module.exports.forwardReferenceSections = forwardReferenceSections; \ No newline at end of file +module.exports.forwardReferenceSections = forwardReferenceSections; diff --git a/template/partials/polymer.hbs b/template/partials/polymer.hbs index c2cf799..452496c 100644 --- a/template/partials/polymer.hbs +++ b/template/partials/polymer.hbs @@ -7709,6 +7709,11 @@ this.fire('dom-change'); var body = document.createElement('body'); body.classList.add(this.is); + // add the namespace of an example to the body + if(this.dataset.namespace) { + body.classList.add(this.dataset.namespace); + } + // add scoped class to all content injected child nodes var nodes = this.querySelectorAll('*'); for (var i = 0; i < nodes.length; i++) { @@ -7725,4 +7730,4 @@ this.fire('dom-change'); } }); })(); - \ No newline at end of file + diff --git a/template/partials/section.hbs b/template/partials/section.hbs index 70d9959..658b12f 100644 --- a/template/partials/section.hbs +++ b/template/partials/section.hbs @@ -1,11 +1,11 @@
{{{description}}}
{{#if example}} -{{{example.description}}} +{{{example.description}}} {{/if}} {{#if code}}
{{code.description}}
-{{/if}} \ No newline at end of file +{{/if}} From a0876929de336af8fb9a85485982f33f7dcd7d58 Mon Sep 17 00:00:00 2001 From: Hamish Coates Date: Fri, 1 Jun 2018 16:58:31 +0800 Subject: [PATCH 4/5] namespace passing test created --- test/data/namespace.css | 3 +++ test/tags.spec.js | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/data/namespace.css diff --git a/test/data/namespace.css b/test/data/namespace.css new file mode 100644 index 0000000..26cf744 --- /dev/null +++ b/test/data/namespace.css @@ -0,0 +1,3 @@ +/** + * @namespace test + */ diff --git a/test/tags.spec.js b/test/tags.spec.js index 815f559..b7c3adb 100644 --- a/test/tags.spec.js +++ b/test/tags.spec.js @@ -677,4 +677,29 @@ describe('tags', function() { }); + // -------------------------------------------------- + // @namespace + // -------------------------------------------------- + describe('@namespace', function () { + + it('should set namespace property', function (done) { + var file = path.join(__dirname, 'data/namespace.css'); + var sections = []; + var pages = []; + + fs.readFile(file, 'utf8', function (err, data) { + if (err) { + throw err; + } + + parseComments(data, file, tags, {sections: sections, pages: pages}, function (block) { + expect(block.namespace).to.equal('test'); + }); + + done(); + }); + }); + + }); + }); From 78186a635e8d228f5a65022dc9cb54d4d8f85e71 Mon Sep 17 00:00:00 2001 From: Hamish Coates Date: Mon, 4 Jun 2018 23:17:48 +0800 Subject: [PATCH 5/5] Namespace tag added to docs --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index fe7cc9c..e32f5c6 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,21 @@ It also generates a JSON object of the parsed comments that can be used to gener * @hideCode */ ``` + +* `@namespace` - Add a namespace class to the example output. + + ```css + /** + * A namespace is a class added to the parent DOM element of the example + * + * @section namespace Example + * @namespace my-magical-namespace + * @example + *
+ *
Example
+ *
+ */ + ``` * `@doc` - A file that defines the section name, description, example, or code. Useful if your section description needs to output HTML. The first heading of the file will be used as the section description if one is not defined.