Fix for styling bug + additional styleguide examples

This commit is contained in:
Jay Traband 2015-09-15 12:26:37 -07:00
parent a9e96389c0
commit 11ab09c30b
2 changed files with 31 additions and 5 deletions

View File

@ -98,7 +98,9 @@ mixin makeJson(path, fileName, title, jsonConfig, stylePatterns)
- } while (matches != null && rx.global ); - } while (matches != null && rx.global );
- for (var match in repls) { - for (var match in repls) {
- var repl = repls[match]; - var repl = repls[match];
- var rx2 = new RegExp(match, repl.isGlobal ? "g" : ""); - // var escapedMatch = match.replace(/\\/g,'\\').replace(/\(/g,'\(').replace(/\)/g, '\)').replace(/\./,'\.');
- // var rx2 = new RegExp(escapedMatch, repl.isGlobal ? "g" : "");
- var rx2 = match;
- str = str.replace(rx2, repl.repl); - str = str.replace(rx2, repl.repl);
- }; - };
- return str; - return str;

View File

@ -199,13 +199,13 @@ include ../../../_includes/_util-fns
A more complicated example might be: A more complicated example might be:
code-example(format="linenums" language="js"). code-example(format="linenums" language="js").
- var stylePattern = { pnk: /script (src=.*&ampquot)/g, otl: /(my-app)/ }; - var stylePattern = { pnk: /script (src=.*&ampquot;)/g, otl: /(\S*my-app.*$)/m };
+makeExample('styleguide', 'js/index.html', 'index.html', stylePattern ) +makeExample('styleguide', 'js/index.html', 'index.html', stylePattern )
:markdown :markdown
Which applies multiple styles and uses an intermediate javascript object as opposed to a literal. Which applies multiple styles and uses an intermediate javascript object as opposed to a literal.
- var stylePattern = { pnk: /script (src=.*&quot)/g, otl: /(my-app)/ }; - var stylePattern = { pnk: /script (src=.*")/g, otl: /(\S*my-app.*$)/m };
+makeExample('styleguide', 'js/index.html', 'index.html', stylePattern ) +makeExample('styleguide', 'js/index.html', 'index.html', stylePattern )
:markdown :markdown
@ -214,10 +214,10 @@ include ../../../_includes/_util-fns
object is passed in then it is assumed to apply to all of the tabs. object is passed in then it is assumed to apply to all of the tabs.
code-example(format="linenums" language="js"). code-example(format="linenums" language="js").
-var stylePatterns = [{ pnk: /script (src=.*&quot)/g }, {pnk: /(result)/ }]; -var stylePatterns = [{ pnk: /script (src=.*&ampquot;)/g }, {pnk: /(result)/ }];
+makeTabs('styleguide', 'js/index.html, js/spec.js', 'index.html,unit test', stylePatterns) +makeTabs('styleguide', 'js/index.html, js/spec.js', 'index.html,unit test', stylePatterns)
-var stylePatterns = [{ pnk: /script (src=.*&quot)/g }, {pnk: /(result)/ }]; -var stylePatterns = [{ pnk: /script (src=.*")/g }, {pnk: /(result)/ }];
+makeTabs('styleguide', 'js/index.html, js/spec.js', 'index.html,unit test', stylePatterns) +makeTabs('styleguide', 'js/index.html, js/spec.js', 'index.html,unit test', stylePatterns)
.l-sub-section .l-sub-section
@ -257,6 +257,23 @@ include ../../../_includes/_util-fns
+makeJson('styleguide', 'package.json', "Selected parts of the package.json file", {paths: 'version, scripts.tsc, scripts.start '} ) +makeJson('styleguide', 'package.json', "Selected parts of the package.json file", {paths: 'version, scripts.tsc, scripts.start '} )
:markdown
Styling selected portions of the json is also supported.
code-example(format="linenums" language="js").
+makeJson('styleguide', 'package.json', "package.json dependencies", {paths: 'dependencies'}, { pnk: [/(\S*traceur.*)/, /(\Sangular2.*)/, /(\Ssystem.*)/ ]})
+makeJson('styleguide', 'package.json', "package.json dependencies", {paths: 'dependencies'}, { pnk: [/(\S*traceur.*)/, /(\Sangular2.*)/, /(\Ssystem.*)/ ]})
:markdown
As well as styling across multiple lines.
code-example(format="linenums" language="js").
+makeJson('styleguide', 'package.json', "Foo", {paths: 'name, version, dependencies '}, styles )
- var styles = { pnk: /(^.*dependencies[\s\S]* \})/gm };
+makeJson('styleguide', 'package.json', "Foo", {paths: 'name, version, dependencies '}, styles )
.l-sub-section .l-sub-section
:markdown :markdown
### Inline code and code examples provided directly i.e. not from an example file. ### Inline code and code examples provided directly i.e. not from an example file.
@ -362,3 +379,10 @@ include ../../../_includes/_util-fns
+makeExample('styleguide', 'js/app-class-w-annotations.js')(format="linenums:15") +makeExample('styleguide', 'js/app-class-w-annotations.js')(format="linenums:15")
:markdown
Or to supress line numbering completely you can use
code-example().
+makeExample('styleguide', 'js/app-class-w-annotations.js')(format=".")
+makeExample('styleguide', 'js/app-class-w-annotations.js')(format=".")