diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..23a9a65 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,239 @@ +{ + "env": { + "amd": false, + "browser": false, + "es6": true, + "jasmine": false, + "jquery": false, + "meteor": false, + "mocha": false, + "node": true, + "prototypejs": false, + "shelljs": false + }, + + "ecmaFeatures": { + "arrowFunctions": true, + "binaryLiterals": false, + "blockBindings": false, + "classes": true, + "defaultParams": true, + "destructuring": true, + "forOf": true, + "generators": false, + "globalReturn": false, + "jsx": false, + "modules": true, + "objectLiteralComputedProperties": true, + "objectLiteralDuplicateProperties": false, + "objectLiteralShorthandMethods": true, + "objectLiteralShorthandProperties": true, + "octalLiterals": false, + "regexUFlag": false, + "regexYFlag": false, + "spread": true, + "superInFunctions": false, + "templateStrings": true, + "unicodeCodePointEscapes": true + }, + + "rules": { + // Possible Errors + "comma-dangle": [2, "never"], // disallow or enforce trailing commas + "no-cond-assign": "except-parens", // disallow assignment in conditional expressions + "no-console": 0, // disallow use of console (off by default in the node environment) + "no-constant-condition": 2, // disallow use of constant expressions in conditions + "no-control-regex": 2, // disallow control characters in regular expressions + "no-debugger": 2, // disallow use of debugger + "no-dupe-args": 2, // disallow duplicate arguments in functions + "no-dupe-keys": 2, // disallow duplicate keys when creating object literals + "no-duplicate-case": 2, // disallow a duplicate case label. + "no-empty": 2, // disallow empty statements + "no-empty-class": 2, // disallow the use of empty character classes in regular expressions + "no-ex-assign": 2, // disallow assigning to the exception in a catch block + "no-extra-boolean-cast": 2, // disallow double-negation boolean casts in a boolean context + "no-extra-parens": 2, // disallow unnecessary parentheses (off by default) + "no-extra-semi": 2, // disallow unnecessary semicolons + "no-func-assign": 2, // disallow overwriting functions written as function declarations + "no-inner-declarations": [2, "both"], // disallow function or variable declarations in nested blocks + "no-invalid-regexp": 2, // disallow invalid regular expression strings in the RegExp constructor + "no-irregular-whitespace": 2, // disallow irregular whitespace outside of strings and comments + "no-negated-in-lhs": 2, // disallow negation of the left operand of an in expression + "no-obj-calls": 2, // disallow the use of object properties of the global object (Math and JSON) as functions + "no-regex-spaces": 2, // disallow multiple spaces in a regular expression literal + "no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default) + "no-sparse-arrays": 2, // disallow sparse arrays + "no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement + "use-isnan": 2, // disallow comparisons with the value NaN + "value-jsdoc": 0, + // "valid-jsdoc": [2, { // Ensure JSDoc comments are valid (off by default) + // "prefer": { + // "returns": "return" + // }, + // "requireParamDescription": true, + // "requireReturn": false, + // "requireReturnDescription": true + // }], + "valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string + + // Best Practices + "block-scoped-var": 0, // treat var statements as if they were block scoped (off by default) + "complexity": 2, // specify the maximum cyclomatic complexity allowed in a program (off by default) + "consistent-return": 2, // require return statements to either always or never specify values + "curly": [2, "multi-line"], // specify curly brace conventions for all control statements + "default-case": 2, // require default case in switch statements (off by default) + "dot-notation": [2, { // encourages use of dot notation whenever possible + "allowKeywords": true, + "allowPattern": "^[a-z]+([_-][a-z]+)+$" + }], + "eqeqeq": 2, // require the use of === and !== + "guard-for-in": 2, // make sure for-in loops have an if statement (off by default) + "no-alert": 2, // disallow the use of alert, confirm, and prompt + "no-caller": 2, // disallow use of arguments.caller or arguments.callee + "no-div-regex": 2, // disallow division operators explicitly at beginning of regular expression (off by default) + "no-else-return": 2, // disallow else after a return in an if (off by default) + "no-empty-label": 2, // disallow use of labels for anything other then loops and switches + "no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default) + "no-eval": 2, // disallow use of eval() + "no-extend-native": 2, // disallow adding to native types + "no-extra-bind": 2, // disallow unnecessary function binding + "no-fallthrough": 2, // disallow fallthrough of case statements + "no-floating-decimal": 2, // disallow the use of leading or trailing decimal points in numeric literals (off by default) + "no-implied-eval": 2, // disallow use of eval()-like methods + "no-iterator": 2, // disallow usage of __iterator__ property + "no-labels": 0, // disallow use of labeled statements + "no-lone-blocks": 2, // disallow unnecessary nested blocks + "no-loop-func": 2, // disallow creation of functions within loops + "no-multi-spaces": 2, // disallow use of multiple spaces + "no-multi-str": 2, // disallow use of multiline strings + "no-native-reassign": 2, // disallow reassignments of native objects + "no-new": 2, // disallow use of new operator when not part of the assignment or comparison + "no-new-func": 2, // disallow use of new operator for Function object + "no-new-wrappers": 2, // disallows creating new instances of String,Number, and Boolean + "no-octal": 2, // disallow use of octal literals + "no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251"; + "no-param-reassign": 0, // disallow reassignment of function parameters (off by default) + "no-process-env": 2, // disallow use of process.env (off by default) + "no-proto": 2, // disallow usage of __proto__ property + "no-redeclare": 2, // disallow declaring the same variable more then once + "no-return-assign": 0, // disallow use of assignment in return statement + "no-script-url": 0, // disallow use of javascript: urls. + "no-self-compare": 2, // disallow comparisons where both sides are exactly the same (off by default) + "no-sequences": 2, // disallow use of comma operator + "no-throw-literal": 2, // restrict what can be thrown as an exception (off by default) + "no-unused-expressions": 2, // disallow usage of expressions in statement position + "no-void": 2, // disallow use of void operator (off by default) + "no-warning-comments": 1, // disallow usage of configurable warning terms in comments": 0, // e.g. TODO or FIXME (off by default) + "no-with": 2, // disallow use of the with statement + "radix": 0, // require use of the second argument for parseInt() (off by default) + "vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default) + "wrap-iife": [2, "inside"], // require immediate function invocation to be wrapped in parentheses (off by default) + "yoda": 0, // require or disallow Yoda conditions + + // Strict mode + "strict": "global", // controls location of Use Strict Directives + + // Variables + "no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) + "no-delete-var": 2, // disallow deletion of variables + "no-label-var": 2, // disallow labels that share a name with a variable + "no-shadow": 2, // disallow declaration of variables already declared in the outer scope + "no-shadow-restricted-names": 2, // disallow shadowing of names such as arguments + "no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block + "no-undef-init": 2, // disallow use of undefined when initializing variables + "no-undefined": 0, // disallow use of undefined variable (off by default) + "no-unused-vars": [2, { // disallow declaration of variables that are not used in the code + "vars": "all", + "args": "after-used" + }], + "no-use-before-define": 2, // disallow use of variables before they are defined + + // Node.js + "handle-callback-err": 2, // enforces error handling in callbacks (off by default) (on by default in the node environment) + "no-mixed-requires": 0, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment) + "no-new-require": 2, // disallow use of new operator with the require function (off by default) (on by default in the node environment) + "no-path-concat": 2, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment) + "no-process-exit": 2, // disallow process.exit() (on by default in the node environment) + "no-restricted-modules": 0, // restrict usage of specified node modules (off by default) + "no-sync": 0, // disallow use of synchronous methods (off by default) + + // Style + "indent": [2, "tab", { // this option sets a specific tab width for your code (off by default) + "indentSwitchCase": true + }], + "brace-style": [2, "stroustrup"], // enforce one true brace style (off by default) + "camelcase": [2, { // require camel case names + "properties": "always" + }], + "comma-spacing": [2, { // enforce spacing before and after comma + "before": false, + "after": true + }], + "comma-style": [2, "last"], // enforce one true comma style (off by default) + "consistent-this": [0, "self"], // enforces consistent naming when capturing the current execution context (off by default) + "eol-last": 2, // enforce newline at the end of file, with no multiple empty lines + "func-names": 0, // require function expressions to have a name (off by default) + "func-style": [2, "declaration"], // enforces use of function declarations or expressions (off by default) + "key-spacing": [2, { // enforces spacing between keys and values in object literal properties + "beforeColon": false, + "afterColon": true + }], + "max-nested-callbacks": [2, 4], // specify the maximum depth callbacks can be nested (off by default) + "new-cap": 2, // require a capital letter for constructors + "new-parens": 2, // disallow the omission of parentheses when invoking a constructor with no arguments + "newline-after-var": [2, "always"], // allow/disallow an empty newline after var statement (off by default) + "no-array-constructor": 2, // disallow use of the Array constructor + "no-continue": 0, // disallow use of the continue statement (off by default) + "no-inline-comments": 0, // disallow comments inline after code (off by default) + "no-lonely-if": 2, // disallow if as the only statement in an else block (off by default) + "no-mixed-spaces-and-tabs": 2, // disallow mixed spaces and tabs for indentation + "no-multiple-empty-lines": [2, { // disallow multiple empty lines (off by default) + "max": 1 + }], + "no-nested-ternary": 2, // disallow nested ternary expressions (off by default) + "no-new-object": 2, // disallow use of the Object constructor + "no-spaced-func": 2, // disallow space between function identifier and application + "no-ternary": 0, // disallow the use of ternary operators (off by default) + "no-trailing-spaces": 2, // disallow trailing whitespace at the end of lines + "no-underscore-dangle": 0, // disallow dangling underscores in identifiers + "no-wrap-func": 2, // disallow wrapping of non-IIFE statements in parens + "one-var": [2, "always"], // allow or disallow one variable declaration per function (off by default) + "operator-assignment": [2, "always"], // require assignment operator shorthand where possible or prohibit it entirely (off by default) + "operator-linebreak": [2, "before"], // enforce operators to be placed before or after line breaks (off by default) + "padded-blocks": [2, "never"], // enforce padding within blocks (off by default) + "quote-props": [2, "as-needed"], // require quotes around object literal property names (off by default) + "quotes": [2, "single", "avoid-escape"], // specify whether backticks, double or single quotes should be used + "semi": [2, "always"], // require or disallow use of semicolons instead of ASI + "semi-spacing": [2, { // enforce spacing before and after semicolons + "before": false, + "after": true + }], + "sort-vars": 0, // sort variables within the same declaration block (off by default) + "space-after-keywords": [2, "always"], // require a space after certain keywords (off by default) + "space-before-blocks": [2, "always"], // require or disallow space before blocks (off by default) + "space-before-function-paren": [2, { // require or disallow space before function opening parenthesis (off by default) + "anonymous": "always", + "named": "never" + }], + "space-in-brackets": 0, /* need v1.0 */ // require or disallow spaces inside brackets (off by default) + "space-in-parens": [2, "never"], // require or disallow spaces inside parentheses (off by default) + "space-infix-ops": [2, "always"], // require spaces around operators + "space-return-throw-case": 2, // require a space after return, throw, and case + "space-unary-ops": [1, { // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default) + "words": true, + "nonwords": false + }], + "spaced-line-comment": [2, "always"], // require or disallow a space immediately following the // in a line comment (off by default) + "wrap-regex": 2, // require regex literals to be wrapped in parentheses (off by default) + + // ES6 + "no-var": 0, // require let or const instead of var (off by default) + "object-shorthand": [2, "methods"], // require method and property shorthand syntax for object literals (off by default) + + // Complexity + "max-depth": [2, 7], // specify the maximum depth that blocks can be nested (off by default) + "max-len": [2, 120, 4], // specify the maximum length of a line in your program (off by default) + "max-params": [2, 5], // limits the number of parameters that can be used in the function declaration. (off by default) + "max-statements": [2, 50] // specify the maximum number of statement allowed in a function (off by default) + } +} diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index da75400..0000000 --- a/.jscsrc +++ /dev/null @@ -1,85 +0,0 @@ -{ - "excludeFiles": [ - "node_modules/**" - ], - - "disallowEmptyBlocks": true, - "disallowMixedSpacesAndTabs": "smart", - "disallowMultipleLineBreaks": true, - "disallowMultipleLineStrings": true, - "disallowQuotedKeysInObjects": "allButReserved", - "disallowSpaceAfterObjectKeys": true, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideParentheses": true, - "disallowTrailingWhitespace": true, - "disallowYodaConditions": true, - "requireBlocksOnNewline": true, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "requireCapitalizedConstructors": true, - "requireCommaBeforeLineBreak": true, - "requireDotNotation": true, - "requireMultipleVarDecl": true, - "requireParenthesesAroundIIFE": true, - "requireSpaceAfterLineComment": true, - "requireSpacesInConditionalExpression": true, - "requireSpacesInsideObjectBrackets": "all", - "safeContextKeyword": "that", - "validateIndentation": "\t", - - "disallowImplicitTypeConversion": [ - "numeric", "binary", "string" - ], - "disallowKeywords": [ - "with" - ], - "disallowSpaceAfterPrefixUnaryOperators": [ - "++", "--", "+", "-", "~", "!" - ], - "disallowSpaceBeforePostfixUnaryOperators": [ - "++", "--" - ], - "requireCurlyBraces": [ - "if", "else", "for", "while", "do", - "try", "catch", "case", "default" - ], - "requireKeywordsOnNewLine": [ - "catch", "else" - ], - "requireOperatorBeforeLineBreak": [ - "+", "-", "/", "*", "=", "==", "===", - "!=", "!==", ">", ">=", "<", "<=" - ], - "requireSpaceAfterKeywords": [ - "if", "else", "for", "while", "do", "switch", - "return", "try", "catch", "typeof" - ], - "requireSpaceBeforeBinaryOperators": [ - "+", "-", "/", "*", "=", "==", "===", - "!=", "!==" - ], - - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInFunctionDeclaration": { - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInNamedFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "validateJSDoc": { - "checkParamNames": true, - "requireParamTypes": true - }, - "validateQuoteMarks": { - "mark": "'", - "escape": true - } -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index a7a1d4f..0000000 --- a/.jshintrc +++ /dev/null @@ -1,74 +0,0 @@ -{ - "asi": false, - "bitwise": false, - "boss": false, - "browser": true, - "camelcase": true, - "couch": false, - "curly": true, - "debug": false, - "devel": true, - "dojo": false, - "eqeqeq": true, - "eqnull": true, - "esnext": false, - "evil": false, - "expr": false, - "forin": true, - "funcscope": false, - "globalstrict": false, - "immed": true, - "indent": false, - "iterator": false, - "jquery": false, - "lastsemic": false, - "latedef": true, - "laxbreak": false, - "laxcomma": false, - "loopfunc": false, - "maxcomplexity": false, - "maxdepth": 4, - "maxerr": 50, - "maxlen": 120, - "maxparams": 7, - "maxstatements": false, - "mootools": false, - "moz": false, - "multistr": false, - "newcap": true, - "noarg": true, - "node": true, - "noempty": true, - "nomen": false, - "nonew": true, - "nonstandard": false, - "onevar": false, - "passfail": false, - "plusplus": false, - "proto": false, - "prototypejs": false, - "quotmark": "single", - "rhino": false, - "scripturl": false, - "shadow": false, - "smarttabs": false, - "strict": true, - "sub": false, - "supernew": false, - "trailing": true, - "undef": true, - "unused": true, - "validthis": false, - "white": false, - "worker": true, - "wsh": false, - "yui": false, - - "globals": { - "afterEach": true, - "beforeEach": true, - "describe": true, - "expect": true, - "it": true - } -} diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9314e84..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Shannon Moeller - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 29bf3ad..2cbdeef 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +**NOTE: This project is under active development. APIs subject to change.** + # `toga-css` [![NPM version][npm-img]][npm-url] [![Downloads][downloads-img]][npm-url] [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Chat][gitter-img]][gitter-url] @@ -41,7 +43,7 @@ Standards for this project, including tests, code coverage, and semantics are en ---- -© 2014 Shannon Moeller +© 2015 Shannon Moeller Licensed under [MIT](http://shannonmoeller.com/mit.txt) diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index f994c80..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var gulp = require('gulp'), - paths = { - gulp: 'gulpfile.js', - src: 'index.js', - test: 'test/**/*.{e2e,spec}.js' - }; - -gulp.task('default', ['test']); - -gulp.task('lint', function () { - var jscs = require('gulp-jscs'), - jshint = require('gulp-jshint'); - - return gulp - .src([paths.gulp, paths.src, paths.test]) - .pipe(jscs()) - .pipe(jshint()) - .pipe(jshint.reporter('jshint-stylish')); -}); - -gulp.task('cover', function () { - var istanbul = require('gulp-istanbul'); - - return gulp - .src(paths.src) - .pipe(istanbul()) - .pipe(istanbul.hookRequire()); -}); - -gulp.task('test', ['lint', 'cover'], function () { - var istanbul = require('gulp-istanbul'), - mocha = require('gulp-mocha'); - - return gulp - .src(paths.test) - .pipe(mocha({ reporter: 'spec' })) - .pipe(istanbul.writeReports()); -}); diff --git a/index.js b/index.js index 9d3ae92..64a2a67 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -'use strict'; - /** * # Toga CSS Parser * @@ -14,20 +12,19 @@ * - scss */ -var tunic = require('tunic'), - mixin = require('mtil/object/mixin'), +import Tunic from 'tunic'; +import mixin from 'mtil/object/mixin'; - /** Default options. */ - defaults = { - extension: /.(css|less|scss)$/, - namedTags: [ - 'module', - 'extends' - ] - }; +var parserDefaults = { + extension: /.(css|less|scss)$/, + namedTags: [ + 'module', + 'extends' + ] +}; -exports.parser = function (options) { - options = mixin({}, defaults, options); +export function parser(options) { + options = mixin({}, parserDefaults, options); - return tunic(options); -}; + return new Tunic(options); +} diff --git a/package.json b/package.json index 21af4e4..57719f1 100644 --- a/package.json +++ b/package.json @@ -29,18 +29,22 @@ "tunic": "^0.3.0" }, "devDependencies": { + "babel": "^5.1.13", "coveralls": "^2.11.2", - "event-stream": "^3.1.7", - "expect.js": "^0.3.1", - "gulp": "^3.8.10", - "gulp-istanbul": "^0.5.0", - "gulp-jscs": "^1.3.1", - "gulp-jshint": "^1.9.0", - "gulp-mocha": "^2.0.0", - "jshint-stylish": "^1.0.0", - "toga": "^0.3.2" + "eslint": "^0.20.0", + "expect": "^1.6.0", + "isparta": "^3.0.3", + "mocha": "^2.2.4", + "nodemon": "^1.3.7", + "stream-array": "^1.1.0", + "vinyl-fs": "^1.0.0" }, - "engines": { - "node": ">= 0.10" + "scripts": { + "build": "babel index.js --out-file dist/index.js", + "cover": "babel-node ./node_modules/.bin/isparta cover --include index.js --reporter text --reporter lcov ./node_modules/.bin/_mocha -- test/*.js", + "coveralls": "cat ./coverage/lcov.info | coveralls", + "lint": "eslint index.js test/*.js", + "test": "npm run lint && npm run cover", + "watch": "nodemon --exec 'npm run test' --watch index.js --watch test" } } diff --git a/test/expected/arg.css.json b/test/expected/arg.css.json deleted file mode 100644 index 036053d..0000000 --- a/test/expected/arg.css.json +++ /dev/null @@ -1,191 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "[name]", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "[name]", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "[name]" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "[name]", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "[name]", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "name", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "name", - "description": "Description." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "[name]" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "name" - } - ] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/expected/desc.css.json b/test/expected/desc.css.json deleted file mode 100644 index af3ee72..0000000 --- a/test/expected/desc.css.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "description", - "tags": [] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "description", - "tags": [] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "description", - "tags": [] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/expected/empty.css.json b/test/expected/empty.css.json deleted file mode 100644 index b842803..0000000 --- a/test/expected/empty.css.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "/**/" - }, - { - "type": "Comment", - "description": "", - "tags": [] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/expected/ignore.css.json b/test/expected/ignore.css.json deleted file mode 100644 index 54c70f1..0000000 --- a/test/expected/ignore.css.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "// ignore\n/* ignore */\n/*! ignore */\n\n//\n// ignore\n//\n/*\n * ignore\n */\n/*!\n * ignore\n */\n\n// /** ignore\nvar ignore = '/** ignore */';\nvar foo = function(/** ignore */) {};\nconsole.log(foo(ignore));\n// ignore */" - } - ] -} diff --git a/test/expected/indents.css.json b/test/expected/indents.css.json deleted file mode 100644 index 382c163..0000000 --- a/test/expected/indents.css.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "# Title\n\nLong description that spans multiple\nlines and even has other markdown\ntype things.\n\nLike more paragraphs.\n\n* Like\n* Lists\n\n var code = 'samples';\n\n", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n\n And has line breaks, etc.\n\n" - }, - { - "tag": "example", - "description": "\n\n var foo = 'bar';\n\n" - }, - { - "tag": "tag", - "description": "Foo bar.\n" - }, - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "# Title\n\nLong description that spans multiple\nlines and even has other markdown\ntype things.\n\nLike more paragraphs.\n\n* Like\n* Lists\n\n var code = 'samples';\n\n", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n\n And has line breaks, etc.\n\n" - }, - { - "tag": "example", - "description": "\n\n var foo = 'bar';\n\n" - }, - { - "tag": "tag", - "description": "Foo bar.\n" - }, - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "# Title\n\nLong description that spans multiple\nlines and even has other markdown\ntype things.\n\nLike more paragraphs.\n\n* Like\n* Lists\n\n var code = 'samples';\n\n", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n\n And has line breaks, etc.\n\n" - }, - { - "tag": "example", - "description": "\n\n var foo = 'bar';\n\n" - }, - { - "tag": "tag", - "description": "Foo bar.\n" - }, - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "# Title\n\nLong description that spans multiple\nlines and even has other markdown\ntype things.\n\nLike more paragraphs.\n\n* Like\n* Lists\n\n var code = 'samples';\n\n", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n\n And has line breaks, etc.\n\n" - }, - { - "tag": "example", - "description": "\n\n var foo = 'bar';\n\n" - }, - { - "tag": "tag", - "description": "Foo bar.\n" - }, - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "# Title\n\nLong description that spans multiple\nlines and even has other markdown\ntype things.\n\nLike more paragraphs.\n\n* Like\n* Lists\n\n var code = 'samples';\n\n", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n\n And has line breaks, etc.\n\n" - }, - { - "tag": "example", - "description": "\n\n var foo = 'bar';\n\n" - }, - { - "tag": "tag", - "description": "Foo bar.\n" - }, - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "# Title\n\nLong description that spans multiple\nlines and even has other markdown\ntype things.\n\nLike more paragraphs.\n\n* Like\n* Lists\n\n var code = 'samples';\n\n", - "tags": [ - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n" - }, - { - "tag": "param", - "type": "{Type}", - "name": "name", - "description": "Description that is really long\n and wraps to other lines.\n\n And has line breaks, etc.\n\n" - }, - { - "tag": "example", - "description": "\n\n var foo = 'bar';\n\n" - }, - { - "tag": "tag", - "description": "Foo bar.\n" - }, - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/expected/name.css.json b/test/expected/name.css.json deleted file mode 100644 index de749f3..0000000 --- a/test/expected/name.css.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "name" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "[name]" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "[name={}]" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "name": "[name=\"hello world\"]" - } - ] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/expected/tag.css.json b/test/expected/tag.css.json deleted file mode 100644 index 9048b2f..0000000 --- a/test/expected/tag.css.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "tag", - "type": "{Type}", - "description": "Description here." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "tag", - "type": "{Type}", - "description": "Description here." - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "tag", - "description": "Description. undefined" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "tag", - "description": "Description. undefined" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "tag" - } - ] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/expected/tags.css.json b/test/expected/tags.css.json new file mode 100644 index 0000000..12c8313 --- /dev/null +++ b/test/expected/tags.css.json @@ -0,0 +1,202 @@ +{ + "type": "Document", + "blocks": [ + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "description text", + "tags": [] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "description\n", + "tags": [ + { + "tag": "module", + "type": "{Type.)>}", + "name": "[name={}]", + "description": "description text\n" + }, + { + "tag": "module", + "type": "{Type}", + "name": "name", + "description": "description text\n" + }, + { + "tag": "module", + "name": "[name]", + "description": "description text\n" + }, + { + "tag": "module", + "name": "name", + "description": "description text\n" + }, + { + "tag": "module", + "name": "name" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "type": "{Type.)>}", + "name": "[name={}]", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "type": "{Type}", + "name": "name", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "[name]", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "name", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "name" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "type": "{Type.)>}", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "type": "{Type}", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag" + } + ] + }, + { + "type": "Code", + "contents": "/*! ignore */\n/*!\n * ignore\n */\n\n/* ignore */\n/*\n * ignore\n */" + } + ], + "nav": {} +} diff --git a/test/expected/tags.less.json b/test/expected/tags.less.json new file mode 100644 index 0000000..12c8313 --- /dev/null +++ b/test/expected/tags.less.json @@ -0,0 +1,202 @@ +{ + "type": "Document", + "blocks": [ + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "description text", + "tags": [] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "description\n", + "tags": [ + { + "tag": "module", + "type": "{Type.)>}", + "name": "[name={}]", + "description": "description text\n" + }, + { + "tag": "module", + "type": "{Type}", + "name": "name", + "description": "description text\n" + }, + { + "tag": "module", + "name": "[name]", + "description": "description text\n" + }, + { + "tag": "module", + "name": "name", + "description": "description text\n" + }, + { + "tag": "module", + "name": "name" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "type": "{Type.)>}", + "name": "[name={}]", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "type": "{Type}", + "name": "name", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "[name]", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "name", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "name" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "type": "{Type.)>}", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "type": "{Type}", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag" + } + ] + }, + { + "type": "Code", + "contents": "/*! ignore */\n/*!\n * ignore\n */\n\n/* ignore */\n/*\n * ignore\n */" + } + ], + "nav": {} +} diff --git a/test/expected/tags.scss.json b/test/expected/tags.scss.json new file mode 100644 index 0000000..12c8313 --- /dev/null +++ b/test/expected/tags.scss.json @@ -0,0 +1,202 @@ +{ + "type": "Document", + "blocks": [ + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "description text", + "tags": [] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "description\n", + "tags": [ + { + "tag": "module", + "type": "{Type.)>}", + "name": "[name={}]", + "description": "description text\n" + }, + { + "tag": "module", + "type": "{Type}", + "name": "name", + "description": "description text\n" + }, + { + "tag": "module", + "name": "[name]", + "description": "description text\n" + }, + { + "tag": "module", + "name": "name", + "description": "description text\n" + }, + { + "tag": "module", + "name": "name" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "type": "{Type.)>}", + "name": "[name={}]", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "type": "{Type}", + "name": "name", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "[name]", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "name", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "extends", + "name": "name" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "type": "{Type.)>}", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "type": "{Type}", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag", + "description": "description text" + } + ] + }, + { + "type": "Code", + "contents": "" + }, + { + "type": "Comment", + "description": "", + "tags": [ + { + "tag": "tag" + } + ] + }, + { + "type": "Code", + "contents": "/*! ignore */\n/*!\n * ignore\n */\n\n/* ignore */\n/*\n * ignore\n */" + } + ], + "nav": {} +} diff --git a/test/expected/type.css.json b/test/expected/type.css.json deleted file mode 100644 index b05ab02..0000000 --- a/test/expected/type.css.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "type": "Document", - "blocks": [ - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Type}" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{String|Object}" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Array.>}" - } - ] - }, - { - "type": "Code", - "contents": "" - }, - { - "type": "Comment", - "description": "", - "tags": [ - { - "tag": "param", - "type": "{Function(String, ...[Number]): Number}", - "name": "callback" - } - ] - }, - { - "type": "Code", - "contents": "" - } - ] -} diff --git a/test/fixtures/arg.css b/test/fixtures/arg.css deleted file mode 100644 index 5636170..0000000 --- a/test/fixtures/arg.css +++ /dev/null @@ -1,12 +0,0 @@ -/** @param {Type} [name] - Description. */ -/** @param {Type} [name] Description. */ -/** @param {Type} name - Description. */ -/** @param {Type} name Description. */ -/** @param {Type} [name] */ -/** @param {Type} name */ -/** @param [name] - Description. */ -/** @param [name] Description. */ -/** @param name - Description. */ -/** @param name Description. */ -/** @param [name] */ -/** @param name */ diff --git a/test/fixtures/desc.css b/test/fixtures/desc.css deleted file mode 100644 index f15edb5..0000000 --- a/test/fixtures/desc.css +++ /dev/null @@ -1,7 +0,0 @@ -/** description */ -/** - * description - */ -/** -description -*/ diff --git a/test/fixtures/empty.css b/test/fixtures/empty.css deleted file mode 100644 index 0205432..0000000 --- a/test/fixtures/empty.css +++ /dev/null @@ -1,9 +0,0 @@ -/**/ -/***/ -/** */ -/** - * - */ -/** - -*/ diff --git a/test/fixtures/ignore.css b/test/fixtures/ignore.css deleted file mode 100644 index 775a223..0000000 --- a/test/fixtures/ignore.css +++ /dev/null @@ -1,19 +0,0 @@ -// ignore -/* ignore */ -/*! ignore */ - -// -// ignore -// -/* - * ignore - */ -/*! - * ignore - */ - -// /** ignore -var ignore = '/** ignore */'; -var foo = function(/** ignore */) {}; -console.log(foo(ignore)); -// ignore */ diff --git a/test/fixtures/indents.css b/test/fixtures/indents.css deleted file mode 100644 index 262ffd4..0000000 --- a/test/fixtures/indents.css +++ /dev/null @@ -1,179 +0,0 @@ -/** - * # Title - * - * Long description that spans multiple - * lines and even has other markdown - * type things. - * - * Like more paragraphs. - * - * * Like - * * Lists - * - * var code = 'samples'; - * - * @param {Type} name Description. - * @param {Type} name Description that is really long - * and wraps to other lines. - * @param {Type} name Description that is really long - * and wraps to other lines. - * - * And has line breaks, etc. - * - * @example - * - * var foo = 'bar'; - * - * @tag Foo bar. - * @tag - */ - -/** -# Title - -Long description that spans multiple -lines and even has other markdown -type things. - -Like more paragraphs. - -* Like -* Lists - - var code = 'samples'; - -@param {Type} name Description. -@param {Type} name Description that is really long - and wraps to other lines. -@param {Type} name Description that is really long - and wraps to other lines. - - And has line breaks, etc. - -@example - - var foo = 'bar'; - -@tag Foo bar. -@tag - */ - -/** - # Title - - Long description that spans multiple - lines and even has other markdown - type things. - - Like more paragraphs. - - * Like - * Lists - - var code = 'samples'; - - @param {Type} name Description. - @param {Type} name Description that is really long - and wraps to other lines. - @param {Type} name Description that is really long - and wraps to other lines. - - And has line breaks, etc. - - @example - - var foo = 'bar'; - - @tag Foo bar. - @tag - */ - - /** - * # Title - * - * Long description that spans multiple - * lines and even has other markdown - * type things. - * - * Like more paragraphs. - * - * * Like - * * Lists - * - * var code = 'samples'; - * - * @param {Type} name Description. - * @param {Type} name Description that is really long - * and wraps to other lines. - * @param {Type} name Description that is really long - * and wraps to other lines. - * - * And has line breaks, etc. - * - * @example - * - * var foo = 'bar'; - * - * @tag Foo bar. - * @tag - */ - - /** - # Title - - Long description that spans multiple - lines and even has other markdown - type things. - - Like more paragraphs. - - * Like - * Lists - - var code = 'samples'; - - @param {Type} name Description. - @param {Type} name Description that is really long - and wraps to other lines. - @param {Type} name Description that is really long - and wraps to other lines. - - And has line breaks, etc. - - @example - - var foo = 'bar'; - - @tag Foo bar. - @tag - */ - - /** - # Title - - Long description that spans multiple - lines and even has other markdown - type things. - - Like more paragraphs. - - * Like - * Lists - - var code = 'samples'; - - @param {Type} name Description. - @param {Type} name Description that is really long - and wraps to other lines. - @param {Type} name Description that is really long - and wraps to other lines. - - And has line breaks, etc. - - @example - - var foo = 'bar'; - - @tag Foo bar. - @tag - */ diff --git a/test/fixtures/name.css b/test/fixtures/name.css deleted file mode 100644 index d65f548..0000000 --- a/test/fixtures/name.css +++ /dev/null @@ -1,4 +0,0 @@ -/** @param name */ -/** @param [name] */ -/** @param [name={}] */ -/** @param [name="hello world"] */ diff --git a/test/fixtures/tag.css b/test/fixtures/tag.css deleted file mode 100644 index c34ce06..0000000 --- a/test/fixtures/tag.css +++ /dev/null @@ -1,5 +0,0 @@ -/** @tag {Type} - Description here. */ -/** @tag {Type} Description here. */ -/** @tag - Description. */ -/** @tag Description. */ -/** @tag */ diff --git a/test/fixtures/tags.css b/test/fixtures/tags.css new file mode 100644 index 0000000..03692ff --- /dev/null +++ b/test/fixtures/tags.css @@ -0,0 +1,32 @@ +/** description text */ + +/** + * description + * @module {Type.)>} [name={}] - description text + * @module {Type} name description text + * @module [name] - description text + * @module name - description text + * @module name + */ + +/** @extends {Type.)>} [name={}] - description text */ +/** @extends {Type} name description text */ +/** @extends [name] - description text */ +/** @extends name - description text */ +/** @extends name */ + +/** @tag {Type.)>} - description text */ +/** @tag {Type} description text */ +/** @tag - description text */ +/** @tag description text */ +/** @tag */ + +/*! ignore */ +/*! + * ignore + */ + +/* ignore */ +/* + * ignore + */ diff --git a/test/fixtures/tags.less b/test/fixtures/tags.less new file mode 100644 index 0000000..03692ff --- /dev/null +++ b/test/fixtures/tags.less @@ -0,0 +1,32 @@ +/** description text */ + +/** + * description + * @module {Type.)>} [name={}] - description text + * @module {Type} name description text + * @module [name] - description text + * @module name - description text + * @module name + */ + +/** @extends {Type.)>} [name={}] - description text */ +/** @extends {Type} name description text */ +/** @extends [name] - description text */ +/** @extends name - description text */ +/** @extends name */ + +/** @tag {Type.)>} - description text */ +/** @tag {Type} description text */ +/** @tag - description text */ +/** @tag description text */ +/** @tag */ + +/*! ignore */ +/*! + * ignore + */ + +/* ignore */ +/* + * ignore + */ diff --git a/test/fixtures/tags.scss b/test/fixtures/tags.scss new file mode 100644 index 0000000..03692ff --- /dev/null +++ b/test/fixtures/tags.scss @@ -0,0 +1,32 @@ +/** description text */ + +/** + * description + * @module {Type.)>} [name={}] - description text + * @module {Type} name description text + * @module [name] - description text + * @module name - description text + * @module name + */ + +/** @extends {Type.)>} [name={}] - description text */ +/** @extends {Type} name description text */ +/** @extends [name] - description text */ +/** @extends name - description text */ +/** @extends name */ + +/** @tag {Type.)>} - description text */ +/** @tag {Type} description text */ +/** @tag - description text */ +/** @tag description text */ +/** @tag */ + +/*! ignore */ +/*! + * ignore + */ + +/* ignore */ +/* + * ignore + */ diff --git a/test/fixtures/type.css b/test/fixtures/type.css deleted file mode 100644 index d506288..0000000 --- a/test/fixtures/type.css +++ /dev/null @@ -1,4 +0,0 @@ -/** @param {Type} */ -/** @param {String|Object} */ -/** @param {Array.>} */ -/** @param {Function(String, ...[Number]): Number} callback */ diff --git a/test/toga-css.e2e.js b/test/toga-css.e2e.js index 747f6d4..b56a811 100644 --- a/test/toga-css.e2e.js +++ b/test/toga-css.e2e.js @@ -1,81 +1,93 @@ -'use strict'; +/*eslint-env mocha */ -var css = require('../index'), - es = require('event-stream'), - expect = require('expect.js'), - toga = require('toga'), +import { parser } from '../index'; +import expect from 'expect'; +import streamArray from 'stream-array'; +import vinylFs from 'vinyl-fs'; +import { join } from 'path'; +import { readFileSync } from 'fs'; - config = { - css: __dirname + '/fixtures/**/*.css', - less: __dirname + '/fixtures/**/*.less', - scss: __dirname + '/fixtures/**/*.scss', - txt: __dirname + '/fixtures/**/*.txt', - dest: __dirname + '/actual' - }; +var config = { + fixtures: join(__dirname, '/fixtures'), + expected: join(__dirname, '/expected'), + actual: join(__dirname, '/actual') +}; describe('toga-css e2e', function () { - var count; + describe('raw streams', function () { + function testWithArray(array, stream, done) { + function expectChunk(chunk) { + expect(chunk).toEqual({ + type: 'Document', + blocks: [{ + contents: 'hello', + type: 'Code' + }] + }); + } - function toEqualExpected(file, cb) { - count++; + streamArray(array) + .pipe(stream) + .on('data', expectChunk) + .on('error', done) + .on('end', done); + } - var expected = file.path.replace('fixtures', 'expected') + '.json'; - expect(JSON.stringify(file.ast)).to.be(JSON.stringify(require(expected))); - cb(null, file); - } + it('should parse strings', function (done) { + var strings = ['hello', 'hello']; - function toEqualUndefined(file, cb) { - count++; + testWithArray(strings, parser(), done); + }); - expect(file.toga).to.be(undefined); - cb(null, file); - } + it('should parse buffers', function (done) { + var buffers = [new Buffer('hello'), new Buffer('hello')]; - beforeEach(function () { - count = 0; + testWithArray(buffers, parser(), done); + }); }); - it('should parse css files', function (done) { - toga - .src(config.css) - .pipe(css.parser()) - .pipe(es.map(toEqualExpected)) - .pipe(toga.dest(config.dest)) - .on('error', done) - .on('end', function () { - expect(count).to.be(8); - done(); - }); - }); + describe('object streams', function () { + function testWithFile(filename, stream, done) { + var fixture = join(config.fixtures, filename), + expected = join(config.expected, filename + '.json'); - it('should not parse empty files', function (done) { - var files = [ - { path: 'foo.css' }, - { path: 'foo.css', content: null }, - undefined - ]; - - es - .readArray(files) - .pipe(css.parser()) - .pipe(es.map(toEqualUndefined)) - .on('error', done) - .on('end', function () { - expect(count).to.be(2); - done(); - }); - }); + function expectFile(file) { + var actual = JSON.stringify(file.ast, null, 2) + '\n'; + + expect(actual).toEqual(String(readFileSync(expected))); + } + + vinylFs + .src(fixture) + .pipe(stream) + .on('data', expectFile) + .on('error', done) + .on('end', done); + } + + it('should parse css', function (done) { + testWithFile('tags.css', parser(), done); + }); + + it('should parse less', function (done) { + testWithFile('tags.less', parser(), done); + }); + + it('should parse scss', function (done) { + testWithFile('tags.scss', parser(), done); + }); + + it('should ignore unknown files', function (done) { + function expectFile(file) { + expect(file.ast).toBe(undefined); + } - it('should not parse unknown file types', function (done) { - toga - .src(config.txt) - .pipe(css.parser()) - .pipe(es.map(toEqualUndefined)) - .pipe(toga.dest(config.dest)) - .on('error', done) - .on('end', function () { - expect(count).to.be(0); - done(); - }); + vinylFs + .src(join(config.fixtures, 'unused.coffee')) + .pipe(parser()) + .on('data', expectFile) + .on('error', done) + .on('end', done); + }); }); }); diff --git a/test/toga-css.spec.js b/test/toga-css.spec.js index fba688a..ef91f2b 100644 --- a/test/toga-css.spec.js +++ b/test/toga-css.spec.js @@ -1,12 +1,12 @@ -'use strict'; +/*eslint-env mocha */ -var css = require('../index'), - expect = require('expect.js'); +import { parser } from '../index'; +import expect from 'expect.js'; describe('toga-css spec', function () { describe('parser', function () { it('should return a transform stream', function () { - var retval = css.parser(); + var retval = parser(); expect(retval.pipe).to.be.a(Function); expect(retval.readable).to.be(true);