From 84f09f99531b1697905a8455cbc6afa211dfb771 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 13 Apr 2015 17:25:21 -0700 Subject: [PATCH 1/2] More intense kind inference Can now infer * function * constant * class Remove unused var and inapplicable comment Use strict, use a string to run functions not legal in strict mode Make output fancier and better. Use difflet, channel rage Normalize html / json output Omit json from test output Fixup output --- package.json | 3 +- streams/infer_kind.js | 54 +- streams/output/html.js | 2 +- test/fixture/_multi-file-input.json | 12 +- test/fixture/es6.output.json | 7 +- test/fixture/html/nested.output.files | 1604 +++++++++++++++++++++- test/fixture/simple-hashbang.output.json | 5 + test/fixture/simple-two.output.json | 7 +- test/fixture/simple.output.json | 5 + test/streams/infer_kind.js | 80 +- test/test.js | 9 +- 11 files changed, 1762 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 86c3874..249492e 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "eslint": "^0.17.1", "glob": "^5.0.2", "istanbul": "^0.3.7", - "prova": "^2.1.1" + "prova": "^2.1.1", + "tap-difflet": "^0.3.0" } } diff --git a/streams/infer_kind.js b/streams/infer_kind.js index e3acecf..e286ac6 100644 --- a/streams/infer_kind.js +++ b/streams/infer_kind.js @@ -1,6 +1,10 @@ 'use strict'; -var through = require('through'); +var through = require('through'), + types = require('ast-types'); + +var kindShorthands = ['class', 'constant', 'event', 'external', 'file', + 'function', 'member', 'mixin', 'module', 'namespace', 'typedef']; /** * Create a transform stream that attempts to infer a `kind` tag from other @@ -18,17 +22,45 @@ module.exports = function () { } if (!hasTag('kind')) { - ['class', 'constant', 'event', 'external', 'file', - 'function', 'member', 'mixin', 'module', 'namespace', 'typedef'].forEach(function (kind) { - if (hasTag(kind)) { - comment.tags.push({ - title: 'kind', - kind: kind - }); - } - }); - } + for (var i = 0; i < kindShorthands.length; i++) { + var kind = kindShorthands[i]; + if (hasTag(kind)) { + comment.tags.push({ + title: 'kind', + kind: kind + }); + // only allow a comment to have one kind + this.push(comment); + return; + } + } + types.visit(comment.context.ast, { + setKind: function (kind) { + comment.tags.push({ + title: 'kind', + kind: kind + }); + this.abort(); + }, + + visitFunction: function (path) { + if (path.value && path.value.id && path.value.id.name && !!/^[A-Z]/.exec(path.value.id.name)) { + this.setKind('class'); + } else { + this.setKind('function'); + } + }, + + visitVariableDeclaration: function (path) { + if (path.value.kind === 'const') { + this.setKind('constant'); + } else { + this.traverse(path); + } + } + }); + } this.push(comment); }); }; diff --git a/streams/output/html.js b/streams/output/html.js index d10c7de..4c928a7 100644 --- a/streams/output/html.js +++ b/streams/output/html.js @@ -216,7 +216,7 @@ module.exports = function (opts) { this.push(new File({ path: 'index.json', - contents: new Buffer(JSON.stringify(comments), 'utf8') + contents: new Buffer(JSON.stringify(comments, null, 2), 'utf8') })); this.push(new File({ diff --git a/test/fixture/_multi-file-input.json b/test/fixture/_multi-file-input.json index 613d950..a107bb4 100644 --- a/test/fixture/_multi-file-input.json +++ b/test/fixture/_multi-file-input.json @@ -14,6 +14,10 @@ "title": "name", "name": "exports" }, + { + "title": "kind", + "kind": "function" + }, { "title": "memberof", "description": "module" @@ -47,6 +51,7 @@ } ], "name": "exports", + "kind": "function", "memberof": "module", "scope": "static" }, @@ -77,6 +82,10 @@ { "title": "name", "name": "returnTwo" + }, + { + "title": "kind", + "kind": "function" } ], "context": { @@ -117,6 +126,7 @@ "examples": [ "var result = returnTwo(4);\n// result is 6" ], - "name": "returnTwo" + "name": "returnTwo", + "kind": "function" } ] \ No newline at end of file diff --git a/test/fixture/es6.output.json b/test/fixture/es6.output.json index 9026393..9e61188 100644 --- a/test/fixture/es6.output.json +++ b/test/fixture/es6.output.json @@ -13,6 +13,10 @@ { "title": "name", "name": "multiply" + }, + { + "title": "kind", + "kind": "function" } ], "context": { @@ -39,6 +43,7 @@ } } ], - "name": "multiply" + "name": "multiply", + "kind": "function" } ] \ No newline at end of file diff --git a/test/fixture/html/nested.output.files b/test/fixture/html/nested.output.files index 34bae63..5477f0f 100644 --- a/test/fixture/html/nested.output.files +++ b/test/fixture/html/nested.output.files @@ -1,7 +1,1597 @@ -> -> - - -> -> -> \ No newline at end of file + + +/* + + Basscss v5.2.0 + Low-level CSS toolkit + http://basscss.com + +*/ + + +body, button { margin: 0 } + +button, input, select, textarea { + font-family: inherit; + font-size: 100%; +} + +img { max-width: 100% } +svg { max-height: 100% } +/* Basscss Base Forms */ + +input, +select, +textarea, +fieldset { + font-size: 1rem; + margin-top: 0; + margin-bottom: .5rem; + margin-bottom: .5rem; +} + +input[type=text], +input[type=datetime], +input[type=datetime-local], +input[type=email], +input[type=month], +input[type=number], +input[type=password], +input[type=search], +input[type=tel], +input[type=time], +input[type=url], +input[type=week] { + box-sizing: border-box; + height: 2.25rem; + padding: .5rem .5rem; + vertical-align: middle; + -webkit-appearance: none; +} + +select { + box-sizing: border-box; + line-height: 1.75; + padding: .5rem .5rem; +} + +select:not([multiple]) { + height: 2.25rem; + vertical-align: middle; +} + +textarea { + box-sizing: border-box; + line-height: 1.75; + padding: .5rem .5rem; +} + +.fieldset-reset { + padding: 0; + margin-left: 0; + margin-right: 0; + border: 0; +} +.fieldset-reset legend { + padding: 0; +} +/* Basscss Base Buttons */ + +button, +.button { + font-size: inherit; + font-weight: bold; + text-decoration: none; + cursor: pointer; + display: inline-block; + box-sizing: border-box; + line-height: 1.125rem; + padding: .4rem 0.6rem; + margin: 0; + height: auto; + border: 1px solid transparent; + vertical-align: middle; + -webkit-appearance: none; +} + +::-moz-focus-inner { + border: 0; + padding: 0; +} + +.button:hover { text-decoration: none } +/* Basscss Base Tables */ + +table { + border-collapse: separate; + border-spacing: 0; + max-width: 100%; + width: 100%; +} + +th { + text-align: left; + font-weight: bold; +} + +th, +td { + padding: .25rem 1rem; + line-height: inherit; +} + +th { vertical-align: bottom } +td { vertical-align: top } +/* Basscss Base Typography */ + +body { + font-family: 'Helvetica Neue', Helvetica, sans-serif; + line-height: 1.5; + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Helvetica Neue', Helvetica, sans-serif; + font-weight: bold; + line-height: 1.25; + margin-top: 1em; + margin-bottom: .5em; +} + +p, dl, ol, ul { + font-size: 1rem; + margin-top: 0; + margin-bottom: 1rem; +} + +ol, ul { + padding-left: 2rem; +} + +pre, code, samp { + font-family: Consolas, 'Source Code Pro', monospace; + font-size: inherit; +} + +pre { + margin-top: 0; + margin-bottom: 1rem; + overflow-x: scroll; + padding: 1rem; + background-color: rgba(0,0,0,.03125); +} + +hr { + margin-top: 2rem; + margin-bottom: 2rem; +} + +blockquote { + margin-top: 2rem; + margin-bottom: 2rem; + margin-left: 0; + padding-left: 1rem; + padding-right: 1rem; +} + blockquote, + blockquote p { + font-size: 1.25rem; + font-style: italic; + } + +h1, .h1 { font-size: 2rem } +h2, .h2 { font-size: 1.5rem } +h3, .h3 { font-size: 1.25rem } +h4, .h4 { font-size: 1rem } +h5, .h5 { font-size: .875rem } +h6, .h6 { font-size: .75rem } + +.list-reset { + list-style: none; + padding-left: 0; +} + +/* Basscss Utility Layout */ + +.inline { display: inline } +.block { display: block } +.inline-block { display: inline-block } + +.overflow-hidden { overflow: hidden } +.overflow-scroll { overflow: scroll } +.overflow-auto { overflow: auto } + +.clearfix:before, +.clearfix:after { + content: " "; + display: table +} +.clearfix:after { clear: both } + +.left { float: left } +.right { float: right } + +.fit { max-width: 100% } + +.half-width { width: 50% } +.full-width { width: 100% } +/* Basscss Utility Typography */ + +.bold { font-weight: bold } +.regular { font-weight: normal } +.italic { font-style: italic } +.caps { text-transform: uppercase; letter-spacing: .2em; } + +.left-align { text-align: left } +.center { text-align: center } +.right-align { text-align: right } +.justify { text-align: justify } + +.nowrap { white-space: nowrap } +/* Basscss Utility White Space */ + +.m0 { margin: 0 } +.mt0 { margin-top: 0 } +.mr0 { margin-right: 0 } +.mb0 { margin-bottom: 0 } +.ml0 { margin-left: 0 } + +.m1 { margin: .5rem } +.mt1 { margin-top: .5rem } +.mr1 { margin-right: .5rem } +.mb1 { margin-bottom: .5rem } +.ml1 { margin-left: .5rem } + +.m2 { margin: 1rem } +.mt2 { margin-top: 1rem } +.mr2 { margin-right: 1rem } +.mb2 { margin-bottom: 1rem } +.ml2 { margin-left: 1rem } + +.m3 { margin: 2rem } +.mt3 { margin-top: 2rem } +.mr3 { margin-right: 2rem } +.mb3 { margin-bottom: 2rem } +.ml3 { margin-left: 2rem } + +.m4 { margin: 4rem } +.mt4 { margin-top: 4rem } +.mr4 { margin-right: 4rem } +.mb4 { margin-bottom: 4rem } +.ml4 { margin-left: 4rem } + +.mxn1 { margin-left: -.5rem; margin-right: -.5rem; } +.mxn2 { margin-left: -1rem; margin-right: -1rem; } +.mxn3 { margin-left: -2rem; margin-right: -2rem; } +.mxn4 { margin-left: -4rem; margin-right: -4rem; } + +.mx-auto { margin-left: auto; margin-right: auto; } +.p1 { padding: .5rem } +.py1 { padding-top: .5rem; padding-bottom: .5rem } +.px1 { padding-left: .5rem; padding-right: .5rem } + +.p2 { padding: 1rem } +.py2 { padding-top: 1rem; padding-bottom: 1rem } +.px2 { padding-left: 1rem; padding-right: 1rem } + +.p3 { padding: 2rem } +.py3 { padding-top: 2rem; padding-bottom: 2rem } +.px3 { padding-left: 2rem; padding-right: 2rem } + +.p4 { padding: 4rem } +.py4 { padding-top: 4rem; padding-bottom: 4rem } +.px4 { padding-left: 4rem; padding-right: 4rem } +/* Basscss Utility Responsive States */ + +.sm-show, .md-show, .lg-show { + display: none !important +} + +@media (min-width: 40em) { + .sm-show { display: block !important } +} + +@media (min-width: 52em) { + .md-show { display: block !important } +} + +@media (min-width: 64em) { + .lg-show { display: block !important } +} + + +@media (min-width: 40em) { + .sm-hide { display: none !important } +} + +@media (min-width: 52em) { + .md-hide { display: none !important } +} + +@media (min-width: 64em) { + .lg-hide { display: none !important } +} + +.display-none { display: none !important } + +.hide { + position: absolute !important; + height: 1px; + width: 1px; + overflow: hidden; + clip: rect(1px, 1px, 1px, 1px); +} +/* Basscss Positions */ + +.relative { position: relative } +.absolute { position: absolute } +.fixed { position: fixed } + +.top-0 { top: 0 } +.right-0 { right: 0 } +.bottom-0 { bottom: 0 } +.left-0 { left: 0 } + +.z1 { z-index: 1 } +.z2 { z-index: 2 } +.z3 { z-index: 3 } +.z4 { z-index: 4 } + +.absolute-center { + top: 0; + right: 0; + bottom: 0; + left: 0; + margin: auto; + display: table; +} +/* Basscss UI Utility Button Sizes */ + +.button-small { + padding: .25rem .5rem; +} + +.button-big { + padding: 1rem 1.25rem; +} + +.button-narrow { + padding-left: .5rem; + padding-right: .5rem; +} + +/* Basscss Grid */ + +.container { + max-width: 64em; + margin-left: auto; + margin-right: auto; +} +.col { + float: left; + box-sizing: border-box; +} + +.col-right { + float: right; + box-sizing: border-box; +} + +.col-1 { + width: 8.33333%; +} + +.col-2 { + width: 16.66667%; +} + +.col-3 { + width: 25%; +} + +.col-4 { + width: 33.33333%; +} + +.col-5 { + width: 41.66667%; +} + +.col-6 { + width: 50%; +} + +.col-7 { + width: 58.33333%; +} + +.col-8 { + width: 66.66667%; +} + +.col-9 { + width: 75%; +} + +.col-10 { + width: 83.33333%; +} + +.col-11 { + width: 91.66667%; +} + +.col-12 { + width: 100%; +} +@media (min-width: 40em) { + + .sm-col { + float: left; + box-sizing: border-box; + } + + .sm-col-right { + float: right; + box-sizing: border-box; + } + + .sm-col-1 { + width: 8.33333%; + } + + .sm-col-2 { + width: 16.66667%; + } + + .sm-col-3 { + width: 25%; + } + + .sm-col-4 { + width: 33.33333%; + } + + .sm-col-5 { + width: 41.66667%; + } + + .sm-col-6 { + width: 50%; + } + + .sm-col-7 { + width: 58.33333%; + } + + .sm-col-8 { + width: 66.66667%; + } + + .sm-col-9 { + width: 75%; + } + + .sm-col-10 { + width: 83.33333%; + } + + .sm-col-11 { + width: 91.66667%; + } + + .sm-col-12 { + width: 100%; + } + +} +@media (min-width: 52em) { + + .md-col { + float: left; + box-sizing: border-box; + } + + .md-col-right { + float: right; + box-sizing: border-box; + } + + .md-col-1 { + width: 8.33333%; + } + + .md-col-2 { + width: 16.66667%; + } + + .md-col-3 { + width: 25%; + } + + .md-col-4 { + width: 33.33333%; + } + + .md-col-5 { + width: 41.66667%; + } + + .md-col-6 { + width: 50%; + } + + .md-col-7 { + width: 58.33333%; + } + + .md-col-8 { + width: 66.66667%; + } + + .md-col-9 { + width: 75%; + } + + .md-col-10 { + width: 83.33333%; + } + + .md-col-11 { + width: 91.66667%; + } + + .md-col-12 { + width: 100%; + } + +} +@media (min-width: 64em) { + + .lg-col { + float: left; + box-sizing: border-box; + } + + .lg-col-right { + float: right; + box-sizing: border-box; + } + + .lg-col-1 { + width: 8.33333%; + } + + .lg-col-2 { + width: 16.66667%; + } + + .lg-col-3 { + width: 25%; + } + + .lg-col-4 { + width: 33.33333%; + } + + .lg-col-5 { + width: 41.66667%; + } + + .lg-col-6 { + width: 50%; + } + + .lg-col-7 { + width: 58.33333%; + } + + .lg-col-8 { + width: 66.66667%; + } + + .lg-col-9 { + width: 75%; + } + + .lg-col-10 { + width: 83.33333%; + } + + .lg-col-11 { + width: 91.66667%; + } + + .lg-col-12 { + width: 100%; + } + +} +/* + * Basscss Flex Object + */ + +.flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex } + +.flex-column { -webkit-box-orient: vertical; -webkit-box-direction: normal; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column } +.flex-wrap { -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap } + +.flex-center { -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center } +.flex-baseline { -webkit-box-align: baseline; -webkit-align-items: baseline; -ms-flex-align: baseline; align-items: baseline } +.flex-stretch { -webkit-box-align: stretch; -webkit-align-items: stretch; -ms-flex-align: stretch; align-items: stretch } +.flex-start { -webkit-box-align: start; -webkit-align-items: flex-start; -ms-flex-align: start; align-items: flex-start } +.flex-end { -webkit-box-align: end; -webkit-align-items: flex-end; -ms-flex-align: end; align-items: flex-end } + +.flex-first { -webkit-box-ordinal-group: 0; -webkit-order: -1; -ms-flex-order: -1; order: -1 } +.flex-last { -webkit-box-ordinal-group: 1025; -webkit-order: 1024; -ms-flex-order: 1024; order: 1024 } + +.flex-auto { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; -ms-flex: 1 1 auto; flex: 1 1 auto } +.flex-grow { -webkit-box-flex: 1; -webkit-flex: 1 0 auto; -ms-flex: 1 0 auto; flex: 1 0 auto } +.flex-none { -webkit-box-flex: 0; -webkit-flex: none; -ms-flex: none; flex: none } + +.flex > div { box-sizing: border-box } +@media (min-width: 40em) { + .sm-flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex } + .sm-flex > div { box-sizing: border-box } +} +@media (min-width: 52em) { + .md-flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex } + .md-flex > div { box-sizing: border-box } +} +@media (min-width: 64em) { + .lg-flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex } + .lg-flex > div { box-sizing: border-box } +} /* New */ + +/* Basscss Color Base */ + +/* + + COLOR VARIABLES + + - Cool + - Warm + - Gray Scale + +*/ + +:root { + + /* Cool */ + + + /* Warm */ + + + /* Gray scale */ + +} + +body { + color: #222; + background-color: white; +} + +a { + color: #0074d9 ; + color: #0074d9; + text-decoration: none; +} + + a:hover { + text-decoration: underline; + } + +hr { + border: 0; + border-bottom-style: solid; + border-bottom-width: 1px; + border-bottom-color: rgba(0,0,0,.125); +} + +.button { + color: white; + background-color: #0074d9 ; + background-color: #0074d9; + border-radius: 3px; + /* + -webkit-transition-duration: .05s; + transition-duration: .05s; + -webkit-transition-timing-function: ease-out; + transition-timing-function: ease-out; + -webkit-transition-property: box-shadow, background-color; + transition-property: box-shadow, background-color; + */ +} + +.button:hover { + box-shadow: inset 0 0 0 20rem rgba(0,0,0,.0625); +} + +.button:focus { + outline: none; + border-color: rgba(0,0,0,.125); + box-shadow: 0 0 2px 1px rgba(0,0,0,.25); +} + +.button:active, +.button.is-active { + box-shadow: inset 0 0 0 20rem rgba(0,0,0,.125), + inset 0 3px 4px 0 rgba(0,0,0,.25), + 0 0 1px rgba(0,0,0,.125); +} + +.button:disabled, +.button.is-disabled { + opacity: .5; +} +/* Basscss Color Forms */ + +/* + + COLOR VARIABLES + + - Cool + - Warm + - Gray Scale + +*/ + +:root { + + /* Cool */ + + + /* Warm */ + + + /* Gray scale */ + +} + +.field-light { + background-color: white; + -webkit-transition: box-shadow .2s ease; + transition: box-shadow .2s ease; + border-style: solid; + border-width: 1px; + border-color: rgba(0,0,0,.125); + border-radius: 3px; +} + +.field-light:focus { + outline: none; + border-color: #0074d9; + box-shadow: 0 0 2px rgba(0, 116, 217, 0.5); +} + +.field-light:disabled { + color: #aaa; + background-color: rgba(0,0,0,.125); +} + +.field-light:read-only:not(select) { + background-color: rgba(0,0,0,.125); +} + +.field-light:invalid { + border-color: #ff4136; +} + +.field-light.is-success { + border-color: #2ecc40; +} + +.field-light.is-warning { + border-color: #ffdc00; +} + +.field-light.is-error { + border-color: #ff4136; +} + + +.radio-light, +.checkbox-light { + -webkit-transition: box-shadow .2s ease; + transition: box-shadow .2s ease; +} + +.radio-light { + border-radius: 50%; +} + +.radio-light:focus, +.checkbox-light:focus { + outline: none; + box-shadow: 0 0 2px rgba(0, 116, 217, 0.5); +} +/* Basscss Color Forms Dark */ + +/* + + COLOR VARIABLES + + - Cool + - Warm + - Gray Scale + +*/ + +:root { + + /* Cool */ + + + /* Warm */ + + + /* Gray scale */ + +} + +.field-dark { + color: white; + background-color: rgba(0,0,0,.25); + border: 1px solid rgba(0,0,0,.0625); + border-radius: 3px; + border-radius: 3px; +} + +.field-dark::-webkit-input-placeholder { + color: rgba(255,255,255,.75); +} + +.field-dark::-moz-placeholder { + color: rgba(255,255,255,.75); +} + +.field-dark:-ms-input-placeholder { + color: rgba(255,255,255,.75); +} + +.field-dark::placeholder { + color: rgba(255,255,255,.75); +} + +.field-dark:focus { + outline: 0; + border: 1px solid rgba(255,255,255,.5); +} + +.field-dark:read-only:not(select) { + background-color: rgba(255,255,255,.25); +} + +.field-dark:invalid { + border-color: #ff4136; +} + +.field-dark.is-success { + border-color: #2ecc40; +} + +.field-dark.is-warning { + border-color: #ffdc00; +} + +.field-dark.is-error { + border-color: #ff4136; +} +/* Basscss Input Range */ + +input[type=range] { + vertical-align: middle; + background-color: transparent; +} + +.range-light { + color: inherit; + -webkit-appearance: none; + padding-top: .5rem; + padding-bottom: .5rem; +} + +.range-light::-webkit-slider-thumb { + -webkit-appearance: none; + position: relative; + width: .5rem; + height: 1.25rem; + border-radius: 3px; + background-color: currentcolor; + cursor: pointer; + margin-top: -0.5rem; +} + +/* Touch screen friendly pseudo element */ +.range-light::-webkit-slider-thumb:before { + content: ''; + display: block; + position: absolute; + top: -0.5rem; + left: -0.875rem; + width: 2.25rem; + height: 2.25rem; + opacity: 0; +} + +.range-light::-moz-range-thumb { + width: .5rem; + height: 1.25rem; + border-radius: 3px; + border-color: transparent; + border-width: 0; + background-color: currentcolor; + cursor: pointer; +} + +.range-light::-webkit-slider-runnable-track { + height: 0.25rem; + cursor: pointer; + border-radius: 3px; + background-color: rgba(0,0,0,.25); +} + +.range-light::-moz-range-track { + height: 0.25rem; + cursor: pointer; + border-radius: 3px; + background-color: rgba(0,0,0,.25); +} + +.range-light:focus { + outline: none; +} + +.range-light:focus::-webkit-slider-thumb { + outline: none; + border: 0; + box-shadow: 0 0 1px 2px currentcolor; +} + +.range-light:focus::-moz-range-thumb { + outline: none; + border: 0; + box-shadow: 0 0 1px 2px currentcolor; +} +/* Basscss Progress */ + +.progress { + display: block; + width: 100%; + height: 0.5625rem; + margin: .5rem 0; + background-color: rgba(0,0,0,.125); + border: 0; + border-radius: 10000px; + overflow: hidden; + -webkit-appearance: none; + cursor: pointer; +} + +.progress::-webkit-progress-bar { + -webkit-appearance: none; + background-color: rgba(0,0,0,.125) +} + +.progress::-webkit-progress-value { + -webkit-appearance: none; + background-color: currentColor; +} + +.progress::-moz-progress-bar { + background-color: currentColor; +} +/* Basscss Color Tables */ + +.table-light th, +.table-light td { + border-bottom-style: solid; + border-bottom-width: 1px; + border-bottom-color: rgba(0,0,0,.125); +} + +.table-light tr:last-child td { + border-bottom: 0; +} + +/* Basscss Button Outline */ + +.button-outline { + position: relative; + z-index: 2; + color: inherit; + background-color: transparent; + border-radius: 3px; + border: 1px solid currentcolor; + -webkit-transition-duration: .1s; + transition-duration: .1s; + -webkit-transition-timing-function: ease-out; + transition-timing-function: ease-out; + -webkit-transition-property: box-shadow, background-color; + transition-property: box-shadow, background-color; +} + +.button-outline:before { + content: ''; + width: 100%; + height: 100%; + display: block; + position: absolute; + z-index: -1; + top: -1px; + left: -1px; + border: 1px solid transparent; + background-color: currentcolor; + border-radius: 3px; + -webkit-transition-duration: .1s; + transition-duration: .1s; + -webkit-transition-timing-function: ease-out; + transition-timing-function: ease-out; + -webkit-transition-property: opacity; + transition-property: opacity; + opacity: 0; +} + +.button-outline:hover { + box-shadow: none; +} + +.button-outline:hover:before { + opacity: .125; +} + +.button-outline:focus { + outline: none; + border: 1px solid currentcolor; + box-shadow: 0 0 3px 1px; +} + +.button-outline:active, +.button-outline.is-active { + box-shadow: inset 0 1px 5px 0, 0 0 1px; +} + +.button-outline:disabled, +.button-outline.is-disabled { + opacity: .5; +} /* New */ +/* Basscss Button Transparent */ + +.button-transparent { + position: relative; + z-index: 2; + color: inherit; + background-color: transparent; + border-radius: 0; + border: 1px solid transparent; + /* + -webkit-transition-duration: .1s; + transition-duration: .1s; + -webkit-transition-timing-function: ease-out; + transition-timing-function: ease-out; + -webkit-transition-property: box-shadow; + transition-property: box-shadow; + */ +} + +.button-transparent:before { + content: ''; + width: 100%; + height: 100%; + display: block; + position: absolute; + z-index: -1; + top: -1px; + left: -1px; + border: 1px solid transparent; + background-color: currentcolor; + -webkit-transition-duration: .1s; + transition-duration: .1s; + -webkit-transition-timing-function: ease-out; + transition-timing-function: ease-out; + -webkit-transition-property: opacity; + transition-property: opacity; + opacity: 0; +} + +.button-transparent:hover { + box-shadow: none; +} + +.button-transparent:hover:before { + opacity: .0625; + opacity: .09375; +} + +.button-transparent:focus { + outline: none; + border-color: transparent; + box-shadow: 0 0 3px; +} + +.button-transparent:active:before, +.button-transparent.is-active:before { + opacity: .0625; +} + +.button-transparent:disabled, +.button-transparent.is-disabled { + opacity: .5; +} /* New */ +/* Basscss Background Images */ + +.bg-cover { background-size: cover } +.bg-contain { background-size: contain } + +.bg-center { background-position: center } +.bg-top { background-position: top } +.bg-right { background-position: right } +.bg-bottom { background-position: bottom } +.bg-left { background-position: left } /* New */ +/* Basscss Color Borders */ + +.border { + border-style: solid; + border-width: 1px; + border-color: rgba(0,0,0,.125); +} + +.border-top { + border-top-style: solid; + border-top-width: 1px; + border-top-color: rgba(0,0,0,.125); +} + +.border-right { + border-right-style: solid; + border-right-width: 1px; + border-right-color: rgba(0,0,0,.125); +} + +.border-bottom { + border-bottom-style: solid; + border-bottom-width: 1px; + border-bottom-color: rgba(0,0,0,.125); +} + +.border-left { + border-left-style: solid; + border-left-width: 1px; + border-left-color: rgba(0,0,0,.125); +} + +.rounded { border-radius: 3px } +.circle { border-radius: 50% } + +.rounded-top { border-radius: 3px 3px 0 0 } +.rounded-right { border-radius: 0 3px 3px 0 } +.rounded-bottom { border-radius: 0 0 3px 3px } +.rounded-left { border-radius: 3px 0 0 3px } + +.not-rounded { border-radius: 0 } + +/* Basscss Colors */ + + +/* Color */ + +.black, .dark-gray { color: #222 } +.gray, .mid-gray { color: #aaa } +.silver, .light-gray { color: #ddd } +.white { color: #fff } + +.aqua { color: #7fdbff } +.blue { color: #0074d9 } +.navy { color: #001f3f } +.teal { color: #39cccc } +.green { color: #2ecc40 } +.olive { color: #3d9970 } +.lime { color: #01ff70 } + +.yellow { color: #ffdc00 } +.orange { color: #ff851b } +.red { color: #ff4136 } +.fuchsia { color: #f012be } +.purple { color: #b10dc9 } +.maroon { color: #85144b } + + +/* Background Color */ + +.bg-black, .bg-dark-gray { background-color: #222 } +.bg-gray, .bg-mid-gray { background-color: #aaa } +.bg-silver, .bg-light-gray { background-color: #ddd } +.bg-white { background-color: #fff } + +.bg-aqua { background-color: #7fdbff } +.bg-blue { background-color: #0074d9 } +.bg-navy { background-color: #001f3f } +.bg-teal { background-color: #39cccc } +.bg-green { background-color: #2ecc40 } +.bg-olive { background-color: #3d9970 } +.bg-lime { background-color: #01ff70 } + +.bg-yellow { background-color: #ffdc00 } +.bg-orange { background-color: #ff851b } +.bg-red { background-color: #ff4136 } +.bg-fuchsia { background-color: #f012be } +.bg-purple { background-color: #b10dc9 } +.bg-maroon { background-color: #85144b } + +.bg-darken-0 { background-color: rgba(0,0,0,.03125) } +.bg-darken-1 { background-color: rgba(0,0,0,.0625) } +.bg-darken-2 { background-color: rgba(0,0,0,.125) } +.bg-darken-3 { background-color: rgba(0,0,0,.25) } +.bg-darken-4 { background-color: rgba(0,0,0,.5) } + + +/* Border Color */ + +.border-aqua { border-color: #7fdbff } +.border-blue { border-color: #0074d9 } +.border-navy { border-color: #001f3f } +.border-teal { border-color: #39cccc } +.border-green { border-color: #2ecc40 } +.border-olive { border-color: #3d9970 } +.border-lime { border-color: #01ff70 } + +.border-yellow { border-color: #ffdc00 } +.border-orange { border-color: #ff851b } +.border-red { border-color: #ff4136 } +.border-fuchsia { border-color: #f012be } +.border-purple { border-color: #b10dc9 } +.border-maroon { border-color: #85144b } + +.border-black { border-color: #222 } +.border-gray { border-color: #aaa } +.border-silver { border-color: #ddd } +.border-white { border-color: #fff } + +.border-darken-1 { border-color: rgba(0,0,0,.0625) } +.border-darken-2 { border-color: rgba(0,0,0,.125) } +.border-darken-3 { border-color: rgba(0,0,0,.25) } +.border-darken-4 { border-color: rgba(0,0,0,.5) } + +/* Opacity */ +.muted { opacity: .5 } + + +/* Variables */ +/* Basscss Defaults */ + +:root { + + /* Legacy support */ + +} + + +/* + +github.com style (c) Vasily Polovnyov + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; + -webkit-text-size-adjust: none; +} + +.hljs-comment, +.diff .hljs-header, +.hljs-javadoc { + color: #998; + font-style: italic; +} + +.hljs-keyword, +.css .rule .hljs-keyword, +.hljs-winutils, +.nginx .hljs-title, +.hljs-subst, +.hljs-request, +.hljs-status { + color: #333; + font-weight: bold; +} + +.hljs-number, +.hljs-hexcolor, +.ruby .hljs-constant { + color: #008080; +} + +.hljs-string, +.hljs-tag .hljs-value, +.hljs-phpdoc, +.hljs-dartdoc, +.tex .hljs-formula { + color: #d14; +} + +.hljs-title, +.hljs-id, +.scss .hljs-preprocessor { + color: #900; + font-weight: bold; +} + +.hljs-list .hljs-keyword, +.hljs-subst { + font-weight: normal; +} + +.hljs-class .hljs-title, +.hljs-type, +.vhdl .hljs-literal, +.tex .hljs-command { + color: #458; + font-weight: bold; +} + +.hljs-tag, +.hljs-tag .hljs-title, +.hljs-rules .hljs-property, +.django .hljs-tag .hljs-keyword { + color: #000080; + font-weight: normal; +} + +.hljs-attribute, +.hljs-variable, +.lisp .hljs-body { + color: #008080; +} + +.hljs-regexp { + color: #009926; +} + +.hljs-symbol, +.ruby .hljs-symbol .hljs-string, +.lisp .hljs-keyword, +.clojure .hljs-keyword, +.scheme .hljs-keyword, +.tex .hljs-special, +.hljs-prompt { + color: #990073; +} + +.hljs-built_in { + color: #0086b3; +} + +.hljs-preprocessor, +.hljs-pragma, +.hljs-pi, +.hljs-doctype, +.hljs-shebang, +.hljs-cdata { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + background: #fdd; +} + +.hljs-addition { + background: #dfd; +} + +.diff .hljs-change { + background: #0086b3; +} + +.hljs-chunk { + color: #aaa; +} + +.documentation a { + color: #416381; +} + +.container-small { + max-width: 58rem; + margin-left: auto; + margin-right: auto; +} + +.font-smaller { + font-size:80%; +} + +.fade { + opacity:0.50; +} + +.button-indent { + padding: .25rem 1.5rem; + font-size: 90%; +} + +.section-indent { + border-left: 2px solid #eee; +} + +.bg-cloudy { + background: rgba(230, 235, 237, 1); +} + +.bg-cloudy-light { + background: rgba(230, 235, 237, 0.5); +} + +.keyline-top { + border-top:5px solid #eee; +} + +.keyline-top:first-child { + border-top:0; +} + +.force-inline * { + display:inline; +} + +section:target { + background: #fcfbf2; +} + +.documentation-sidebar a:active { + background: #fcfbf2; +} + + + + + + + + + +
+
+ +
+
+
+

+ + + Klass + + +

+

Creates a new Klass

+ + + + + +
+
+

+ + + getFoo + + +

+

Get this Klass's foo

+ + + +

Returns

+ Number + : + +

foo

+ +
+ + + + +
+
+ +
+
+

+ + + isClass(other) + + +

+

Decide whether an object is a Klass instance

+ + +

+ + + + + + + + + + + +
parametertypedescription
otherObject
+

+ +

Returns

+ boolean + : + +

whether the other thing is a Klass

+ +
+ + + + +
+
+
+
+

+ + + MAGIC_NUMBER + + +

+

A magic number that identifies this Klass.

+ + + + + + + +
+
+ +
+ +
+
+
+
+ + diff --git a/test/fixture/simple-hashbang.output.json b/test/fixture/simple-hashbang.output.json index 5736b2f..35c7ae8 100644 --- a/test/fixture/simple-hashbang.output.json +++ b/test/fixture/simple-hashbang.output.json @@ -14,6 +14,10 @@ "title": "name", "name": "exports" }, + { + "title": "kind", + "kind": "function" + }, { "title": "memberof", "description": "module" @@ -47,6 +51,7 @@ } ], "name": "exports", + "kind": "function", "memberof": "module", "scope": "static" } diff --git a/test/fixture/simple-two.output.json b/test/fixture/simple-two.output.json index 274449c..ba9f0e4 100644 --- a/test/fixture/simple-two.output.json +++ b/test/fixture/simple-two.output.json @@ -26,6 +26,10 @@ { "title": "name", "name": "returnTwo" + }, + { + "title": "kind", + "kind": "function" } ], "context": { @@ -66,6 +70,7 @@ "examples": [ "var result = returnTwo(4);\n// result is 6" ], - "name": "returnTwo" + "name": "returnTwo", + "kind": "function" } ] \ No newline at end of file diff --git a/test/fixture/simple.output.json b/test/fixture/simple.output.json index 7a8e02a..d3384ba 100644 --- a/test/fixture/simple.output.json +++ b/test/fixture/simple.output.json @@ -14,6 +14,10 @@ "title": "name", "name": "exports" }, + { + "title": "kind", + "kind": "function" + }, { "title": "memberof", "description": "module" @@ -47,6 +51,7 @@ } ], "name": "exports", + "kind": "function", "memberof": "module", "scope": "static" } diff --git a/test/streams/infer_kind.js b/test/streams/infer_kind.js index 343a968..b9fb028 100644 --- a/test/streams/infer_kind.js +++ b/test/streams/infer_kind.js @@ -1,5 +1,5 @@ 'use strict'; - +/*eslint-disable no-unused-vars*/ var test = require('prova'), concat = require('concat-stream'), parse = require('../../streams/parse'), @@ -20,6 +20,20 @@ function evaluate(fn, callback) { }); } +function evaluateString(string, callback) { + var stream = parse(); + + stream + .pipe(inferKind()) + .pipe(flatten()) + .pipe(concat(callback)); + + stream.end({ + file: __filename, + source: string + }); +} + test('inferKind - explicit', function (t) { evaluate(function () { /** @kind class */ @@ -149,3 +163,67 @@ test('inferKind - typedef', function (t) { t.end(); }); }); + +test('inferKind - context: function', function (t) { + evaluate(function () { + /** + * @returns {number} two + */ + function foo() { + } + + foo(); + }, function (result) { + t.equal(result[0].kind, 'function'); + t.end(); + }); +}); + +test('inferKind - context: var function', function (t) { + evaluate(function () { + /** + * @returns {number} two + */ + var foo = function () { + }; + }, function (result) { + t.equal(result[0].kind, 'function'); + t.end(); + }); +}); + +test('inferKind - context: class (uppercase function)', function (t) { + evaluate(function () { + /** + * @returns {number} two + */ + function Foo() { + } + }, function (result) { + t.equal(result[0].kind, 'class'); + t.end(); + }); +}); + +test('inferKind - context: const', function (t) { + evaluateString( + '/**' + + ' * This is a constant called foo' + + ' */' + + 'const foo = "bar";', function (result) { + t.equal(result[0].kind, 'constant'); + t.end(); + }); +}); + +test('inferKind - no hint or ast', function (t) { + evaluate(function () { + /** + * @returns {number two + */ + return 0; + }, function (result) { + t.equal(result[0].kind, undefined); + t.end(); + }); +}); diff --git a/test/test.js b/test/test.js index 03bf858..d06ca37 100644 --- a/test/test.js +++ b/test/test.js @@ -16,6 +16,7 @@ function normalize(result) { result.forEach(function (item) { item.context.file = path.relative(__dirname, item.context.file); }); + return result; } test('parse', function (tt) { @@ -59,8 +60,12 @@ test('html', function (tt) { documentation([file]) .pipe(outputHtml()) .pipe(concat(function (result) { - var clean = result.map(function (r) { - return r.inspect(); + var clean = result.sort(function (a, b) { + return a.path > b.path; + }).filter(function (r) { + return (!r.path.match(/json$/)); + }).map(function (r) { + return r.contents; }).join('\n'); var outputfile = file.replace('.input.js', '.output.files'); if (UPDATE) fs.writeFileSync(outputfile, clean, 'utf8'); From 0167d8e827b44397c1c9d135e7acacc3281523f7 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 13 Apr 2015 17:58:34 -0700 Subject: [PATCH 2/2] Remove difflet dep --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 249492e..86c3874 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "eslint": "^0.17.1", "glob": "^5.0.2", "istanbul": "^0.3.7", - "prova": "^2.1.1", - "tap-difflet": "^0.3.0" + "prova": "^2.1.1" } }