diff --git a/.babelrc b/.babelrc index 31b2172..a818e4e 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,13 @@ { - "stage": 1 -} \ No newline at end of file + "presets": [ + "es2015", + "stage-0" + ], + "plugins": [ + "syntax-async-functions", + "transform-async-to-generator", + "transform-decorators-legacy", + "transform-regenerator", + "transform-runtime" + ] +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..20e9d15 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,204 @@ +{ + "ecmaFeatures": { + "arrowFunctions": true, + "binaryLiterals": true, + "blockBindings": true, + "classes": true, + "defaultParams": true, + "destructuring": true, + "forOf": true, + "generators": true, + "modules": true, + "objectLiteralComputedProperties": true, + "objectLiteralDuplicateProperties": true, + "objectLiteralShorthandMethods": true, + "objectLiteralShorthandProperties": true, + "octalLiterals": true, + "regexUFlag": true, + "regexYFlag": true, + "restParams": true, + "spread": true, + "superInFunctions": true, + "templateStrings": true, + "unicodeCodePointEscapes": true, + "globalReturn": true, + "experimentalObjectRestSpread": true + }, + "env": { + "node": true, + "mocha": true, + "es6": true + }, + "parser": "babel-eslint", + "globals": {}, + "plugins": [ + "babel" + ], + "rules": { + "babel/generator-star-spacing": [ 0, "before" ], + "generator-star-spacing": [ 0, "before" ], + + "babel/new-cap": 2, + "new-cap": 0, + + "babel/array-bracket-spacing": [ 2, "always" ], + "array-bracket-spacing": 0, + + "babel/object-curly-spacing": [ 2, "always" ], + "object-curly-spacing": 0, + + "babel/object-shorthand": [ 2, "always" ], + "object-shorthand": 0, + + "babel/arrow-parens": [ 2, "always" ], + "arrow-parens": 0, + + "babel/no-await-in-loop": 1, + + "arrow-spacing": 2, + "block-scoped-var": 2, + "block-spacing": [ 2, "always" ], + "brace-style": [ 2, "1tbs" ], + "camelcase": [ 0, { "properties": "never" } ], + "comma-spacing": [ 2, { "before": false, "after": true } ], + "comma-style": [ 2, "last" ], + "complexity": [ 2, 12 ], + "computed-property-spacing": [ 2, "never" ], + "consistent-this": [ 2, "self" ], + "constructor-super": 2, + "curly": [ 2, "multi-line" ], + "default-case": 2, + "dot-location": [ 2, "property" ], + "dot-notation": [ 2, { "allowKeywords": true } ], + "eol-last": 2, + "eqeqeq": [ 2, "allow-null" ], + "func-names": 1, + + "guard-for-in": 1, + "id-length": [ + 1, + { + "min": 2, + "max": 30, + "properties": "always", + "exceptions": [ "i", "k", "a", "b", "c", "d", "e", "l", "x", "y", "z", "_", "t" ] + } + ], + "id-match": [ 2, "^(?:[a-z]{2,}([A-Z]{1}[a-z]+)*$)|([a-z_]+$)" ], + "indent": [ 2, 2 , { "SwitchCase": 1 } ], + "key-spacing": [ 2, { "beforeColon": false, "afterColon": true } ], + "linebreak-style": [ 2, "unix" ], + "max-depth": [ 2, 5 ], + "max-len": [ + 2, + 150, + 2, + { + "ignoreUrls": true, + "ignorePattern": "^\\s*(var|const|let)\\s.+=\\s*(?:(?:[a-z.\\[\\]'\"]+\\s+\\+)|(?:'|\"))" + } + ], + "max-nested-callbacks": [2, 3], + "max-params": [ 1, 4 ], + "max-statements": [ 1, 30 ], + "new-parens": 2, + "no-alert": 2, + "no-array-constructor": 2, + "no-bitwise": 0, + "no-caller": 2, + "no-catch-shadow": 2, + "no-class-assign": 2, + "no-cond-assign": [ 2, "except-parens" ], + "no-const-assign": 2, + "no-continue": 2, + "no-debugger": 2, + "no-delete-var": 2, + "no-div-regex": 2, + "no-dupe-class-members": 2, + "no-else-return": 2, + "no-empty": 2, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-parens": 0, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-implied-eval": 2, + "no-invalid-this": 2, + "no-irregular-whitespace": 2, + "no-iterator": 2, + "no-label-var": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-lonely-if": 1, + "no-loop-func": 2, + "no-mixed-spaces-and-tabs": 2, + "no-multi-spaces": 2, + "no-multi-str": 2, + "no-multiple-empty-lines": [ 2, { "max": 3, "maxEOF": 1 } ], + "no-native-reassign": 2, + "no-nested-ternary": 2, + "no-new-func": 2, + "no-new-object": 2, + "no-new-wrappers": 2, + "no-new": 2, + "no-octal-escape": 2, + "no-octal": 2, + "no-proto": 2, + "no-redeclare": [ 2, { "builtinGlobals": true } ], + "no-regex-spaces": 2, + "no-restricted-syntax": [ 2, "WithStatement" ], + "no-return-assign": 2, + "no-script-url": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-shadow-restricted-names": 2, + "no-shadow": 2, + "no-spaced-func": 2, + "no-this-before-super": 2, + "no-throw-literal": 2, + "no-trailing-spaces": 2, + "no-undef-init": 2, + "no-undef": 2, + "no-unneeded-ternary": 2, + "no-unused-expressions": [ 2, { "allowShortCircuit": true, "allowTernary": true } ], + "no-unused-vars": 2, + "no-use-before-define": 0, + "no-useless-call": 2, + "no-useless-concat": 2, + "no-var": 0, + "no-void": 2, + "no-warning-comments": [ 1, { "terms": [ "@todo", "@fix", "@fixme" ], "location": "start" } ], + "no-with": 2, + "one-var": [ 2, { "uninitialized": "always", "initialized": "never" } ], + "operator-assignment": [ 2, "always" ], + "operator-linebreak": [ 2, "after" ], + "padded-blocks": [ 2, "never" ], + "prefer-arrow-callback": 2, + "prefer-const": 0, + "prefer-spread": 2, + "prefer-template": 0, + "quote-props": [ 2, "as-needed" ], + "quotes": [ 2, "single", "avoid-escape" ], + "require-yield": 2, + "semi-spacing": 2, + "semi": [ 1, "never" ], + "no-extra-semi": [ 1 ], + "keyword-spacing": [ 2, { "before": true, "after": true, "overrides": {} } ], + "space-before-blocks": [ 2, "always" ], + "space-before-function-paren": [ 2, "never" ], + "space-in-parens": [ 2, "never" ], + "space-infix-ops": [ 2, { "int32Hint": true } ], + "space-unary-ops": 2, + "spaced-comment": [ + 2, + "always", + { + "line": { "markers": [ "/", "/#" ], "exceptions": [ "-", "+", "/", "#" ] }, + "block": { "markers": [ "!", "*#" ], "exceptions": [ "*", "#" ] } + } + ], + "valid-typeof": 2, + "wrap-iife": [ 2, "inside" ], + "yoda": 2 + } +} diff --git a/.gitignore b/.gitignore index e58098a..d17bf21 100755 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ -node_modules/ -**/nmp-debug.log -build/ -build.zip +node_modules +bower_components +jspm_packages +dist .tmp .DS_Store .sass-cache -bower_components/ +npm-debug.log *.map -docs/docs.json \ No newline at end of file +docs/docs.json +coverage +.nyc_output diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index e6b7096..0000000 --- a/.jscsrc +++ /dev/null @@ -1,95 +0,0 @@ -{ - "disallowEmptyBlocks": true, - "disallowIdentifierNames": ["foo", "bar", "baz", "qux"], - "disallowKeywords": ["with"], - "disallowMixedSpacesAndTabs": "smart", - "disallowMultipleLineStrings": true, - "disallowMultipleSpaces": true, - "disallowPaddingNewlinesInBlocks": true, - "disallowPaddingNewlinesBeforeKeywords": [ - "case", - "catch", - "void", - "with" - ], - "disallowQuotedKeysInObjects": "allButReserved", - "disallowSpaceAfterKeywords": [ - "if", - "else if", - "for", - "while", - "do", - "switch", - "try", - "catch" - ], - "disallowSpaceBeforeKeywords": [ - "if", - "else", - "else if", - "for", - "while", - "catch" - ], - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch", - "case", - "default" - ], - "requireMultipleVarDecl": true, - "requireLineBreakAfterVariableAssignment": true, - "disallowSpaceAfterObjectKeys": "ignoreSingleLine", - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!", "!!", "~~"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInFunction": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInCallExpression": true, - "requireSpacesInConditionalExpression": true, - "requireSpacesInForStatement": true, - "disallowTrailingWhitespace": "ignoreEmptyLines", - "requireBlocksOnNewline": true, - "requireCommaBeforeLineBreak": true, - "disallowYodaConditions": true, - "requireOperatorBeforeLineBreak": ["?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "requireSpaceBeforeBinaryOperators": true, - "requirePaddingNewLinesInObjects": true, - "requireSpaceBeforeObjectValues": true, - "requireSpaceBetweenArguments": true, - "requireSemicolons": true, - "requireSpaceAfterBinaryOperators": true, - "requireSpaceAfterKeywords": ["return", "typeof", "void"], - "disallowSpacesInsideObjectBrackets": null, - "safeContextKeyword": ["$obj", "obj", "$that", "that", "$elem", "elem", "_this", "self", "_self", "_", "$parent", "parent", "instance", "result", "context"], - "fileExtensions": [".js", "jscs"], - "validateQuoteMarks": { - "mark": "\"", - "escape": true - }, - "requireParenthesesAroundIIFE": true, - "validateLineBreaks": "LF", - "validateIndentation": 1, - "validateParameterSeparator": ", ", - "excludeFiles": [ - "node_modules/**/*" - ] -} diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..66a5a07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,26 @@ +{ + "esversion": 6, + "mocha": true, + "node": true, + "curly": false, + "eqeqeq": true, + "forin": true, + "immed": true, + "freeze": true, + "funcscope": true, + "futurehostile": true, + "latedef": false, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "varstmt": true, + "asi": true, + "unused": true, + "boss": true, + "eqnull": true, + "loopfunc": true, + "globals": [ + "define" + ] +} diff --git a/.npmignore b/.npmignore index 3d0dbe4..8670170 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,15 @@ -tests/ \ No newline at end of file +tests/ +tools/ +app/ +coverage/ +.coveralls.yml +.travis.yml +.gitignore +.jscsrc +.jshintrc +.eslintrc +.babelrc +**/.DS_Store +.DS_Store +.tmp +.nyc_output diff --git a/.travis.yml b/.travis.yml index 9bc8db2..912a5e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ language: node_js node_js: - - "0.12" - -before_install: - - npm i npm@latest -g - -script: cd tests; npm install; gulp docs; \ No newline at end of file + - "iojs" + - "0.12" + - "4.0" + - "4" + - "5.0" + - "5" +sudo: false +install: npm i +script: npm test diff --git a/Makefile b/Makefile deleted file mode 100644 index cfd3055..0000000 --- a/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -BIN = $(PWD)/node_modules/.bin -GBIN = $(npm -g bin) -# BABEL = [[ -f $(npm -g bin)/babel ]] && $(npm -g bin)/babel || $(BIN)/babel -BABEL = [[ -d $(npm -g root)/babel ]] && babel || $(BIN)/babel - -all: es6 - -# es6: lib -# @mkdir -p build/ -# @for path in src/*.js; do \ -# file=`basename $$path`; \ -# $(BIN) "build/$$file" > "build/$$file"; \ -# done - - -# Compile ES6 from `src` to ES5 in `dist` -# ======================================= -run: - rm -rf build/ - make build - -build: - babel app -d build - -postinstall: - # [[ -d $(npm -g root)/babel ]] || npm i babel - make build - -# Development -# =========== - -develop: - $(BIN)babel-node $@ - -# Publish package to npm -# @see npm/npm#3059 -# ======================= - -publish: all - npm publish - -# Release, publish -# ================ - -# "patch", "minor", "major", "prepatch", -# "preminor", "premajor", "prerelease" -VERS ?= "patch" -TAG ?= "latest" - -release: all - npm version $(VERS) -m "Release %s" - npm publish --tag $(TAG) - git push --follow-tags - -# Tools -# ===== - -rebuild: - rm -rf node_modules - npm install \ No newline at end of file diff --git a/README.md b/README.md index c36a34b..f150c1f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ Docs, addapts to any language and will help you document all the things. -Where there is development there is a need for documentation. There are several great libraries for all sorts of files, written by brilliant developers, libraries like [SassDoc][sass-doc], [JSDoc][js-doc], [JavaDoc][java-doc], [Jazzy][jazzy], [StyleDocco][styledocco], [KSS][kss], [Hologram][hologram], [DSS][dss] and several more. All of these libraries do a very good job for documenting their respective languages. However there are very few projects that only require 1 file type. Which means if you really want to document all you code you may have to use 3 or 4 of these documentation generators. Each of the generators have their own way of documenting and their annotations, and their own document site which just makes it harder to keep all your documentation in one spot. +Where there is development there is a need for documentation. There are several great libraries for all sorts of files, written by brilliant developers, libraries like [SassDoc][sass-doc], [JSDoc][js-doc], [JavaDoc][java-doc], [Jazzy][jazzy], [StyleDocco][styledocco], [KSS][kss], [Hologram][hologram], [DSS][dss] and several more. All of these libraries do a very good job for documenting their respective languages. However there are very few projects that only require 1 file type. Which means if you really want to document all your code you may have to use 3 or 4 of these documentation generators. Each of the generators have their own way of documenting and their annotations, and their own document site which just makes it harder to keep all your documentation in one spot. + Docs fixes all these issues by giving you the ability to generate documentation for all your files. While giving you control over what annotations you want to use in each file type. ## Table of contents @@ -18,7 +19,17 @@ Docs fixes all these issues by giving you the ability to generate documentation - [Documenting your items](#documenting-your-items) ## Settings -There're 3 different settings that're avaiable to change on a per file basis. When you define out new settings for a specific filetype it will be merged with the default settings. +There're 3 different settings that are available to change on a per file basis. When you define out new settings for a specific filetype it will be merged with the default settings. + + +## Usage + +Install: + +```bash +npm i tjbenton/docs --save-dev +``` + #### Options `file_comment`: @@ -310,8 +321,34 @@ This type of comment can only occur **once** per file. Any annotations that are # Todo - Add the ability to add aliases - Take into account the ability to specify alias and file types. For example being able to extend something onto the `name` but use the `scss` specific filetype callback. - - ~~Filter out files that haven't changed, and only pass through the new files.~~ - - Refactor the function that get's the blocks to be seperate functions so it can reused for both header level comments and body comments. + - Double check to make sure that if a user specifies the same name and page for a comment block that it gets merged properly + ```scss + /// @name Beards + /// @page beards + /// @description + /// An awesome collection of beards in css + /// @markup + ///
+ .c-beard { + ... + } + ``` + + ```js + /// @name Beards + /// @page beards + /// @markup + ///
+ /// @markup + /// beard_me('.js-beardme') + function beard_me(selector) { + document.body.addEventListener('click', function(e) { + if ((e.target || {}).classList.contains(selector.replace('.', ''))) { + e.target.classList.toggle('is-bearded') + } + }) + } + ``` - Ability to add single line notations, or allow the user to define how many lines they want to return. The way it would work is to have a special identifier after the opening comments(eg `/**#{2} @remove */`) for laguages that use them, or after the single line comment(`///#{5}`). If you didn't want to return multiple lines, then you could just write `///#` and it would return everything before the comment. Note that `///#` is different that `///#{1}` because the `{2}` telling the parser to return the next 2 lines. There couldn't be any spaces inbetween the specified comment style and the special character that's used to identify this type of comment. Having this ability would allow you to do things like the following. ###### Returning a single line example @@ -322,7 +359,7 @@ This type of comment can only occur **once** per file. Any annotations that are outline: 1px solid red; /**# @remove #*/ margin: 10px; /**# @todo {10} - fix spacing */ } - .foo--bar{ /** @state */ + .foo--bar{ /**# @state */ background: black; } ``` @@ -380,10 +417,10 @@ This type of comment can only occur **once** per file. Any annotations that are - Figure out a way to have nested comment blocks so the nested comment blocks can be tied to the initial comment block. ```js - /// @name parse_blocks + /// @name parseBlocks /// @description Parses each block in blocks /// @returns {array} - parse_blocks = function(){ + parseBlocks = function(){ /// @name this.merge /// @description Used as a helper function because this action is performed in two spots /// @arg {object} annotation - information of the current annotation block @@ -394,59 +431,6 @@ This type of comment can only occur **once** per file. Any annotations that are }; }; ``` - - - Instead of returning - - ```json - "cs": { - "/Users/tylerbenton/ui-development/docs/tests/lib/c#/test.cs": [ - { - "author": "Tyler Benton", - "page": "tests/c#-file", - "name": "main", - "description": "

Rerum exercitationem tenetur iure facere, iusto dolores cumque repudiandae. Voluptate repudiandae soluta, deleniti, repellat explicabo placeat id maxime ea veniam error quasi!

" - }, - { - "author": "Tyler Benton", - "page": "tests/c#-file", - "name": "Something", - "description": "

Rerum exercitationem tenetur iure facere, iusto dolores cumque repudiandae. Voluptate repudiandae soluta, deleniti, repellat explicabo placeat id maxime ea veniam error quasi!

" - }, - { - "author": "Tyler Benton", - "page": "tests/c#-file", - "name": "Something else", - "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

" - } - ] - } - ``` - - change to return - - ```json - "cs": { - "/Users/tylerbenton/ui-development/docs/tests/lib/c#/test.cs": { - "header": { - "author": "Tyler Benton", - "page": "tests/c#-file", - "description": "

Rerum exercitationem tenetur iure facere, iusto dolores cumque repudiandae. Voluptate repudiandae soluta, deleniti, repellat explicabo placeat id maxime ea veniam error quasi!

" - }, - "body": [ - { - "name": "main" - }, - { - "name": "Something" - }, - { - "name": "Something else", - "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

" - } - ] - } - } - ``` - Look into adding a callback function that runs after the block has been completely parsed this would be run after the single line comments are parsed. I'm not sure how useful this would be but it's a thought. - This could allow you to create your own data structure. - Come up with a name for the project @@ -464,7 +448,7 @@ This type of comment can only occur **once** per file. Any annotations that are @name something awesome @description Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae praesentium voluptates beatae ducimus dolore velit excepturi maiores delectus doloribus labore totam odio culpa, magni reprehenderit est similique aspernatur dolor rerum? - /---> + ----> ``` ###### Need to figure out @@ -495,4 +479,4 @@ This type of comment can only occur **once** per file. Any annotations that are [travis-url]: https://travis-ci.org/tjbenton/docs?branch=master [travis-image]: https://travis-ci.org/tjbenton/docs.svg?style=flat-square [license-image]: http://img.shields.io/npm/l/sassdoc.svg?style=flat-square -[license-url]: LICENSE.md \ No newline at end of file +[license-url]: LICENSE.md diff --git a/app/annotation-api.js b/app/annotation-api.js new file mode 100644 index 0000000..c2282ee --- /dev/null +++ b/app/annotation-api.js @@ -0,0 +1,332 @@ +'use strict' +import { is, to } from './utils' + +export default class AnnotationApi { + constructor({ annotations, file, type }) { + // object of the all the annotation + // This object holds all the annotations + this.annotations_list = { + default: { + // holds all default annotations for all filetypes that aren't + // specific to an individual filetype. + } + // You can add file specific overrides if you need to. All you have + // to do is specific the filetype as the key(aka replace default with the filetype) + // js: { + // annotation + // } + } + + this.file = file || { type } + + + // stores the current annotation that is being added + // to the annotations list. + // the name of the annotation is always the key + this.annotation_base = { + // this declares where this annotation get's applied + filetypes: [ 'default' ], + + // holds an array of aliases for the given annotation + alias: [], + + // This function runs when the parser gets + // the annotations information + parse() { + return this.contents.shift() + }, + + // Runs when the each annotation in the block has been + // parsed. If the annotation doesn't exist and the autofill + // is set to be a function then autofill get's called, and + // the block and file info are accessible within `this` if + // it is a function.`. **Note** this will not run if the + // annotation exists + autofill: false, + + // Runs after the parsed and/or autofill runs the contents + // of `this` is what was returned by the parse and/or autofill. + // It's used to fixed data that was returned by parse. + // It helps when members on your team pass in the wrong keyword(s) + // and let's you resolve them here in the data instead of resolving + // the issues on the client side. It's also useful if you want want + // to ensure the data always returns an `array`. + resolve: false + } + + this.annotation_base_keys = to.keys(this.annotation_base) + + + this.addAnnotations(annotations) + + this.annotations = to.reduce([ 'alias', 'autofill', 'resolve' ], (previous, current) => { + return to.extend(previous, { + [current]: this.list(current) + }) + }, { parse: this.list() }) + } + + /// @name add + /// @description + /// Adds a single annotation to the list + /// + /// @arg {string, array} annotation - Name of the annotation + /// @arg {function, object} parses [annotation_base.callbacks] - Functions + /// @arg {string} ...alias - the rest of the arguments are alias + /// + /// @returns {this} + /// + /// @markup {js} **Example:** Declaring a basic annotation + /// annotationsApi.add("name", function(){ + /// return this.annotation.line + /// }) + /// + /// @markup {js} **Example:** Declaring a annotation with more options + /// annotationsApi.add("name", { + /// alias: ['title', 'heading'], + /// parse(){ + /// return this.annotation.line + /// }, + /// autofill: false, + /// resolve: false + /// }) + /// + /// @markup {js} **Example** Specifing a file specific annotation + /// annotationsApi.add('promise', { + /// // the filetypes passed will use the `parse` and the other + /// // settings in the config. It can be a string or an array of + /// // filetypes. Note that if a filetype isn't specificed it defaults + /// // to be `'default'` which will apply to all files. + /// filetype: ['js', 'jsx', 'es', 'es6', 'es7'], + /// parse(){ + /// return this.annotation.line + /// }, + /// ... + /// }) + /// + /// @markup {js} **Example** Specifing a file specific annotation(Option 2) + /// This is very useful + /// docs.annotation.add('name', { + /// default: { // for all filetypes that aren't defined for this annotation + /// parse(){ + /// return this.annotation.line + /// }, + /// ... + /// }, + /// js: { // use the file extention + /// parse() { + /// return `JS ${this.annotation.line}` + /// }, + /// ... + /// } + /// }) + add(name, config) { + let initial_config = config + let result = to.clone(this.annotation_base) + // a) throw an error + if (!is.string(name)) { + throw new Error('name must be a string') + return + } + + // a) set the passed `array` as the `alias` + // b) set the passed `function` as the `parse` function + // c) it's a filetype specific `object` + // d) throw an error + if (is.array(config)) { + config = { alias: config } + } else if (is.fn(config)) { + config = { parse: config } + } else if ( + is.plainObject(config) && + !is.empty(config) && + !is.any.in(config, ...this.annotation_base_keys) + ) { + // loop through each filetype in the passed + // object and rerun the add function + for (let filetype in config) { + if (config.hasOwnProperty(filetype)) { + let obj = config[filetype] + obj.filetypes = is.in(obj, 'filetype') ? to.flatten([ filetype, config.filetype ]) : to.array(filetype) + this.add(name, obj) + } + } + return + } else if (!is.plainObject(config)) { + throw new Error('config must be a function or object and you passed') + this.log.error(initial_config) + return + } + + // merge the passed `config` with the base config + // to ensure all settings are defined. + to.merge(result, config) + + // merge the passed annotation with the + // global list of annotations by filetype/default + for (let filetype of result.filetypes) { + to.merge(this.annotations_list, { + [filetype]: { [name]: result } + }) + } + + return this + } + + addAnnotations(annotations) { + for (let name in annotations) { + if (annotations.hasOwnProperty(name)) { + this.add(name, annotations[name]) + } + } + } + + /// @name list + /// @description + /// This gets the annotations to use for the current filetype. + /// Basically the file specific annotations get extended onto the default annotations + /// @returns {object} - the annotations to use for the current file + list(type) { + let result = this.annotations_list.default + if (!is.undefined(this.annotations_list[this.file.type])) { + result = to.extend(to.clone(result), this.annotations_list[this.file.type]) + } + + if (is.undefined(type)) { + return result + } + + return to.map(result, ({ key: name, value: annotation }) => { + if (is.truthy(annotation[type]) && !is.empty(annotation[type])) { + return { [name]: annotation[type] } + } + + return false + }) + } + + run(type, ...options) { + { + const base = { contents: [], start: -1, end: -1 } + options = to.arguments({ + annotation: { name: '', alias: '', ...base }, + file: { path: '', name: '', type: '', ...base }, + comment: { ...base }, + code: { ...base }, + }, ...options) + } + + // /// @name add + // /// @page annotation + // /// @description Allows you to add a different annotation from within a annotation + // /// @arg {string} name - the name of the annotation you want to add + // /// @arg {string} str - information that is passed to the annotation + // const add = (name, contents) => { + // contents = to.normalize(contents) + // return this.run({ + // annotation: { + // name, + // alias: is.in(this.annotations.alias, name) ? this.annotations.alias[name] : [], + // line: to.normalize(contents[0]), + // contents, + // start: null, + // end: null + // }, + // annotation_types, + // ...block, + // log + // }) + // } + + { + const list = this.annotations_list + const { annotation, file } = options + const fn = (list[file.type] || {})[annotation.name] + let default_fn = (list.default || {})[annotation.name] + + if (fn && default_fn && (default_fn = default_fn[type])) { + options.default = () => default_fn.call(options) + } + } + + let details = options + + try { + const fn = this.getAnnotationFn(options.annotation.name, type) + + if (type === 'parse') { + details = copyInvisible(options.annotation, options) + } else if (type === 'resolve') { + details = copyInvisible(options.parsed[options.annotation.name], options) + } + + + let result = is.function(fn) ? fn.call(details) : fn + + if (type === 'parse' && !is.any.undefined(details, result)) { + // copy the details that were used to call the parse function command onto the result + // as `details` this gives the resolve function the ability to access all of the information if needed + if (is.array(result) && result.length === 1) { + result = to.map(result, (obj) => copyInvisible(obj, { details })) + } + + result = copyInvisible(result, { details }) + } + + return result + } catch (e) { + throw new Error(e) + } + + + function copyInvisible(obj, value) { + let _type = to.type(obj) + + switch (_type) { + case 'array': + case 'object': + break + default: + let types = { String, Number, Boolean } + let Type = types[_type.charAt(0).toUpperCase() + _type.slice(1)] + obj = new Type(obj) + } + + // loop over the data and set them to be getters on the + // passed object. This makes them available but they don't show + // up in the console and clutter up all the things + for (var item in value) { + if (value.hasOwnProperty(item)) { + Object.defineProperty(obj, item, { value: value[item] }) + } + } + + // set the prototype to the the passed data + Object.defineProperty(obj, 'prototype', { value }) + return obj + } + } + + getAnnotationFn(name, type) { + let fn = this.annotations + fn = fn[type] || {} + fn = fn[name] || {} + if (is.function(fn)) { + return fn + } + fn = fn[type] || {} + return fn + } + + alias_check() { + for (let i in this.annotation_names) { + if (this.annotation_names.hasOwnProperty(i)) { + let name = this.annotation_names[i] + if (is.in(this.annotation_aliases, name)) { + throw new Error(`${name} is already declared as an annotation`) + return + } + } + } + } +} diff --git a/app/annotation/annotations/access.js b/app/annotation/annotations/access.js deleted file mode 100644 index 4b7055d..0000000 --- a/app/annotation/annotations/access.js +++ /dev/null @@ -1,11 +0,0 @@ -/// @name access -/// @page annotations -/// @description Access of the documented item -/// @returns {string} -export default { - access: { - callback: function(){ - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/alias.js b/app/annotation/annotations/alias.js deleted file mode 100644 index 2e537e2..0000000 --- a/app/annotation/annotations/alias.js +++ /dev/null @@ -1,11 +0,0 @@ -/// @name alias -/// @page annotations -/// @description Whether the documented item is an alias of another item -/// @returns {string} -export default { - alias: { - callback: function(){ - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/arg.js b/app/annotation/annotations/arg.js deleted file mode 100644 index 8e714ee..0000000 --- a/app/annotation/annotations/arg.js +++ /dev/null @@ -1,15 +0,0 @@ -/// @name arg -/// @page annotations -/// @description Parameters from the documented function/mixin -/// @note Description runs through markdown -/// @returns {object} -export default { - arg: { - alias: ["argument", "param", "parameter"], - callback: function(){ // - // add regex for `{type} name-of-variable [default value] - description` - // make sure it supports multiple lines - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/author.js b/app/annotation/annotations/author.js deleted file mode 100644 index 4d3b5ae..0000000 --- a/app/annotation/annotations/author.js +++ /dev/null @@ -1,7 +0,0 @@ -/// @name author -/// @page annotations -/// @description Author of the documented item -/// @returns {string} -export default { - author: {} -}; diff --git a/app/annotation/annotations/chainable.js b/app/annotation/annotations/chainable.js deleted file mode 100644 index d92f2d0..0000000 --- a/app/annotation/annotations/chainable.js +++ /dev/null @@ -1,11 +0,0 @@ -/// @name chainable -/// @page annotations -/// @description Used to notate that a function is chainable -/// @returns {boolean} -export default { - chainable: { - callback: function(){ - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/construct.js b/app/annotation/annotations/construct.js deleted file mode 100644 index 49203c2..0000000 --- a/app/annotation/annotations/construct.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name constructor -/// @page annotations -/// @description Describes the type of a variable -/// @returns {boolean} -export default { - construct: { - alias: ["constructor"], - callback: function(){ - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/deprecated.js b/app/annotation/annotations/deprecated.js deleted file mode 100644 index a69ad32..0000000 --- a/app/annotation/annotations/deprecated.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name deprecated -/// @page annotations -/// @description Lets you know that a mixin/function has been depricated -/// @returns {string} -export default { - deprecated: { - callback: function(){ - // add regex for `{version} - description` - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/description.js b/app/annotation/annotations/description.js deleted file mode 100644 index 45b8aff..0000000 --- a/app/annotation/annotations/description.js +++ /dev/null @@ -1,13 +0,0 @@ -import {to} from "../../utils.js"; -/// @name description -/// @page annotations -/// @description Description of the documented item -/// @note Runs through markdown -/// @returns {string} -export default { - description: { - callback: function(){ - return to.markdown(this.annotation.line ? this.annotation.line + "\n" + this.annotation.contents : this.annotation.contents); - } - } -}; diff --git a/app/annotation/annotations/index.js b/app/annotation/annotations/index.js deleted file mode 100644 index 6888206..0000000 --- a/app/annotation/annotations/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import {to} from "../../utils"; -// Exports out all the annotations in this folder -let result = {}, - annotations = [ - require("./access.js"), - require("./alias.js"), - require("./arg.js"), - require("./author.js"), - require("./chainable.js"), - require("./construct.js"), - require("./deprecated.js"), - require("./description.js"), - require("./markup.js"), - require("./name.js"), - require("./note.js"), - require("./page.js"), - require("./readonly.js"), - require("./requires.js"), - require("./returns.js"), - require("./since.js"), - require("./state.js"), - require("./todo.js"), - require("./type.js"), - require("./version.js"), - ]; - -for(let i in annotations){ - to.extend(result, annotations[i]); -} - -module.exports = result; diff --git a/app/annotation/annotations/markup.js b/app/annotation/annotations/markup.js deleted file mode 100644 index daa1e7b..0000000 --- a/app/annotation/annotations/markup.js +++ /dev/null @@ -1,13 +0,0 @@ -/// @name markup -/// @page annotations -/// @description Code for the documented item -/// @note Description is parsed as markdown -/// @returns {object} -export default { - markup: { - callback: function(){ - // add regex for `{language} [settings] - description` - return this.annotation.contents; - } - } -}; diff --git a/app/annotation/annotations/name.js b/app/annotation/annotations/name.js deleted file mode 100644 index f109fc8..0000000 --- a/app/annotation/annotations/name.js +++ /dev/null @@ -1,9 +0,0 @@ -/// @name name -/// @page annotations/name -/// @description Name of the documented item -/// @returns {string} -export default { - name: { - alias: ["title", "heading"] - } -}; diff --git a/app/annotation/annotations/note.js b/app/annotation/annotations/note.js deleted file mode 100644 index 27c2569..0000000 --- a/app/annotation/annotations/note.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name note -/// @page annotations -/// @description A note about the documented item -/// @returns {object} -export default { - note: { - callback: function(){ - // add regex for `{7} - A note` - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/page.js b/app/annotation/annotations/page.js deleted file mode 100644 index 4209fd0..0000000 --- a/app/annotation/annotations/page.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name page -/// @page annotations -/// @description The page you want the documented item to be on -/// @returns {string} -export default { - page: { - alias: ["group"], - callback: function(){ - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/readonly.js b/app/annotation/annotations/readonly.js deleted file mode 100644 index 40f2c1e..0000000 --- a/app/annotation/annotations/readonly.js +++ /dev/null @@ -1,11 +0,0 @@ -/// @name readonly -/// @page annotations -/// @description To note that a property is readonly -/// @returns {boolean} -export default { - readonly: { - callback: function(){ - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/requires.js b/app/annotation/annotations/requires.js deleted file mode 100644 index 5c826f1..0000000 --- a/app/annotation/annotations/requires.js +++ /dev/null @@ -1,13 +0,0 @@ -/// @name requires -/// @page annotations -/// @description Requirements from the documented item -/// @returns {object} -export default { - requires: { - alias: ["require"], - callback: function(){ - // add regex for {type} item - description - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/returns.js b/app/annotation/annotations/returns.js deleted file mode 100644 index 202fbde..0000000 --- a/app/annotation/annotations/returns.js +++ /dev/null @@ -1,13 +0,0 @@ -/// @name returns -/// @page annotations -/// @description Return from the documented function -/// @returns {string} -export default { - returns: { - alias: ["return"], - callback: function(){ // return - // add regex for `{type} - description`. Also ensure it supports multiple lines - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/since.js b/app/annotation/annotations/since.js deleted file mode 100644 index c25db64..0000000 --- a/app/annotation/annotations/since.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name since -/// @page annotations -/// @description Let's you know what version of the project a something was added -/// @returns {string} -export default { - since: { - callback: function(){ - // add regex for `{type} - description` - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/state.js b/app/annotation/annotations/state.js deleted file mode 100644 index b65ce4d..0000000 --- a/app/annotation/annotations/state.js +++ /dev/null @@ -1,14 +0,0 @@ -/// @name state -/// @page annotations -/// @description A state of a the documented item -/// @returns {object} -export default { - state: { - callback: function(){ - // add regex for `modifier - description` - // should consider supporting multiple lines - // should `modifier` change to be `{modifier}` since it's sorta like `type`? - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/todo.js b/app/annotation/annotations/todo.js deleted file mode 100644 index 8608c1d..0000000 --- a/app/annotation/annotations/todo.js +++ /dev/null @@ -1,13 +0,0 @@ -/// @name todo -/// @page annotations -/// @description Things to do related to the documented item -/// @returns {object} -export default { - todo: { - callback: function(){ - // add regex for {5} [assignee-one, assignee-two] - Task to be done - // make sure it supports multiple lines - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/type.js b/app/annotation/annotations/type.js deleted file mode 100644 index 3a1f442..0000000 --- a/app/annotation/annotations/type.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name type -/// @page annotations -/// @description Describes the type of a variable -/// @returns {string} -export default { - type: { - callback: function(){ - // add regex for `{type} - description` - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/version.js b/app/annotation/annotations/version.js deleted file mode 100644 index 451d178..0000000 --- a/app/annotation/annotations/version.js +++ /dev/null @@ -1,12 +0,0 @@ -/// @name version -/// @page annotations -/// @description Describes the type of a variable -/// @returns {string} -export default { - version: { - callback: function(){ - // add regex for `{type} - description` - return this.annotation.line; - } - } -}; diff --git a/app/annotation/index.js b/app/annotation/index.js deleted file mode 100644 index 4d995aa..0000000 --- a/app/annotation/index.js +++ /dev/null @@ -1,197 +0,0 @@ -"use strict"; - -import annotations from "./annotations"; -import {is, to} from "../utils.js"; - -export default class AnnotationApi{ - constructor(){ - // object of the all the annotation - // This object holds all the annotations - this.annotations = { - default: { - // holds all default annotations for all filetypes that aren't - // specific to an individual filetype. - } - // You can add file specific overrides if you need to. All you have - // to do is specific the filetype as the key(aka replace default with the filetype) - // js: { - // annotation - // } - }; - - // adds the default annotations to the list - this.add_annotations(annotations); - }; - - /// @name add - /// @description - /// Adds a single annotation to the list - /// - /// @arg {string, array} annotation - Name of the annotation - /// @arg {function, object} callbacks [annotation_base.callbacks] - Functions - /// @arg {string} ...alias - the rest of the arguments are alias - /// - /// @returns {this} - /// - /// @markup {js} **Example:** Declaring a basic annotation - /// docs.annotation.add("name", function(){ - /// return this.annotation.line; - /// }); - /// - /// @markup {js} **Example:** Declaring a annotation with more options - /// docs.annotation.add("name", { - /// alias: ["title", "heading"], - /// callback: function(){ - /// return this.annotation.line; - /// }, - /// autofill: false, - /// resolve: false - /// }); - /// - /// @markup {js} **Example** Specifing a file specific annotation - /// docs.annotation.add("promise", { - /// // the filetypes passed will use the `callback` and the other - /// // settings in the config. It can be a string or an array of - /// // filetypes. Note that if a filetype isn't specificed it defaults - /// // to be `"default"` which will apply to all files. - /// filetype: ["js", "jsx", "es", "es6", "es7"], - /// callback: function(){ - /// return this.annotation.line; - /// }, - /// ... - /// }); - /// - /// @markup {js} **Example** Specifing a file specific annotation(Option 2) - /// This is very useful - /// docs.annotation.add("name", { - /// default: { // for all filetypes that aren't defined for this annotation - /// callback: function(){ - /// return this.annotation.line; - /// }, - /// ... - /// }, - /// js: { // use the file extention - /// } - /// }); - add(name, config){ - // stores the current annotation that is being added - // to the annotations list. - // the name of the annotation is always the key - const base_config = { - // this declares where this annotation get's applied - filetypes: ["default"], - - // holds an array of aliases for the given annotation - alias: [], - - // This function runs when the parser gets - // the annotations information - callback: function(){ - return this.annotation.line; - }, - - // Runs when the each annotation in the block has been - // parsed. If the annotation doesn't exist and the autofill - // is set to be a function then autofill get's called, and - // the block and file info are accessible within `this` if - // it is a function.`. **Note** this will not run if the - // annotation exists - autofill: false, - - // Runs after the callback and/or autofill runs the contents - // of `this` is what was returned by the callback and/or autofill. - // It's used to fixed data that was returned by callback. - // It helps when members on your team pass in the wrong keyword(s) - // and let's you resolve them here in the data instead of resolving - // the issues on the client side. It's also useful if you want want - // to ensure the data always returns an `array`. - resolve: false - }; - - // a) throw an error - if(!is.string(name)){ - throw new Error("name must be a string"); - return; - } - - // a) set the passed `array` as the `alias` - // b) set the passed `function` as the `callback` function - // c) it's a filetype specific `object` - // d) throw an error - if(is.array(config)){ - config = { - alias: config - }; - } - else if(is.function(config)){ - config = { - callback: config - }; - } - else if(is.object(config) && !is.empty(config) && !is.any.in(config, ...to.keys(base_config))){ - // loop through each filetype in the passed - // object and rerun the add function - for(let filetype in config){ - let obj = config[filetype]; - obj.filetypes = is.in(obj, "filetype") ? to.array.flat([filetype, config.filetype]) : to.array(filetype); - this.add(name, obj); - } - return; - } - else if(!is.object(config)){ - throw new Error("config must be a function or object"); - return; - } - - // merge the passed `config` with the base config - // to ensure all settings are defined. - to.merge(base_config, config); - - // merge the passed annotation with the - // global list of annotations by filetype/default - for(var filetype in base_config.filetypes){ - to.merge(this.annotations, { - [is.falsy(base_config.filetypes[filetype]) ? "default" : base_config.filetypes[filetype]]: { - [name]: base_config - } - }); - } - - return this; - }; - - /// @description - /// Add an array of annotations - /// @arg {array} annotations - Annotation objects - add_annotations(annotations){ - for(let name in annotations){ - this.add(name, annotations[name]); - } - }; - - /// @name list - /// @description - /// This gets the annotations to use for the current filetype. - /// Basically the file specific annotations get extended onto the default annotations - /// @returns {object} - the annotations to use for the current file - list(filetype){ - return !is.undefined(this.annotations[filetype]) ? to.extend(to.clone(this.annotations.default), this.annotations[filetype]) : this.annotations.default; - }; - - /// @name file_list - /// @description Gets the full list of annotations by filetype - /// @returns {object} - get file_list(){ - return this.annotations; - }; - - alias_check(){ - for(let i in this.annotation_names){ - let name = this.annotation_names[i]; - if(is.in(this.annotation_aliases, name)){ - throw new Error(`${name} is already declared as an annotation`); - return; - } - } - } -}; diff --git a/app/annotations/access.js b/app/annotations/access.js new file mode 100644 index 0000000..6eeb942 --- /dev/null +++ b/app/annotations/access.js @@ -0,0 +1,36 @@ +/// @name @access +/// @page annotations +/// @arg {string} line [public] - public, private, protected +/// @description +/// Access of the documented item. If access isn't declared then it defaults to public. +/// @markup Usage +/// /// @access public +/// +/// /// @access private +/// +/// /// @access protected +/// @note This is autofilled on every comment block +export default { + autofill() { + let access = 'public' + try { + if (this.comment.type === 'inline') { + access = this.parent.parsed.access + } + } catch (e) { + // do nothing + } + return access + }, + parse() { + const line = `${this.annotation.contents[0]}` + if ( + line === 'private' || + line === 'protected' + ) { + return line + } + + return 'public' + } +} diff --git a/app/annotations/alias.js b/app/annotations/alias.js new file mode 100644 index 0000000..5618c8e --- /dev/null +++ b/app/annotations/alias.js @@ -0,0 +1,25 @@ +import { is } from '../utils' +import { list, logAnnotationError } from './annotation-utils' + +/// @name @alias +/// @page annotations +/// @arg {string, list} line - The aliases to that are avaliable for this documented item +/// @description Whether the documented item is an alias of another item +/// @returns {array} +/// @markup Usage +/// /// @alias foo +/// +/// /// @alias foo, bar +/// +/// /// @alias foo +/// /// @alias bar +export default { + parse() { + let alias_list = list(this.annotation.contents[0] || '') + if (is.empty(alias_list)) { + this.log.emit('warning', "You didn't pass in an alias to @alias on", logAnnotationError(this, '@alias name[, name]')) + } + + return alias_list + } +} diff --git a/app/annotations/annotation-utils.js b/app/annotations/annotation-utils.js new file mode 100644 index 0000000..8ff1a8f --- /dev/null +++ b/app/annotations/annotation-utils.js @@ -0,0 +1,192 @@ +import { is, to } from '../utils' +import clor from 'clor' + +// holds all the base regex expressions for the annotations +// They're broken down so they can be reused instead of writing the same +// regexp over and over with slightly different variations +let regexes + +{ + const types = '(?:{(.*)})?' + const name = '([^\\s]*)?' + const space = '(?:\\s*)?' + const value = '(?:\\[(.*)\\])?' + const id = '(?:\\((.*)\\))?' + const description = '(?:\\s*\\-?\\s+)?(.*)?' + + let rg = {} + + rg.arg = + rg.property = to.regex(types, space, name, space, value, space, description, 'i') + + rg.markup = to.regex(id, space, types, space, value, space, description, 'i') + + rg.deprecated = + rg.note = + rg.throws = + rg.returns = + rg.since = + rg.type = + rg.version = to.regex(types, space, description, 'i') + + rg.requires = to.regex(types, space, name, description, 'i') + + rg.state_id = to.regex(id, space, '(.*)', 'i') + + rg.state = + rg.todo = to.regex(types, space, value, space, description, 'i') + + regexes = rg +} + +export function regex(name, str) { + return regexes[name].exec(`${str}`).slice(1) +} + +function list(arg) { + if (is.array(arg)) { + return to.map(arg, list) + } + + if (arg == null) { + return [] + } + + return to.array(`${arg}`, ',').map((item) => item.trim()).filter(Boolean) +} + +export { list } + +export function toBoolean(contents) { + let line = `${contents[0]}` + if (!is.empty(contents.slice(1))) { + return undefined + } + + if (line === 'false') { + return false + } else if ( + is.undefined(line) || + line.length === 0 || + line === 'true' + ) { + return true + } + + return undefined +} + +export function logAnnotationError(obj, expected) { + expected = to.array(expected) + const { + annotation, + comment, + code, + file, + options + } = obj + + const total_lines = ~~((11 + (annotation.end - annotation.start)) / 2) + + let indent = ' ' + indent += ' ' + + const getSpaces = (number) => (number + '').split('').filter(Boolean).map(() => ' ').slice(1).join('') + + comment.contents = to.array(comment.contents) + code.contents = to.array(code.contents) + + // used to modifiy the indention of numbers so that they align to the right + let modifier = getSpaces(file.end) + let temp_contents = to.flatten([ comment.contents, code.contents ]) + let comment_style = options.language[comment.type].single + // The line below should get the correct length but it currently doesn't + // let total_comment_lines = comment.end - comment.start + let total_comment_lines = comment.contents.length - 1 + let contents = [] + let expected_contents = [] + + + // @todo the code block doesn't return the correct number in some cases + code.end = code.end > -1 ? code.end : file.end + + for (let i = comment.start; i < code.end; i++) { + let index = i - comment.start + let line = temp_contents[index] + let line_number = i + 1 + let is_in_comment = is.between(index, 0, total_comment_lines) + // let + + if (getSpaces(line_number) === modifier) { + modifier = modifier.slice(1) + } + + if (is.between(index, annotation.start, annotation.end)) { + let expected_line = expected[index - annotation.start] + + if (expected_line) { + contents.push( + `${indent.slice(2)}${clor.red('-')} ${modifier}${clor.red(line_number)} | ${comment_style} ${clor.bgRed(line)}` + ) + expected_contents.push( + `${indent.slice(2)}${clor.green('+')} ${modifier}${clor.green(line_number)} | ${comment_style} ${clor.bgGreen(expected_line)}` + ) + } + + if ( + expected_contents !== undefined && ( + !expected_line || + index === annotation.end + ) + ) { + contents.push(...expected_contents) + expected_contents = undefined + } + + if (!expected_line) { + contents.push( + `${indent}${modifier}${line_number} | ${comment_style} ${line}` + ) + } + } else { + if (is_in_comment) { + line = `${comment_style} ${line}` + } + contents.push(`${indent}${modifier}${line_number} | ${line}`) + } + } + + // trim the contents so there's not to much showing + contents = contents.slice( + to.clamp(annotation.start - total_lines, 0, contents.length), + to.clamp(annotation.end + total_lines, 0, contents.length) + ) + + + contents.unshift(...[ + '', + `${indent}${clor.bold(file.path)}`, // adds the file path of the error + `${indent}${clor.green('+ expected')} ${clor.red('- actual')}`, // adds a legend + '' + ]) + contents.push(...[ '', '' ]) + + return contents.join('\n') +} + + +export function escape(arg) { + return to.array(arg) + .map((line) => { + return line.replace(/[&<>'"]/g, (match) => { + return { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' + }[match] + }) + }) + .join('\n') +} diff --git a/app/annotations/arg.js b/app/annotations/arg.js new file mode 100644 index 0000000..b2bcad9 --- /dev/null +++ b/app/annotations/arg.js @@ -0,0 +1,35 @@ +import { regex, list } from './annotation-utils' +import { to } from '../utils' + +/// @name @arg +/// @page annotations +/// @description Parameters from the documented function/mixin +/// @note Description runs through markdown +/// @returns {object} +/// @markup Usage +/// /// @param {type} name +/// /// @param {type, othertype} name +/// /// @param {type} name - description +/// /// @param {type} name description +/// /// @param {type} name [default value] - description +export default { + alias: [ 'argument', 'param', 'parameter' ], + parse() { + let { contents } = this.annotation + let [ + types = [], + name = '', + value = '', + description = '', + ] = regex('arg', contents.shift() || '') + + return [ + { + types: list(types), + name, + value, + description: to.markdown(description, contents) + } + ] + } +} diff --git a/app/annotations/author.js b/app/annotations/author.js new file mode 100644 index 0000000..e76a94c --- /dev/null +++ b/app/annotations/author.js @@ -0,0 +1,19 @@ +import { list } from './annotation-utils' +/// @name @author +/// @page annotations +/// @alias @authors +/// @description Author of the documented item +/// @returns {string} +/// @markup Usage +/// /// @author Author's name +/// +/// /// @author Author One, Author Two +/// +/// /// @author Author One +/// /// @author Author Two +export default { + alias: [ 'authors' ], + parse() { + return list(this.annotation.contents) + } +} diff --git a/app/annotations/blockinfo.js b/app/annotations/blockinfo.js new file mode 100644 index 0000000..b1b1a97 --- /dev/null +++ b/app/annotations/blockinfo.js @@ -0,0 +1,55 @@ +import { to, is } from '../utils' +import { logAnnotationError } from './annotation-utils' +import path from 'path' +/// @name blockinfo +/// @page annotations +/// @description +/// This annotation is a special one in that it's only autofilled, and it adds +/// information about the current block +/// +/// Here's an example of the information that it returns +/// +/// ``` +/// "blockinfo": { +/// "comment": { +/// "start": 1, +/// "end": 3, +/// "type": "header" +/// }, +/// "code": { +/// "start": -1, +/// "end": -1 +/// }, +/// "file": { +/// "path": "docs/tests/annotations/access/access.header.js", +/// "start": 1, +/// "end": 4 +/// } +/// } +/// ``` +const root = process.cwd() +const root_dir = root.split(path.sep).pop() +export default { + autofill() { + let obj = to.clone(this) + let comment = obj.comment + delete comment.contents + + let code = obj.code + delete code.contents + + const file_filter = [ 'contents', 'name', 'type', 'comment', 'options' ] + let file = to.filter(obj.file, ({ key }) => !is.in(file_filter, key)) + // this ensures that the path that's displayed is always relative + file.path = path.normalize(file.path) + if (path.isAbsolute(file.path)) { + file.path = path.join(root_dir, file.path.replace(root, '')) + } + + return { comment, code, file } + }, + parse() { + this.log.emit('warning', "Passed @blockinfo, it's only supposed to be an autofilled annotation", logAnnotationError(this, '')) + return + } +} diff --git a/app/annotations/chainable.js b/app/annotations/chainable.js new file mode 100644 index 0000000..99e4709 --- /dev/null +++ b/app/annotations/chainable.js @@ -0,0 +1,29 @@ +import { toBoolean, list } from './annotation-utils' + +/// @name @chainable +/// @page annotations +/// @alias @chain +/// @description Used to notate that a function is chainable +/// @returns {boolean, array} +/// @markup Usage +/// // this will return true +/// /// @chainable +/// +/// /// @chainable false +/// +/// /// @chainable true +/// +/// /// @chainable jQuery +/// +/// /// @chainable Something, Something else +export default { + alias: [ 'chain' ], + parse() { + const { contents } = this.annotation + let bool = toBoolean(contents) + if (bool !== undefined) { + return bool + } + return list(contents) + } +} diff --git a/app/annotations/deprecated.js b/app/annotations/deprecated.js new file mode 100644 index 0000000..b60b884 --- /dev/null +++ b/app/annotations/deprecated.js @@ -0,0 +1,30 @@ +import { regex } from './annotation-utils' +import { to } from '../utils' +/// @name @deprecated +/// @page annotations +/// @description Lets you know that a mixin/function has been depricated +/// @returns {object} +/// @markup Usage +/// /// @deprecated +/// +/// /// @deprecated description +/// +/// /// @deprecated {version} - description +/// +/// /// @deprecated {version} description +/// +/// /// @deprecated {version} +/// description +/// +/// /// @deprecated {version} description +/// /// more of the description +export default { + parse() { + let { contents } = this + let [ version = '0', description = '' ] = regex('deprecated', contents.shift() || '') + return { + version, + description: to.markdown(description, contents) + } + } +} diff --git a/app/annotations/description.js b/app/annotations/description.js new file mode 100644 index 0000000..f9e6bd2 --- /dev/null +++ b/app/annotations/description.js @@ -0,0 +1,24 @@ +import { to } from '../utils' + +/// @name @description +/// @page annotations +/// @alias @desc, @definition, @explanation, @writeup, @summary, @summarization +/// @description Description of the documented item +/// @note Runs through markdown +/// @returns {string} +/// @markup Usage +/// /// @description description +/// +/// /// @description +/// /// # Long description. +/// /// Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed +/// /// do eiusmod tempor incididunt ut labore et dolore magna aliqua. +export default { + alias: [ + 'desc', 'definition', 'explanation', + 'writeup', 'summary', 'summarization' + ], + parse() { + return to.markdown(this.annotation.contents) + } +} diff --git a/app/annotations/index.js b/app/annotations/index.js new file mode 100644 index 0000000..99114d0 --- /dev/null +++ b/app/annotations/index.js @@ -0,0 +1,24 @@ +export access from './access' +export alias from './alias' +export arg from './arg' +export author from './author' +export blockinfo from './blockinfo' +export chainable from './chainable' +export deprecated from './deprecated' +export description from './description' +export markdown from './markdown' +export markup from './markup' +export name from './name' +export note from './note' +export page from './page' +export property from './property' +module.exports['raw-code'] = require('./raw-code.js') +export readonly from './readonly' +export requires from './requires' +export returns from './returns' +export since from './since' +export states from './states' +export throws from './throws' +export todo from './todo' +module.exports.type = require('./type') +export version from './version' diff --git a/app/annotations/markdown.js b/app/annotations/markdown.js new file mode 100644 index 0000000..131422f --- /dev/null +++ b/app/annotations/markdown.js @@ -0,0 +1,35 @@ +import { to } from '../utils' + +/// @name @markdown +/// @page annotations +/// @filetypes @markdown, @mark, @mdown, @mkdn, @mdtxt, @mkd, @mdml, @mdwn, @mdtext, @text, @md +/// @description +/// This markdown annotation is used to add a markdown files contents to the documentation. +/// It's typically only used in a header comment along with `@page`. +/// +/// @note +/// On a side note, I have absolutly no idea why markdown has to many different file types +/// but I think I got all of them but If I missed open an issue or submit a pull request +/// +/// @returns {string} The parsed markdown file +/// +/// @markup Usage +/// +export default { + filetypes: [ + 'markdown', 'mark', 'mdown', + 'mkdn', 'mdtxt', 'mkd', + 'mdml', 'mdwn', 'mdtext', + 'text', 'md' + ], + parse() { + const { header, body } = this.options.language + const start = `(?:${header.start}|${body.start})`.replace('\\', '\\\\') + const end = `(?:${header.end}|${body.end})`.replace('\\', '\\\\') + const md_regex = new RegExp(`${start}(?:.|\\n)*\\n${end}`, 'gmi') + + return to.markdown(this.file.contents.replace(md_regex, '')) + } +} diff --git a/app/annotations/markup.js b/app/annotations/markup.js new file mode 100644 index 0000000..9bc7710 --- /dev/null +++ b/app/annotations/markup.js @@ -0,0 +1,101 @@ +import { is, to } from '../utils' +import { regex, list, escape } from './annotation-utils' +/// @name @markup +/// @page annotations +/// @alias @code, @example, @output, @outputs +/// @description +/// Example code on how to use the documented block. +/// +/// - `id` is a way for a `@state` annotation to specify which `@markup` annotation it's state(s) should be applied to. +/// - `language` The language you're documenting. It defaults to the current file extention +/// - `settings` Settings that are passed to the code block +/// - `description` A short description of the documented item that is parsed in markdown +/// +/// @note Description is parsed as markdown +/// @returns {object} +/// ```js +/// { +/// id: 'string', // id of the markup block, it defaults to '0' +/// language: 'string', // language of the block, defaults to +/// settings: {}, // settings for the code block +/// description: 'string', +/// raw: 'string', // raw string of code +/// raw_stateless: 'string', // same as the raw string but without `@state` references +/// escaped: 'string', // escaped code, aka `` turns to `<span>` +/// escaped_stateless: 'string', // same as the escaped string but without `@state` references +/// } +/// ``` +/// @markup Usage +/// /// @markup +/// /// code +/// +/// /// @markup (id) +/// /// code +/// +/// /// @markup {language} +/// /// code +/// +/// /// @markup [settings] +/// /// code +/// +/// /// @markup description +/// /// code +/// +/// /// @markup (id) {language} [settings] - description +/// /// code +/// +/// /// @markup (id) {language} [settings] description +/// /// code +export default { + alias: [ 'code', 'example', 'output', 'outputs' ], + parse() { + let { contents } = this + let [ + id = null, + language = this.file.type, + settings = {}, + description + ] = regex('markup', contents.shift() || '') + + let raw = to.string(contents) + let escaped = escape(raw) + let state_interpolation + + { + const { interpolation, prefix } = this.options.language + const { start, end } = interpolation + + state_interpolation = `${start}${prefix}states?[^${end}]*${end}` + } + + state_interpolation = new RegExp(`\\s*${state_interpolation}\\s*`, 'gi') + let raw_stateless = raw.replace(state_interpolation, '') + let escaped_stateless = escaped.replace(state_interpolation, '') + + if (is.string(settings)) { + settings = to.object(list(settings).map((setting) => setting.split('='))) + } + + + let result = { + id, + language, + settings, + description: to.markdown(description), + raw, + escaped, + raw_stateless, + escaped_stateless, + } + + return [ result ] + }, + resolve() { + return to.map(this, (obj, i) => { + if (obj.id === null) { + obj.id = `${i}` + } + return obj + }) + } +} diff --git a/app/annotations/name.js b/app/annotations/name.js new file mode 100644 index 0000000..20e22ba --- /dev/null +++ b/app/annotations/name.js @@ -0,0 +1,14 @@ +/// @name @name +/// @page annotations +/// @alias @title, @heading, @header +/// @description Name of the documented item +/// @returns {string} +/// +/// @markup Usage +/// /// @name Name of the documented item +export default { + alias: [ 'title', 'heading', 'header' ], + parse() { + return `${this.annotation.contents[0]}` + } +} diff --git a/app/annotations/note.js b/app/annotations/note.js new file mode 100644 index 0000000..d370fd9 --- /dev/null +++ b/app/annotations/note.js @@ -0,0 +1,32 @@ +import { regex } from './annotation-utils' +import { to } from '../utils' +/// @name @note +/// @page annotations +/// @alias @notes +/// @description A note about the documented item +/// @returns {object} +/// +/// @markup Usage +/// /// @note description +/// +/// /// @note {importance} description +/// +/// /// @note {importance} +/// /// multi +/// /// line +/// /// description +export default { + alias: [ 'notes' ], + parse() { + let { contents } = this.annotation + let line = contents.shift() + let [ importance = '0', description = '' ] = regex('note', line || '') + + return [ + { + importance, + description: to.markdown(description, contents) + } + ] + } +} diff --git a/app/annotations/page.js b/app/annotations/page.js new file mode 100644 index 0000000..af8cfa2 --- /dev/null +++ b/app/annotations/page.js @@ -0,0 +1,55 @@ +import { list } from './annotation-utils' + +/// @name @page +/// @page annotations +/// @alias @group +/// @description The page you want the documented item to be on +/// @note {5} +/// If a header comment exists in a file without a `@page` annotation +/// it will be auto filled to other. +/// +/// @note {10} +/// The `@page` attribute is one of the most important annotations because +/// it is what determines where your documentation for each file or block will go +/// in the documentation site. If you fail to have a header comment, and don't add +/// a `@page` annotation to your body comment then that documentation block will +/// be ignored if `options.raw` is `false` +/// +/// @notes {10} +/// #### Usage +/// - If you specify a `@page` annotation in the header comment, all the body blocks on the page +/// will also be added to that page. +/// - If you want all the documentation for a specific file to be in multiple locations you can add +/// multiple pages to the header comment +/// - If you want a specific body comment block to go to a page you can just add a `@page` annotation, +/// and it will get added to the page specified in the header comment and the page that's specified +/// in the body comment block +/// +/// @returns {array} +/// +/// @markup Usage +/// //// +/// /// @page path +/// //// +/// +/// /// @page path +/// +/// /// @page add-block/to/location 1 +/// /// @page also/add-block/to/location 2 +/// +/// /// @page add-block/to/location 1, also/add-block/to/location 2 +import { to } from '../utils' +export default { + alias: [ 'group' ], + parse() { + return list(this.annotation.contents[0] || '') + }, + autofill() { + // autofill header comments + if (this.comment.type === 'header') { + return [ this.options.page_fallback ] + } + // don't autofill body comments + return + } +} diff --git a/app/annotations/property.js b/app/annotations/property.js new file mode 100644 index 0000000..229d89f --- /dev/null +++ b/app/annotations/property.js @@ -0,0 +1,35 @@ +import { regex, list } from './annotation-utils' +import { to } from '../utils' + +/// @name @property +/// @page annotations +/// @description A property from the documented object/array +/// @note Description runs through markdown +/// @returns {object} +/// @markup Usage +/// /// @property {type} name +/// /// @property {type, othertype} name +/// /// @property {type} name - description +/// /// @property {type} name description +/// /// @property {type} name [key list] - description +export default { + alias: [ 'prop', 'key' ], + parse() { + let { contents } = this.annotation + let [ + types = [], + name = '', + value = '', + description = '', + ] = regex('property', contents.shift() || '') + + return [ + { + types: list(types), + name, + value, + description: to.markdown(description, contents) + } + ] + } +} diff --git a/app/annotations/raw-code.js b/app/annotations/raw-code.js new file mode 100644 index 0000000..d10dd2c --- /dev/null +++ b/app/annotations/raw-code.js @@ -0,0 +1,13 @@ +import { escape } from './annotation-utils' +import { to } from '../utils' +/// @name @raw-code +/// @page annotations +/// @description +/// This will output the raw code below the comment block +/// @returns {object} +export default { + parse() { + const raw = to.string(this.code.contents) + return { raw, escaped: escape(raw) } + } +} diff --git a/app/annotations/readonly.js b/app/annotations/readonly.js new file mode 100644 index 0000000..bf651bb --- /dev/null +++ b/app/annotations/readonly.js @@ -0,0 +1,27 @@ +import { toBoolean } from './annotation-utils' + +/// @name @readonly +/// @page annotations +/// @description +/// To note that a property is readonly. +/// @returns {boolean} +/// +/// @note {5} If `@readonly` is present without any arguments it will return `true` +/// +/// @markup Usage +/// /// @readonly +/// +/// /// @readonly true +/// +/// /// @readonly false +export default { + parse() { + let bool = toBoolean(this.annotation.contents) + + if (bool !== undefined) { + return bool + } + + return true + } +} diff --git a/app/annotations/requires.js b/app/annotations/requires.js new file mode 100644 index 0000000..e0c21d1 --- /dev/null +++ b/app/annotations/requires.js @@ -0,0 +1,34 @@ +import { regex, list } from './annotation-utils' +import { to } from '../utils' + +/// @name @requires +/// @page annotations +/// @alias @require +/// @description Requirements from the documented item +/// @returns {object} +/// +/// @markup Usage +/// /// @requires {type[, type]} +/// +/// /// @requires name +/// +/// /// @requires description +/// +/// /// @requires {type[, type]} name - description +/// +/// /// @requires {type[, type]} name description +export default { + alias: [ 'require' ], + parse() { + let { contents } = this.annotation + const [ types, name = '', description ] = regex('requires', contents.shift() || '') + + return [ + { + types: list(types), + name, + description: to.markdown(description, contents) + } + ] + } +} diff --git a/app/annotations/returns.js b/app/annotations/returns.js new file mode 100644 index 0000000..e336f34 --- /dev/null +++ b/app/annotations/returns.js @@ -0,0 +1,40 @@ +import { regex, list } from './annotation-utils' +import { to } from '../utils' + +/// @name @returns +/// @page annotations +/// @alias @return +/// @description Return from the documented function +/// @returns {string} +/// @markup Usage +/// /// @returns +/// +/// /// @returns {type[, type]} +/// +/// /// @returns {type[, type]} - description +/// +/// /// @returns {type[, type]} description +/// +/// /// @returns {type[, type]} +/// /// multi +/// /// line +/// /// description +export default { + alias: [ 'return' ], + parse() { + let { contents } = this.annotation + let [ types, description ] = regex('returns', contents.shift() || '') + + if ( + types == null || + types === '' + ) { + types = 'undefined' + } + + return { + types: list(types), + description: to.markdown(description, contents) + } + } +} diff --git a/app/annotations/since.js b/app/annotations/since.js new file mode 100644 index 0000000..1144365 --- /dev/null +++ b/app/annotations/since.js @@ -0,0 +1,28 @@ +import { regex } from './annotation-utils' +import { to } from '../utils' +/// @name @since +/// @page annotations +/// @description Let's you know what version of the project a something was added +/// @returns {string} +/// @markup Usage +/// /// @since {version} +/// +/// /// @since {version} - description +/// +/// /// @since {version} description +/// +/// /// @since {version} +/// /// multi +/// /// line +/// /// description +export default { + parse() { + let { contents } = this.annotation + let [ version = 'undefined', description = '' ] = regex('since', contents.shift() || '') + + return { + version, + description: to.markdown(description, contents) + } + } +} diff --git a/app/annotations/states.js b/app/annotations/states.js new file mode 100644 index 0000000..2bc5d9c --- /dev/null +++ b/app/annotations/states.js @@ -0,0 +1,171 @@ +import { is, to } from '../utils' +import { regex } from './annotation-utils' + +/// @name @states +/// @page annotations +/// @alias @state +/// @description A state of a the documented item +/// @returns {hashmap} +/// @note {10} This annotation must be used with @markup +/// @markup Usage +/// /// @state {state} +/// /// @state {state} +/// /// @state {state} +/// /// @state {state} +/// +/// /// @state (id) {state} [state_id] - description +/// /// @state (id) {state} [state_id] - description +/// /// @state (id) {state} [state_id] - description +/// +/// /// @state (id) +/// /// {state} - description +/// /// {state} - description +/// /// {state} - description +/// +/// /// @states (id) +/// /// {state} [state_id] - description +/// /// {state} [state_id] - description +/// /// {state} [state_id] - description +export default { + alias: [ 'state' ], + parse() { + let { contents } = this + let [ markup_id = null, state_line ] = regex('state_id', contents.shift()) + let state = to.flatten(state_line, contents).filter(Boolean) + + state = state.reduce((previous, current, i) => { + let [ state = '', id = `${i}`, description = '' ] = regex('state', current) // eslint-disable-line + return to.extend(previous, { + [id]: { state, description: to.markdown(description) } + }) + }, {}) + + return [ { markup_id, state } ] + }, + resolve() { + const { parsed, log, file, parent } = this + + const is_inline = this.comment.type === 'inline' + return this.reduce((previous, current) => { // eslint-disable-line + let { markup_id, state, details } = current + let markup = (parsed || {}).markup || !is.empty(parent) && parent.parsed.markup // might need to be cloned + let start_at = details.annotation.start // gets the starting point of the current state annotation being parsed + + // throw an error because a state should always be accompanied by a `@markup` block + if (!markup) { + log.emit('error', ` + You must have a @markdown annotation associated with @state + ${this.file.path}:${(current.details || {}).start || this.comment.start} + `) + } else if (is.falsy(markup_id)) { + if (is_inline && !parsed.markup) { + markup = findMarkupById(markup, 'default') || markup[0] + } else { + markup = findMarkupAfter(markup, start_at) + } + markup_id = (markup || {}).id + if (!markup) { + log.emit('error', ` + There's no instance of a '@markup' annotation after line ${start_at} + in ${file.path} + `) + } + } else { + markup = findMarkupById(markup, markup_id) + if (!markup) { + log.emit('error', ` + There's no instance of a '@markup' annotation with an id of ${markup_id}. + in ${file.path} + `) + } + } + + // return just the state and a empty markup block + // because a markup block wasn't found + if (!markup) { + return to.merge(previous, { + [markup_id]: [ { state, markup: {} } ] + }) + } + + // filter out the `raw_stateless`, and `escaped_stateless` keys because this is + // a state so it shouldn't have a stateless instance + markup = to.filter(to.clone(markup), ({ key }) => !is.in(key, 'state')) + + // this allows users to specify interpolations like `@state.description` + // without affecting the actual state output + let _state = to.clone(state) + // this adds the first state to the `_state` object. This allows + // users to write `@state.description` instead of `@state[0].description` + to.extend(_state, _state[to.keys(_state)[0]]) + markup.raw = replaceStates.call(this, markup.raw, _state) + markup.escaped = replaceStates.call(this, markup.escaped, _state) + + return to.merge(previous, { + [markup_id]: [ { state, markup } ] + }) + }, {}) + } +} + +/* eslint-disable no-invalid-this */ +function replaceStates(str, states) { + let state_interpolation, replacement + + { + let names = [ this.annotation.name, ...(this.annotation.alias) ].join('|') + const { interpolation, prefix } = this.options.language + const { start, end } = interpolation + + state_interpolation = new RegExp(`${start}${prefix}(?:${names})[^${end}]*${end}`, 'g') + replacement = new RegExp(`${start}${prefix}(?:${names})|${end}`, 'g') + } + + return str.replace(state_interpolation, (original_match) => { + let match = original_match.replace(replacement, '').slice(1) + + if (!match) { + return states.state + } + + let dot_index = match.indexOf('.') + let bracket_index = match.indexOf('[') + let index = dot_index > bracket_index ? dot_index : bracket_index + + if (index > -1) { + let key = clean(match.slice(0, index)) + let item = clean(match.slice(index)) + return (states[key] || {})[item] + } + + let result = states[clean(match)] + + if (is.plainObject(result)) { + return result.state + } + + return result + }) +} + +function clean(str) { + return str.replace(/[\[\]\.]/g, '') +} + +function findMarkupById(markup, id) { + for (let item of markup) { + if (item.id === id) { + return item + } + } + return +} + +function findMarkupAfter(markup, start_at) { + for (let item of markup) { + if (start_at < item.details.start) { + return item + } + } + return +} diff --git a/app/annotations/throws.js b/app/annotations/throws.js new file mode 100644 index 0000000..45464e5 --- /dev/null +++ b/app/annotations/throws.js @@ -0,0 +1,35 @@ +import { regex, list } from './annotation-utils' +import { to } from '../utils' +/// @name @throws +/// @page annotations +/// @alias @throw, @exception, @error, @catch +/// @description +/// The error that happends if something goes wrong +/// @returns {hashmap} +/// @markup Usage +/// /// @throws {type} +/// +/// /// @throws description +/// +/// /// @throws {type} - description +/// +/// /// @throws {type} description +/// +/// /// @throws +/// /// multi +/// /// line +/// /// description +export default { + alias: [ 'throw', 'exception', 'error', 'catch' ], + parse() { + let { contents } = this.annotation + let [ types, description = '' ] = regex('throws', contents.shift() || '') + + return [ + { + types: list(types), + description: to.markdown(description, contents) + } + ] + } +} diff --git a/app/annotations/todo.js b/app/annotations/todo.js new file mode 100644 index 0000000..96001af --- /dev/null +++ b/app/annotations/todo.js @@ -0,0 +1,42 @@ +import { regex, list } from './annotation-utils' +import { to } from '../utils' + +/// @name @todo +/// @page annotations +/// @description Things to do related to the documented item +/// @returns {object} +/// // todo - {5} [assignee-one, assignee-two] - Task to be done +/// @mrkup Usage +/// /// @todo description +/// +/// /// @todo {importance} - description +/// +/// /// @todo {importance} [assignee[, assignee]] - description +/// +/// /// @todo {importance} [assignee[, assignee]] description +/// +/// /// @todo {importance} [assignee[, assignee]] +/// /// multi +/// /// line +/// /// description +export default { + parse() { + let { contents } = this.annotation + let [ + importance = '0', + assignees, + description = '' + ] = regex('todo', contents.shift() || '') + + return [ + { + importance, + assignees: list(assignees), + description: to.markdown(description, contents) + } + ] + }, + resolve() { + // come back and add a setting that auto creates a todo page + } +} diff --git a/app/annotations/type.js b/app/annotations/type.js new file mode 100644 index 0000000..5f6120c --- /dev/null +++ b/app/annotations/type.js @@ -0,0 +1,39 @@ +import { regex, logAnnotationError } from './annotation-utils' +import { to } from '../utils' +import clor from 'clor' + +/// @name @type +/// @page annotations +/// @description Describes the type of a variable +/// @returns {object} +/// @markup Usage +/// /// @type {type} +/// +/// /// @type {type} description +/// +/// /// @type {type} - description +/// +/// /// @type {type} +/// /// multi +/// /// line +/// /// description +export default { + parse() { + let { contents } = this.annotation + let [ type, description = '' ] = regex('type', contents.shift() || '') + + if (!type) { + this.log.emit( + 'warning', + `You didn't pass in a type to ${clor.bold('@type')}`, + logAnnotationError(this, `@type {type}${description ? ' - ' + description : ''}`) + ) + type = 'undefined' + } + + return { + type, + description: to.markdown(description, contents) + } + } +} diff --git a/app/annotations/version.js b/app/annotations/version.js new file mode 100644 index 0000000..c645b4c --- /dev/null +++ b/app/annotations/version.js @@ -0,0 +1,38 @@ +import { logAnnotationError, regex } from './annotation-utils' +import { to } from '../utils' +import clor from 'clor' + +/// @name @version +/// @page annotations +/// @description Describes the type of a variable +/// @returns {object} +/// @markup Usage +/// /// @version {version} +/// +/// /// @version {version} - description +/// +/// /// @version {version} description +/// +/// /// @version {version} +/// /// multi +/// /// line +/// /// description +export default { + parse() { + let { contents } = this.annotation + let [ version = 'undefined', description = '' ] = regex('version', contents.shift() || '') + + if (version === 'undefined') { + this.log.emit( + 'warning', + `You didn't pass in a version to ${clor.bold('@version ')}`, + logAnnotationError(this, `@version {version}${description ? ' - ' + description : ''}`) + ) + } + + return { + version, + description: to.markdown(description, contents) + } + } +} diff --git a/app/cli.js b/app/cli.js new file mode 100644 index 0000000..487b383 --- /dev/null +++ b/app/cli.js @@ -0,0 +1,82 @@ +/* eslint-disable no-bitwise */ +import pkg from '../package.json' +import { fs, to } from './utils' +import program from 'commander' +import docs from './docs' +import { default_options } from './config' + +export default function cli() { + // helper functions to parse passed options + const to_list = (str) => str.replace(/\s/g, '').split(',').filter(Boolean) + const to_boolean = () => false + const to_number = (str) => ~~str + const root = process.cwd() + + program + .version(pkg.version) + .usage("docs [options] ''") + .description(` + Parse all your documentation, and output a json file. To see all the default options + see @todo add a link to the options + + Note: Put globs quotes \`'.*, app/**/*'\` to avoid issues + `) + .option('-d, --dest [path]', 'Documentation folder', default_options.dest) + .option('-c, --config [path]', 'Path to configuration file', default_options.config) + .option('-i, --ignore ', 'Paths to ignore', to_list, default_options.ignore) + .option('-w, --watch', 'Recompile docs on changes', true, default_options.watch) + .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', default_options.gitignore) + .option('-x, --no-debug', 'Output debugging information', to_boolean, default_options.debug) + .option('-n, --no-warning', 'Output warning messages', to_boolean, default_options.warning) + .option('-m, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, default_options.timestamps) + .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, default_options.blank_lines) + .option('-p, --print', 'This will only print the results instead of outputting them', false) + .option('-r, --raw', 'This prevents the data from each file from being sorted', false) + .option('-t, --dry-run', 'This will run everything without outputting anything', false) + .parse(process.argv) + + + let { + blankLines: blank_lines, + dryRun: dry_run, + print, + ignore, + watch, + gitignore, + debug, + warning, + timestamps, + raw, + dest, + args + } = program + + let files = to.flatten(args.map((arg) => to_list(arg))) + + if (!files.length) { + files = default_options.files + } + + return docs({ + files, + ignore, + gitignore, + dest, + debug, + warning, + timestamps, + raw, + blank_lines, + watch, + }) + .then((parsed) => { + if (print) { + console.log(to.json(parsed)) + } else if (dry_run) { + // do nothing + } else { + fs.outputJson(dest, parsed, { spaces: 2 }) + } + }) + .catch((err) => console.error(err.stack)) +} diff --git a/app/config.js b/app/config.js new file mode 100644 index 0000000..16d172d --- /dev/null +++ b/app/config.js @@ -0,0 +1,243 @@ +/* eslint-disable guard-for-in */ +import { fs, is, to, Logger } from './utils' +import path from 'path' +import * as annotations from './annotations' +import clor from 'clor' +let log = new Logger() + +// changed by `options` key +export const default_options = { + config: `${process.cwd()}/.docsfile.js`, + + // files to parse for documentation + files: [ 'app/**/*', 'src/**/*', '*.md' ], + + // files to be ignored + ignore: [ + '.*', // all dot files + 'node_modules/', 'bower_components/', 'jspm_packages/', // package managers + 'dist/', 'build/', 'docs/', // normal folders + 'tests/', 'coverage/' // unit tests and coverage results + ], + + // when true it will watch files for changes + watch: false, + + dest: `${process.cwd()}/docs/docs.json`, + + page_fallback: 'general', // used if `@page` isn't defined + + // add gitignore files to the ignore list. Depending on ignored files it + // could cause things to ge parsed slower, that's why it's defaulted to `false` + gitignore: false, + + // this stops the current block from adding lines if there're `n` + // blank line lines between code, and starts a new block. + blank_lines: 4, + debug: true, + warning: true, + timestamps: true, + + // stop adding code to the token.code.contents if the indent is less than the starting line indent + indent: true, + + // this will return the raw data by file, aka data won't be sorted + raw: false, + + // this is used to sort the annotations to be in a specific order after + // the block has been parsed initial and before the the resolve functions run + // for each annotation. You can manipulate this list to ensure that a specific + // annotation resolves before another one does, this is used in the event that + // one annotation depends on another annotation to be resolved first + sort(a, b) { + return a.localeCompare(b) // same as the default sort function + }, + + languages: { + default: { + // annotation identifier that can be change on a file specific basis if needed. + // While this is a setting, it probably should probably never be changed. If it does + // need to be changed it should be changed to be a special character. + prefix: '@', + + // header comment style + // @note {10} only 1 of these can be used per file + header: { start: '////', line: '///', end: '////', type: 'header' }, + + // body comment style + body: { start: '', line: '///', end: '', type: 'body' }, + + // inline comments for body comments + inline: { start: '', line: '///#', end: '', type: 'inline' }, + + // this is used for any interpolations that might occur in annotations. + // I don't see this needing to change but just incase I'm making it a setting. + // @note {10} This setting is used to create a RegExp so certain characters need to be escaped + interpolation: { + start: '\\${', + end: '}' + }, + }, + css: { + header: { start: '/***', line: '*', end: '***/' }, + body: { start: '/**', line: '*', end: '**/' }, + inline: { start: '/**#', line: '', end: '**/' } + }, + 'rb, py, coffee, sh, bash, pl': { + header: { start: '###', line: '##', end: '###' }, + body: { line: '##' }, + inline: { line: '##$' } + }, + 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { + header: { start: '' }, + body: { start: '' }, + inline: { start: '' } + }, + jade: { + header: { start: '//-//', line: '//-/', end: '//-//' }, + body: { line: '//-/' }, + inline: { line: '//-#' } + }, + cfm: { + header: { start: '' }, + body: { start: '' }, + inline: { start: '' } + } + }, + + // default annotation list + annotations, +} + +export default async function config(options = {}) { + let config_file = (options.config ? options : default_options).config + + // try to get the `docsfile.js` so the user config can be merged + try { + // merge the default options with the user options + config_file = require(config_file) + } catch (err) { + config_file = {} + } + + // merge the config file with passed options + options = to.extend(config_file, options) + // Not sure this valid config should be a thing because what if a user + // want's to pass in options here for their annotations. + // Should It be a option that determins if this runs? like `strict_config` + // options = to.extend(ensureValidConfig(config_file), options) + + // ensures `files`, `ignore` is always an array this way no + // more checks have to happen for it + if (options.files) options.files = to.array(options.files) + if (options.ignore) options.ignore = to.array(options.ignore) + + + // merge options with default_options so there's a complete list of settings + options = to.extend(to.clone(default_options), options) + const root = process.cwd() + if (options.gitignore) { + try { + options.ignore = to.flatten([ + options.ignore, + to.array(to.string(await fs.readFile(path.join(root, '.gitignore')))) + ]) + } catch (err) { + // do nothing because there's no `.gitignore` + } + } + + // always ignore json files because they don't support comments + options.ignore.push('*.json') + + // ensures blank_lines is a number to avoid errors + options.blank_lines = to.number(options.blank_lines) + + options.languages = parseLanguages(options.languages) + + options.log = new Logger({ + debug: options.debug, + warning: options.warning, + timestamps: options.timestamps + }) + + + { + const { inline } = options.annotations + if (inline) { + options.log.error(`you can't have an ${clor.bold.red('@inline')} annotation because it's reserved`) + } + } + + return options +} + + +export function parseLanguages(languages) { + let parsed = {} + + // ensures comments are a normal structure (aka not `'rb, py': {...}`) + for (let [ option, value ] of to.entries(languages)) { + // converts option into an array so multiple languages can be declared at the same time + option = option.replace(/\s/g, '').split(',') + + for (let lang in option) parsed[option[lang]] = value + } + + // ensures each comment has all the required comment settings + // this makes it easier later on when parsing + for (let [ lang, value ] of to.entries(parsed)) { + if (lang !== '_') { + parsed[lang] = to.extend(to.clone(default_options.languages.default), value) + } + } + + // extend any languages that have the extend option + for (let [ lang, value ] of to.entries(parsed)) { + if ( + lang !== '_' && + value.extend + ) { + if (!parsed[value.extend]) { + throw new Error(`${value.extend} comment style doesn't exist`) + } else if (!is.string(value.extend)) { + throw new Error(`the value of extend must be a string you passed ${value.extend}`) + } else { + parsed[lang] = to.extend(value, to.clone(parsed[value.extend])) + } + } + delete parsed[lang].extend + } + + return parsed +} + +let valid_options = to.keys(default_options) +let valid_language_options = to.keys(default_options.languages.default) + +/// @name ensureValidConfig +/// @description +/// Ensures that the user set's a valid config +/// @access private +function ensureValidConfig(user_config) { + for (let key in user_config) { + if (!is.in(valid_options, key)) { + log.emit('warning', `'${key}' is not a valid option, see docs options for more details`) ///# @todo add link to the doc options + } + } + + // ensures the newly added language has the correct comment format + if (user_config.languages) { + for (let [ lang, options ] of to.entries(user_config.languages)) { + for (let [ key ] of to.entries(options)) { + if (!is.in(valid_language_options, key)) { + log.emit( + 'warning', + `'${key}' is not a valid comment option in '${lang}'. Here's the default language config`, + default_options.languages.default + ) + } + } + } + } +} diff --git a/app/docs.js b/app/docs.js old mode 100755 new mode 100644 index 2b4e2a8..79cf978 --- a/app/docs.js +++ b/app/docs.js @@ -1,185 +1,173 @@ -"use strict"; -import {info, fs, path, is, to} from "./utils.js"; -import paths from "./paths.js"; -import AnnotationApi from "./annotation"; -import parser from "./parser.js"; +'use strict' + +import path from 'path' +import { + fs, + to, + glob, +} from './utils' +import Parser from './parser' +import sorter from './sorter' +import getConfig from './config' +import array, { map } from 'async-array-methods' +import chokidar from 'chokidar' +import clor from 'clor' + +export { + fs, + glob, + is, + to, + debug +} from './utils' + +export { + Parser, + getConfig, + array +} //// /// @name docs.js /// @author Tyler Benton /// @description -/// This is used to parse any filetype that you want to and gets the documentation for it and returns an {} of the document data +/// This is used to parse any filetype that you want to and gets the +/// documentation for it and returns an `{}` of the document data //// -var docs = (function(){ - // the main object to return - let _ = { - is, - to, - annotation: new AnnotationApi() - }; - - // the settings object that holds the file specific settings as well as the base settings - _.file_specific_settings = { - css: { - header: { - start: "/***", - line: "*", - end: "***/" - }, - body: { - start: "/**", - line: "*", - end: "**/" - } - }, - rb: { - header: { - start: "###", - line: "##", - end: "###" - }, - body: { - line: "##" - } - }, - html: { - header: { - start: "" - }, - body: { - start: "" - } - }, - cfm: { - header: { - start: "" - }, - body: { - start: "" - } - } - }; - _.file_specific_settings.py = _.file_specific_settings.rb; - // _.file_specific_settings.coffee = _.file_specific_settings.rb; - - /// @name settings - /// @description Merges the default settings with the file specific settings - /// @arg {string} filetype - the current filetype that is being parsed - /// @returns {object} the settings to use - _.settings = filetype => { - let defaults = { - header: { // file level comment block identifier - start: "////", - line: "///", - end: "////" - }, - body: { // block level comment block identifier - start: "", - line: "///", - end: "" - }, - blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. - annotation_prefix: "@", // annotation identifier(this should probably never be changed) - single_line_prefix: "#" // single line prefix for comments inside of the code below the comment block - }; - return !is.undefined(_.file_specific_settings[filetype]) ? to.extend(defaults, _.file_specific_settings[filetype]) : defaults; - }; - - /// @name setting - /// @description Allows you to specify settings for specific file types - /// @arg {string} extention - the file extention you want to target - /// @arg {object} obj - the settings you want to adjust for this file type - _.setting = (extention, obj) => { - return to.extend(_.file_specific_settings, { - [extention]: obj - }); - }; - - /// @name parse - /// @description Takes the contents of a file and parses it - /// @arg {string, array} files - file paths to parse - /// @arg {boolean} changed [true] - If true it will only parse changed files - /// @promise - /// @returns {object} - the data that was parsed - _.parse = (files, changed) => { - console.time("total-runtime"); // starts the timer for the total runtime - - return new Promise((resolve, reject) => { - paths(files, changed) - .then((file_paths) => { - console.log("FILE_PATHS:", file_paths.length); - console.time("parsing-runtime"); - - // Converts the `file_paths` into an array of parsing files. - // Onces they're all parsed then return the array of parsed files. - return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))); - }) - .then((parsed_files) => { - console.timeEnd("parsing-runtime"); - // get the stored data file if it exists, or return an empty object - return new Promise((resolve, reject) => { - fs.readJson(info.temp.file) - .then((json) => json) - .catch((err) => { - return {}; - }) - .then((json) => { - // Loop through the parsed files and update the - // json data that was stored. - for(let data in parsed_files){ - to.extend(json, parsed_files[data]); +export default async function docs(options = {}, callback) { + options = await getConfig(options) + + /* eslint-disable no-unused-vars */ + // these are all the options that can be used + let { + files: initial_files, + ignore, + blank_lines, + page_fallback, + dest, + debug, + warning, + timestamps, + raw, + indent, + sort, + annotations, + watch, + languages, + log, + } = options + /* eslint-enable no-unused-vars */ + + let json = {} + let parsers = {} + const ignored = await glob(ignore) + const root = process.cwd() + + let walk = async (files) => { + files = to.array(files) + + log.emit('start', 'total') + try { + log.emit('start', 'paths') + files = await glob(files, ignored) + + let paths_message = `%s completed ${to.map(files, (file) => clor.bold(file.replace(process.cwd() + '/', ''))).join(', ')} after %dms` + if (files.length > 3) { + let s = files.length > 1 ? 's' : '' // eslint-disable-line + paths_message = `%s completed after %dms with ${files.length} file${s} to parse` + } + log.emit('complete', 'paths', paths_message) + + log.emit('start', 'parser') + options.annotationsApi = annotations + + const parse = async ({ file, type }) => { + return { + [file]: await parsers[type].parse(file) } + } + + + const parser_options = { page_fallback, blank_lines, indent, annotations, sort, log } + const parsed_files = await map(files, (file) => { + const type = path.extname(file).replace('.', '') + if (!parsers[type]) { + parsers[type] = new Parser(languages[type] || languages.default, type, parser_options) + } + + return parse({ file, type }) + }) + + log.emit('complete', 'parser') - resolve(json); - - // Update the temp json data. Even though this returns a promise - // it's not returned below because there's no need to wait for it - // to finish writing out the json file before moving on. Because the - // `json` object has already been updated. - fs.outputJson(info.temp.file, json, { - spaces: 2 - }, 1); - }); - }); - }) - .then((json) => { - console.timeEnd("total-runtime"); // ends the timer for the total runtime - resolve({ - /// @name parse().data - /// @description Placeholder for the data so if it's manipulated the updated data will be in the other functions - data: json, - - /// @name parse().write - /// @description Helper function to write out the data to a json file - /// @arg {string} location - The location to write the file too - /// @arg {number,\t,\s} spacing [1] - The spacing you want the file to have. - /// @returns {this} - write(location, spacing){ - fs.writeJson(temp_file, this.data, (err) => err && console.error(err)); - return this; - }, - - // @todo {tylerb} - Add a way to documentize the files - // This should be apart of it's own code base so it doesn't pollute this one. - // @returns {this} - documentize(){ - console.log("documentize"); + // Loop through the parsed files and update the + // json data that was stored. + for (let file of parsed_files) { + to.extend(json, file) } - }); - }) - .catch((err) => { - reject({}); - throw new Error(err); - }); - }); - }; - return _; -})(); + let result = json + + if (!raw) { + log.emit('start', 'sorter') + result = sorter({ json, page_fallback, log }) + log.emit('complete', 'sorter') + } + + log.emit('complete', 'total') + timestamps && log.space() + + if (typeof callback === 'function') { + callback(result, files) + } else if (watch) { + console.log('updated: ', dest) + await fs.outputJson(dest, result) + } + + return result + } catch (err) { + log.error(err.stack) + } + } + + + + + let result = await walk(initial_files) + + initial_files = initial_files.map((_glob) => !path.isAbsolute(_glob) ? path.join(root, _glob) : _glob) + initial_files = await glob(initial_files, ignored) + + if (!watch) { + return result + } + + let watcher = chokidar.watch(initial_files, { ignored, persistent: true, ignoreInitial: true }) + + log.space() + log.print('Watching', to.map(initial_files, (file) => clor.bold(file.replace(`${root}/`, ''))).join(', ')) + log.print('Excluding', to.map(ignore, (file) => clor.bold(file.replace(`${root}/`, ''))).join(', ')) + log.space() + + watcher.on('all', async (type, file) => { + if ( + type === 'add' || + type === 'changed' || + type === 'change' + ) { + try { + await walk(file) + } catch (err) { + log.emit('error', file, 'was not updated', err) + } + } + }) + return watcher +} -export default docs; +// Catch uncaught exceptions +process.on('uncaughtException', (err) => { + // handle the error safely + console.log(err) +}) diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..a36184e --- /dev/null +++ b/app/index.js @@ -0,0 +1,21 @@ +/* + eslint + no-undef: 0, + prefer-arrow-callback: 0 + */ +var docs = require('./docs.js') + +// Module exports +// a) export module +// b) define amd +// c) add docs to the root +if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = docs + } + exports.docs = docs +} else if (typeof define === 'function' && define.amd) { // AMD definition + define(() => docs) +} else { + root.docs = docs +} diff --git a/app/parser.js b/app/parser.js deleted file mode 100644 index aafb376..0000000 --- a/app/parser.js +++ /dev/null @@ -1,378 +0,0 @@ -import {info, fs, path, is, to} from "./utils.js"; - -/// @name parse_file -/// @description -/// Parses a single file -/// @arg {string} - The path to the file you're wanting to parse -/// @returns {array} - Array of parsed blocks -export default function(file_path, settings, api){ - let filetype = path.extname(file_path).replace(".", ""), // the filetype of the current file - setting = settings(filetype), - annotations = api.list(filetype), // gets the annotations to use on this file - annotation_keys = to.keys(annotations), // stores the annotation names for this file in an array - file = {}, // placeholder to hold the file information that is defined in the return promise - debug = { - get_blocks: {}, - parse_blocks: {} - }; - debug.get_blocks.self = false; - debug.get_blocks.result = false; - debug.parse_blocks.self = false; - debug.parse_blocks.result = false; - - // @name get_blocks - // @description Parses the file and returns the comment blocks in an array - // @returns {array} of the comment blocks - // @todo {5} - add a line offest argument to this so that you can call parse content on other language types. - function get_blocks(content, config, restrict = true, start_at = 0){ - start_at = is.number(start_at) ? start_at : 0; - let lines = to.array(content), - parsed_blocks = [], - block_info, - is_start_and_end = is.all.truthy(config.start, config.end), - in_comment = false, // used to determin that you are in a comment - in_code = false; // used to determin if you are in the code after the comment block - // a) The file doesn't contain any header level comments, or body level comments - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - // debug.get_blocks.self && console.log("file =", to.json(file)); - debug.get_blocks.self && console.log("start_at =", start_at); - debug.get_blocks.self && console.log("starting line =", lines[start_at]); - debug.get_blocks.self && console.log("is_start_and_end =", is_start_and_end); - debug.get_blocks.self && console.log("config.start check =", is.in(file.contents, config.start)); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log("test 1:", is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); - debug.get_blocks.self && console.log("test 2:", !is.between(start_at, 0, lines.length - 1)); - - if((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)){ - debug.get_blocks.self && console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); - return []; - } - - for(let i = start_at, l = lines.length; i < l; i++){ - let line = lines[i], - comment_index = { - start: is_start_and_end ? is.included(line, config.start) : false, - line: is.included(line, config.line), - end: is_start_and_end ? is.included(line, config.end) : false - }; - debug.get_blocks.self && console.log("line", i, "=", line); - debug.get_blocks.self && console.log("length"); - // a) The line isn't empty so parse it. - if(!is.empty(line)){ - // a) is the start and end style or there was an instance of a comment line - if(is_start_and_end && (!is.false(comment_index.start) || in_comment) || !is.false(comment_index.line)){ - debug.get_blocks.self && console.log("IN COMMENT", "{", "start:", comment_index.start, ", line:", comment_index.line, ", end:", comment_index.end, "}"); - - // a) is the start of a new block - if(!is.false(comment_index.start) || !is_start_and_end && !in_comment){ - debug.get_blocks.self && console.log("START OF A NEW BLOCK ---------------------------------------------------------------"); - in_code = false; - - // a) There was block that has already been processed - if(!is.undefined(block_info)){ // holds the current block information - debug.get_blocks.self && console.log("BLOCK WAS PUSHED TO PARSED_BLOCKS"); - block_info.code.end = i - 1; // @todo check to make sure this is correct - parsed_blocks.push(block_info); - - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if(restrict){ - debug.get_blocks.self && console.log("IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); - block_info.comment.end = i; - return parsed_blocks; - } - } - - // reset the `block_info` to use on the new block - block_info = { - comment: { - contents: [], - start: i, - end: -1 - }, - code: { - contents: [], - start: -1, - end: -1 - }, - file - }; - - in_comment = true; - } - - // a) check for the end comment - if(is_start_and_end && block_info.comment.start !== i && !is.false(comment_index.end)){ - debug.get_blocks.self && console.log("LAST LINE IN COMMENT"); - in_comment = false; - block_info.comment.end = i; // sets the end line in the comment block - - // @todo might need to remove this - i++; // skips end comment line - line = lines[i]; // updates to be the next line - comment_index.end = is.included(config.end); // updates the index - } - - // a) adds this line to block_info comment contents - if(in_comment && is.false(comment_index.start) && is.false(comment_index.end)){ - debug.get_blocks.self && console.log("LINE ADDED TO BLOCK COMMENT CONTENTS"); - // a) removes the `config.line` from the line. - if(!is.false(comment_index.line)){ - line = line.slice(comment_index.line + config.line.length); - } - - block_info.comment.contents.push(line); - } - - // a) check the next line for an instance of the a line comment - if(!is_start_and_end && is.false(is.included(lines[i + 1], config.line))){ - debug.get_blocks.self && console.log("NEXT 'LINE' IS A COMMENT && NOT START AND END STYLE"); - in_comment = false; - block_info.comment.end = i; // sets the end line in the comment block - i++; // skips end comment line // @todo why does this need to be skipped? - line = lines[i]; // updates to be the next line - } - - // a) The last line in the file is a commment - if(in_comment && (is_start_and_end && !is.false(comment_index.end) ? i === l : i === l - 1)){ - debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS A COMMENT"); - block_info.comment.end = is_start_and_end ? i - 1 : i; - parsed_blocks.push(block_info); - break; // ensures that the loop stops because it's the last line in the file - } - } - - // a) add code to current block_info - if(!in_comment && is.false(comment_index.end) && !is.undefined(block_info)){ - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if(restrict){ - debug.get_blocks.self && console.log("IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); - parsed_blocks.push(block_info); - break; - } - debug.get_blocks.self && console.log("IN CODE"); - // a) The previous line was a comment - if(!in_code){ - debug.get_blocks.self && console.log("THE PREVIOUS LINE WAS A COMMENT"); - in_code = true; - block_info.code.start = i; - } - - // adds this line to block code contents - block_info.code.contents.push(line); - - // a) pushes the last block onto the body - if(i === l - 1){ - debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS CODE"); - block_info.code.end = i; - parsed_blocks.push(block_info); - } - } - } - // the last line in the file was an empty line. - else if(i === l - 1 && is.truthy(block_info)){ - block_info[is.between(block_info.comment.end) ? "comment" : "code"].end = i; - parsed_blocks.push(block_info); - debug.get_blocks.self && console.log("LINE WAS EMPTY"); - } - - debug.get_blocks.self && console.log(""); - } // end loop - - return parsed_blocks; - }; - - // @name this.run_annotation - // @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) - function run_annotation(annotation, block = {}){ - // removes the first line because it's the "line" of the annotation - annotation.contents.shift(); - - // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents); - - // normalizes the current annotation line - annotation.line = to.normalize(annotation.line); - - // Merges the data together so it can be used to run all the annotations - let result = to.extend({ - annotation: annotation, // sets the annotation block information to be in it's own namespace of `annotation` - - /// @name this.add - /// @page annotation - /// @description Allows you to add a different annotation from within a annotation - /// @arg {string} name - the name of the annotation you want to add - /// @arg {string} str - information that is passed to the annotation - add: (name, str) => { - str = str.split("\n"); - return run_annotation({ - name: name, - line: to.normalize(str[0]), - contents: str, - start: null, - end: null - }); - } - }, block); - - // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if(is.truthy(api.file_list[filetype] && api.file_list[filetype][annotation.name]) && is.truthy(api.file_list.default[annotation.name])){ - result.default = api.file_list.default[annotation.name].call(result); - } - - - result = annotations[annotation.name].callback.call(result); - - return result; - }; - - // @name parsed_blocks - // @description - // Used to parse an array of blocks and runs the annotations function and returns the result - // @arg {array} - The block/blocks you want to have parsed - // @returns {array} of parsed blocks - function parse_blocks(blocks){ - if(is.empty(blocks)){ - return []; - } - // if it's an object then convert it to an array. - // blocks = to.array(blocks); - - let parsed_blocks = []; - - // @name parse_block - // @description - // This parses the content passed to it seperates out each annotation - // parses and figures out the annotation line, and the content after it. - // Then once it has all the information it calls the annotation function(the annotation one it found) - // for this file type or the default function. - // @arg {object} - The blocks to parse - const parse_block = (block, prefix = setting.annotation_prefix, restrict_lines = false) => { - let contents = to.array(block.comment.contents), - block_annotations = {}, - current = {}; // holds the current annotation - - // loop over each line in the comment block - for(let i = 0, l = contents.length; i < l; i++){ - let line = contents[i], - prefix_index = line.indexOf(prefix); - - // a) there is an index of the annotation prefix - if(prefix_index >= 0){ - let first_space = line.indexOf(" ", prefix_index), - name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length); - - // a) the name is one of the annotation names - if(annotation_keys.indexOf(name_of_annotation) >= 0){ - // a) parse the current annotation - if(!is.empty(current)){ - current.end = i - 1; - - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [current.name]: run_annotation(current, block) - }); - } - - // redefines resets the current annotation to be blank - current = { - name: name_of_annotation, // sets the current annotation name - line: line.slice(prefix_index + 1 + name_of_annotation.length), // removes the current annotation name and it's prefix from the first line - contents: [], - start: i, // sets the starting line of the annotation - end: 0 - }; - } - } - - // a) adds the current line to the contents - if(!is.empty(current) && restrict_lines === false){ - current.contents.push(line); - } - - // a) is the last line in the comment block - if(i === l - 1 && !is.empty(current)){ - current.end = i; - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [current.name]: run_annotation(current, block) - }); - } - } // end block loop - - return block_annotations; - }; - - - // loop over each block - for(let i in blocks){ - let block = blocks[i]; - - block.comment.contents = to.normalize(block.comment.contents); - block.code.contents = to.normalize(block.code.contents); - - let parsed_block = parse_block(block); - - if(!is.empty(parsed_block)){ - parsed_blocks.push(parsed_block); - } - } // end blocks loop - - debug.parse_blocks.self && console.log("parsed_blocks", parsed_blocks); - - return parsed_blocks; - }; - - return new Promise((resolve, reject) => { - fs.readFile(file_path) - .then(contents => { - contents = to.normal_string(to.string(contents)); // normalize the file - file = { - contents, // all of the contents of the file - path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, "." + filetype), // name of the file - type: filetype, // filetype of the file - start: 0, // starting point of the file - end: to.array(contents).length - 1 // ending point of the file - }; - - debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); - - let header = get_blocks(contents, setting.header); - debug.get_blocks.result && console.log("get_blocks(header) =", !is.empty(header) ? header[0].comment.contents : "no header for this file"); debug.get_blocks.result && console.log(""); debug.get_blocks.result && console.log(""); - - let body = get_blocks(contents, setting.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0); - debug.get_blocks.result && console.log("get_blocks(body) =", body); - - debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); - - header = parse_blocks(header)[0]; - debug.parse_blocks.result && console.log("parse_blocks(header) =", header); debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && console.log(""); - - body = parse_blocks(body); - debug.parse_blocks.result && console.log("parse_blocks(body) =", body); - - // removes the contents from the file info because it's - // not something that is needed in the returned data. - delete file.contents; - - resolve({ - [file.type]: { - [file.path]: { - file, - header, - body - } - } - }); - }) - .catch(err => { - console.log(err); - reject({}); - }); - }); -}; diff --git a/app/parser/index.js b/app/parser/index.js new file mode 100644 index 0000000..a6b9d0c --- /dev/null +++ b/app/parser/index.js @@ -0,0 +1,375 @@ +import { fs, is, to, Logger } from '../utils' +import AnnotationApi from '../annotation-api' +import path from 'path' +import Tokenizer from './tokenizer' + +export default class Parser { + constructor(options) { // eslint-disable-line + this.setOptions(arguments) + } + + setOptions(options) { + options = to.arguments({ + language: { + prefix: '@', + + // header comment style + // @note {10} only 1 of these can be used per file + header: { start: '////', line: '///', end: '////', type: 'header' }, + + // body comment style + body: { start: '', line: '///', end: '', type: 'body' }, + + // inline comment style + inline: { start: '', line: '///#', end: '', type: 'inline' }, + + // this is used for any interpolations that might occur in annotations. + // I don't see this needing to change but just incase I'm making it a setting. + // @note {10} This setting is used to create a RegExp so certain characters need to be escaped + interpolation: { start: '\\${', end: '}' }, + }, + type: undefined, + blank_lines: 4, + indent: true, + annotations: {}, + sort: (a, b) => a.localeCompare(b), // same as the default sort function + log: new Logger() + }, arguments) + + let { annotations, type, log, ...rest } = options + this.log = log + this.options = rest + this.api = new AnnotationApi({ annotations, type }) + + // this is used to pass to the annotations when they're called + this.annotation_options = { log: this.log, options: this.options } + + const { language } = this.options + + this.comment_values = to.flatten([ + ...to.values(language.header, '!type'), + ...to.values(language.body, '!type'), + ...to.values(language.inline, '!type') + ]) + this.comment_values = to.unique(this.comment_values).filter(Boolean) + + { + let { alias, parse } = this.api.annotations + parse = to.keys(parse) + const reverse_alias_list = to.reduce(alias, (previous, { key, value }) => { + value = value + .filter((_alias) => !is.in(parse, _alias)) + .reduce((a, b) => to.extend(a, { [b]: key }), {}) + return to.extend(previous, value) + }, {}) + const regex = new RegExp(`^\s*${language.prefix}(?:(${to.keys(reverse_alias_list).join('|')})|(${parse.join('|')}))\\b\\s*`) + + this.annotations_list = { reverse_alias_list, regex } + } + } + + async parse(file = {}) { + file = is.plainObject(file) ? file : { path: file } + file.type = file.type || path.extname(file.path).replace('.', '') + file.contents = file.contents || to.string(await fs.readFile(file.path)) + file.name = path.basename(file.path, `.${file.type}`) // name of the file + file.start = 1 // starting point of the file + file.end = to.array(file.contents).length // ending point of the file + // add the file to the annotation_options that are passed to the annotation functions + this.annotation_options.file = this.file = file + + // if the file is empty or there aren't any comments then + // just return the the empty values + if ( + is.empty(file.contents) || + !is.any.in(file.contents, ...(this.comment_values)) + ) { + return { header: {}, body: [] } + } + + let tokens = this.getTokens(file.contents) + tokens = this.getAnnotations(tokens) + tokens = this.parseTokens(tokens) + tokens = this.autofillTokens(tokens) + tokens = this.resolveTokens(tokens) + tokens = this.cleanupTokens(tokens) + return tokens + } + + getTokens(contents = '') { + const { language, blank_lines, indent } = this.options + const base = { blank_lines, indent, verbose: true } + const header = new Tokenizer(contents, 0, language.header, { restrict: true, ...base })[0] || {} + + // remove the code from the header comment because it shouldn't be used. + if (header.code) { + header.code = { contents: [], start: -1, end: -1 } + } + + let body = new Tokenizer(contents, header.comment ? header.comment.end + 1 : 0, language.body, base) + const inline_tokenizer = new Tokenizer({ comment: language.inline, ...base }) + + body = body.map((token) => { + let { start: offset } = token.code + offset -= 1 + token.inline = inline_tokenizer.parse(token.code.contents, { offset }) + return token + }) + + return { header, body } + } + + map({ header, body }, callback) { + const map = (token, index, parent = false) => { + if (is.empty(token)) return {} + if (parent.inline) { + delete parent.inline + } + token = callback(token, parent) + + if (token.inline && !is.empty(token.inline)) { + token.inline = to.map(token.inline, (obj, i) => map(obj, i, token)) + } + + return token + } + + header = map(header) + body = to.map(body, (token, i) => map(token, i, header)) + return { header, body } + } + + getAnnotations({ header, body }) { + const { language } = this.options + const { reverse_alias_list, regex } = this.annotations_list + const hasAnnotation = (line) => { + line.has_annotation = false // by default each line doesn't have a annotation + // remove the annotation from the line + line.str = `${line}`.replace(regex, (match, alias, annotation) => { + if (alias) { + // find the correct annotation to use if an alias is found + annotation = reverse_alias_list[alias] + } + line.raw_without_comment = line.str // save the origial string with the annotation just in case it needs to be used later + line.annotation = annotation || '' // if an annotation was found then set the name of the annotation + line.raw_annotation = !!annotation ? `${language.prefix}${annotation}` : '' // set the raw annotation with the prefix + line.alias = alias || '' // if an alias was used the save it + line.has_annotation = true + return '' + }) + + return line + } + + return this.map({ header, body }, (token) => { + let { comment, code, inline } = token + + // find lines that have annotations and set the correct annotation if an alias is found + comment.contents = to.map(comment.contents, hasAnnotation) + + // get the annotations that are in the comment + const annotations = new Annotations(comment.contents, language.prefix) + + return { comment, code, inline, annotations } + }) + } + + parseTokens(tokens) { + return this.map(tokens, (token, parent) => { + token.parsed = to.reduce(token.annotations, (result, annotation) => { + const current = this.api.run('parse', { + annotation, + ...token, + parent, + ...(this.annotation_options) + }) + + if (result != null) { + return to.merge(result, { + [annotation.name]: current + }) + } + }, {}) + + return token + }) + } + + autofillTokens(tokens) { + const autofill_list = to.keys(this.api.annotations.autofill) + return this.map(tokens, (token, parent) => { + const parsed_keys = to.keys(token.parsed) + for (let name of autofill_list) { + if (!is.in(parsed_keys, name)) { + const result = this.api.run('autofill', { + annotation: { name }, + ...token, + parent, + ...(this.annotation_options) + }) + if (result != null) { + token.parsed[name] = result + } + } + } + + return token + }) + } + + resolveTokens(tokens) { + const { sort } = this.options + let resolve_list = to.keys(this.api.annotations.resolve) + // sort the parsed object before the annotations are resolved + if (is.fn(sort)) { + resolve_list = to.sort(resolve_list, sort) + } + + return this.map(tokens, (token, parent) => { + const parsed_keys = to.keys(token.parsed) + for (let name of resolve_list) { + if (is.in(parsed_keys, name)) { + const result = this.api.run('resolve', { + annotation: { name, alias: this.api.annotations.alias[name] }, + ...token, + parent, + ...(this.annotation_options) + }) + if (result != null) { + token.parsed[name] = result + } + } + } + return token + }) + } + + cleanupTokens(tokens) { + // option a + // return + return this.map(tokens, ({ parsed, inline }) => { + return to.object(to.json({ ...parsed, inline })) + }) + + // option b + let { header, body } = tokens + let autofill_keys = to.keys(this.api.annotations.autofill) + const cleanup = ({ inline, parsed }) => { + if (!parsed) return {} + parsed = to.object(to.json(parsed)) // this get's rid of any weird objects that might still be present + if (inline) { + return to.merge(parsed, to.reduce(inline, (prev, next) => { + return to.merge(prev, to.filter(next.parsed, ({ key }) => { + return !is.in(autofill_keys, key) + })) + }, {})) + } + return parsed + } + + header = cleanup(header) + body = to.map(body, cleanup) + + return { header, body } + } +} + + +class Annotations { + constructor(lines) { + this.annotations = [] + this.stash = lines + this.iterator = to.entries(this.stash) + this.index = 0 + this.getAnnotations() + return this.annotations + } + + peak(amount = 1) { + return this.stash[this.index + amount] + } + + next() { + const obj = this.iterator.next().value + if (!obj) return false + this.index = obj[0] + this.line = obj[1] + return true + } + + hasNext() { + return !!this.peak() + } + + getAnnotations() { + this.next() + this.annotation = new Annotation(this.line) + + if (this.hasNext() && !this.peak().has_annotation) { + this.next() + this.getContent() + } + + this.pushAnnotation() + this.annotation = undefined + + if (this.hasNext()) { + return this.getAnnotations() + } + + return this.annotations + } + + pushAnnotation() { + let { contents, start, end, ...rest } = this.annotation + + // this ensures that the line of the annotation always stays intact + // even if it's empty + let line = contents.shift() + line.str = `${line}`.trim() + + let { content, leading, trailing } = to.normalize(contents.join('\n'), { info: true }) + + trailing += contents.length + content = to.array(content) + if (is.empty(content)) { + contents = [] + } else { + contents = contents + .filter((a, i) => i >= leading && i < trailing) // filter out the lines that were removed + .map((_line, i) => { + _line.str = content[i] // update the lines content to be the normalized version + return _line + }) + } + + // prepend the line back onto the contents + contents.unshift(line) + + start = (contents[0] || {}).lineno || start || -1 // get the starting line of the comment + end = (contents.slice(-1)[0] || {}).lineno || end || start || -1 // get the end line of the comment + + this.annotations.push({ contents, start, end, ...rest }) + } + + getContent() { + this.annotation.contents.push(this.line) + if (this.hasNext() && !this.peak().has_annotation) { + this.next() + return this.getContent() + } + } +} + +class Annotation { + constructor(line) { + const { annotation: name, alias, lineno: start } = line + return { + name, // sets the current annotation name + alias, + contents: [ line ], + start, + end: 0 + } + } +} diff --git a/app/parser/tokenizer.js b/app/parser/tokenizer.js new file mode 100644 index 0000000..158027f --- /dev/null +++ b/app/parser/tokenizer.js @@ -0,0 +1,545 @@ +/* eslint-disable complexity, max-statements, max-depth */ +import { is, to, debug as _debug } from '../utils' +import { default_options } from '../config' +import clor from 'clor' + +/* eslint-enable */ +@_debug('Tokenizer') +export default class Tokenizer { + constructor(str, options = {}) { // eslint-disable-line + this.options = {} + this.setOptions(arguments) + + if (!is.empty(this.stash)) { + return this.parse() + } + return + } + + setOptions(options) { // eslint-disable-line + const debug = this.debugSet('options') + options = to.arguments({ + content: '', + lineno: 0, + comment: this.options.comment || { start: '', line: '///', end: '', type: undefined }, // the default comment style to look for + blank_lines: this.options.blank_lines || default_options.blank_lines, + // determins if all the extra line info will be returned or if it will just return strings + verbose: !is.undefined(this.options.verbose) ? this.options.verbose : false, + // determins if the comment should be stripped from the line + strip: !is.undefined(this.options.strip) ? this.options.strip : false, + // if true this option will only return the first token + restrict: !is.undefined(this.options.restrict) ? this.options.restrict : false, + // determins if the code below should stop parsing if the indent level is less than the starting indent level + indent: !is.undefined(this.options.indent) ? this.options.indent : true, + offset: 0, + }, arguments) + + + debug.push('options 1:', options) + + { // parse the comment to ensure the settings are valid, and attempt to update them + // to be valid if they aren't valid + let { start, line, single, end, type } = options.comment + + single = single || line + // this ensures there aren't any errors while looking comment lines + // because `''` will always have an index of `0` + if (single === '') { + single = undefined + } + + if (is.any.in([ single, '' ], start, end)) { + start = end = undefined + } + + if (!single && is.any.undefined(start, end)) { + throw new Error("You must set the start and end comment style if you don't specify a single comment") + } else if (!start && !end && !single) { + throw new Error('You must set the single comment or the start and end comment') + } else if (is.all.existy(single, start, end) && (start.length <= single.length || start.end <= single.length)) { + throw new Error('The start and end comments must be longer than the single comment') + } + + options.comment = { start, single, end, type } + this.is_multi = is.all.truthy(start, end) + this.is_same_multi = this.is_multi && start === end + } + + { // set the lineno to start with + const { i, index, lineno, start_at, ...rest } = options + this.lineno = i || index || start_at || lineno || 0 + options = rest + } + + + let stash + { // set the string to use + let { str, string, source, code, content, contents, ...rest } = options + stash = str || string || source || code || content || contents || '' + options = rest + } + + // update the options + this.options = options + + // holds the parsed tokens + this.tokens = [] + + this.current_blank_lines = 0 + + // update the stash + this.stash = this.getStash(stash) + + // update the iterator to use + this.iterator = to.entries(this.stash, this.lineno) + + debug.push('this.options', this.options, '') + debug.run() + } + + /// @name hasNext + /// @description + /// Used to check if the next line exists + /// @returns {boolean} + hasNext() { + return this.debugHasNext.ifFalse(this.peak(), "doesn't have another element", true) + } + + /// @name next + /// @description + /// Used to progress forward to the next line + /// @returns {boolean} - If true it means the next line exists, else the next line doesn't exisit + next() { + const obj = this.iterator.next().value + if (!obj) return false + this.line = obj[1] + this.lineno = obj[0] + return true + } + + /// @name peak + /// @description + /// This function is used to peak ahead or behind the current line + /// @arg {number} amount [1] - The amount to look ahead or before + /// @returns {object} - The line + peak(amount = 1) { + return this.stash[this.lineno + amount] + } + + /// @name stash + /// @description + /// This updates the stash that's used for this parser + /// @arg {string} str [''] - The string to use for the stash + /// @returns {array} - The array of lines with the correct info + getStash(content = '') { + // add a starting line to the content to convert it to be 1 based instead of 0 based + // fixes stupid ass issues with windows + content = '\n' + to.normalString(content) + + // if the content is empty return an empty string + if (this.isEmpty(content)) return [] + + // add a space to each line so the line index is 1 based instead of 0 based. If the line is empty, + // a space will not be added so that it's still easy to check if a line is empty or not. Doing this makes it + // much easier to determine if any of the indexes are actually falsy or not, and it makes tracking errors easier + return to.map(to.array(content), (line, i) => { + line = new Line(!line ? line : ` ${line}`, i) + const str = `${line}` + line.index = to.reduce([ 'start', 'single', 'end' ], (prev, next) => { + prev[next] = this.commentExists(str, this.options.comment[next]) + return prev + }, {}) + + // This ensures that `line` can't be true if there's already a `start` or `end` style comment + if (this.is_multi && (line.index.start || line.index.end)) { + line.index.single = false + } + + + { + const { start, single, end } = this.options.comment + let code_exsists + // remove the comment and check to see if it has a line has code on it. + if (this.isEmpty(str)) { + code_exsists = true + } else if (!this.is_multi && line.index.single) { + code_exsists = !this.isEmpty(this.getBefore(single, str)) + } else if (this.is_same_multi || line.index.start) { + code_exsists = !this.isEmpty(this.getBefore(start || end, str)) + } else { + code_exsists = !this.isEmpty(this.getAfter(end, str)) + } + + line.index.code = code_exsists && line.indent + } + + line.has_comment = is.any.truthy(line.index.start, line.index.single, line.index.end) + line.has_code = is.truthy(this.isEmpty(str) || line.index.code) + + return line + }) + } + + /// @name parse + /// @description + /// This will parse the passed content + /// @arg {string} content [''] - The content to parse + /// @arg {number} start_at [0] - The starting line to start parsing at + /// @arg {boolean} verbose [this.verbose] - The default is what was passed when creating the Tokenizer + /// @returns {array} - Of parsed tokens + /// @note {5} This function also accepts a object to be passed with named arguments + /// @markup Usage + parse(content = '', start_at = 0) { // eslint-disable-line + if (is.empty(this.stash)) { + this.setOptions(arguments) + } + + this.setDebug() + const debug = this.debugParse + const result = to.clone(this.getTokens()) + this.tokens = [] // reset the tokens list to be empty + this.stash = [] // resets the stash to be empty + this.token = undefined // reset the current token to be empty + debug.push('parsed:', result).run() + return result + } + + /// @name isEmpty + /// @description checks to see if the passed string is empty(only contains spaces) + /// @returns {boolean} + isEmpty(str) { + return !str.replace(/\s+/gm, '') + } + + /// @name getTokens + /// @description + /// This function will recursively get all the tokens in the file + getTokens() { + this.token = undefined + this.setDebug(true) + const debug = this.debugGetTokens + if (!this.hasNext()) { + return this.tokens + } + + this.next() + + if ( + debug.ifTrue(is.empty(`${this.line}`.trim()), "the line was empty, and isn't in a token already") || + debug.ifTrue(!this.line.has_comment, "The line doesn't have a comment, and isn't in a token already") || + debug.ifTrue(this.is_multi && !this.line.index.start, "The line doesn't have a starting comment") + ) { + debug.push('', '', '', '').run() + return this.getTokens() + } + + debug.push(`line [${this.lineno}]: ${clor.bgBlue(this.line)}`, this.line).run() + + if (this.line.has_comment) { + this.token = new Token() + + if (this.options.comment.type) { + this.token.comment.type = this.options.comment.type + } + + debug.push('has comment').run() + + if (this.is_same_multi && this.line.index.start === this.line.index.end) { + this.line.index.end = false + } + + if (!this.is_multi) { + this.getSingleComment() + } else { + this.getMultiComment() + } + } + + if (this.line.has_code) { + this.getCode() + } + + if (is.truthy(this.token)) { + this.pushToken() + } + + debug.push('', '', '', '').run() + + return !this.options.restrict ? this.getTokens() : this.tokens + } + + /// @name this.getBefore + /// @description + /// This function is used to get the content before a comment + /// @arg {string} comment - the comment to start after + /// @arg {string} str - the content to extract the content from + /// @returns {string} + getBefore(comment, str) { + if (!comment || !str) return str + return str.slice(0, str.indexOf(comment)) + } + + /// @name this.getAfter + /// @description + /// This function is used to get the content after a comment + /// @arg {string} comment - the comment to start after + /// @arg {string} str - the content to extract the content from + /// @returns {string} + getAfter(comment, str) { + if (!comment || !str) return str + return str.slice(str.indexOf(comment) + comment.length) + } + + /// @name getCode + /// @description + /// Recursively pushes the code from each line onto the current token + getCode() { + const debug = this.debugGetCode + // store the starting lines indent + const { indent } = this.line + + const recursiveCode = () => { + let line = to.clone(this.line) + let str = `${line}` + if ( + !this.is_same_multi && + !line.index.start && + line.index.end + ) { + line.str = str = str.slice(line.index.end + this.options.comment.end.length + 1) + } else { + line.str = str = str.slice(1, line.index.start || line.index.single || line.index.end || undefined) + } + + + // check to see if the current lines indent is less than the starting indent of the code + if (!is.empty(str)) { + this.current_blank_lines = 0 + if (this.options.indent && line.indent < indent) { + return + } + } else if (++this.current_blank_lines >= this.options.blank_lines) { + return + } + + // push the line onto the code contents + this.token.code.contents.push(line) + + if ( + this.hasNext() && + debug.ifTrue(!this.is_same_multi || !line.has_comment, `the current line(${line.lineno}) doesn't have a comment: ${clor.bgGreen(line)}`) + ) { + const next_line = this.peak() + const next_msg = `the next line(${next_line.lineno}) has a comment: ${clor.bgRed(next_line)}` + return debug.ifFalse(!next_line.has_comment, next_msg) && this.next() && recursiveCode() + } + } + + recursiveCode() + debug.run() + } + + /// @name getSingleComment + /// @description + /// Recursively pushes the single comment lines from each line onto the + /// current token until the next instance of code + getSingleComment() { + const debug = this.debugGetSingleComment + const { comment } = this.options + let line = to.clone(this.line) + line.str = this.getAfter(comment.single, `${line}`) + + this.token.comment.contents.push(line) + const current_msg = `the current line(${line.lineno}) doesn't have code: ${clor.bgGreen(line)}` + if (debug.ifTrue(!line.has_code, current_msg) && this.hasNext()) { + const next_line = this.peak() + const context = next_line.has_code ? 'has code' : 'is empty' + const next_msg = `the next line(${next_line.lineno}) ${context}: ${clor.bgRed(next_line)}` + + this.next() + return debug.ifFalse(next_line.has_comment && !next_line.has_code, next_msg, true) && this.getSingleComment() + } + debug.run() + } + + /// @name getMultiComment + /// @description + /// Recursively pushes the multi line comment lines onto the + /// current token until the next instance of code + getMultiComment() { + const debug = this.debugGetMultiComment + const { comment } = this.options + + let line = to.clone(this.line) + let str = `${line}` + + if (line.index.end) { + str = this[this.is_same_multi ? 'getAfter' : 'getBefore'](comment.end, str) + + // update the start index if the indexes are the same + if (this.is_same_multi && line.index.start === line.index.end) { + line.index.start = false + } + } + + if (line.index.start || line.index.single) { + str = this.getAfter(line.index.start ? comment.start : comment.single, str) + } + + line.str = str + this.token.comment.contents.push(line) + debug.push(line) + if (this.hasNext()) { + if (debug.ifTrue(!line.index.end, `the current line(${line.lineno}) wasn't the last comment: ${clor.bgGreen(this.line)}`)) { + debug.run() + return this.next() && this.getMultiComment() + } + const next = this.peak() + if ( + debug.ifTrue(!line.index.code, `the current line(${line.lineno}) doesn't has code: ${clor.bgGreen(line)}`) && + debug.ifTrue(!next.has_comment, `the next line(${next.lineno}) doesn't have a comment: ${clor.bgGreen(next)}`) + ) { + debug.run() + return this.next() + } + } + + debug.run() + return + } + + /// @name pushToken + /// @description + /// This function is used to push the current token onto the parsed token list(`this.tokens`). + /// It will normalize all the content that's passed to the comment and code in the token, then + /// determin the starting and ending point for the comment and code. + pushToken() { + const debug = this.debugPushToken + const { offset } = this.options + let token = to.clone(this.token) + + const normalizeContent = (obj, set_start_end_before = false) => { + if (is.number(offset) && offset > 0) { + obj.contents = to.map(obj.contents, (line) => { + line.lineno += offset + return line + }) + } + + // normalize the contents of the obj + let { content, leading, trailing } = to.normalize(obj.contents.join('\n'), { info: true }) + let lines = to.array(content) + trailing += obj.contents.length + const points = () => { + obj.start = (obj.contents[0] || {}).lineno || -1 // get the starting line of the comment + obj.end = (obj.contents.slice(-1)[0] || {}).lineno || -1 // get the end line of the comment + } + + if (set_start_end_before) points() + + obj.contents = obj.contents + .filter((line, i) => i >= leading && i < trailing) // filter out the lines that were removed + .map((line, i) => { + line.str = lines[i] // update the lines content to be the normalized version + return line + }) + + if (!set_start_end_before) points() + + if (this.isEmpty(content)) { + obj = new Token().code + return obj + } + + if (!this.options.verbose) { + obj.contents = content.split('\n') + } + + return obj + } + + token.comment = normalizeContent(token.comment, true) + token.code = normalizeContent(token.code) + debug.push(token).run() + this.tokens.push(token) + this.token = undefined + this.current_blank_lines = 0 + } + + /// @name commentExisits + /// @description + /// this is a helper function that is used to test the existence of the comment on a given line + commentExists(line, comment_type) { + // ensure that the line, and comment_type are truthy + if (is.any.falsy(line, comment_type)) { + return false + } + + // store the index of the comment_type + let index = line.indexOf(comment_type) + + // check to see if the comment_type exisits + if (index > -1) { + if ( + is.in(line, `${comment_type} `) || // check to see if the required space after the comment_type exisits + line.length === index + comment_type.length // check to see if the comment_type is the last thing on that line (aka ) + ) { + return index + } + } + + return false + } + + /// @name setDebug + /// @description + /// This function is used to turn the debug options on or off + /// @arg {boolean} condition + setDebug(condition) { + if (is.undefined(condition)) { + condition = this.should_debug || false + } + + this.debugParse = this.debugSet('parse', { condition, spaces: 0 }) + this.debugGetTokens = this.debugSet('parse', { condition, spaces: 0 }) + this.debugGetSingleComment = this.debugGetTokens.set('getSingleComment', 0) + this.debugGetMultiComment = this.debugGetTokens.set('getMultiComment', 0) + this.debugGetCode = this.debugGetTokens.set('getCode', 0) + this.debugPushToken = this.debugGetTokens.set('pushToken', 0) + this.debugHasNext = this.debugGetTokens.set('hasNext', 0) + } +} + + +class Token { + constructor() { + // The base of what each token looks like + this.token_base = { + comment: { contents: [], start: -1, end: -1 }, + code: { contents: [], start: -1, end: -1 } + } + + return to.clone(this.token_base) + } +} + + +class Line { + constructor(...args) { + args = to.arguments({ + str: '', + lineno: '' + }, ...args) + to.extend(this, args) + this.raw = this.str + this.indent = to.indentLevel(this.str) + } + + get length() { + return this.str.length + } + + toString() { + return this.str + } +} diff --git a/app/paths.js b/app/paths.js deleted file mode 100644 index 721f300..0000000 --- a/app/paths.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -import {Deferred, fs, path, info, glob, is, to} from "./utils.js"; - -// @name paths -// @description -// Filters out changed files, `.md` files, and paths that aren't files -// @promise -// @args {array, string} -// @returns {array} - Filtered file paths -export default function paths(globs, changed = true){ - console.time("paths-runtime"); - - globs = to.array(globs); // Converts globs into an array if it's not already. - - // @name get_paths - // @description - // This gets the file paths to check - // @arg {array} - of file path globs - // @promise - // @returns {array} - the filepaths to return - function get_paths(files){ - return new Promise((resolve, reject) => { - let globs = []; - // get the files paths using glob - for(let i = 0, l = files.length; i < l; i++){ - globs.push(glob(files[i])); - } - - Promise.all(globs) - .then((result) => resolve(to.array.flat(result))) - .catch(err => { - throw err; - }); - }); - }; - - // @name check - // @description - // checks the status of the file to see if it has changed or not. - // @arg {string} - path to file - // @promise - // @returns {string} - this will be the filepath or an empty string - function check(file){ - var source = path.join(info.root, file), - target = path.join(info.temp.folder, file); - return new Promise((resolve, reject) => { - Promise.all([fs.stat(source), fs.stat(target)]) - .then(function(stats){ - // a) copies source file into the target directory because it's newer - if(stats[0].mtime > stats[1].mtime){ - resolve(source); - fs.fake_copy(source, target); // copies new files over. - }else{ - resolve(Promise.resolve("")); - } - }) - .catch((err) => { - fs.fake_copy(source, target); // copies new files over. - resolve(source); - }); - }); - }; - - // @name filter - // @description - // Filters out - // - changed files if `changed` is true, - // - `.md`, and `.` files(always) - // - any paths that aren't files - // - // @arg {array} of globs - // @promise - // @returns {array} - Array of file paths - function filter(files){ - files = files.filter(obj => { - let ext = path.extname(obj).toLowerCase(); - return ext !== ".md" && ext.charAt(0) === "."; - }); - - // a) Return all the files that were passed except - // the `.md`, and `.` files. - if(!changed){ - return Promise.resolve(files); - } - - return new Promise((resolve, reject) => { - Promise.all(files.map((file) => check(file))) - .then(to_filter => resolve(to.array.unique(to.array(to_filter)))) - .catch((err) => { - resolve([]); - throw err; - }); - }); - }; - - return new Promise((resolve, reject) => { - get_paths(globs) - .then(files => filter(files)) - .then(filtered_files => resolve(filtered_files)) - .then(() => console.timeEnd("paths-runtime")) - .catch((err) => { - throw err; - }); - }); -}; diff --git a/app/sorter/index.js b/app/sorter/index.js new file mode 100644 index 0000000..8f52cba --- /dev/null +++ b/app/sorter/index.js @@ -0,0 +1,14 @@ +import getPages from './pages' +import getNav from './nav' + +/// @name sort +/// @description +/// Sorts the parsed data into pages and creates the navigation +/// @arg {object} +/// @returns {object} +export default function sorter(options = {}) { + const pages = getPages(options) + const nav = getNav(pages) + + return { nav, pages } +} diff --git a/app/sorter/nav.js b/app/sorter/nav.js new file mode 100644 index 0000000..14f0013 --- /dev/null +++ b/app/sorter/nav.js @@ -0,0 +1,75 @@ +import { is, to } from '../utils' + +/// @name nav +/// @description +/// This function builds the navigation based of how the pages were built. +export default function nav(pages) { + let result = [] + + // loop over the pages structure to create the navigation + for (let [ key, value ] of to.entries(pages)) { + result.push(set({ + title: to.titleCase(to.sentenceCase(key)), + href: `/${key}`, + body: bodyNames(`/${key}`, value.page.body), + subpages: [] + }, value)) + } + + return result +} + +/// @name bodyNames +/// @description Helper function to get the name of each block in the body +/// @arg {string} - the href to append the `name` of the block to +/// @arg {array} - the body of the page +/// @returns {array} +function bodyNames(href, body) { + let names = [] + // loop over each block in the body + for (let block of body) { + // a) Add the name to the bodyNames + if (is.existy(block.name)) { + names.push({ + title: block.name, + href: `${href}#${to.paramCase(block.name)}` + }) + } + } + + return names +} + + +/// @name set +/// @description +/// This is a helper function that recursivly goes through the +/// structure(`a`) creating the navigation structure for +/// the passed item. +/// @arg {object} - This is the top level object to continue to drill down. +/// @arg {object} - The inner structure to continue to loop over. +/// @returns {object} +function set(a, b) { + for (let [ key, value ] of to.entries(b)) { + if (key !== 'page') { + let nav_item = { + title: is.truthy(value.page.header.name) ? value.page.header.name : to.titleCase(to.sentenceCase(key)), + href: `${a.href}/${key}`, + body: [], + subpages: [] + } + + // add the name of each block in the body + nav_item.body = bodyNames(nav_item.href, value.page.body) + + // a) Call `set` again because it's not the last level + if (to.keys(value).length > 1) { // the reason it's `> 1` is because `page` will always be defined. + nav_item = set(nav_item, value) + } + + a.subpages.push(nav_item) + } + } + + return a +} diff --git a/app/sorter/pages.js b/app/sorter/pages.js new file mode 100644 index 0000000..0fb5950 --- /dev/null +++ b/app/sorter/pages.js @@ -0,0 +1,142 @@ +/* eslint-disable complexity, max-depth */ +import { is, to } from '../utils' +import clor from 'clor' + +/// @name pages +/// @description +/// This function loops over the json that was passed and creates a organized structure +/// based on the `@pages` annotations that were passed. +export default function pages(options) { + return new Pages(options) +} + +class Pages { + constructor({ json, page_fallback, log }) { + this.json = json + this.page_fallback = page_fallback + this.log = log + this.base = { page: { header: {}, body: [] } } + this.result = {} + + for (const obj of to.objectEntries(this.json, 'path')) { + let { path, header, body } = this.obj = obj + this.path = path + this.header = header + to.each({ header, body }, this.parse, this) + } + + return this.result + } + + parse({ key, value: val }) { + if (!is.empty(val)) { + if (is.array(val)) { + return to.each(val, (value) => this.parse({ key, value }), this) + } + + if (!is.empty(val)) { + this.parseToken({ key, value: val }) + } + } + } + + parseToken({ key: token_type, value: token }) { + let token_title = to.titleCase(token_type) + const is_header = token_type === 'header' + const path = this.path + + if (is.falsy(token.page) && is_header) { + if (is.falsy(this.page_fallback)) { + this.log.emit('warning', to.normalize(` + ${token_title} comment ${token.name && '@name ' + token.name} doesn't have a ${clor.bold('@page')} defined in + ${clor.bold.blue(path)} + `)) + return + } + + this.header.page = [ this.page_fallback ] + } + + let page_list = [] + // if the header doesn't exist or the page is empty + if (!token.page || is.empty(token.page)) { + if (this.header.page && !is.empty(this.header.page)) { + page_list.push(...(this.header.page)) + } else if (!this.header.page || is.empty(this.header.page)) { + page_list.push(this.page_fallback) + } + } + + page_list.push(token.page || '') + + token.page = page_list = to.unique(to.flatten(to.filter(page_list))) + + // If the token doesn't contain a name and isn't a header comment it get's skipped + if (is.falsy(token.name)) { + if (!is_header) { + this.log.emit('warning', to.normalize(` + The hardest thing in development is naming all the things but you gotta try, add a ${clor.bold('@name')} annotation + to the comment block starting on line ${token.blockinfo.comment.start} in ${clor.bold.blue(path)} + `)) + // return + } + + // set the token name to be the filepath name + // let name = path.split('/').pop() + // token.name = name.split('.') + // token.name = `${to.titleCase(token.name[0])} ${to.upperCase(token.name[1])} File` // `(${name})` + } + + if (is.empty(page_list)) { + this.log.emit('warning', to.normalize(` + The documentation starting on line ${token.blockinfo.comment.start} isn't being added because a ${clor.bold('@page')} annotation doesn't exist + ${clor.bold.blue(path)} + `)) + return + } + for (const page of token.page) this.set(page, token_type, token) + } + + // @name set + // @description + // creates a structure from an array, and adds the passed object to + // the `base` array if it was passed. + // + // @returns {object} - The nested object with the set value + set(path, type, value) { + // ensures values won't change in the passed value + value = to.clone(value) + + // deletes the page from the value so it + // won't get added to the data + delete value.page + + let obj = this.result + // convert to array, and filter out empty strings + let path_list = path.split('/').filter(Boolean) + + // 1 less than the link so the last item in the `path_list` is what + // the passed value will be set to + let length = path_list.length - 1 + + // loop over all the pages in in the `path_list` except the + // last one and create the `page`, and `nav` if they don't exist. + for (let [ i, page ] of to.entries(path_list, 0, length)) { // eslint-disable-line + if (!obj[page]) { + obj[page] = to.clone(this.base) + } + obj = obj[page] + } + + // a) Define the default data set(can't use `page` because it will be overwritten) + if (!obj[path_list[length]]) { + obj[path_list[length]] = to.clone(this.base) + } + + if (type === 'header') { + obj[path_list[length]].page.header = to.merge(obj[path_list[length]].page.header, value) + } else { + obj[path_list[length]].page.body.push(value) + } + } +} diff --git a/app/utils.js b/app/utils.js deleted file mode 100644 index 58549a2..0000000 --- a/app/utils.js +++ /dev/null @@ -1,604 +0,0 @@ -// import and export `path` so all general -// utils can be imported from this file -import path from "path"; -export {path}; - -// Stores the project directory to use later -let info = {}; -info.root = process.cwd(); // gets the root directory - -info.dir = info.root.split(path.sep); // splits the project dir by the system specific delimiter -info.dir = info.dir[info.dir.length - 1]; // gets the working directory - -info.temp = {}; -info.temp.folder = path.join(info.root, ".tmp"); -info.temp.file = path.join(info.temp.folder, "data.json"); -export {info}; - -// @name denodeify -// @description -// Takes functions that takes callbacks -// and converts it into a promise. -// @returns {promise} -// @markup {js} -// import fs from "fs"; -// fs.readFile = denodeify(fs.readFile); -export function denodeify(func){ - return function(...args){ - return new Promise((resolve, reject) => { - func(...args, (err, ...args) => err ? reject(err) : resolve(...args)); - }); - }; -}; - - -// File System -import * as fs from "fs-extra"; -// @name fs.fake_copy -// @description -// Creates an empty file temp file in the `.tmp/`. This is so that I can -// check to see if the source file has been updated. -fs.fake_copy = (source, target, callback) => { - var cbCalled = false, - source = path.parse(source), - target = path.parse(target); - - // creates the directory path if it doesn't exist - fs.mkdirp(path.resolve(source.dir, path.relative(source.dir, target.dir)), () => { - fs.writeFile(path.join(target.dir, target.base), "", () => callback && callback()); - }); -}; - -// The functions below are converted into promises -fs.readJson = denodeify(fs.readJson); -fs.outputJson = denodeify(fs.outputJson); -fs.stat = denodeify(fs.stat); -fs.readFile = denodeify(fs.readFile); -export {fs}; - -// can't use `import` from es6 because it -// returns an error saying "glob" is read only -let glob = denodeify(require("glob")); -export {glob}; - -const to_string = arg => Object.prototype.toString.call(arg), - array_slice = arg => Array.prototype.slice.call(arg); - -import markdown from "marked"; - -export let to = { - /// @name to.log - /// @description - /// Shortcut for `console.log` - log: console.log.bind(console), - - /// @name to.markdown - /// @description - /// Helper function to convert markdown text to html - /// For more details on how to use marked [see](https://www.npmjs.com/package/marked) - /// @returns {string} of `html` - markdown, - - // @name to.string - // @description - // Converts an object, array, number, or boolean to a string - // @arg {string, object, array, number, boolean} - // @returns {string} - string: (arg, glue = "\n") => is.string(arg) ? arg : is.buffer(arg) ? arg + "" : is.object(arg) ? to_string(arg) : is.array(arg) ? arg.join(glue) : is.number(arg) || is.boolean(arg) ? arg.toString() : arg + "", - - // The ` + ""` converts the file from a buffer to a string - // - // The `replace` fixes a extremely stupid issue with strings, that is caused by shitty microsoft computers. - // It removes`\r` and replaces it with `\n` from the end of the line. If this isn't here then when `match` - // runs it will return 1 more item in the matched array than it should(in the normalize function) - // http://stackoverflow.com/questions/20023625/javascript-replace-not-replacing-text-containing-literal-r-n-strings - normal_string: (str) => (is.string(str) ? str : to.string(str)).replace(/(?:\\[rn]+)+/g, "\n"), - - // @name to.keys - // @description - // Converts an object to an array of it's key names - // @arg {object} - // @returns {array} - keys: (arg) => is.object(arg) && Object.getOwnPropertyNames(arg), - - // @name to.json - // @description - // Converts an object to a json string - // @arg {object} - // @returns {json object} - json: (arg, spacing = 2) => is.object(arg) && JSON.stringify(arg, null, spacing), - - /// @name to.normalize - /// @description - /// Removes trailing blank lines. Removes extra whitespace before all the lines that - /// are passed without affecting the formatting of the passes string. Then removes - /// all whitespace at the end of each line. - /// @arg {string, array} content - The content you want to be normalized - /// @returns {string} - The normalized string - normalize: (content) => { - content = to.array(content); // this allows arrays and strings to be passed - - // remove trailing blank lines - for(let i = content.length; i-- && content[i].length === 0;){ - content.pop(); - }; - - return content - .map(line => line.slice( - content.join("\n") // converts content to string to string - .match(/^\s*/gm) // gets the extra whitespace at the beginning of the line and returns a map of the spaces - .sort((a, b) => a.length - b.length)[0].length // sorts the spaces array from smallest to largest and then checks returns the length of the first item in the array - )) // remove extra whitespace from the beginning of each line - .join("\n").replace(/[^\S\r\n]+$/gm, ""); // convert to string and remove all trailing white spaces - }, - - /// @name extend - /// @description - /// Extend object `b` onto `a` - /// http://jsperf.com/deep-extend-comparison - /// @arg {object} a - Source object. - /// @arg {object} b - Object to extend with. - /// @returns {object} The extended object. - extend: (a, b) => { - // Don't touch `null` or `undefined` objects. - if(!a || !b){ - return a; - } - - for(let k in b){ - a[k] = is.object(b[k]) ? is.object(a[k]) ? to.extend(a[k], b[k]) : b[k] : b[k]; - } - - return a; - }, - - /// @name to.clone - /// @description - /// This will clone argument so the passed arg doesn't change - /// - /// @arg {*} - The item you want to clone - /// @returns {*} - The copied result - clone: (arg) => is.object(arg) ? to.extend({}, arg) : is.array(arg) ? [].concat(arg) : [].concat(arg)[0], - - /// @name to.merge - /// @description - /// This is similar to `to.extend` except in `to.extend` the values - /// in `a` are replaced with the values in `b`. This function will - /// not only merge the objects together, it also merges the values of - /// the objects together. - /// - /// If the value in `b` is a function **or** the value of `a` is undefined - /// it will just set the value of `a` to be the value of `b` - /// - /// If the value in `a` is an array, then the value in `b` gets pushed - /// onto the value in `a`. - /// - /// If the value in `a` is an object then it checks the value in `b` to - /// see if it's an object and if it is then it calls `to.merge` again on - /// those objects for recursion. If the value in `b` isn't an object then - /// the value in `a` get's replaced by the value in `b`. - /// - /// If the value in `a` is anything else, then it converts it into an array - /// and adds the value in `b` to it.(`[a[key], b[key]]`) - /// - /// @arg {object} - The object to be modified - /// @arg {object} - The object that has the updates - /// @arg {boolean} - If true every array will be flattend to a single dimensional array, and will remove duplicate values - /// - /// @markeup {js} **Example:** - /// let a = { foo: { bar: "1", baz: ["3", "4"], qux: "one", quux: { garply: { waldo: "one" } }, waldo: "" } }, - /// b = { foo: { bar: "2", baz: ["5", "6"], qux: ["two", "three"], quux: { garply: { waldo: "two" } }, waldo: function(){ return this; }, garply: "item" } }; - /// - /// to.merge(a, b); - /// - /// @markup {js} **Output:** - /// { - /// foo: { - /// bar: [ "1", "2" ], // started as a string and converted to an array - /// baz: [ "3", "4", "5", "6" ], // merged two arrays together - /// qux: [ "one", "two", "three" ], // started as a string and merged the array with the string - /// quux: { garply: { waldo: [ "one", "two" ] } }, // `foo.quux.garply.waldo` started as string and converted to an array - /// waldo: function(){ return this; }, // started as a string and changed to be a function - /// garply: "item" // didn't exist before so it stays as a string - /// } - /// } - merge: (a, b, unique = true) => { - // a) Don't touch `null` or `undefined` objects. - if(!a || !b){ - return a; - } - - // loop over each key in the second map - for(let k in b){ - // a) Set the value of `a` to be the value in `b` because it was either - // a function or it didn't exsit already in `a` - // c) Push the value in `b` into the `a` values array - // b) The recursive functionality happends here - // a) Call the merge function go further into the object - // b) Sets the value of `a` to be the value of `b` - // d) Convert the a value to be an array, and add the `b` value to it - if(is.function(b[k]) || is.function(a[k]) || is.undefined(a[k])){ - a[k] = b[k]; - } - else if(is.array(a[k])){ - a[k].push(b[k]); - } - else if(is.object(a[k])){ - a[k] = is.object(b[k]) ? to.merge(a[k], b[k]) : b[k]; - } - else{ - a[k] = [a[k], b[k]]; - } - - // a) Flatten the array, and filter out duplicates - if(unique && is.array(a[k])){ - a[k] = to.array.unique([].concat.apply([], a[k])); - } - } - - return a; - }, - - object: (arg) => is.json(arg), - - // @name to.array - // @description - // Converts `...args` to array - // It converts multiple arrays into a single array - // @arg {array, string, object, number} - The item you want to be converted to array - // @returns {array} - // array: (arg, glue = "\n") => is.array(arg) ? arg : is.string(arg) ? arg.split(glue) : is.object(arg) || is.number(arg) ? [arg] : [], - array: (arg, ...args) => { - let glue = args.length > 0 && is.regexp(args[args.length - 1]) ? args.pop() : "\n", - to_array = arg => is.array(arg) ? arg : is.argument(arg) ? array_slice(arg) : is.string(arg) ? arg.split(glue) : is.object(arg) || is.number(arg) ? [arg] : [], - result = to_array(arg); - - if(args.length > 0){ - for(let i = 0, l = args.length; i < l; i++){ - let arg = args[i]; - result = result.concat(); - } - } - - return result; - }, - - // @name to.sort - // @description - // Sorts an array or object based off your callback function. If one is provided. - // @arg {array, object} - // @returns {array, object} - The sorted version - sort: (arg, callback) => { - let run_sort = (obj) => is.function(callback) ? obj.sort.apply(null, callback) : obj.sort(), - result; - if(is.object(arg)){ - let sorted = {}, - keys = run_sort(to.keys(arg)); - - for(let i = 0, l = keys.length; i < l; i++){ - sorted[keys[i]] = arg[keys[i]]; - } - - result = sorted; - }else if(is.array(arg)){ - result = run_sort(callback); - } - return result; - }, - - // @name to.regex - // @description - // Converts `...args` to regex - // @returns {string} - // - // @markup {js} - // new RegExp(":((" + to.regex(")|(", "link", "visited", "hover") + "))", "gi"); - regex: (glue, ...args) => to.array(args).join(glue), - - // @name to.boolean - // @description - // Converts `arg` to boolean - // @arg {boolean, array, object, string, number} - // @returns {boolean} - boolean: (arg) => is.boolean(arg) ? arg : is.array(arg) ? !!arg.length : is.object(arg) ? is.empty(arg) : is.number(arg) ? arg > 0 ? !!arg : !!0 : !!arg, - - // @name to.number - // @description - // Converts `arg` to number - // @arg {number, array, object, string, boolean} - // @returns {number} - number: (arg) => is.number(arg) ? arg : is.array(arg) ? arg.length : is.object(arg) ? to.keys(arg).length : ~~arg, - - // @name to.abs - // @description - // Converts `arg` to a positive number - // @arg {number, array, object, string, boolean} - // @returns {number} - abs: (arg) => Math.abs(to.number(arg)), - - // @name to.neg - // @description - // Converts `arg` to a negative number - // @arg {number, array, object, string, boolean} - // @returns {number} - neg: (arg) => ~to.abs(arg) -}; - -// @name to.array.flat -// @description -// Flattens an array, and arrays inside of it into a single array -// @arg {array} -// @returnes {array} -to.array.flat = (arg) => [].concat.apply([], to.array(arg)); - -// @name to.array.unique -// @description -// Removes duplicate values from an array -// @arg {array} -// @returns {array} -to.array.unique = (arg) => { - let o = {}, - r = []; - for(let i in arg){ - o[arg[i]] = arg[i]; - } - for(let i in o){ - r.push(o[i]); - } - return r; -}; - -// to.array.flat.unique = (arg) => to.array.unique(to.array.flat(arg)); - -// var seen = new Set(); -// return a.filter((x) => !seen.has(x) && seen.add(x)) -export let is = { - // placeholder for the interfaces - not: {}, - all: {}, - any: {}, - - // @description is a given arg Arguments? - // fallback check is for IE - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - argument: (arg) => !is.null(arg) && (to_string.call(arg) === "[object Arguments]" || (typeof arg === "object" && "callee" in arg)), - - // @description is a given arg regex expression? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - regex: (value) => to_string.call(value) === "[object RegExp]", - - // @description is a given arg function? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - function: arg => to_string(arg) === "[object Function]" || typeof arg === "function", - - // @description is a given arg Array? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - array: arg => to_string(arg) === "[object Array]", - - // @description is a given arg Boolean? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - boolean: arg => arg === true || arg === false || to_string(arg) === "[object Boolean]", - - // @description is a given arg object? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - object: arg => typeof arg === "object" && !!arg && arg !== null, - - // @description is given value a pure JSON object? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - json: (arg) => to_string(arg) === "[object Object]", - - // @description is a given arg empty? Objects, arrays, strings - // @arg {object, array, string} arg - What you want to check to see if it's empty - // @returns {boolean} - determins if the item you passes was empty or not - empty: (arg) => { - var type = typeof arg; - if(is.falsy(arg)){ - return true; - } - else if(type === "function" || type === "object" && !!arg){ - let num = Object.getOwnPropertyNames(arg).length; - return (num === 0 || (num === 1 && is.array(arg)) || (num === 2 && is.argument(arg))) ? true : false; - } - else{ - return arg === ""; - } - }, - - // @description is a given value existy? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - existy: (arg) => arg !== null && arg !== undefined, - - // @description is a given arg String? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test - string: arg => to_string(arg) === "[object String]", - - // @description is a given arg undefined? - // @arg {*} arg - The item to check - // @returns {boolean} - undefined: arg => arg === void 0, - - // @description is a given string include parameter substring? - // @arg {string, array} a - string to match against - // @arg {string, array} b - string to look for in `str` - // @todo {1} update this to work with arrays - // @todo {1} change name to be `index` because it still makes sense and it's shorter - // @returns {number, boolean} - included: (a, b) => !is.empty(a) && !is.empty(b) && a.indexOf(b) > -1 ? a.indexOf(b) : false, - - - // @description is the `value` in `obj`? - // @arg {array, string, object} obj - the item to check against - // @arg {*} value - the value to look for in the `obj` - // @returns {boolean} - in: (obj, value) => is.included(is.object(obj) ? to.keys(obj) : obj, value) !== false, - - // @description is a given arg false - // @arg {*} arg - arg to check if it is false - // @returns {boolean} - false: arg => arg === false, - - // @description is a given arg truthy? - // @arg {*} arg - // @returns {boolean} - truthy: arg => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== "" && arg !== 0, - - // @description is given arg falsy? - // @arg {*} arg - // @returns {boolean} - falsy: arg => !is.truthy(arg), - - // NaN is number :) Also it is the only arg which does not equal itself - nan: (arg) => arg !== arg, - - // @description is given arg a number? - // @arg {*} arg - // @returns {boolean} - number: (arg) => is.not.nan(arg) && to_string(arg) === "[object Number]", - - // is a given number within minimum and maximum parameters? - between: (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max), - - // @description is a given number positive? - // @arg {*} arg - // @returns {boolean} - positive: (arg) => is.number(arg) && arg > 0, - - // @description is a given number negative? - // @arg {*} arg - // @returns {boolean} - negative: (arg) => is.number(arg) && arg < 0, - - // @description is a given number above minimum parameter? - // @arg {*} arg - // @returns {boolean} - above: (arg, min = -1) => is.all.number(arg, min) && arg > min, - - // @description is a given number above maximum parameter? - // @arg {*} arg - // @returns {boolean} - under: (arg, max = 100) => is.all.number(arg, max) && arg < max, - - // @description is a given arg null? - // @arg {*} arg - the item you want to check and see if it's `null` - // @returns {boolean} - null: (arg) => arg === null, - - // @description is a given arg a promise? - // @arg {*} arg - the item you want to check and see if it's a `Promise` - // @returns {boolean} - promise: arg => arg && is.function(arg.then), - - // @description is a given arg a stream? - // @arg {*} arg - the item you want to check and see if it's a `stream` - // @returns {boolean} - stream: arg => arg && is.function(arg.pipe), - - // @description is a given arg a stream? - // @arg {*} arg - the item you want to check and see if it's a `stream` - // @returns {boolean} - buffer: arg => Buffer.isBuffer(arg) -}; - -// included method does not support `all` and `any` interfaces -is.included.api = ["not"]; - -// within method does not support `all` and `any` interfaces -is.between.api = ["not"]; - -// `above` method does not support `all` and `any` interfaces -is.above.api = ["not"]; - -// least method does not support `all` and `any` interfaces -is.under.api = ["not"]; - - -is.in.api = ["not"]; - -is.all.in = (obj, ...values) => { - values = to.array.flat(values); - for(let i in values){ - if(!is.in(obj, values[i])){ - return false; - } - } - return true; -}; - -is.any.in = (obj, ...values) => { - values = to.array.flat(values); - for(let i in values){ - if(is.in(obj, values[i])){ - return true; - } - } - return false; -}; - -const not = (func) => () => !func.apply(null, array_slice(arguments)), - all = (func) => { - return function(){ - let parameters = array_slice(arguments), - length = parameters.length; - - // support array - if(length === 1 && is.array(parameters[0])){ - parameters = parameters[0]; - length = parameters.length; - } - - for(let i = 0, l = length; i < length; i++){ - if(!func.call(null, parameters[i])){ - return false; - } - } - - return true; - }; - }, - any = (func) => { - return function(){ - let parameters = array_slice(arguments), - length = parameters.length; - - // support array - if(length === 1 && is.array(parameters[0])){ - parameters = parameters[0]; - length = parameters.length; - } - - for(var i = 0, l = length; i < l; i++){ - if(func.call(null, parameters[i])){ - return true; - } - } - return false; - }; - }, - setInterfaces = (() => { - var options = is; - for(var option in options){ - if(hasOwnProperty.call(options, option) && is.function(options[option])){ - var interfaces = options[option].api || ["not", "all", "any"]; - for(let i in interfaces){ - if(interfaces[i] === "not"){ - is.not[option] = not(is[option]); - } - if(interfaces[i] === "all"){ - is.all[option] = all(is[option]); - } - if(interfaces[i] === "any"){ - is.any[option] = any(is[option]); - } - } - } - } - })(); diff --git a/app/utils/debug.js b/app/utils/debug.js new file mode 100644 index 0000000..293bb0b --- /dev/null +++ b/app/utils/debug.js @@ -0,0 +1,256 @@ +import { is, to, Logger } from './' +import clor from 'clor' + +/// @name debug +/// @description +/// This is a ES7/ES2016 decorator function. It adds helpful debugging capabilities +/// to any class with the option to turn it off an on with ease +/// +/// @arg {boolean} value [false] determins if you want to debug your function +/// +/// @markup Basic Setup +/// @debug() +/// class MyClass {} +/// +/// @markup Debugging information +/// class MyClass { +/// constructor(str) { +/// this.lines = str.split('\n') +/// ... +/// return this.parse() +/// } +/// parse() { +/// for ( let [ lineno, line] of this.lines.entries()) { +/// this.debug('lineno', lineno) +/// this.debug('line', line) +/// this.debug('other useful information') +/// +/// this.runDebug() +/// } +/// } +/// } +/// +/// const test = new MyClass( +/// ` +/// var foo = 'bar' +/// var bar = 'bar' +/// ` +/// ) +/// +/// @markup Yields +/// [user:~/path/to/project]$ +/// +/// +/// » [DEBUG] +/// lineno: 0 +/// line: +/// +/// +/// » [DEBUG] +/// lineno: 1 +/// line: var foo = 'bar' +/// +/// +/// » [DEBUG] +/// lineno: 2 +/// line: var bar = 'bar' +/// +/// +/// » [DEBUG] +/// lineno: 3 +/// line: +/// +/// @markup Multiple debuggers +/// class MyClass { +/// ... +/// parse() { +/// const parseDebug = this.debugSet() +/// for ( let [ lineno, line] of this.lines.entries()) { +/// parseDebug.debug('lineno', lineno) +/// parseDebug.debug('line', line) +/// parseDebug.debug('other useful information') +/// +/// parseDebug.runDebug() +/// } +/// } +/// } +/// +export default function debug(default_name = 'DEBUG', default_should_debug = false, default_options = {}) { + try { + let color_list = [ 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray' ] + + default_options = to.extend({ + spaces: 2, + seperator: ' > ', + color: to.random(color_list) + }, default_options) + + color_list = color_list.filter((color_name) => color_name !== default_options.color) + + const log = new Logger() + + const icon_chevron = '\xBB ' + + default_name = clor[default_options.color].bold(`${icon_chevron}[${default_name}]: `) + + + function Debugger(name = 'Define a Name', should_debug = default_should_debug, options = {}) { + if (is.plainObject(should_debug)) { + options = should_debug + should_debug = options.should_debug || options.condition || default_should_debug + } + this.should_debug = should_debug + this.debug_list = [] + this.name = name + this.color = options.color + this.spaces = options.spaces + } + + const dp = Debugger.prototype + + dp.push = dp.debug = dp.add = function push(...args) { + this.debug_list.push(...args) + return this + } + + dp.always = function always(arg, ...args) { + this.debug_list.push(...args) + return arg + } + + dp.shouldRun = function shouldRun(...args) { + let should_run = false + let last = args.slice(-1)[0] + if (is.boolean(last)) { + should_run = last + args.pop() + } + this.debug_list.push(...args) + if (should_run) { + this.run() + } + return args + } + + dp.debugIfElse = dp.ifElse = dp.ife = dp.if = function debugIfElse(arg, if_true, if_false) { + if (is.truthy(arg) && !is.undefined(if_true)) { + this.debug_list.push(if_true) + } else if (!is.undefined(if_false)) { + this.debug_list.push(if_false) + } + return arg + } + + dp.debugIfTrue = dp.ifTrue = function debugIfTrue(arg, ...args) { + if (is.truthy(arg)) { + this.shouldRun(...args) + } + + return arg + } + + + dp.debugIfFalse = dp.ifFalse = function debugIfFalse(arg, ...args) { + if (arg === false) { + this.shouldRun(...args) + } + + return arg + } + + dp.debugWrap = dp.wrap = function debugWrap(arg, cb, ...args) { + if (is.undefined(cb)) { + cb = () => true + } + if (cb(arg)) { + this.shouldRun(...args) + } + + return arg + } + + dp.debugSet = dp.set = function debugSet(name = 'define a name silly', should_debug, options = {}) { + if (is.plainObject(should_debug)) { + options = should_debug + should_debug = undefined + } if (is.number(should_debug)) { + options.spaces = should_debug + should_debug = undefined + } else if (is.string(should_debug)) { + options.color = should_debug + should_debug = undefined + } + + // if should_debug is not defined then it will inherit the value that + // was set on the original debugSet or its parent + if (is.undefined(should_debug)) { + should_debug = !is.undefined(this.should_debug) ? this.should_debug : default_should_debug + } + + if ( + options.color === 'inherit' || ( + this.color === 'inherit' && + is.undefined(options.color) + ) + ) { + options.color = this.color ? this.color : default_options.color + } + + options = to.extend({ + // if the parent debugSet exsists then use it's defined spaces, + // else use the default spaces + spaces: this.spaces ? this.spaces : default_options.spaces, + seperator: this.seperator ? this.seperator : default_options.seperator, + color: to.random(color_list) + }, options) + + // colorize the name + name = clor[options.color].bold(name) + + // if a name exists then prepend it to the name that was passed + name = this.name ? this.name + options.seperator + name : default_name + name + + return new Debugger(`${name}`, should_debug, options) + } + + /* eslint-disable */ + dp.runDebug = dp.run = function runDebug() { + try { + if (this.should_debug) { + for (let i = this.spaces; i; i--) console.log('') + console.log(this.name) + if (this.debug_list.length > 0) { + this.debug_list.slice(0, 1).forEach((obj) => log.print(obj)) + this.debug_list.slice(1).forEach((obj) => log.print(obj)) + } + // update the debug list to be empty + this.debug_list = [] + } + } catch (e) { + console.trace(e) + } + } + /* eslint-enable */ + + for (let fn in dp) { + if (fn !== 'run' || fn !== 'runDebug') { + dp[fn].run = dp[fn].runDebug = dp.runDebug + } + } + + // for (let fn_to_set in dp) { + // for (let fn in dp) { + // if (fn_to_set !== 'run' || fn_to_set !== 'runDebug') { + // dp[fn_to_set][fn] = dp[fn_to_set].prototype[fn] = dp[fn] + // } + // } + // } + + return function debugDecorator(target) { + target.prototype.debugSet = Debugger.prototype.debugSet + return target + } + } catch (err) { + console.trace(err) + } +} diff --git a/app/utils/fs.js b/app/utils/fs.js new file mode 100644 index 0000000..cd1f008 --- /dev/null +++ b/app/utils/fs.js @@ -0,0 +1,12 @@ +// File System +import fs from 'fs-extra' +import promisify from 'es6-promisify' + +// The functions below are converted into promises +fs.readJson = promisify(fs.readJson) +fs.outputJson = promisify(fs.outputJson) +fs.stat = promisify(fs.stat) +fs.readFile = promisify(fs.readFile) +fs.ensureFile = promisify(fs.ensureFile) + +export default fs diff --git a/app/utils/glob.js b/app/utils/glob.js new file mode 100644 index 0000000..30bd860 --- /dev/null +++ b/app/utils/glob.js @@ -0,0 +1,57 @@ +import to from './to' +import is from './is' +import promisify from 'es6-promisify' +import path from 'path' +import { map, filter } from 'async-array-methods' + +// can't use `import` from es6 because it +// returns an error saying "glob" is read only +const rawGlob = promisify(require('glob')) + + +/// @description +/// This is a better version of glob. It is built as a generator +/// that has the ability to ignore files. As well as the ability to run +/// a callback filter on the matched files. The callback can be async as well. +/// +/// @arg {string, array} files - Glob patterns to get +/// @arg {string, array} ignore [[]] - Glob patterns to ignore +/// @arg {function, boolean} filter - Filter to run on the files +/// @arg {boolean} files_only [true] - Only return file paths +export default async function glob(files, ignore = [], callback, files_only = true) { + files = map(to.array(files), (file) => rawGlob(file)) + ignore = map(to.array(ignore), (file) => rawGlob(file.replace(/!/, ''))) + + files = to.flatten(await files) + ignore = to.flatten(await ignore) + + // removed any files that are supposed to be ignored + if (ignore.length) { + files = files.filter((file) => { + for (var i in ignore) { + if (ignore.hasOwnProperty(i)) { + if (file.indexOf(ignore[i]) > -1) { + return false + break + } + } + } + + return true + }) + } + + if (files_only) { + files = files.filter((file) => path.extname(file).indexOf('.') > -1) + } + + if (is.fn(callback)) { + if (is.promise(callback())) { + return await filter(files, callback) + } + + return files.filter(callback) + } + + return files +} diff --git a/app/utils/index.js b/app/utils/index.js new file mode 100644 index 0000000..cb8e966 --- /dev/null +++ b/app/utils/index.js @@ -0,0 +1,7 @@ +export Logger from './logger' +export { Purdy } from './purdy' +export fs from './fs' +export glob from './glob' +export is from './is' +export to from './to' +export debug from './debug' diff --git a/app/utils/is.js b/app/utils/is.js new file mode 100644 index 0000000..0f4ffdb --- /dev/null +++ b/app/utils/is.js @@ -0,0 +1,97 @@ +//// +/// @author Tyler Benton +/// @description +/// A few additional helper functions for the fantastic [`is.js`](https://github.com/arasatasaygin/is.js/blob/master/is.js) library. +/// @page utils/is +//// + +const toString = (arg) => Object.prototype.toString.call(arg) + +import to from './to.js' +import is from 'is_js' + +/// @name is.false +/// @description is a given arg false +/// @arg {*} arg - arg to check if it is false +/// @returns {boolean} +is.false = (arg) => arg === false + +/// @name is.false +/// @alias is.function +/// @description is a given arg a function +/// @arg {*} arg - arg to check if it is a function +/// @returns {boolean} +is.fn = is.function + +/// @name is.in +/// @description is the `value` in `obj`? +/// @arg {array, string, object} obj - the item to check against +/// @arg {*} value - the value to look for in the `obj` +/// @returns {boolean} +is.in = (obj, value) => (is.plainObject(obj) ? to.keys(obj) : obj).indexOf(value) > -1 + + +/// @name is.plainObject +/// @description is the `value` in `obj`? +/// @arg {array, string, object} obj - the item to check against +/// @arg {*} value - the value to look for in the `obj` +/// @returns {boolean} +is.plainObject = (arg) => toString(arg) === '[object Object]' + + +/// @name is.between +/// @description is a given number within minimum and maximum parameters? +/// @arg {*} arg +/// @arg {number} min [0] +/// @arg {number} max [Infinity] +/// @returns {boolean} +is.between = (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max) + +/// @name is.promise +/// @description is a given arg a promise? +/// @arg {*} arg - the item you want to check and see if it's a `Promise` +/// @returns {boolean} +is.promise = (arg) => arg && is.fn(arg.then) + +/// @name is.buffer +/// @description is a given arg a stream? +/// @arg {*} arg - the item you want to check and see if it's a `stream` +/// @returns {boolean} +is.buffer = (arg) => Buffer.isBuffer(arg) + +/// @name is.included +/// @description is a given string include parameter substring? +/// @arg {string, array} a - string to match against +/// @arg {string, array} b - string to look for in `str` +/// @returns {number, boolean} +/// @todo {10} remove this because it doesn't really fit with the `is` library +is.included = (a, b) => !is.empty(a) && !is.empty(b) && a.indexOf(b) > -1 ? a.indexOf(b) : false + +/// @name is.symbol +/// @description is a given arg a symbol? +/// @arg {*} arg - The item to check +/// @returns {boolean} - The result of the test +is.symbol = (arg) => typeof arg === 'symbol' + +is.all.in = (obj, ...values) => { + values = to.flatten(values) + for (let i in values) { + if (!is.in(obj, values[i])) { + return false + } + } + return true +} + +is.any.in = (obj, ...values) => { + values = to.flatten(values) + for (let i in values) { + if (is.in(obj, values[i])) { + return true + } + } + return false +} + + +export default is diff --git a/app/utils/logger.js b/app/utils/logger.js new file mode 100644 index 0000000..779fbd4 --- /dev/null +++ b/app/utils/logger.js @@ -0,0 +1,155 @@ +import Purdy from './purdy' +import clor from 'clor' +import to from './to' + +let icon = { + chevron: '\xBB ', + check: '\u2713 ', + warning: '\u26A0 ', + error: '\u2326 ' +} + +const messaging = { + warning: clor.yellow.bold(`${icon.warning}[WARNING]`), + debug: clor.magenta.bold(`${icon.chevron}[DEBUG]`), + error: clor.red.bold(`${icon.error}[ERROR]`), + file: clor.bgBlue.white(`${icon.chevron}[FILE]`) +} + +const purdy = new Purdy() + +export default class Logger { + constructor(options = {}) { + this.events = [] + this.times = {} + this.options = options + + this.report() + } + + /// @description + /// Observe an event. + /// @arg {string} name of event to observe + /// @arg {function} handler + on(name, cb) { + (this.events[name] = this.events[name] || []).push(cb) + return this + } + + /// @description Emit an event to observers. + /// @arg {string} name of event to emit + /// @arg {object} data to send + emit(name, ...args) { + (this.events[name] || []).forEach((event) => event.call(this, ...args)) + return this + } + + format(...args) { + return to.map(args, (arg) => { + switch (to.type(arg)) { + case 'array': + case 'object': + case 'number': + return purdy.format(arg).toString() + case 'function': + let obj = to.array(arg.toString()) + const first = obj.shift() + return first + '\n' + to.normalize(obj) + case 'string': + return to.normalize(arg) + default: + return arg + } + }) + } + + print(...args) { + console.log(...this.format(...args)) + return this + } + + space() { + console.log('') + } + + report() { + let { + debug = true, + warning = true, + timestamps = true + } = this.options + + this.on('annotation_error', ({ annotation, error_message }) => + this.error(`with ${annotation}`, error_message)) + + if (timestamps) { + this + .on('start', (name) => this.time(name)) + .on('complete', (name, format = '%s finished after %dms') => + this.timeEnd(name, format)) + } + + if (debug) { + this + .on('debug', this.debug) + .on('file', this.file) + } + + if (warning) this.on('warning', this.warn) + + this.on('success', this.success) + } + + warn(...args) { + console.log('') + this.print(`${messaging.warning}`) + this.print(...args) + return this + } + + error(...args) { + console.log('') + this.print(`${messaging.error}`) + this.print(...args) + return this + } + + time(label) { + this.times[label] = Date.now() + return this + } + + timeEnd(label, format = '%s completed after %dms') { + let time = this.times[label] + + if (!time) { + throw new Error(`No such label: ${label}`) + } + + let duration = Date.now() - time + console.log( + `${clor.green(icon.check)}${format}`, + label, + duration + ) + return this + } + + debug(...args) { + console.log('') + this.print(`${messaging.debug}`) + this.print(...args) + return this + } + + success(...args) { + this.print(`${clor.green(icon.check)}`, ...args) + } + + file(file, ...args) { + console.log('') + this.print(`${messaging.file} ${file}`) + this.print(...args) + return this + } +} diff --git a/app/utils/purdy.js b/app/utils/purdy.js new file mode 100644 index 0000000..6a08eea --- /dev/null +++ b/app/utils/purdy.js @@ -0,0 +1,263 @@ +// Load modules +import to from './to' +import clor from 'clor' + +export default class Purdy { + constructor(options = {}) { + this.config = { + plain: false, + path: false, + indent: 2, + align: 'left', + arrayIndex: true, + path_prefix: '// ', + colors: { + BoolFalse: 'red.bold', + BoolTrue: 'green.bold', + Circular: 'grey.bold.inverse', + Date: 'yellow', + error: 'red', + Function: 'cyan', + Key: 'white.bold', + Null: 'red.bold', + Number: 'blue.bold', + RegExp: 'magenta', + String: 'green', // use the default color + Undefined: 'red.inverse', + path: 'grey' + } + } + + to.extend(this.config, options) + + this.indent_level = 0 + this.seen = [] + this.path = [] + + return this + } + + print(...args) { + return console.log(...this.format(...args)) + } + + log(...args) { + return this.print(...args) + } + + format(...args) { + this.seen = [] + this.path = [] + return args.map((arg) => { + this.indent_level = 0 + return this.travel(arg) + }) + } + + travel(object, path = '') { + let type = global.toString.call(object).split(' ')[1].slice(0, -1) + return this.colorize((this[`_${type.toLowerCase()}`] || String).call(this, object, path), type) + } + + colorize(string, type) { + if (this.config.plain) { + return string + } + + let colors = this.config.colors[type] + + if (!colors) { + return string + } + + colors = colors.split('.') + + for (let color of colors) { + string = clor[color](string) + } + + return string + } + + length_compare(a, b) { + return a.length - b.length + } + + tidy_path(path) { + return this.colorize(path.slice(1, path.size), 'path') + } + + print_member(member, max) { + if (this.config.align === 'left') { + max = 0 + } + + return this.colorize(this.spaces(max.length - member.length) + member, 'Key') + } + + indent() { + return this.spaces(this.indent_level * this.config.indent) + } + + spaces(count) { + let out = '' + while (count--) out += ' ' + return out + } + + show_circular(index) { + let show_path = this.path[index] + show_path = show_path === '' ? '' : ` ${show_path.slice(1, show_path.length)}` + return this.colorize(`[Circular~${show_path}]`, 'Circular') + } + + + _object(object, path) { + if (to.keys(object).length === 0) { + return '{}' + } + + const index = this.seen.indexOf(object) + + if (index !== -1) { + return this.show_circular(index) + } + + this.seen.push(object) + this.path.push(path) + + const keys = to.keys(object) + let key_lengths = to.clone(keys) + + this.indent_level += 1 + + let out = '{\n' + + for (let i = 0, l = keys.length; i < l; ++i) { + let key = keys[i] + let item = object[key] + + if (this.config.path && path.length > 0) { + key_lengths.push(this.config.path_prefix) + out += this.indent() + + this.colorize(this.config.path_prefix, 'path') + + this.tidy_path(path + '.' + key) + + '\n' + } + + let longest = key_lengths.sort(this.length_compare)[key_lengths.length - 1] + let key_str = key.toString() + + out += this.indent() + + this.print_member(key_str, longest) + + ': ' + + this.travel(item, `${path}.${key_str}`) + + if (i !== l - 1) { + out += ',' + } + + out += '\n' + } + + this.indent_level -= 1 + + out += this.indent() + '}' + + return out + } + + _array(array, path) { + if (array.length === 0) { + return '[]' + } + + let index = this.seen.indexOf(array) + + if (index !== -1) { + return this.show_circular(index) + } + + this.seen.push(array) + this.path.push(path) + + let out = '[\n' + + this.indent_level += 1 + + for (let i = 0, l = array.length; i < l; ++i) { + let item = array[i] + + if (this.config.path && path.length > 0) { + out += this.indent() + + this.colorize(this.config.path_prefix, 'path') + + this.tidy_path(path + '.' + i) + + '\n' + } + + let index_str = this.config.arrayIndex ? `[${this.print_member(i, l)}] ` : '' + + out += this.indent() + '' + index_str + this.travel(item, `${path}.${i}`) + + if (i !== l - 1) { + out += ',' + } + + out += '\n' + } + + this.indent_level -= 1 + out += this.indent() + ']' + return out + } + + _error(err) { + if (Object.keys(err).length === 0) { + return this.colorize(`[${err}]`, 'error') + } + return this.types.Object(err) + .replace(/^{/, '{ ' + this.colorize(`[Error: ${err.message}]`, 'error')) + } + + _string(str) { + // str = to.normalize(str, false).split('\n') + str = to.array(str) + let quote = str.length > 1 ? '`' : "'" + let l = str.length + + // returns because it's a single line string + if (l <= 1) { + return quote + to.string(str) + quote + } + + // let has_newline_only = /(?:\s*?(\n)\s*?)(.*)/.exec(str[0]) + + str.splice(0, 1, quote + str[0]) + str.splice(l - 1, l, str[l - 1] + quote) + + // removes the first line from the str so it doesn't get indented + let out = str.splice(0, 1) + + for (let line of str) { + out.push(this.indent() + this.colorize(line, 'string')) + } + + return out.join('\n') + } + + _boolean(bool) { + if (bool === true) { + return this.colorize(bool + '', 'BoolTrue') + } + + return this.colorize(bool + '', 'BoolFalse') + } + + _function(func) { + if (func.name) { + return this.colorize(`[Function: ${func.name}]`, 'Function') + } + + return this.colorize('[Function: ?]', 'Function') + } +} diff --git a/app/utils/to.js b/app/utils/to.js new file mode 100644 index 0000000..b52c25b --- /dev/null +++ b/app/utils/to.js @@ -0,0 +1,841 @@ +const toString = (arg) => Object.prototype.toString.call(arg) +const arraySlice = (arg) => Array.prototype.slice.call(arg) + +import markdown from 'marked' +import changeCase from 'change-case' +import is from './is.js' +import clone from 'clone' + +let to = { + /// @name to.markdown + /// @description + /// Helper function to convert markdown text to html + /// For more details on how to use marked [see](https://www.npmjs.com/package/marked) + /// @returns {string} of `html` + markdown: (...args) => markdown(to.string(to.flatten(...args))), + + ...changeCase, + + /// @name to.type + /// @description + /// since `typeof` can't tell the difference between an array and an actual object + /// this function will return the correct result + /// @returns {string} + type(arg) { + let result = toString(arg).slice(8, -1).toLowerCase() + + if (result === 'uint8array') { + return 'buffer' + } + + return result + }, + + /// @name to.clamp + /// @description + /// This is used to clamp a number between a min an max value + /// It ensures a number will always be between the passed values + /// @returns {number} + clamp(value, min = 0, max = Infinity) { + if (value > max) { + return max + } else if (value < min) { + return min + } + + return value + }, + + /// @name to.random + /// @description + /// This function will return a random number or value depending on what it's passed + /// @arg {array, object, number} - Item you want to get a random value or number from + /// @returns {*} + random(min = 0, max = 100) { + let value + let length = arguments.length + + switch (to.type(min)) { + case 'number': + if (min === max) { + return min + } + return Math.floor(Math.random() * (max - min + 1)) + min + break + case 'array': + case 'object': + switch (length) { + case 3: + value = min + min = max + max = arguments[2] + break + case 2: + value = min + min = 0 + break + case 1: + value = min + min = 0 + break + default: + throw new Error('a max of 3 params is allowed') + break + } + case 'array': // eslint-disable-line + if (length === 1) { + max = value.length - 1 + } + return value[to.random(min, max)] + break + case 'object': + const keys = to.keys(value) + if (length === 1) { + max = keys.length - 1 + } + return value[keys[to.random(min, max)]] + break + default: + console.log(`${to.type(min)} is not allowed`) + return min + } + }, + + /// @name to.string + /// @description + /// Converts an object, array, number, or boolean to a string + /// @arg {string, object, array, number, boolean} + /// @returns {string} + string(arg, glue = '\n') { + if (is.string(arg)) { + return arg + } + + if (Buffer.isBuffer(arg)) { + return arg + '' + } + + if (is.plainObject(arg)) { + return toString(arg) + } + + if (is.array(arg)) { + return arg.join(glue) + } + + return arg + '' + }, + + + /// @name to.normalString + /// @description + /// The ` + ""` converts the file from a buffer to a string + /// + /// The `replace` fixes a extremely stupid issue with strings, that is caused by shitty microsoft computers. + /// It removes`\r` and replaces it with `\n` from the end of the line. If this isn't here then when `match` + /// runs it will return 1 more item in the matched array than it should(in the normalize function) + /// http://stackoverflow.com/questions/20023625/javascript-replace-not-replacing-text-containing-literal-r-n-strings + /// + /// @arg {*} + /// @returns {string} That has microsoft crap removed from it + normalString: (str) => to.string(str).replace(/\r\n|\n/g, '\n'), + + /// @name to.keys + /// @description + /// Converts an object to an array of it's key names. + /// It also get's symbols if they're set as a key name. + /// @arg {object} + /// @returns {array} + keys(arg) { + if (!is.plainObject(arg) && !is.symbol(arg)) { + return arg + } + + return to.flatten([ Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg) ]) + }, + + /// @name to.keys + /// @description + /// Converts an object to an array of it's values names. + /// @arg {object} arg - The object to get the values from + /// @arg {string} ...rest - A list of values + /// if you want to exclude a specific key you can use `!keyname` + /// or if you want to only get specific values then you can pass in + /// the specific values that you want to get. By default if ``...rest` + /// is empty it will return all the values in the object. + /// @returns {array} + /// @markup Example: + /// const obj = { one: 1, two: 2, three: 3 } + /// to.values(obj) // [ 1, 2, 3 ] + /// to.values(obj, '!two') // [ 1, 3 ] + /// to.values(obj, 'two', 'three') // [ 2, 3 ] + values(arg, ...rest) { + let values = [] + let not = [] + let include = [] + + for (let item of rest) { + if (item.slice(0, 1) === '!') { + not.push(item.slice(1)) + } else { + include.push(item) + } + } + + let iterate = is.empty(include) ? to.keys(arg) : include + + for (var i = 0; i < iterate.length; i++) { + if (!is.in(not, iterate[i])) { + values.push(arg[iterate[i]]) + } + } + + return values + }, + + /// @name to.entries + /// @description + /// Makes objects, and arrays easier to iterate over! + /// + /// @returns {Symbol.iterator} + /// + /// @markup {js} **Example:** + /// let obj = { + /// first: "Jane", + /// last: "Doe" + /// } + /// + /// for(let [key, value] of to.entries(obj)){ + /// console.log(`${key}: ${value}`) + /// } + /// + /// // Output: + /// // first: Jane + /// // last: Doe + /// + /// @markup {js} **Example:** + /// let obj = ["Jane", "Doe"] + /// + /// for(let [index, value] of to.entries(obj)){ + /// console.log(`${index}: ${value}`) + /// } + /// + /// // Output: + /// // 0: Jane + /// // 1: Doe + entries(obj, start = 0, end /* = item.length || to.keys(item).length */) { + let i = start + // this is what's returned when the iterator is done + const done = { done: true } + // this is the base iterator + let iterator = { + [Symbol.iterator]() { + return this + } + } + + if (is.array(obj)) { + if (is.undefined(end)) { + end = obj.length + } + + if (i < end) { + iterator.next = () => { + if (i < end) { + return { value: [ i, obj[i++] ] } + } + return done + } + } else { + iterator.next = () => { + if (i > end) { + return { value: [ i, obj[i--] ] } + } + return done + } + } + + return iterator + } + + // In ES6, you can use strings or symbols as property keys, + // Reflect.ownKeys() retrieves both. But the support it is + // extremly low at the time of writing this. + let keys = to.keys(obj) + if (is.undefined(end)) { + end = keys.length + } + + if (i < end) { + iterator.next = () => { + if (i < end) { + let key = keys[i] + return { value: [ key, obj[key], i++ ] } + } + return done + } + } else { + iterator.next = () => { + if (i > end) { + let key = keys[i] + return { value: [ key, obj[key], i-- ] } + } + return done + } + } + + return iterator + }, + + /// @name object entries + /// @description + /// This function takes advatage of es6 object deconstructing abilities. + /// It dramatically simplifies looping over objects, when you know the keys + /// you're looping over. + /// + /// @arg {object} obj - The object you're looping over + /// @arg {string} key_name ['key'] - The name of the current key in the object loop + /// @arg {string} index_name ['i'] - The name of the current index in the loop + /// + /// @markup {js} **Example:** + /// let example = { + /// foo: { + /// one: 'Item one', + /// two: 'Item two', + /// three: 'Item three' + /// } + /// } + /// + /// for (let { key, one, two, three } of to.objectEntries(example)) { + /// // key -> 'foo' + /// // one -> 'Item one' + /// // two -> 'Item two' + /// // three -> 'Item three' + /// } + objectEntries(obj, key_name = 'key', index_name = 'i') { + let i = 0 + let keys = to.keys(obj) + let length = keys.length + + return { + [Symbol.iterator]() { + return this + }, + next() { + if (i < length) { + let key = keys[i] + i++ + return { + value: { + [key_name]: key, + [index_name]: i - 1, + ...obj[key] + } + } + } + + return { done: true } + } + } + }, + + /// @name to.normalize + /// @description + /// Removes trailing/leading blank lines. Removes extra whitespace before all the lines that + /// are passed without affecting the formatting of the passes string. Then removes + /// all whitespace at the end of each line. + /// @arg {string, array} content - The content you want to be normalized + /// @arg {boolean} leading [true] - Determins if leading blank lines should be removed + /// @arg {boolean} trailing [leading] - Determins if trailing blank lines should be removed. It defaults to `leading`. + /// @arg {boolean} info [false] + /// If this is set to true it will return an object of the information of what was removed + /// along with the normalized string + /// + /// ```js + /// { + /// content, // the updated string + /// leading, // the total leading lines that were removed + /// trailing, // the total trailing lines that were removed + /// } + /// ``` + /// + /// @note {5} You can also pass in named arguments in the form of an object + /// + /// @markup Usage: All of these return the same result + /// let content = ` + /// + /// foo + /// bar + /// baz + /// + /// ` // aka "\n\n foo\n bar\n baz\n\n" + /// to.normalize(content) + /// to.normalize(content.split('\n')) // aka [ '', '', ' foo', ' bar', ' baz', '', '' ] + /// to.normalize({ content }) + /// // => "foo\nbar\nbaz" + /// + /// @markup Usage: passing options + /// let content = ` + /// Lorem ipsum dolor sit amet, consectetur adipisicing elit. + /// Nemo cum, nostrum rem neque perspiciatis fugiat similique + /// unde adipisci officia, placeat suscipit explicabo non + /// consequuntur in numquam eaque laborum voluptas. Cumque? + /// ` + /// let trailing = true + /// let leading = trailing + /// let info = false + /// + /// to.normalize(content) + /// to.normalize({ content }) + /// to.normalize({ content }, trailing) + /// to.normalize(content, trailing, leading, info) + /// to.normalize(content, { trailing, leading, info }) + /// to.normalize({ content, trailing, leading, info }) + /// + /// // all the `to.normalize` functions above result in the same thing + /// // because these are the defaults + /// + /// // `Lorem ipsum dolor sit amet, consectetur adipisicing elit. + /// // Nemo cum, nostrum rem neque perspiciatis fugiat similique + /// // unde adipisci officia, placeat suscipit explicabo non + /// // consequuntur in numquam eaque laborum voluptas. Cumque?` + /// + /// + /// @markup Usage with info + /// let content = ` + /// + /// Lorem ipsum dolor sit amet, consectetur adipisicing elit. + /// Nemo cum, nostrum rem neque perspiciatis fugiat similique + /// + /// ` aka "\n\n Lorem ipsum dolor sit amet, consectetur adipisicing elit.\n Nemo cum, nostrum rem neque perspiciatis fugiat similique\n\n" + /// + /// to.normalize(content, true, true, true) + /// to.normalize(content, { info: true }) + /// to.normalize({ content, info: true }) + /// + /// // { + /// // "content": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nNemo cum, nostrum rem neque perspiciatis fugiat similique", + /// // "indent": 4, + /// // "leading": 2, // 2 leading blanks lines were remove + /// // "trailing": -2 // 2 trailing lines were removed + /// // } + /// + /// @returns {string} - The normalized string + normalize(...args) { + const options = to.arguments({ + content: '', + leading: true, + trailing: undefined, + info: false + }, ...args) + options.trailing = !is.undefined(options.trailing) ? options.trailing : options.leading + + let content = to.array(options.content) // this allows arrays and strings to be passed + let leading = 0 + let trailing = 0 + + if (options.leading) { + while (content.length && !!!content[0].trim().length) { + leading++ + content.shift() + } + } + + if (options.trailing) { + while (content.length && !!!(content[content.length - 1].trim()).length) { + trailing-- + content.pop() + } + } + + const indent = to.indentLevel(content) + + content = content + .map((line) => line.slice(indent)) // remove extra whitespace from the beginning of each line + .join('\n') // converts content to string + .replace(/[^\S\r\n]+$/gm, '') // removes all trailing white spaces from each line + + if (!options.info) { + return content + } + + return { content, indent, leading, trailing } + }, + + indentLevel(str) { + return to.string(str) // ensures argument is a string + // gets the extra whitespace at the beginning of the line and + // returns a map of the spaces + .match(/^\s*/gm) + // sorts the spaces array from smallest to largest and then checks + // returns the length of the first item in the array + .sort((a, b) => a.length - b.length)[0].length + }, + + arguments(defaults = {}, ...args) { + let result = {} // placeholder for the result + let keys = to.keys(defaults) + + for (let [ i, arg ] of to.entries(args)) { + if (is.arguments(arg)) { + arg = to.arguments(defaults, ...arraySlice(arg)) + } + if (is.plainObject(arg)) { + const initial = defaults[keys[i]] + if ( + is.plainObject(initial) && + is.any.in(to.keys(initial), ...to.keys(arg)) + ) { + result[keys[i]] = to.extend(to.clone(initial), arg) + } else { + to.extend(result, arg) + } + } else { + result[keys[i] || i] = arg + } + } + + return to.extend(defaults, result) + }, + + /// @name to.extend + /// @description + /// Extend object `b` onto `a` + /// http://jsperf.com/deep-extend-comparison + /// @arg {object} a - Source object. + /// @arg {object} b - Object to extend with. + /// @returns {object} The extended object. + extend(a, b) { + // Don't touch `null` or `undefined` objects. + if (!a || !b) { + return a + } + + for (let k in b) { + if (b.hasOwnProperty(k)) { + if (is.plainObject(b[k])) { + a[k] = is.plainObject(a[k]) ? to.extend(a[k], b[k]) : b[k] + } else { + a[k] = b[k] + } + } + } + + return a + }, + + /// @name to.clone + /// @description + /// This will clone argument so the passed arg doesn't change + /// + /// @arg {*} - The item you want to clone + /// @returns {*} - The copied result + clone, + + /// @name to.merge + /// @description + /// This is similar to `to.extend` except in `to.extend` the values + /// in `a` are replaced with the values in `b`. This function will + /// not only merge the objects together, it also merges the values of + /// the objects together. + /// + /// If the value in `b` is a function **or** the value of `a` is undefined + /// it will just set the value of `a` to be the value of `b` + /// + /// If the value in `a` is an array, then the value in `b` gets pushed + /// onto the value in `a`. + /// + /// If the value in `a` is an object then it checks the value in `b` to + /// see if it's an object and if it is then it calls `to.merge` again on + /// those objects for recursion. If the value in `b` isn't an object then + /// the value in `a` get's replaced by the value in `b`. + /// + /// If the value in `a` is anything else, then it converts it into an array + /// and adds the value in `b` to it.(`[a[key], b[key]]`) + /// + /// @arg {object} - The object to be modified + /// @arg {object} - The object that has the updates + /// @arg {boolean} - If true every array will be flattend to a single dimensional array, and will remove duplicate values + /// + /// @markeup {js} **Example:** + /// let a = { foo: { bar: "1", baz: ["3", "4"], qux: "one", quux: { garply: { waldo: "one" } }, waldo: "" } } + /// let b = { + /// foo: { + /// bar: "2", + /// baz: ["5", "6"], + /// qux: ["two", "three"], + /// quux: { garply: { waldo: "two" } }, + /// waldo: function(){ return this; }, + /// garply: "item" + /// } + /// } + /// + /// to.merge(a, b) + /// + /// @markup {js} **Output:** + /// { + /// foo: { + /// bar: [ "1", "2" ], // started as a string and converted to an array + /// baz: [ "3", "4", "5", "6" ], // merged two arrays together + /// qux: [ "one", "two", "three" ], // started as a string and merged the array with the string + /// quux: { garply: { waldo: [ "one", "two" ] } }, // `foo.quux.garply.waldo` started as string and converted to an array + /// waldo: function(){ return this; }, // started as a string and changed to be a function + /// garply: "item" // didn't exist before so it stays as a string + /// } + /// } + merge(a, b, unique = true, flat = true) { // eslint-disable-line + // a) Don't touch `null` or `undefined` objects. + if (!a || !b) { + return a + } + + // loop over each key in the second map + for (let k in b) { + if (b.hasOwnProperty(k)) { + // a) Set the value of `a` to be the value in `b` because it was either + // a function or it didn't exsit already in `a` + // c) Push the value in `b` into the `a` values array + // b) The recursive functionality happends here + // a) Call the merge function go further into the object + // b) Sets the value of `a` to be the value of `b` + // d) Convert the a value to be an array, and add the `b` value to it + if (is.fn(b[k]) || is.fn(a[k]) || is.undefined(a[k])) { + a[k] = b[k] + } else if (is.array(a[k])) { + a[k].push(b[k]) + } else if (is.plainObject(a[k])) { + a[k] = is.plainObject(b[k]) ? to.merge(a[k], b[k]) : b[k] + } else { + a[k] = [ a[k], b[k] ] + } + + // a) is array + if (is.array(a[k])) { + // a) Flatten the array + if (flat) { + a[k] = to.flatten(a[k]) + } + + // a) Filter out duplicates + if (unique && !is.plainObject(a[k][0])) { + a[k] = to.unique(a[k]) + } + } + } + } + + return a + }, + + /// @name to.object + /// @description Converts a json object to a plain object + /// @arg {json} - The json to parse + /// @returns {object} + object(arg) { + if (is.array(arg)) { + let result = {} + for (let item of arg) result[item[0]] = item[1] + return result + } + + return JSON.parse(arg) + }, + + /// @name to.json + /// @description Converts an object to a json string + /// @arg {object} - The object to convert + /// @arg {number} - The spacing to use + /// @returns {json} + json: (arg, spacing = 2) => (is.object(arg) || is.string(arg)) && JSON.stringify(arg, null, spacing), + + /// @name to.array + /// @description + /// Converts `...args` to array + /// It converts multiple arrays into a single array + /// @arg {array, string, object, number} - The item you want to be converted to array + /// @returns {array} + array(arg, glue = '\n') { + if (is.array(arg)) { + return arg + } else if (is.arguments(arg)) { + return arraySlice(arg) + } else if (is.string(arg)) { + arg = arg.split(glue) + return arg.length === 1 && arg[0] === '' ? [] : arg + } else if (is.plainObject(arg) || is.number(arg)) { + return [ arg ] + } + + return [] + }, + + /// @name to.flatten + /// @description + /// Flattens an array, and arrays inside of it into a single array + /// @arg {array} + /// @returnes {array} - single dimensional + // flatten(...args) { + // const flatten = (arg) => is.array(arg) ? arg.reduce((a, b) => a.concat(is.array(b) ? to.flatten(b) : b), []) : arg + // return args.map(flatten) + // }, + flatten(...args) { + let _flatten = (arg) => is.array(arg) ? [].concat(...arg.map(_flatten)) : arg + return _flatten(args.map(_flatten)) + }, + + /// @name to.unique + /// @description + /// Removes duplicate values from an array + /// @arg {array} + /// @returns {array} - without duplicates + unique(arg) { + if (!is.array(arg)) { + return arg + } + + let obj = {} + let result = [] + /* eslint-disable guard-for-in */ + for (let i in arg) obj[arg[i]] = arg[i] + + for (let i in obj) result.push(obj[i]) + /* eslint-enable guard-for-in */ + + return result + }, + + /// @name to.sort + /// @description + /// Sorts an array or object based off your callback function. If one is provided. + /// @arg {array, object} + /// @returns {array, object} - The sorted version + sort(obj, callback) { + if (is.array(obj)) { + return obj.sort(callback) + } + + let sorted = {} + let keys = to.keys(obj).sort(callback) + + for (let i = 0, l = keys.length; i < l; i++) { + sorted[keys[i]] = obj[keys[i]] + } + + return sorted + }, + + /// @name to.map + /// @description This function allows you to map an array or object + /// @arg {array, object} obj + /// @arg {function} callback + /// @returns {array, object} that was mapped + map(obj, callback, context = null) { + if (is.array(obj)) { + return obj.map(callback, context) + } + + let result = {} + + for (let [ key, value, i ] of to.entries(obj)) { + let cb_result = callback.call(context, { key, value }, i, obj) + if (is.truthy(cb_result) && !is.empty(cb_result) && is.plainObject(cb_result)) { + to.extend(result, cb_result) + } + } + + return result + }, + + + /// @name to.map + /// @description This function allows you to map an array or object + /// @arg {array, object} obj + /// @arg {function} callback + /// @returns {array, object} that was mapped + each(obj, callback, context = null) { + if (is.array(obj)) { + for (let [ i, value ] of to.entries(obj)) { + callback.call(context, value, i, obj) + } + return + } + + for (let [ key, value, i ] of to.entries(obj)) { + callback.call(context, { key, value }, i, obj) + } + }, + + /// @name to.reduce + /// @description This function allows you to reduce an array or object + /// @arg {array, object} obj + /// @arg {function} callback + /// @returns {*} What ever the object or array was reduced to + reduce(obj, callback, initial) { + if (is.array(obj)) { + return obj.reduce(callback, initial) + } + + for (let [ key, value, i ] of to.entries(obj)) { + initial = callback(initial, { key, value }, i, obj) + } + + return initial + }, + + /// @name to.filter + /// @description This function allows you to filter an array or object + /// @arg {array, object} obj + /// @arg {function} callback [Boolean] + /// @returns {array, object} that was filtered + filter(obj, callback = Boolean, context = null) { + if (is.array(obj)) { + return obj.filter(callback, context) + } + + let result = {} + + for (let [ key, value, i ] of to.entries(obj)) { + if (is.truthy(callback.call(context, { key, value }, i, obj))) { + to.extend(result, { [key]: value }) + } + } + + return result + }, + + /// @name to.number + /// @description + /// Converts `arg` to number + /// @arg {number, array, object, string, boolean} + /// @returns {number} + number(arg) { + if (is.number(arg)) { + return arg + } else if (is.array(arg)) { + return arg.length + } else if (is.plainObject(arg)) { + return to.keys(arg).length + } + + return ~~arg // eslint-disable-line + }, + + /// @name to.regex + /// @description + /// This function will convert a string or array into a regex expression + /// @arg {string, array} + /// @returns {Regex} + regex(...args/* , flags */) { + let flags = args.pop() + const length = flags.length + const test = flags.match(/[gimy]+/) + if (is.any.falsy(is.between(length, 1, 3), test && test.length === length)) { + args.push(flags) + flags = '' + } + + return new RegExp(to.flatten(...args).join(''), flags) + } +} + +export default to diff --git a/bin/docs b/bin/docs new file mode 100755 index 0000000..c0c8dc7 --- /dev/null +++ b/bin/docs @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +'use strict' +require('../dist/cli.js').default() diff --git a/index.js b/index.js deleted file mode 100644 index 2ad27dd..0000000 --- a/index.js +++ /dev/null @@ -1,18 +0,0 @@ -var docs = require("./build/docs") - -// Module exports -// a) export module -// b) define amd -// c) add docs to the root -if(typeof exports !== "undefined"){ - if(typeof module !== "undefined" && module.exports){ - exports = module.exports = docs; - } - exports.docs = docs; -}else if(typeof define === "function" && define.amd){ // AMD definition - define(function(require){ - return docs; - }); -}else{ - root[ "docs" ] = docs; -} \ No newline at end of file diff --git a/package.json b/package.json index c7facdb..d615d78 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,93 @@ { "name": "docs", - "description": "Documentation chameleon, addapts to any language and will help you document all the things.", - "author": { - "name": "Tyler Benton", - "email": "tjbenton21@gmail.com" + "description": "Documentation chameleon, adapts to any language and will help you document all the things.", + "author": "Tyler Benton ", + "version": "0.0.0beta1", + "main": "dist/index.js", + "scripts": { + "clean": "rm -rf ./dist", + "refresh": "rm -rf -- node_modules/ .tmp/ dist/ .nyc_output/ coverage/; npm i", + "compile": "npm run clean; babel app/ -d dist/", + "watch": "npm run clean; babel app/ -d dist/ --watch", + "mocha": "mocha --compilers js:babel-register --ui tdd --check-leaks --colors --delay --bail", + "unit-tests": "npm run mocha -- tests/unit/*.js tests/unit/**/*.js", + "mock-tests": "npm run mocha -- tests/run.test.js", + "test": "npm run unit-tests; npm run mock-tests", + "coverage": "nyc npm run unit-tests", + "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls", + "plato": "rm -rf coverage/plato; plato --recurse --exclude .json --jshint .jshintrc -d coverage/plato app", + "deploy": "npm run test && git push origin master && npm publish", + "prepublish": "npm run compile" }, - "version": "0.1.0", - "license": { - "type": "MIT", - "url": "http://opensource.org/licenses/MIT" + "nyc": { + "exclude": [ + "node_modules/", + "tests/", + "tools/" + ] }, + "files": [ + "dist/", + "bin/", + "LICENSE" + ], + "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/tjbenton/docs" + "url": "git+https://github.com/tjbenton/docs.git" }, "bugs": { "url": "https://github.com/tjbenton/docs/issues" }, + "bin": { + "docs": "bin/docs" + }, + "engines": { + "node": ">=0.12.0" + }, "dependencies": { - "fs-extra": "^0.22.1", - "glob": "^5.0.6", - "marked": "^0.3.3" + "async-array-methods": "^2.1.0", + "babel-runtime": "^6.6.1", + "change-case": "^2.3.1", + "chokidar": "^1.4.3", + "clone": "^1.0.2", + "clor": "^2.0.2", + "commander": "^2.9.0", + "es6-promisify": "^3.0.0", + "fs-extra": "^0.26.5", + "glob": "^7.0.0", + "is_js": "^0.8.0", + "marked": "^0.3.5" + }, + "devDependencies": { + "babel-cli": "^6.6.5", + "babel-eslint": "^6.0.4", + "babel-plugin-syntax-async-functions": "^6.5.0", + "babel-plugin-transform-async-to-generator": "^6.7.0", + "babel-plugin-transform-decorators-legacy": "^1.3.4", + "babel-plugin-transform-regenerator": "^6.6.5", + "babel-plugin-transform-runtime": "^6.6.0", + "babel-preset-es2015": "^6.6.0", + "babel-preset-stage-0": "^6.5.0", + "babel-register": "^6.6.5", + "core-assert": "^0.1.3", + "coveralls": "^2.11.8", + "eslint": "^2.5.3", + "eslint-plugin-babel": "^3.1.0", + "mocha": "^2.4.5", + "nyc": "^6.0.0", + "plato": "deedubs/es6-plato", + "proxyquire": "^1.7.4", + "sinon": "^1.17.3" + }, + "babel": { + "presets": [ + "stage-0", + "es2015" + ], + "plugins": [ + "transform-runtime" + ] }, "keywords": [ "css", @@ -61,14 +128,5 @@ "parser", "annotation", "comments" - ], - "engines": { - "node": ">=0.10.0" - }, - "devDependencies": { - "babel": "^5.5.4" - }, - "scripts": { - "postinstall": "make postinstall" - } + ] } diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index ac42d19..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -rebuild: - rm -rf node_modules/ - npm i - -build: - rm -rf node_modules/docs - rm -rf .tmp/ - npm i - gulp \ No newline at end of file diff --git a/tests/annotations/access/access.autofill.body.js b/tests/annotations/access/access.autofill.body.js new file mode 100644 index 0000000..e52df67 --- /dev/null +++ b/tests/annotations/access/access.autofill.body.js @@ -0,0 +1 @@ +/// @name autofill access diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json new file mode 100644 index 0000000..b524c66 --- /dev/null +++ b/tests/annotations/access/access.autofill.body.json @@ -0,0 +1,26 @@ +{ + "header": {}, + "body": [ + { + "name": "autofill access", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/access/access.autofill.body.js", + "start": 1, + "end": 2 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/access/access.autofill.header.js b/tests/annotations/access/access.autofill.header.js new file mode 100644 index 0000000..b3f6e24 --- /dev/null +++ b/tests/annotations/access/access.autofill.header.js @@ -0,0 +1,3 @@ +//// +/// @name autofill access +//// diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json new file mode 100644 index 0000000..0cd8ec6 --- /dev/null +++ b/tests/annotations/access/access.autofill.header.json @@ -0,0 +1,26 @@ +{ + "header": { + "name": "autofill access", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/access/access.autofill.header.js", + "start": 1, + "end": 4 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/access/access.header.js b/tests/annotations/access/access.header.js new file mode 100644 index 0000000..6fb91e8 --- /dev/null +++ b/tests/annotations/access/access.header.js @@ -0,0 +1,3 @@ +//// +/// @access private +//// diff --git a/tests/annotations/access/access.header.json b/tests/annotations/access/access.header.json new file mode 100644 index 0000000..d843d2e --- /dev/null +++ b/tests/annotations/access/access.header.json @@ -0,0 +1,25 @@ +{ + "header": { + "access": "private", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/access/access.header.js", + "start": 1, + "end": 4 + } + } + }, + "body": [] +} diff --git a/tests/annotations/access/access.options.js b/tests/annotations/access/access.options.js new file mode 100644 index 0000000..b1f9593 --- /dev/null +++ b/tests/annotations/access/access.options.js @@ -0,0 +1,5 @@ +/// @access public + +/// @access auto + +/// @access private diff --git a/tests/annotations/access/access.options.json b/tests/annotations/access/access.options.json new file mode 100644 index 0000000..d88a579 --- /dev/null +++ b/tests/annotations/access/access.options.json @@ -0,0 +1,65 @@ +{ + "header": {}, + "body": [ + { + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/access/access.options.js", + "start": 1, + "end": 6 + } + }, + "inline": [] + }, + { + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/access/access.options.js", + "start": 1, + "end": 6 + } + }, + "inline": [] + }, + { + "access": "private", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/access/access.options.js", + "start": 1, + "end": 6 + } + }, + "inline": [] + } + ] +} diff --git a/tests/annotations/alias/alias.js b/tests/annotations/alias/alias.js new file mode 100644 index 0000000..4484ce1 --- /dev/null +++ b/tests/annotations/alias/alias.js @@ -0,0 +1,5 @@ +/// @alias foo + +/// @alias foo, bar + +/// @alias foo, bar, diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json new file mode 100644 index 0000000..a436f66 --- /dev/null +++ b/tests/annotations/alias/alias.json @@ -0,0 +1,76 @@ +{ + "header": {}, + "body": [ + { + "alias": [ + "foo" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/alias/alias.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "alias": [ + "foo", + "bar" + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/alias/alias.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "alias": [ + "foo", + "bar" + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/alias/alias.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/arg/arg.aliases.js b/tests/annotations/arg/arg.aliases.js new file mode 100644 index 0000000..42cd108 --- /dev/null +++ b/tests/annotations/arg/arg.aliases.js @@ -0,0 +1,5 @@ +/// @argument {type} name-of-variable - argument alias + +/// @param {type} name-of-variable - param alias + +/// @parameter {type} name-of-variable - parameter alias diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json new file mode 100644 index 0000000..7bb12e0 --- /dev/null +++ b/tests/annotations/arg/arg.aliases.json @@ -0,0 +1,95 @@ +{ + "header": {}, + "body": [ + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

argument alias

\n" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.aliases.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

param alias

\n" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.aliases.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

parameter alias

\n" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.aliases.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/arg/arg.js b/tests/annotations/arg/arg.js new file mode 100644 index 0000000..64914fe --- /dev/null +++ b/tests/annotations/arg/arg.js @@ -0,0 +1,16 @@ +/// @arg + +/// @arg {type} name-of-variable + +/// @arg {type, othertype} name-of-variable + +/// @arg {type} name-of-variable - description + +/// @arg {type} name-of-variable [default value] - Lorem ipsum dolor sit amet, consectetur adipisicing elit + +/// @arg {type} name-of-variable [default value] - Lorem ipsum dolor sit amet, consectetur adipisicing elit +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et +/// dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip +/// ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore +/// eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia +/// deserunt mollit anim id est laborum. diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json new file mode 100644 index 0000000..36de179 --- /dev/null +++ b/tests/annotations/arg/arg.json @@ -0,0 +1,184 @@ +{ + "header": {}, + "body": [ + { + "arg": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type", + "othertype" + ], + "name": "name-of-variable", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "default value", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" + } + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "default value", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et\ndolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip\nex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore\neu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\ndeserunt mollit anim id est laborum.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 16, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/author/author.alias.js b/tests/annotations/author/author.alias.js new file mode 100644 index 0000000..3a8cd94 --- /dev/null +++ b/tests/annotations/author/author.alias.js @@ -0,0 +1 @@ +/// @authors Author One, Author Two, Author Three diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json new file mode 100644 index 0000000..5567adf --- /dev/null +++ b/tests/annotations/author/author.alias.json @@ -0,0 +1,30 @@ +{ + "header": {}, + "body": [ + { + "author": [ + "Author One", + "Author Two", + "Author Three" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.alias.js", + "start": 1, + "end": 2 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/author/author.body.js b/tests/annotations/author/author.body.js new file mode 100644 index 0000000..fdf6f3e --- /dev/null +++ b/tests/annotations/author/author.body.js @@ -0,0 +1 @@ +/// @author Tyler Benton diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json new file mode 100644 index 0000000..1680355 --- /dev/null +++ b/tests/annotations/author/author.body.json @@ -0,0 +1,28 @@ +{ + "header": {}, + "body": [ + { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.body.js", + "start": 1, + "end": 2 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/author/author.header.js b/tests/annotations/author/author.header.js new file mode 100644 index 0000000..7cf4bc2 --- /dev/null +++ b/tests/annotations/author/author.header.js @@ -0,0 +1,3 @@ +//// +/// @author Tyler Benton +//// diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json new file mode 100644 index 0000000..4447579 --- /dev/null +++ b/tests/annotations/author/author.header.json @@ -0,0 +1,28 @@ +{ + "header": { + "author": [ + "Tyler Benton" + ], + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.header.js", + "start": 1, + "end": 4 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/author/author.multiple.js b/tests/annotations/author/author.multiple.js new file mode 100644 index 0000000..a559112 --- /dev/null +++ b/tests/annotations/author/author.multiple.js @@ -0,0 +1,13 @@ +//// +/// @author Author One, Author Two +//// + +/// @author Author One +/// @author Author Two + +/// @author Author One, Author Two + + +/// @author +/// Author One +/// Author Two diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json new file mode 100644 index 0000000..3f94c1c --- /dev/null +++ b/tests/annotations/author/author.multiple.json @@ -0,0 +1,102 @@ +{ + "header": { + "author": [ + "Author One", + "Author Two" + ], + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + }, + "access": "public" + }, + "body": [ + { + "author": [ + "Author One", + "Author Two" + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 6, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + }, + "access": "public", + "inline": [] + }, + { + "author": [ + "Author One", + "Author Two" + ], + "blockinfo": { + "comment": { + "start": 8, + "end": 8, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + }, + "access": "public", + "inline": [] + }, + { + "author": [ + "Author One", + "Author Two" + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 13, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/chainable/chainable.js b/tests/annotations/chainable/chainable.js new file mode 100644 index 0000000..5b558e5 --- /dev/null +++ b/tests/annotations/chainable/chainable.js @@ -0,0 +1,17 @@ +/// @chainable + +/// @chainable true + +/// @chainable false + +/// @chainable Object.prototype + +/// @chainable One, Two + +/// @chainable +/// One, +/// Two + +/// @chainable +/// One +/// Two diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json new file mode 100644 index 0000000..4052ff0 --- /dev/null +++ b/tests/annotations/chainable/chainable.json @@ -0,0 +1,163 @@ +{ + "header": {}, + "body": [ + { + "chainable": true, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "chainable": true, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "chainable": false, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "chainable": [ + "Object.prototype" + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "chainable": [ + "One", + "Two" + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "chainable": [ + "One", + "Two" + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 13, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "chainable": [ + "One", + "Two" + ], + "blockinfo": { + "comment": { + "start": 15, + "end": 17, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/depricated/depricated.body.js b/tests/annotations/depricated/depricated.body.js new file mode 100644 index 0000000..454bde9 --- /dev/null +++ b/tests/annotations/depricated/depricated.body.js @@ -0,0 +1,10 @@ +/// @deprecated + +/// @deprecated {0.0.1} - Lorem + +/// @deprecated {0.0.1} Lorem + +/// @deprecated {^0.0.1} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis, +/// sed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident +/// accusamus fugit magnam et adipisci eum, saepe incidunt. diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json new file mode 100644 index 0000000..2cb66cc --- /dev/null +++ b/tests/annotations/depricated/depricated.body.json @@ -0,0 +1,101 @@ +{ + "header": {}, + "body": [ + { + "deprecated": { + "version": "0", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + }, + { + "deprecated": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + }, + { + "deprecated": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + }, + { + "deprecated": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis,\nsed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident\naccusamus fugit magnam et adipisci eum, saepe incidunt.

\n" + }, + "blockinfo": { + "comment": { + "start": 7, + "end": 10, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/depricated/depricated.header.js b/tests/annotations/depricated/depricated.header.js new file mode 100644 index 0000000..dbd009f --- /dev/null +++ b/tests/annotations/depricated/depricated.header.js @@ -0,0 +1,6 @@ +//// +/// @deprecated {^0.0.1} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis, +/// sed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident +/// accusamus fugit magnam et adipisci eum, saepe incidunt. +//// diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json new file mode 100644 index 0000000..38f0234 --- /dev/null +++ b/tests/annotations/depricated/depricated.header.json @@ -0,0 +1,29 @@ +{ + "header": { + "deprecated": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis,\nsed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident\naccusamus fugit magnam et adipisci eum, saepe incidunt.

\n" + }, + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/depricated/depricated.header.js", + "start": 1, + "end": 7 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/description/description.alias.js b/tests/annotations/description/description.alias.js new file mode 100644 index 0000000..3cbee0d --- /dev/null +++ b/tests/annotations/description/description.alias.js @@ -0,0 +1,57 @@ +/// @name single-line `desc` +/// @desc Lorem ipsum + +/// @name multi-line `desc` +/// @desc +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Delectus eaque nesciunt explicabo doloremque temporibus cumque + + + +/// @name single-line `definition` +/// @definition Lorem ipsum + +/// @name multi-line `definition` +/// @definition +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Delectus eaque nesciunt explicabo doloremque temporibus cumque + + + +/// @name single-line `explanation` +/// @explanation Lorem ipsum + +/// @name multi-line `explanation` +/// @explanation +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Delectus eaque nesciunt explicabo doloremque temporibus cumque + + + +/// @name single-line `writeup` +/// @writeup Lorem ipsum + +/// @name multi-line `writeup` +/// @writeup +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Delectus eaque nesciunt explicabo doloremque temporibus cumque + + + +/// @name single-line `summary` +/// @summary Lorem ipsum + +/// @name multi-line `summary` +/// @summary +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Delectus eaque nesciunt explicabo doloremque temporibus cumque + + + +/// @name single-line `summarization` +/// @summarization Lorem ipsum + +/// @name multi-line `summarization` +/// @summarization +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Delectus eaque nesciunt explicabo doloremque temporibus cumque diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json new file mode 100644 index 0000000..d8438eb --- /dev/null +++ b/tests/annotations/description/description.alias.json @@ -0,0 +1,269 @@ +{ + "header": {}, + "body": [ + { + "name": "single-line `desc`", + "description": "

Lorem ipsum

\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 2, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "multi-line `desc`", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nDelectus eaque nesciunt explicabo doloremque temporibus cumque

\n", + "blockinfo": { + "comment": { + "start": 4, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "single-line `definition`", + "description": "

Lorem ipsum

\n", + "blockinfo": { + "comment": { + "start": 11, + "end": 12, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "multi-line `definition`", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nDelectus eaque nesciunt explicabo doloremque temporibus cumque

\n", + "blockinfo": { + "comment": { + "start": 14, + "end": 17, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "single-line `explanation`", + "description": "

Lorem ipsum

\n", + "blockinfo": { + "comment": { + "start": 21, + "end": 22, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "multi-line `explanation`", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nDelectus eaque nesciunt explicabo doloremque temporibus cumque

\n", + "blockinfo": { + "comment": { + "start": 24, + "end": 27, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "single-line `writeup`", + "description": "

Lorem ipsum

\n", + "blockinfo": { + "comment": { + "start": 31, + "end": 32, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "multi-line `writeup`", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nDelectus eaque nesciunt explicabo doloremque temporibus cumque

\n", + "blockinfo": { + "comment": { + "start": 34, + "end": 37, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "single-line `summary`", + "description": "

Lorem ipsum

\n", + "blockinfo": { + "comment": { + "start": 41, + "end": 42, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "multi-line `summary`", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nDelectus eaque nesciunt explicabo doloremque temporibus cumque

\n", + "blockinfo": { + "comment": { + "start": 44, + "end": 47, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "single-line `summarization`", + "description": "

Lorem ipsum

\n", + "blockinfo": { + "comment": { + "start": 51, + "end": 52, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "multi-line `summarization`", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nDelectus eaque nesciunt explicabo doloremque temporibus cumque

\n", + "blockinfo": { + "comment": { + "start": 54, + "end": 57, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/description/description.body.js b/tests/annotations/description/description.body.js new file mode 100644 index 0000000..69c68ff --- /dev/null +++ b/tests/annotations/description/description.body.js @@ -0,0 +1,14 @@ + +/// @description Lorem ipsum dolor sit amet + +/// @description Line one +/// Other +/// lines +/// below +/// it + +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Accusantium vel, eveniet, architecto saepe, modi dolore incidunt +/// quisquam eaque cum porro explicabo velit sunt illo praesentium +/// facere. Sit consequuntur illo nihil. diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json new file mode 100644 index 0000000..f10982c --- /dev/null +++ b/tests/annotations/description/description.body.json @@ -0,0 +1,68 @@ +{ + "header": {}, + "body": [ + { + "description": "

Lorem ipsum dolor sit amet

\n", + "blockinfo": { + "comment": { + "start": 2, + "end": 2, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "description": "

Line one\nOther\nlines\nbelow\nit

\n", + "blockinfo": { + "comment": { + "start": 4, + "end": 8, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nAccusantium vel, eveniet, architecto saepe, modi dolore incidunt\nquisquam eaque cum porro explicabo velit sunt illo praesentium\nfacere. Sit consequuntur illo nihil.

\n", + "blockinfo": { + "comment": { + "start": 10, + "end": 14, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/description/description.header.js b/tests/annotations/description/description.header.js new file mode 100644 index 0000000..87833df --- /dev/null +++ b/tests/annotations/description/description.header.js @@ -0,0 +1,7 @@ +//// +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur autem, +/// inventore modi ratione. Ipsum natus odio inventore quibusdam error dolores +/// numquam sapiente dicta, perferendis quos quo provident, +/// voluptate, alias deserunt? +//// diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json new file mode 100644 index 0000000..9ce9653 --- /dev/null +++ b/tests/annotations/description/description.header.json @@ -0,0 +1,26 @@ +{ + "header": { + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur autem,\ninventore modi ratione. Ipsum natus odio inventore quibusdam error dolores\nnumquam sapiente dicta, perferendis quos quo provident,\nvoluptate, alias deserunt?

\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/description/description.header.js", + "start": 1, + "end": 8 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json new file mode 100644 index 0000000..a0b3bf7 --- /dev/null +++ b/tests/annotations/markdown/mark.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mark.mark", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mark.mark b/tests/annotations/markdown/mark.mark new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mark.mark @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json new file mode 100644 index 0000000..c4123ed --- /dev/null +++ b/tests/annotations/markdown/markdown.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/markdown.markdown", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/markdown.markdown b/tests/annotations/markdown/markdown.markdown new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/markdown.markdown @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json new file mode 100644 index 0000000..8d10089 --- /dev/null +++ b/tests/annotations/markdown/md.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/md.md", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/md.md b/tests/annotations/markdown/md.md new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/md.md @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json new file mode 100644 index 0000000..8458431 --- /dev/null +++ b/tests/annotations/markdown/mdml.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mdml.mdml", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdml.mdml b/tests/annotations/markdown/mdml.mdml new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mdml.mdml @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json new file mode 100644 index 0000000..3ff16bb --- /dev/null +++ b/tests/annotations/markdown/mdown.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mdown.mdown", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdown.mdown b/tests/annotations/markdown/mdown.mdown new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mdown.mdown @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json new file mode 100644 index 0000000..b6bc884 --- /dev/null +++ b/tests/annotations/markdown/mdtext.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mdtext.mdtext", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdtext.mdtext b/tests/annotations/markdown/mdtext.mdtext new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mdtext.mdtext @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json new file mode 100644 index 0000000..4204583 --- /dev/null +++ b/tests/annotations/markdown/mdtxt.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdtxt.mdtxt b/tests/annotations/markdown/mdtxt.mdtxt new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mdtxt.mdtxt @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json new file mode 100644 index 0000000..37a2d88 --- /dev/null +++ b/tests/annotations/markdown/mdwn.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mdwn.mdwn", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdwn.mdwn b/tests/annotations/markdown/mdwn.mdwn new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mdwn.mdwn @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json new file mode 100644 index 0000000..6c4447a --- /dev/null +++ b/tests/annotations/markdown/mkd.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mkd.mkd b/tests/annotations/markdown/mkd.mkd new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mkd.mkd @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json new file mode 100644 index 0000000..496186f --- /dev/null +++ b/tests/annotations/markdown/mkdn.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/mkdn.mkdn", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mkdn.mkdn b/tests/annotations/markdown/mkdn.mkdn new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/mkdn.mkdn @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json new file mode 100644 index 0000000..5595961 --- /dev/null +++ b/tests/annotations/markdown/text.json @@ -0,0 +1,26 @@ +{ + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/markdown/text.text", + "start": 1, + "end": 13 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/text.text b/tests/annotations/markdown/text.text new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/annotations/markdown/text.text @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/lib/edge-cases/empty-file.scss b/tests/annotations/markup/markup.js similarity index 100% rename from tests/lib/edge-cases/empty-file.scss rename to tests/annotations/markup/markup.js diff --git a/tests/annotations/markup/markup.json b/tests/annotations/markup/markup.json new file mode 100644 index 0000000..e7c86d2 --- /dev/null +++ b/tests/annotations/markup/markup.json @@ -0,0 +1,4 @@ +{ + "header": {}, + "body": [] +} diff --git a/tests/annotations/name/name.aliases.js b/tests/annotations/name/name.aliases.js new file mode 100644 index 0000000..c2c53e3 --- /dev/null +++ b/tests/annotations/name/name.aliases.js @@ -0,0 +1,5 @@ +/// @title Title + +/// @heading Heading + +/// @header Header diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json new file mode 100644 index 0000000..d2285df --- /dev/null +++ b/tests/annotations/name/name.aliases.json @@ -0,0 +1,68 @@ +{ + "header": {}, + "body": [ + { + "name": "Title", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/name/name.aliases.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Heading", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/name/name.aliases.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Header", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/name/name.aliases.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/name/name.js b/tests/annotations/name/name.js new file mode 100644 index 0000000..dd2c343 --- /dev/null +++ b/tests/annotations/name/name.js @@ -0,0 +1 @@ +/// @name Foo diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json new file mode 100644 index 0000000..9254b0e --- /dev/null +++ b/tests/annotations/name/name.json @@ -0,0 +1,26 @@ +{ + "header": {}, + "body": [ + { + "name": "Foo", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/name/name.js", + "start": 1, + "end": 2 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/note/note.alias.js b/tests/annotations/note/note.alias.js new file mode 100644 index 0000000..4dffd38 --- /dev/null +++ b/tests/annotations/note/note.alias.js @@ -0,0 +1,9 @@ +/// @notes +/// - note 1 +/// - note 2 +/// - note 3 + +/// @notes {10} +/// - note 1 +/// - note 2 +/// - note 3 diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json new file mode 100644 index 0000000..f4ada51 --- /dev/null +++ b/tests/annotations/note/note.alias.json @@ -0,0 +1,57 @@ +{ + "header": {}, + "body": [ + { + "note": [ + { + "importance": "0", + "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.alias.js", + "start": 1, + "end": 10 + } + }, + "access": "public", + "inline": [] + }, + { + "note": [ + { + "importance": "10", + "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" + } + ], + "blockinfo": { + "comment": { + "start": 6, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.alias.js", + "start": 1, + "end": 10 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/note/note.js b/tests/annotations/note/note.js new file mode 100644 index 0000000..cb76a0b --- /dev/null +++ b/tests/annotations/note/note.js @@ -0,0 +1,19 @@ +/// @note + +/// @note {10} + +/// @note Lorem ipsum dolor sit amet + +/// @note +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, +/// sed do eiusmod tempor incididunt ut labore et dolore magna +/// aliqua. Ut enim ad minim veniam, quis nostrud exercitation +/// ullamco laboris nisi ut aliquip ex ea commodo consequat. + +/// @note {5} Lorem ipsum dolor sit amet + +/// @note {5} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, +/// sed do eiusmod tempor incididunt ut labore et dolore magna +/// aliqua. Ut enim ad minim veniam, quis nostrud exercitation +/// ullamco laboris nisi ut aliquip ex ea commodo consequat. diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json new file mode 100644 index 0000000..aa36a5a --- /dev/null +++ b/tests/annotations/note/note.json @@ -0,0 +1,161 @@ +{ + "header": {}, + "body": [ + { + "note": [ + { + "importance": "0", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + }, + "access": "public", + "inline": [] + }, + { + "note": [ + { + "importance": "10", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + }, + "access": "public", + "inline": [] + }, + { + "note": [ + { + "importance": "0", + "description": "

Lorem ipsum dolor sit amet

\n" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + }, + "access": "public", + "inline": [] + }, + { + "note": [ + { + "importance": "0", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna\naliqua. Ut enim ad minim veniam, quis nostrud exercitation\nullamco laboris nisi ut aliquip ex ea commodo consequat.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 11, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + }, + "access": "public", + "inline": [] + }, + { + "note": [ + { + "importance": "5", + "description": "

Lorem ipsum dolor sit amet

\n" + } + ], + "blockinfo": { + "comment": { + "start": 13, + "end": 13, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + }, + "access": "public", + "inline": [] + }, + { + "note": [ + { + "importance": "5", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna\naliqua. Ut enim ad minim veniam, quis nostrud exercitation\nullamco laboris nisi ut aliquip ex ea commodo consequat.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 15, + "end": 19, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/page/page.alias.js b/tests/annotations/page/page.alias.js new file mode 100644 index 0000000..bef5674 --- /dev/null +++ b/tests/annotations/page/page.alias.js @@ -0,0 +1,6 @@ +/// @group level 1 + +/// @group level 1/level 2 + +/// @group page 1/level 2 +/// @group page 2/level 2 diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json new file mode 100644 index 0000000..f2887e7 --- /dev/null +++ b/tests/annotations/page/page.alias.json @@ -0,0 +1,75 @@ +{ + "header": {}, + "body": [ + { + "page": [ + "level 1" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.alias.js", + "start": 1, + "end": 7 + } + }, + "access": "public", + "inline": [] + }, + { + "page": [ + "level 1/level 2" + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.alias.js", + "start": 1, + "end": 7 + } + }, + "access": "public", + "inline": [] + }, + { + "page": [ + "page 1/level 2", + "page 2/level 2" + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 6, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.alias.js", + "start": 1, + "end": 7 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/page/page.body.autofill.js b/tests/annotations/page/page.body.autofill.js new file mode 100644 index 0000000..ed24a7b --- /dev/null +++ b/tests/annotations/page/page.body.autofill.js @@ -0,0 +1 @@ +/// @description This block shouldn't have a page annotation because page doesn't autofill body comments diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json new file mode 100644 index 0000000..0ca9c54 --- /dev/null +++ b/tests/annotations/page/page.body.autofill.json @@ -0,0 +1,26 @@ +{ + "header": {}, + "body": [ + { + "description": "

This block shouldn't have a page annotation because page doesn't autofill body comments

\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.body.autofill.js", + "start": 1, + "end": 2 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/page/page.body.js b/tests/annotations/page/page.body.js new file mode 100644 index 0000000..ae6d07a --- /dev/null +++ b/tests/annotations/page/page.body.js @@ -0,0 +1,6 @@ +/// @page level 1 + +/// @page level 1/level 2 + +/// @page page 1/level 2 +/// @page page 2/level 2 diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json new file mode 100644 index 0000000..2374f29 --- /dev/null +++ b/tests/annotations/page/page.body.json @@ -0,0 +1,75 @@ +{ + "header": {}, + "body": [ + { + "page": [ + "level 1" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.body.js", + "start": 1, + "end": 7 + } + }, + "access": "public", + "inline": [] + }, + { + "page": [ + "level 1/level 2" + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.body.js", + "start": 1, + "end": 7 + } + }, + "access": "public", + "inline": [] + }, + { + "page": [ + "page 1/level 2", + "page 2/level 2" + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 6, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.body.js", + "start": 1, + "end": 7 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/page/page.header.autofill.js b/tests/annotations/page/page.header.autofill.js new file mode 100644 index 0000000..f7a58d8 --- /dev/null +++ b/tests/annotations/page/page.header.autofill.js @@ -0,0 +1,3 @@ +//// +/// @name page autofill test +//// diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json new file mode 100644 index 0000000..acec66f --- /dev/null +++ b/tests/annotations/page/page.header.autofill.json @@ -0,0 +1,26 @@ +{ + "header": { + "name": "page autofill test", + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.header.autofill.js", + "start": 1, + "end": 4 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/page/page.header.js b/tests/annotations/page/page.header.js new file mode 100644 index 0000000..8eb1120 --- /dev/null +++ b/tests/annotations/page/page.header.js @@ -0,0 +1,3 @@ +//// +/// @page level 1/level 2 +//// diff --git a/tests/annotations/page/page.header.json b/tests/annotations/page/page.header.json new file mode 100644 index 0000000..956078c --- /dev/null +++ b/tests/annotations/page/page.header.json @@ -0,0 +1,25 @@ +{ + "header": { + "page": [ + "level 1/level 2" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/page/page.header.js", + "start": 1, + "end": 4 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/property/property.aliases.js b/tests/annotations/property/property.aliases.js new file mode 100644 index 0000000..50e4a34 --- /dev/null +++ b/tests/annotations/property/property.aliases.js @@ -0,0 +1,16 @@ +/// @prop + +/// @prop {type} key.name + +/// @prop {type, othertype} key.name + +/// @prop {type} key.name - description + +/// @prop {type} key.name [default] - Lorem ipsum dolor sit amet, consectetur adipisicing elit + +/// @prop {type} key.name [default] - Lorem ipsum dolor sit amet, consectetur adipisicing elit +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et +/// dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip +/// ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore +/// eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia +/// deserunt mollit anim id est laborum. diff --git a/tests/annotations/property/property.aliases.json b/tests/annotations/property/property.aliases.json new file mode 100644 index 0000000..31d0775 --- /dev/null +++ b/tests/annotations/property/property.aliases.json @@ -0,0 +1,184 @@ +{ + "header": {}, + "body": [ + { + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type", + "othertype" + ], + "name": "key.name", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "default", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" + } + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "default", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et\ndolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip\nex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore\neu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\ndeserunt mollit anim id est laborum.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 16, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/property/property.inline.js b/tests/annotations/property/property.inline.js new file mode 100644 index 0000000..19e64cc --- /dev/null +++ b/tests/annotations/property/property.inline.js @@ -0,0 +1,44 @@ +/* eslint-disable no-unused-vars*/ +const value = 3 + +/// @name one +/// @type {object} +const foo = { + value: 1, ///# @property +} + +/// @name two +/// @type {object} +const bar = { + value: 2, ///# @property {number} bar.value +} + +/// @name three +/// @type {object} +const baz = { + value, ///# @property {number, array} baz.value +} + +/// @name four +/// @type {object} +const qux = { + value() { ///# @property {function} qux.value - description + return 'whatup' + }, +} + +/// @name five +/// @type {object} +const corge = { + value: 5, ///# @property {number} corge.value [5] - Lorem ipsum dolor sit amet, consectetur adipisicing elit +} + + +/// @name five +/// @type {object} +const grault = { + ///# @property {function} quux.value ['whatup'] - Lorem ipsum dolor sit amet, consectetur adipisicing elit + value() { + return 'whatup' + }, +} diff --git a/tests/annotations/property/property.inline.json b/tests/annotations/property/property.inline.json new file mode 100644 index 0000000..81db080 --- /dev/null +++ b/tests/annotations/property/property.inline.json @@ -0,0 +1,334 @@ +{ + "header": {}, + "body": [ + { + "name": "one", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 4, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 8 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "inline" + }, + "code": { + "start": 7, + "end": 7 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" + } + ] + }, + { + "name": "two", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 10, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 14 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [ + "number" + ], + "name": "bar.value", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 13, + "end": 13, + "type": "inline" + }, + "code": { + "start": 13, + "end": 13 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" + } + ] + }, + { + "name": "three", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 16, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 20 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [ + "number", + "array" + ], + "name": "baz.value", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 19, + "end": 19, + "type": "inline" + }, + "code": { + "start": 19, + "end": 19 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" + } + ] + }, + { + "name": "four", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 22, + "end": 23, + "type": "body" + }, + "code": { + "start": 24, + "end": 28 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [ + "function" + ], + "name": "qux.value", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 25, + "end": 25, + "type": "inline" + }, + "code": { + "start": 25, + "end": 27 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" + } + ] + }, + { + "name": "five", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 30, + "end": 31, + "type": "body" + }, + "code": { + "start": 32, + "end": 34 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [ + "number" + ], + "name": "corge.value", + "value": "5", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" + } + ], + "blockinfo": { + "comment": { + "start": 33, + "end": 33, + "type": "inline" + }, + "code": { + "start": 33, + "end": 33 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" + } + ] + }, + { + "name": "five", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 37, + "end": 38, + "type": "body" + }, + "code": { + "start": 39, + "end": 44 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [ + "function" + ], + "name": "quux.value", + "value": "'whatup'", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" + } + ], + "blockinfo": { + "comment": { + "start": 40, + "end": 40, + "type": "inline" + }, + "code": { + "start": 41, + "end": 43 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" + } + ] + } + ] +} diff --git a/tests/annotations/property/property.js b/tests/annotations/property/property.js new file mode 100644 index 0000000..5f8b657 --- /dev/null +++ b/tests/annotations/property/property.js @@ -0,0 +1,16 @@ +/// @property + +/// @property {type} key.name + +/// @property {type, othertype} key.name + +/// @property {type} key.name - description + +/// @property {type} key.name [default] - Lorem ipsum dolor sit amet, consectetur adipisicing elit + +/// @property {type} key.name [default] - Lorem ipsum dolor sit amet, consectetur adipisicing elit +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et +/// dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip +/// ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore +/// eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia +/// deserunt mollit anim id est laborum. diff --git a/tests/annotations/property/property.json b/tests/annotations/property/property.json new file mode 100644 index 0000000..cd67798 --- /dev/null +++ b/tests/annotations/property/property.json @@ -0,0 +1,184 @@ +{ + "header": {}, + "body": [ + { + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type", + "othertype" + ], + "name": "key.name", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "default", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" + } + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "default", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et\ndolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip\nex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore\neu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\ndeserunt mollit anim id est laborum.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 16, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/raw-code/raw-code.escaped.html b/tests/annotations/raw-code/raw-code.escaped.html new file mode 100644 index 0000000..9c671c6 --- /dev/null +++ b/tests/annotations/raw-code/raw-code.escaped.html @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/tests/annotations/raw-code/raw-code.escaped.json b/tests/annotations/raw-code/raw-code.escaped.json new file mode 100644 index 0000000..5f53766 --- /dev/null +++ b/tests/annotations/raw-code/raw-code.escaped.json @@ -0,0 +1,29 @@ +{ + "header": {}, + "body": [ + { + "raw-code": { + "raw": "", + "escaped": "<nav>\n <ul>\n <li>Item 1</li>\n <li>Item 2</li>\n <li>Item 3</li>\n </ul>\n</nav>" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 10 + }, + "file": { + "path": "docs-parser/tests/annotations/raw-code/raw-code.escaped.html", + "start": 1, + "end": 10 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/raw-code/raw-code.js b/tests/annotations/raw-code/raw-code.js new file mode 100644 index 0000000..5f04249 --- /dev/null +++ b/tests/annotations/raw-code/raw-code.js @@ -0,0 +1,4 @@ +/// @raw-code + function rawCode() { + + } \ No newline at end of file diff --git a/tests/annotations/raw-code/raw-code.json b/tests/annotations/raw-code/raw-code.json new file mode 100644 index 0000000..23286fe --- /dev/null +++ b/tests/annotations/raw-code/raw-code.json @@ -0,0 +1,29 @@ +{ + "header": {}, + "body": [ + { + "raw-code": { + "raw": "function rawCode() {\n\n}", + "escaped": "function rawCode() {\n\n}" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 4 + }, + "file": { + "path": "docs-parser/tests/annotations/raw-code/raw-code.js", + "start": 1, + "end": 4 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/readonly/readonly.js b/tests/annotations/readonly/readonly.js new file mode 100644 index 0000000..ee351fd --- /dev/null +++ b/tests/annotations/readonly/readonly.js @@ -0,0 +1,5 @@ +/// @readonly + +/// @readonly true + +/// @readonly false diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json new file mode 100644 index 0000000..2c986bf --- /dev/null +++ b/tests/annotations/readonly/readonly.json @@ -0,0 +1,68 @@ +{ + "header": {}, + "body": [ + { + "readonly": true, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/readonly/readonly.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "readonly": true, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/readonly/readonly.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + }, + { + "readonly": false, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/readonly/readonly.js", + "start": 1, + "end": 6 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/requires/requires.alias.js b/tests/annotations/requires/requires.alias.js new file mode 100644 index 0000000..dfb6c58 --- /dev/null +++ b/tests/annotations/requires/requires.alias.js @@ -0,0 +1 @@ +/// @require node diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json new file mode 100644 index 0000000..a5200c7 --- /dev/null +++ b/tests/annotations/requires/requires.alias.json @@ -0,0 +1,32 @@ +{ + "header": {}, + "body": [ + { + "requires": [ + { + "types": [], + "name": "node", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.alias.js", + "start": 1, + "end": 2 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/requires/requires.body.js b/tests/annotations/requires/requires.body.js new file mode 100644 index 0000000..df66b56 --- /dev/null +++ b/tests/annotations/requires/requires.body.js @@ -0,0 +1,14 @@ +/// @requires + +/// @requires {*} + +/// @requires {object, array, function, string} + +/// @requires path + +/// @requires path - the path function from node + +/// @requires {function} path - the path function from node + +/// @requires node +/// @requires npm diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json new file mode 100644 index 0000000..66baa51 --- /dev/null +++ b/tests/annotations/requires/requires.body.json @@ -0,0 +1,208 @@ +{ + "header": {}, + "body": [ + { + "requires": [ + { + "types": [], + "name": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "requires": [ + { + "types": [ + "*" + ], + "name": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "requires": [ + { + "types": [ + "object", + "array", + "function", + "string" + ], + "name": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "requires": [ + { + "types": [], + "name": "path", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "requires": [ + { + "types": [], + "name": "path", + "description": "

the path function from node

\n" + } + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "requires": [ + { + "types": [ + "function" + ], + "name": "path", + "description": "

the path function from node

\n" + } + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 11, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "requires": [ + { + "types": [], + "name": "node", + "description": "" + }, + { + "types": [], + "name": "npm", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 13, + "end": 14, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/requires/requires.header.js b/tests/annotations/requires/requires.header.js new file mode 100644 index 0000000..b27addb --- /dev/null +++ b/tests/annotations/requires/requires.header.js @@ -0,0 +1,3 @@ +//// +/// @requires {function} path - the path function from node +//// diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json new file mode 100644 index 0000000..5424ca3 --- /dev/null +++ b/tests/annotations/requires/requires.header.json @@ -0,0 +1,34 @@ +{ + "header": { + "requires": [ + { + "types": [ + "function" + ], + "name": "path", + "description": "

the path function from node

\n" + } + ], + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/requires/requires.header.js", + "start": 1, + "end": 4 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/returns/returns.alias.js b/tests/annotations/returns/returns.alias.js new file mode 100644 index 0000000..1642085 --- /dev/null +++ b/tests/annotations/returns/returns.alias.js @@ -0,0 +1,22 @@ +/// @return + +/// @return {} + +/// @return {array, string, boolean} + +/// @return { array , string , boolean } + +/// @return {object} - Lorem ipsum dolor sit amet + +/// @return {array} Lorem ipsum dolor sit amet + +/// @return {object} - This super awesome object +/// ```js +/// { +/// i: { +/// found: { +/// waldo: 'Shoot, you found me' +/// } +/// } +/// } +/// ``` diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json new file mode 100644 index 0000000..363310f --- /dev/null +++ b/tests/annotations/returns/returns.alias.json @@ -0,0 +1,191 @@ +{ + "header": {}, + "body": [ + { + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "object" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "array" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "blockinfo": { + "comment": { + "start": 11, + "end": 11, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "object" + ], + "description": "

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" + }, + "blockinfo": { + "comment": { + "start": 13, + "end": 22, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/returns/returns.js b/tests/annotations/returns/returns.js new file mode 100644 index 0000000..e48e4e4 --- /dev/null +++ b/tests/annotations/returns/returns.js @@ -0,0 +1,22 @@ +/// @returns + +/// @returns {} + +/// @returns {array, string, boolean} + +/// @returns { array , string , boolean } + +/// @returns {object} - Lorem ipsum dolor sit amet + +/// @returns {array} Lorem ipsum dolor sit amet + +/// @returns {object} - This super awesome object +/// ```js +/// { +/// i: { +/// found: { +/// waldo: 'Shoot, you found me' +/// } +/// } +/// } +/// ``` diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json new file mode 100644 index 0000000..8304bf0 --- /dev/null +++ b/tests/annotations/returns/returns.json @@ -0,0 +1,191 @@ +{ + "header": {}, + "body": [ + { + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "object" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "array" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "blockinfo": { + "comment": { + "start": 11, + "end": 11, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + }, + { + "returns": { + "types": [ + "object" + ], + "description": "

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" + }, + "blockinfo": { + "comment": { + "start": 13, + "end": 22, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/since/since.body.js b/tests/annotations/since/since.body.js new file mode 100644 index 0000000..c48ac93 --- /dev/null +++ b/tests/annotations/since/since.body.js @@ -0,0 +1,10 @@ +/// @since + +/// @since {0.0.1} - Lorem + +/// @since {0.0.1} Lorem + +/// @since {^0.0.1} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis, +/// sed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident +/// accusamus fugit magnam et adipisci eum, saepe incidunt. diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json new file mode 100644 index 0000000..96e19fe --- /dev/null +++ b/tests/annotations/since/since.body.json @@ -0,0 +1,101 @@ +{ + "header": {}, + "body": [ + { + "since": { + "version": "undefined", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + }, + { + "since": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + }, + { + "since": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + }, + { + "since": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis,\nsed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident\naccusamus fugit magnam et adipisci eum, saepe incidunt.

\n" + }, + "blockinfo": { + "comment": { + "start": 7, + "end": 10, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/since/since.header.js b/tests/annotations/since/since.header.js new file mode 100644 index 0000000..1a681c0 --- /dev/null +++ b/tests/annotations/since/since.header.js @@ -0,0 +1,6 @@ +//// +/// @since {^0.0.1} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis, +/// sed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident +/// accusamus fugit magnam et adipisci eum, saepe incidunt. +//// diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json new file mode 100644 index 0000000..c576e54 --- /dev/null +++ b/tests/annotations/since/since.header.json @@ -0,0 +1,29 @@ +{ + "header": { + "since": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis maiores veritatis,\nsed repellat voluptatibus, eaque nihil assumenda odit at, ea consequatur provident\naccusamus fugit magnam et adipisci eum, saepe incidunt.

\n" + }, + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/since/since.header.js", + "start": 1, + "end": 7 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.json b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.json new file mode 100644 index 0000000..da85c20 --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.json @@ -0,0 +1,173 @@ +{ + "header": {}, + "body": [ + { + "states": { + "foo": [ + { + "state": { + "1": { + "state": ":hover", + "description": "

Hover state for example 1, state 1

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 1

\n" + } + }, + "markup": { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 1

\n

\n
    \n
  • Hover state for example 1, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 1, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":focus", + "description": "

Focus state for example 1, state 2

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 2

\n" + } + }, + "markup": { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 2

\n

\n
    \n
  • Focus state for example 1, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 1, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":active", + "description": "

Active state for example 1, state 3

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 3

\n" + } + }, + "markup": { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 3

\n

\n
    \n
  • Active state for example 1, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 1, state 3

\n</li>\n </ul>\n</div>" + } + } + ], + "bar": [ + { + "state": { + "1": { + "state": ":hover", + "description": "

Hover state for example 2, state 1

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 1

\n" + } + }, + "markup": { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 1

\n

\n
    \n
  • Hover state for example 2, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 2, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":focus", + "description": "

Focus state for example 2, state 2

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 2

\n" + } + }, + "markup": { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 2

\n

\n
    \n
  • Focus state for example 2, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 2, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":active", + "description": "

Active state for example 2, state 3

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 3

\n" + } + }, + "markup": { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 3

\n

\n
    \n
  • Active state for example 2, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 2, state 3

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state.modifier.description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state.modifier}">\n <h3>${@state.modifier.description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + }, + { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2 ${@state.modifier.description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state.modifier}">\n <h3>Example 2 ${@state.modifier.description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

Example 2

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 40, + "type": "body" + }, + "code": { + "start": 41, + "end": 59 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss", + "start": 1, + "end": 60 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss new file mode 100644 index 0000000..35615c0 --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss @@ -0,0 +1,59 @@ +/// @state (foo) +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 1 +/// {:hover} Hover state for example 1, state 1 +/// +/// @state (foo) +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 2 +/// {:focus} Focus state for example 1, state 2 +/// +/// @state (foo) +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 3 +/// {:active} Active state for example 1, state 3 +/// +/// @markup (foo) {html} Example 1 +///
+///

${@state.modifier.description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+/// +/// +/// @state (bar) +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 2, state 1 +/// {:hover} Hover state for example 2, state 1 +/// +/// @state (bar) +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 2, state 2 +/// {:focus} Focus state for example 2, state 2 +/// +/// @state (bar) +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 2, state 3 +/// {:active} Active state for example 2, state 3 +/// +/// @markup (bar) {html} Example 2 +///
+///

Example 2 ${@state.modifier.description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json new file mode 100644 index 0000000..e6520d0 --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json @@ -0,0 +1,173 @@ +{ + "header": {}, + "body": [ + { + "states": { + "foo": [ + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 1

\n" + }, + "1": { + "state": ":hover", + "description": "

Hover state for example 1, state 1

\n" + } + }, + "markup": { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 1

\n

\n
    \n
  • Hover state for example 1, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 1, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 2

\n" + }, + "1": { + "state": ":focus", + "description": "

Focus state for example 1, state 2

\n" + } + }, + "markup": { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 2

\n

\n
    \n
  • Focus state for example 1, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 1, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 3

\n" + }, + "1": { + "state": ":active", + "description": "

Active state for example 1, state 3

\n" + } + }, + "markup": { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 3

\n

\n
    \n
  • Active state for example 1, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 1, state 3

\n</li>\n </ul>\n</div>" + } + } + ], + "bar": [ + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 1

\n" + }, + "1": { + "state": ":hover", + "description": "

Hover state for example 2, state 1

\n" + } + }, + "markup": { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 1

\n

\n
    \n
  • Hover state for example 2, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 2, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 2

\n" + }, + "1": { + "state": ":focus", + "description": "

Focus state for example 2, state 2

\n" + } + }, + "markup": { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 2

\n

\n
    \n
  • Focus state for example 2, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 2, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 3

\n" + }, + "1": { + "state": ":active", + "description": "

Active state for example 2, state 3

\n" + } + }, + "markup": { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 3

\n

\n
    \n
  • Active state for example 2, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 2, state 3

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "foo", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state[0].description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state[0]}">\n <h3>${@state[0].description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + }, + { + "id": "bar", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2 ${@state[0].description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state[0]}">\n <h3>Example 2 ${@state[0].description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

Example 2

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 40, + "type": "body" + }, + "code": { + "start": 41, + "end": 59 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss", + "start": 1, + "end": 60 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss new file mode 100644 index 0000000..4d31a5a --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss @@ -0,0 +1,59 @@ +/// @state (foo) +/// {.something-super-awesome--modifier} Modifier state for example 1, state 1 +/// {:hover} Hover state for example 1, state 1 +/// +/// @state (foo) +/// {.something-super-awesome--modifier} Modifier state for example 1, state 2 +/// {:focus} Focus state for example 1, state 2 +/// +/// @state (foo) +/// {.something-super-awesome--modifier} Modifier state for example 1, state 3 +/// {:active} Active state for example 1, state 3 +/// +/// @markup (foo) {html} Example 1 +///
+///

${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+/// +/// +/// @state (bar) +/// {.something-super-awesome--modifier} Modifier state for example 2, state 1 +/// {:hover} Hover state for example 2, state 1 +/// +/// @state (bar) +/// {.something-super-awesome--modifier} Modifier state for example 2, state 2 +/// {:focus} Focus state for example 2, state 2 +/// +/// @state (bar) +/// {.something-super-awesome--modifier} Modifier state for example 2, state 3 +/// {:active} Active state for example 2, state 3 +/// +/// @markup (bar) {html} Example 2 +///
+///

Example 2 ${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json new file mode 100644 index 0000000..0115689 --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json @@ -0,0 +1,173 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "1": { + "state": ":hover", + "description": "

Hover state for example 1, state 1

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 1

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 1

\n

\n
    \n
  • Hover state for example 1, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 1, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":focus", + "description": "

Focus state for example 1, state 2

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 2

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 2

\n

\n
    \n
  • Focus state for example 1, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 1, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":active", + "description": "

Active state for example 1, state 3

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 3

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 3

\n

\n
    \n
  • Active state for example 1, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 1, state 3

\n</li>\n </ul>\n</div>" + } + } + ], + "1": [ + { + "state": { + "1": { + "state": ":hover", + "description": "

Hover state for example 2, state 1

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 1

\n" + } + }, + "markup": { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 1

\n

\n
    \n
  • Hover state for example 2, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 2, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":focus", + "description": "

Focus state for example 2, state 2

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 2

\n" + } + }, + "markup": { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 2

\n

\n
    \n
  • Focus state for example 2, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 2, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":active", + "description": "

Active state for example 2, state 3

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 3

\n" + } + }, + "markup": { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 3

\n

\n
    \n
  • Active state for example 2, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 2, state 3

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state.modifier.description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state.modifier}">\n <h3>${@state.modifier.description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + }, + { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2 ${@state.modifier.description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state.modifier}">\n <h3>Example 2 ${@state.modifier.description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

Example 2

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 40, + "type": "body" + }, + "code": { + "start": 41, + "end": 59 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss", + "start": 1, + "end": 60 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss new file mode 100644 index 0000000..4ee0f4f --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss @@ -0,0 +1,59 @@ +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 1 +/// {:hover} Hover state for example 1, state 1 +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 2 +/// {:focus} Focus state for example 1, state 2 +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 3 +/// {:active} Active state for example 1, state 3 +/// +/// @markup {html} Example 1 +///
+///

${@state.modifier.description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+/// +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 2, state 1 +/// {:hover} Hover state for example 2, state 1 +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 2, state 2 +/// {:focus} Focus state for example 2, state 2 +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 2, state 3 +/// {:active} Active state for example 2, state 3 +/// +/// @markup {html} Example 2 +///
+///

Example 2 ${@state.modifier.description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup.json b/tests/annotations/state/complex-multiple/states-multiple-markup.json new file mode 100644 index 0000000..7322f5a --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup.json @@ -0,0 +1,173 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 1

\n" + }, + "1": { + "state": ":hover", + "description": "

Hover state for example 1, state 1

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 1

\n

\n
    \n
  • Hover state for example 1, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 1, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 2

\n" + }, + "1": { + "state": ":focus", + "description": "

Focus state for example 1, state 2

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 2

\n

\n
    \n
  • Focus state for example 1, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 1, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 3

\n" + }, + "1": { + "state": ":active", + "description": "

Active state for example 1, state 3

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 3

\n

\n
    \n
  • Active state for example 1, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 1, state 3

\n</li>\n </ul>\n</div>" + } + } + ], + "1": [ + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 1

\n" + }, + "1": { + "state": ":hover", + "description": "

Hover state for example 2, state 1

\n" + } + }, + "markup": { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 1

\n

\n
    \n
  • Hover state for example 2, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 2, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 2

\n" + }, + "1": { + "state": ":focus", + "description": "

Focus state for example 2, state 2

\n" + } + }, + "markup": { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 2

\n

\n
    \n
  • Focus state for example 2, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 2, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 2, state 3

\n" + }, + "1": { + "state": ":active", + "description": "

Active state for example 2, state 3

\n" + } + }, + "markup": { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2

Modifier state for example 2, state 3

\n

\n
    \n
  • Active state for example 2, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>Example 2

Modifier state for example 2, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 2, state 3

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state[0].description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state[0]}">\n <h3>${@state[0].description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + }, + { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Example 2 ${@state[0].description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state[0]}">\n <h3>Example 2 ${@state[0].description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

Example 2

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 40, + "type": "body" + }, + "code": { + "start": 41, + "end": 59 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup.scss", + "start": 1, + "end": 60 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup.scss b/tests/annotations/state/complex-multiple/states-multiple-markup.scss new file mode 100644 index 0000000..e4e63a5 --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-multiple-markup.scss @@ -0,0 +1,59 @@ +/// @state +/// {.something-super-awesome--modifier} Modifier state for example 1, state 1 +/// {:hover} Hover state for example 1, state 1 +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state for example 1, state 2 +/// {:focus} Focus state for example 1, state 2 +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state for example 1, state 3 +/// {:active} Active state for example 1, state 3 +/// +/// @markup {html} Example 1 +///
+///

${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+/// +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state for example 2, state 1 +/// {:hover} Hover state for example 2, state 1 +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state for example 2, state 2 +/// {:focus} Focus state for example 2, state 2 +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state for example 2, state 3 +/// {:active} Active state for example 2, state 3 +/// +/// @markup {html} Example 2 +///
+///

Example 2 ${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/complex-multiple/states-with-custom-props.json b/tests/annotations/state/complex-multiple/states-with-custom-props.json new file mode 100644 index 0000000..5067c3f --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-with-custom-props.json @@ -0,0 +1,101 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "1": { + "state": ":hover", + "description": "

Hover state for example 1, state 1

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 1

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 1

\n

\n
    \n
  • Hover state for example 1, state 1

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 1

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for example 1, state 1

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":focus", + "description": "

Focus state for example 1, state 2

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 2

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 2

\n

\n
    \n
  • Focus state for example 1, state 2

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 2

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for example 1, state 2

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "1": { + "state": ":active", + "description": "

Active state for example 1, state 3

\n" + }, + "modifier": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state for example 1, state 3

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state for example 1, state 3

\n

\n
    \n
  • Active state for example 1, state 3

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state for example 1, state 3

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for example 1, state 3

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state.modifier.description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state.modifier}">\n <h3>${@state.modifier.description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 19, + "type": "body" + }, + "code": { + "start": 20, + "end": 38 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex-multiple/states-with-custom-props.scss", + "start": 1, + "end": 39 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex-multiple/states-with-custom-props.scss b/tests/annotations/state/complex-multiple/states-with-custom-props.scss new file mode 100644 index 0000000..b55537a --- /dev/null +++ b/tests/annotations/state/complex-multiple/states-with-custom-props.scss @@ -0,0 +1,38 @@ +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 1 +/// {:hover} Hover state for example 1, state 1 +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 2 +/// {:focus} Focus state for example 1, state 2 +/// +/// @state +/// {.something-super-awesome--modifier} [modifier] Modifier state for example 1, state 3 +/// {:active} Active state for example 1, state 3 +/// +/// @markup {html} Example 1 +///
+///

${@state.modifier.description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/complex-multiple/states.json b/tests/annotations/state/complex-multiple/states.json new file mode 100644 index 0000000..7f225cc --- /dev/null +++ b/tests/annotations/state/complex-multiple/states.json @@ -0,0 +1,101 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state

\n" + }, + "1": { + "state": ":hover", + "description": "

Hover state for .something-super-awesome__item

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state

\n

\n
    \n
  • Hover state for .something-super-awesome__item

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for .something-super-awesome__item

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state

\n" + }, + "1": { + "state": ":focus", + "description": "

Focus state for .something-super-awesome__item

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state

\n

\n
    \n
  • Focus state for .something-super-awesome__item

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state

\n</h3>\n <ul>\n <li class="something-super-awesome__item :focus">

Focus state for .something-super-awesome__item

\n</li>\n </ul>\n</div>" + } + }, + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state

\n" + }, + "1": { + "state": ":active", + "description": "

Active state for .something-super-awesome__item

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state

\n

\n
    \n
  • Active state for .something-super-awesome__item

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state

\n</h3>\n <ul>\n <li class="something-super-awesome__item :active">

Active state for .something-super-awesome__item

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state[0].description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state[0]}">\n <h3>${@state[0].description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 19, + "type": "body" + }, + "code": { + "start": 20, + "end": 38 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex-multiple/states.scss", + "start": 1, + "end": 39 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex-multiple/states.scss b/tests/annotations/state/complex-multiple/states.scss new file mode 100644 index 0000000..c9c7105 --- /dev/null +++ b/tests/annotations/state/complex-multiple/states.scss @@ -0,0 +1,38 @@ +/// @state +/// {.something-super-awesome--modifier} Modifier state +/// {:hover} Hover state for .something-super-awesome__item +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state +/// {:focus} Focus state for .something-super-awesome__item +/// +/// @state +/// {.something-super-awesome--modifier} Modifier state +/// {:active} Active state for .something-super-awesome__item +/// +/// @markup {html} Example 1 +///
+///

${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/complex/single-markup.json b/tests/annotations/state/complex/single-markup.json new file mode 100644 index 0000000..9aacec9 --- /dev/null +++ b/tests/annotations/state/complex/single-markup.json @@ -0,0 +1,61 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ".something-super-awesome--modifier", + "description": "

Modifier state

\n" + }, + "1": { + "state": ":hover", + "description": "

Hover state for .something-super-awesome__item

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Modifier state

\n

\n
    \n
  • Hover state for .something-super-awesome__item

    \n
  • \n
\n
", + "escaped": "<div class="something-super-awesome .something-super-awesome--modifier">\n <h3>

Modifier state

\n</h3>\n <ul>\n <li class="something-super-awesome__item :hover">

Hover state for .something-super-awesome__item

\n</li>\n </ul>\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

${@state[0].description}

\n
    \n
  • ${@state[1].description}
  • \n
\n
", + "escaped": "<div class="something-super-awesome ${@state[0]}">\n <h3>${@state[0].description}</h3>\n <ul>\n <li class="something-super-awesome__item ${@state[1].state}">${@state[1].description}</li>\n </ul>\n</div>", + "raw_stateless": "
\n

\n
    \n
  • \n
\n
", + "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 30 + }, + "file": { + "path": "docs-parser/tests/annotations/state/complex/single-markup.scss", + "start": 1, + "end": 31 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/complex/single-markup.scss b/tests/annotations/state/complex/single-markup.scss new file mode 100644 index 0000000..9724307 --- /dev/null +++ b/tests/annotations/state/complex/single-markup.scss @@ -0,0 +1,30 @@ +/// @state +/// {.something-super-awesome--modifier} Modifier state +/// {:hover} Hover state for .something-super-awesome__item +/// +/// @markup {html} Example 1 +///
+///

${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/multiple-markup/blocks-with-different-states.json b/tests/annotations/state/multiple-markup/blocks-with-different-states.json new file mode 100644 index 0000000..a720ff7 --- /dev/null +++ b/tests/annotations/state/multiple-markup/blocks-with-different-states.json @@ -0,0 +1,117 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Hover state for example 1

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Hover state for example 1

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Hover state for example 1

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Focus state for example 1

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n

Focus state for example 1

\n\n
", + "escaped": "<div class="something-super-awesome :focus">\n

Focus state for example 1

\n\n</div>" + } + } + ], + "something": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Hover state for example 2

\n" + } + }, + "markup": { + "id": "something", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Hover state for example 2

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Hover state for example 2

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Focus state for example 2

\n" + } + }, + "markup": { + "id": "something", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n

Focus state for example 2

\n\n
", + "escaped": "<div class="something-super-awesome :focus">\n

Focus state for example 2

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + }, + { + "id": "something", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 15, + "type": "body" + }, + "code": { + "start": 16, + "end": 26 + }, + "file": { + "path": "docs-parser/tests/annotations/state/multiple-markup/blocks-with-different-states.scss", + "start": 1, + "end": 27 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/multiple-markup/blocks-with-different-states.scss b/tests/annotations/state/multiple-markup/blocks-with-different-states.scss new file mode 100644 index 0000000..fb6cf50 --- /dev/null +++ b/tests/annotations/state/multiple-markup/blocks-with-different-states.scss @@ -0,0 +1,26 @@ +/// @state {:hover} Hover state for example 1 +/// @state {:focus} - Focus state for example 1 +/// +/// @markup {html} Example 1 +///
+/// ${@state.description} +///
+/// +/// @state {:hover} Hover state for example 2 +/// @state {:focus} - Focus state for example 2 +/// +/// @markup (something) {html} Example 2 +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } +} diff --git a/tests/annotations/state/multiple-markup/blocks.json b/tests/annotations/state/multiple-markup/blocks.json new file mode 100644 index 0000000..b316f7c --- /dev/null +++ b/tests/annotations/state/multiple-markup/blocks.json @@ -0,0 +1,83 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description for the hover state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n This is the only block that will get states applied to it.\n
", + "escaped": "<div class="something-super-awesome :hover">\n This is the only block that will get states applied to it.\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Some super awesome description for the focus state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n This is the only block that will get states applied to it.\n
", + "escaped": "<div class="something-super-awesome :focus">\n This is the only block that will get states applied to it.\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

\n", + "raw": "
\n This is the only block that will get states applied to it.\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n This is the only block that will get states applied to it.\n</div>", + "raw_stateless": "
\n This is the only block that will get states applied to it.\n
", + "escaped_stateless": "<div class="something-super-awesome">\n This is the only block that will get states applied to it.\n</div>" + }, + { + "id": "1", + "language": "html", + "settings": {}, + "description": "

Example 2

\n", + "raw": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", + "escaped": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>", + "raw_stateless": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", + "escaped_stateless": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 16, + "type": "body" + }, + "code": { + "start": 17, + "end": 23 + }, + "file": { + "path": "docs-parser/tests/annotations/state/multiple-markup/blocks.scss", + "start": 1, + "end": 24 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/multiple-markup/blocks.scss b/tests/annotations/state/multiple-markup/blocks.scss new file mode 100644 index 0000000..1bfa97d --- /dev/null +++ b/tests/annotations/state/multiple-markup/blocks.scss @@ -0,0 +1,23 @@ +/// @state {:hover} Some super awesome description for the hover state +/// @state {:focus} - Some super awesome description for the focus state +/// +/// @markup {html} Example 1 +///
+/// This is the only block that will get states applied to it. +///
+/// +/// @markup {html} Example 2 +///
+/// There are no states created with this markup because it is the +/// second markup annotation in the comment block and there was no +/// id set so the id is 1 by default. If you are looking for an example +/// of multiple markup blocks with seperate states see +/// `state-multiple-markup-blocks-with-different-states.scss` +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json new file mode 100644 index 0000000..4dee4d4 --- /dev/null +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json @@ -0,0 +1,257 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description for the hover state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the hover state

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Some super awesome description for the hover state

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Some super awesome description for the focus state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the focus state

\n\n
", + "escaped": "<div class="something-super-awesome :focus">\n

Some super awesome description for the focus state

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "

Some super awesome description for the active state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the active state

\n\n
", + "escaped": "<div class="something-super-awesome :active">\n

Some super awesome description for the active state

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 23 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", + "start": 1, + "end": 74 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description for the hover state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the hover state

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Some super awesome description for the hover state

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Some super awesome description for the focus state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the focus state

\n\n
", + "escaped": "<div class="something-super-awesome :focus">\n

Some super awesome description for the focus state

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "

Some super awesome description for the active state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the active state

\n\n
", + "escaped": "<div class="something-super-awesome :active">\n

Some super awesome description for the active state

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state.state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 26, + "end": 33, + "type": "body" + }, + "code": { + "start": 34, + "end": 48 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", + "start": 1, + "end": 74 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description for the hover state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the hover state

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Some super awesome description for the hover state

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Some super awesome description for the focus state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the focus state

\n\n
", + "escaped": "<div class="something-super-awesome :focus">\n

Some super awesome description for the focus state

\n\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "

Some super awesome description for the active state

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description for the active state

\n\n
", + "escaped": "<div class="something-super-awesome :active">\n

Some super awesome description for the active state

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state[description]}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state[description]}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 51, + "end": 58, + "type": "body" + }, + "code": { + "start": 59, + "end": 73 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", + "start": 1, + "end": 74 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss b/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss new file mode 100644 index 0000000..c07f6f2 --- /dev/null +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss @@ -0,0 +1,73 @@ +/// @state {:hover} Some super awesome description for the hover state +/// @state {:focus} Some super awesome description for the focus state +/// @state {:active} Some super awesome description for the active state +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} Some super awesome description for the hover state +/// @state {:focus} Some super awesome description for the focus state +/// @state {:active} Some super awesome description for the active state +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} - Some super awesome description for the hover state +/// @state {:focus} - Some super awesome description for the focus state +/// @state {:active} - Some super awesome description for the active state +/// +/// @markup {html} +///
+/// ${@state[description]} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json new file mode 100644 index 0000000..74a1290 --- /dev/null +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json @@ -0,0 +1,257 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 23 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", + "start": 1, + "end": 74 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state.state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 26, + "end": 33, + "type": "body" + }, + "code": { + "start": 34, + "end": 48 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", + "start": 1, + "end": 74 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state[state]}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 51, + "end": 58, + "type": "body" + }, + "code": { + "start": 59, + "end": 73 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", + "start": 1, + "end": 74 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss new file mode 100644 index 0000000..a6ae5b4 --- /dev/null +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss @@ -0,0 +1,73 @@ +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} diff --git a/tests/annotations/state/stupid-simple-multiple/simple.json b/tests/annotations/state/stupid-simple-multiple/simple.json new file mode 100644 index 0000000..33c4a2f --- /dev/null +++ b/tests/annotations/state/stupid-simple-multiple/simple.json @@ -0,0 +1,89 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 23 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple.scss", + "start": 1, + "end": 24 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/stupid-simple-multiple/simple.scss b/tests/annotations/state/stupid-simple-multiple/simple.scss new file mode 100644 index 0000000..4399672 --- /dev/null +++ b/tests/annotations/state/stupid-simple-multiple/simple.scss @@ -0,0 +1,23 @@ +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: green; + } + + &:active { + background: green; + } +} diff --git a/tests/annotations/state/stupid-simple/simple.json b/tests/annotations/state/stupid-simple/simple.json new file mode 100644 index 0000000..eb79ca8 --- /dev/null +++ b/tests/annotations/state/stupid-simple/simple.json @@ -0,0 +1,57 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 13 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/simple.scss", + "start": 1, + "end": 14 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/stupid-simple/simple.scss b/tests/annotations/state/stupid-simple/simple.scss new file mode 100644 index 0000000..e527198 --- /dev/null +++ b/tests/annotations/state/stupid-simple/simple.scss @@ -0,0 +1,13 @@ +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/state/stupid-simple/with-description.json b/tests/annotations/state/stupid-simple/with-description.json new file mode 100644 index 0000000..955a4ae --- /dev/null +++ b/tests/annotations/state/stupid-simple/with-description.json @@ -0,0 +1,161 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Some super awesome description

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 13 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/with-description.scss", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Some super awesome description

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state.state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 16, + "end": 21, + "type": "body" + }, + "code": { + "start": 22, + "end": 28 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/with-description.scss", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description

\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n

Some super awesome description

\n\n
", + "escaped": "<div class="something-super-awesome :hover">\n

Some super awesome description

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state[description]}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state[description]}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "blockinfo": { + "comment": { + "start": 30, + "end": 35, + "type": "body" + }, + "code": { + "start": 36, + "end": 42 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/with-description.scss", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/stupid-simple/with-description.scss b/tests/annotations/state/stupid-simple/with-description.scss new file mode 100644 index 0000000..cd73f4e --- /dev/null +++ b/tests/annotations/state/stupid-simple/with-description.scss @@ -0,0 +1,42 @@ +/// @state {:hover} Some super awesome description +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + + +/// @state {:hover} Some super awesome description +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + +/// @state {:hover} - Some super awesome description +/// +/// @markup {html} +///
+/// ${@state[description]} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/state/stupid-simple/with-notations.json b/tests/annotations/state/stupid-simple/with-notations.json new file mode 100644 index 0000000..83d9bd4 --- /dev/null +++ b/tests/annotations/state/stupid-simple/with-notations.json @@ -0,0 +1,161 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 13 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/with-notations.scss", + "start": 1, + "end": 44 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state.state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 16, + "end": 21, + "type": "body" + }, + "code": { + "start": 22, + "end": 28 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/with-notations.scss", + "start": 1, + "end": 44 + } + }, + "access": "public", + "inline": [] + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state[state]}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 31, + "end": 36, + "type": "body" + }, + "code": { + "start": 37, + "end": 43 + }, + "file": { + "path": "docs-parser/tests/annotations/state/stupid-simple/with-notations.scss", + "start": 1, + "end": 44 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/state/stupid-simple/with-notations.scss b/tests/annotations/state/stupid-simple/with-notations.scss new file mode 100644 index 0000000..ee980d2 --- /dev/null +++ b/tests/annotations/state/stupid-simple/with-notations.scss @@ -0,0 +1,43 @@ +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + + +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + + +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/throws/throws.alias.js b/tests/annotations/throws/throws.alias.js new file mode 100644 index 0000000..64c48fe --- /dev/null +++ b/tests/annotations/throws/throws.alias.js @@ -0,0 +1,7 @@ +/// @throw {throw} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @exception {exception} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @error {error} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @catch {catch} Lorem ipsum dolor sit amet, consectetur adipisicing elit. diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json new file mode 100644 index 0000000..a5831d7 --- /dev/null +++ b/tests/annotations/throws/throws.alias.json @@ -0,0 +1,117 @@ +{ + "header": {}, + "body": [ + { + "throws": [ + { + "types": [ + "throw" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "exception" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "error" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "catch" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/throws/throws.js b/tests/annotations/throws/throws.js new file mode 100644 index 0000000..0016371 --- /dev/null +++ b/tests/annotations/throws/throws.js @@ -0,0 +1,15 @@ +/// @throws + +/// @throws {fileNotFound} + +/// @throws {fileNotFound} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @throws {fileNotFound} - Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @throws {fileNotFound} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod sequi adipisci illum. +/// Atque itaque sequi, qui ratione aliquid debitis dolorem alias blanditiis, impedit +/// necessitatibus quidem at non, earum a esse. + +/// @throws {warning} some warning message +/// @throws {error} when something goes wrong diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json new file mode 100644 index 0000000..85ab69d --- /dev/null +++ b/tests/annotations/throws/throws.json @@ -0,0 +1,177 @@ +{ + "header": {}, + "body": [ + { + "throws": [ + { + "types": [], + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod sequi adipisci illum.\nAtque itaque sequi, qui ratione aliquid debitis dolorem alias blanditiis, impedit\nnecessitatibus quidem at non, earum a esse.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 12, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + }, + { + "throws": [ + { + "types": [ + "warning" + ], + "description": "

some warning message

\n" + }, + { + "types": [ + "error" + ], + "description": "

when something goes wrong

\n" + } + ], + "blockinfo": { + "comment": { + "start": 14, + "end": 15, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/todo/todo.body.js b/tests/annotations/todo/todo.body.js new file mode 100644 index 0000000..4138094 --- /dev/null +++ b/tests/annotations/todo/todo.body.js @@ -0,0 +1,14 @@ +/// @todo Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @todo {5} - Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @todo {5} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @todo {10} [Assignee One] - Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @todo {10} [Assignee One, Assignee Two] Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @todo {8} [ Assignee One, Assignee Two ] +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Exercitationem sed distinctio, +/// neque molestiae numquam cumque incidunt magni et provident temporibus. Illum, ullam +/// quidem nulla architecto, numquam hic voluptate provident sit! diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json new file mode 100644 index 0000000..3bc2685 --- /dev/null +++ b/tests/annotations/todo/todo.body.json @@ -0,0 +1,175 @@ +{ + "header": {}, + "body": [ + { + "todo": [ + { + "importance": "0", + "assignees": [], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "todo": [ + { + "importance": "5", + "assignees": [], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "todo": [ + { + "importance": "5", + "assignees": [], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "todo": [ + { + "importance": "10", + "assignees": [ + "Assignee One" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "todo": [ + { + "importance": "10", + "assignees": [ + "Assignee One", + "Assignee Two" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + }, + { + "todo": [ + { + "importance": "8", + "assignees": [ + "Assignee One", + "Assignee Two" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Exercitationem sed distinctio,\nneque molestiae numquam cumque incidunt magni et provident temporibus. Illum, ullam\nquidem nulla architecto, numquam hic voluptate provident sit!

\n" + } + ], + "blockinfo": { + "comment": { + "start": 11, + "end": 14, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/todo/todo.header.js b/tests/annotations/todo/todo.header.js new file mode 100644 index 0000000..4c81d56 --- /dev/null +++ b/tests/annotations/todo/todo.header.js @@ -0,0 +1,6 @@ +//// +/// @todo {8} [ Assignee One, Assignee Two ] +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Exercitationem sed distinctio, +/// neque molestiae numquam cumque incidunt magni et provident temporibus. Illum, ullam +/// quidem nulla architecto, numquam hic voluptate provident sit! +//// diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json new file mode 100644 index 0000000..6cd623f --- /dev/null +++ b/tests/annotations/todo/todo.header.json @@ -0,0 +1,35 @@ +{ + "header": { + "todo": [ + { + "importance": "8", + "assignees": [ + "Assignee One", + "Assignee Two" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Exercitationem sed distinctio,\nneque molestiae numquam cumque incidunt magni et provident temporibus. Illum, ullam\nquidem nulla architecto, numquam hic voluptate provident sit!

\n" + } + ], + "page": [ + "general" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/todo/todo.header.js", + "start": 1, + "end": 7 + } + }, + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/type/type.js b/tests/annotations/type/type.js new file mode 100644 index 0000000..10079f8 --- /dev/null +++ b/tests/annotations/type/type.js @@ -0,0 +1,17 @@ +/// @type + +/// @type {object} + +/// @type Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @type - Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @type {array} - Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @type {array} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @type {array} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos, quod +/// libero tenetur rerum odio harum perferendis repellat sunt, soluta expedita +/// iure. Provident, debitis, cupiditate. Quae magnam ipsa modi, +/// aspernatur eligendi. diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json new file mode 100644 index 0000000..5c6fbf9 --- /dev/null +++ b/tests/annotations/type/type.json @@ -0,0 +1,173 @@ +{ + "header": {}, + "body": [ + { + "type": { + "type": "undefined", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "type": { + "type": "undefined", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "type": { + "type": "undefined", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "type": { + "type": "array", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "type": { + "type": "array", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "blockinfo": { + "comment": { + "start": 11, + "end": 11, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + }, + { + "type": { + "type": "array", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos, quod\nlibero tenetur rerum odio harum perferendis repellat sunt, soluta expedita\niure. Provident, debitis, cupiditate. Quae magnam ipsa modi,\naspernatur eligendi.

\n" + }, + "blockinfo": { + "comment": { + "start": 13, + "end": 17, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/annotations/version/version.js b/tests/annotations/version/version.js new file mode 100644 index 0000000..13a9117 --- /dev/null +++ b/tests/annotations/version/version.js @@ -0,0 +1,12 @@ +/// @version + +/// @version {0.0.1} + +/// @version {^0.0.1} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @version {^0.0.1} - Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @version {1.0.1} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Praesentium necessitatibus +/// laboriosam, hic odit sequi facilis, amet consequuntur ullam, rem iure commodi doloremque +/// sapiente numquam. Minima vel voluptates sint nostrum facere. diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json new file mode 100644 index 0000000..526b689 --- /dev/null +++ b/tests/annotations/version/version.json @@ -0,0 +1,125 @@ +{ + "header": {}, + "body": [ + { + "version": { + "version": "undefined", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + }, + "access": "public", + "inline": [] + }, + { + "version": { + "version": "0.0.1", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + }, + "access": "public", + "inline": [] + }, + { + "version": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + }, + "access": "public", + "inline": [] + }, + { + "version": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + }, + "access": "public", + "inline": [] + }, + { + "version": { + "version": "1.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Praesentium necessitatibus\nlaboriosam, hic odit sequi facilis, amet consequuntur ullam, rem iure commodi doloremque\nsapiente numquam. Minima vel voluptates sint nostrum facere.

\n" + }, + "blockinfo": { + "comment": { + "start": 9, + "end": 12, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + }, + "access": "public", + "inline": [] + } + ] +} diff --git a/tests/cases/4-blank-lines-between-code-blocks.json b/tests/cases/4-blank-lines-between-code-blocks.json new file mode 100644 index 0000000..344eaaa --- /dev/null +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -0,0 +1,49 @@ +{ + "nav": [ + { + "title": "4 Blank Lines Between Code Blocks", + "href": "/4-blank-lines-between-code-blocks", + "body": [ + { + "title": "moz-only", + "href": "/4-blank-lines-between-code-blocks#moz-only" + } + ], + "subpages": [] + } + ], + "pages": { + "4-blank-lines-between-code-blocks": { + "page": { + "header": {}, + "body": [ + { + "name": "moz-only", + "raw-code": { + "raw": "@mixin moz-only() {\n $selector: &;\n @at-root {\n @-moz-document url-prefix() {\n #{$selector} {\n @content;\n }\n }\n }\n}", + "escaped": "@mixin moz-only() {\n $selector: &;\n @at-root {\n @-moz-document url-prefix() {\n #{$selector} {\n @content;\n }\n }\n }\n}" + }, + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 13 + }, + "file": { + "path": "docs-parser/tests/cases/4-blank-lines-between-code-blocks.scss", + "start": 1, + "end": 34 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/cases/4-blank-lines-between-code-blocks.scss b/tests/cases/4-blank-lines-between-code-blocks.scss new file mode 100644 index 0000000..f2bd9b3 --- /dev/null +++ b/tests/cases/4-blank-lines-between-code-blocks.scss @@ -0,0 +1,33 @@ +/// @name moz-only +/// @page 4-blank-lines-between-code-blocks +/// @raw-code +@mixin moz-only() { + $selector: &; + @at-root { + @-moz-document url-prefix() { + #{$selector} { + @content; + } + } + } +} + + + + +.nav { + height: 40px; + width: 100%; + background: #455868; + border-bottom: 2px solid #283744; + + li { + width: 600px; + height: 40px; + a { + color: #fff; + line-height: 40px; + text-shadow: 1px 1px 0px #283744; + } + } +} diff --git a/tests/cases/allthethings-js.js b/tests/cases/allthethings-js.js new file mode 100644 index 0000000..e41c585 --- /dev/null +++ b/tests/cases/allthethings-js.js @@ -0,0 +1,23 @@ +//// +/// @name All the things test +/// @author Tyler Benton +/// @page components +//// + + +/// @name Beards +/// @description +/// This is an awesome class about beards +class Beards { + ///# @name constructor + ///# @arg {object} options + constructor({ one, two }) { + // so some shit + } + + ///# @name beard + ///# @arg {string} type ['full beard'] - The type of beard you're wanting to get + beard(type = 'full beard') { + return this.types[type] + } +} \ No newline at end of file diff --git a/tests/cases/allthethings-js.json b/tests/cases/allthethings-js.json new file mode 100644 index 0000000..d82ae58 --- /dev/null +++ b/tests/cases/allthethings-js.json @@ -0,0 +1,129 @@ +{ + "nav": [ + { + "title": "Components", + "href": "/components", + "body": [ + { + "title": "Beards", + "href": "/components#beards" + } + ], + "subpages": [] + } + ], + "pages": { + "components": { + "page": { + "header": { + "name": "All the things test", + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-js.js", + "start": 1, + "end": 23 + } + }, + "access": "public" + }, + "body": [ + { + "name": "Beards", + "description": "

This is an awesome class about beards

\n", + "blockinfo": { + "comment": { + "start": 8, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 23 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-js.js", + "start": 1, + "end": 23 + } + }, + "access": "public", + "inline": [ + { + "name": "constructor", + "arg": [ + { + "types": [ + "object" + ], + "name": "options", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 12, + "end": 13, + "type": "inline" + }, + "code": { + "start": 14, + "end": 16 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-js.js", + "start": 1, + "end": 23 + } + }, + "access": "public" + }, + { + "name": "beard", + "arg": [ + { + "types": [ + "string" + ], + "name": "type", + "value": "'full beard'", + "description": "

The type of beard you're wanting to get

\n" + } + ], + "blockinfo": { + "comment": { + "start": 18, + "end": 19, + "type": "inline" + }, + "code": { + "start": 20, + "end": 22 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-js.js", + "start": 1, + "end": 23 + } + }, + "access": "public" + } + ] + } + ] + } + } + } +} diff --git a/tests/cases/allthethings-scss.json b/tests/cases/allthethings-scss.json new file mode 100644 index 0000000..deb0022 --- /dev/null +++ b/tests/cases/allthethings-scss.json @@ -0,0 +1,218 @@ +{ + "nav": [ + { + "title": "Components", + "href": "/components", + "body": [], + "subpages": [ + { + "title": "All the things test", + "href": "/components/buttons", + "body": [ + { + "title": "Buttons", + "href": "/components/buttons#buttons" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "components": { + "page": { + "header": {}, + "body": [] + }, + "buttons": { + "page": { + "header": { + "name": "All the things test", + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-scss.scss", + "start": 1, + "end": 239 + } + }, + "access": "public" + }, + "body": [ + { + "name": "Buttons", + "description": "

Your standard form button.

\n", + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

@state inline

\n" + } + }, + "markup": { + "id": "0", + "language": "scss", + "settings": {}, + "description": "

EXAMPLE 1

\n", + "raw": "
\n Button (a.button)\n \n \n
", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn :hover">Button (a.button)</a>\n <button class="c-btn :hover">Button (button)</button>\n <input class="c-btn :hover" type="button" value="Button (input.button)">\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "scss", + "settings": {}, + "description": "

EXAMPLE 1

\n", + "raw": "
\n Button (a.button)\n \n \n
", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn ${@state}">Button (a.button)</a>\n <button class="c-btn ${@state}">Button (button)</button>\n <input class="c-btn ${@state}" type="button" value="Button (input.button)">\n</div>", + "raw_stateless": "
\n Button (a.button)\n \n \n
", + "escaped_stateless": "<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>" + }, + { + "id": "1", + "language": "scss", + "settings": {}, + "description": "

* EXAMPLE 2 *

\n", + "raw": "

THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

\n
\n Button (a.button)\n \n \n
", + "escaped": "<p> THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)</p>\n<div class="c-btn-group">\n <a href="#" class="c-btn ${@state}">Button (a.button)</a>\n <button class="c-btn ${@state}">Button (button)</button>\n <input class="c-btn ${@state}" type="button" value="Button (input.button)">\n</div>", + "raw_stateless": "

THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

\n
\n Button (a.button)\n \n \n
", + "escaped_stateless": "<p> THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)</p>\n<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 8, + "end": 26, + "type": "body" + }, + "code": { + "start": 27, + "end": 239 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-scss.scss", + "start": 1, + "end": 239 + } + }, + "access": "public", + "inline": [ + { + "states": { + "1": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "1", + "language": "scss", + "settings": {}, + "description": "

* EXAMPLE 2 *

\n", + "raw": "

THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

\n
\n Button (a.button)\n \n \n
", + "escaped": "<p> THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)</p>\n<div class="c-btn-group">\n <a href="#" class="c-btn :hover">Button (a.button)</a>\n <button class="c-btn :hover">Button (button)</button>\n <input class="c-btn :hover" type="button" value="Button (input.button)">\n</div>" + } + } + ] + }, + "blockinfo": { + "comment": { + "start": 48, + "end": 48, + "type": "inline" + }, + "code": { + "start": 48, + "end": 50 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-scss.scss", + "start": 1, + "end": 239 + } + }, + "access": "public" + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "scss", + "settings": {}, + "description": "

EXAMPLE 1

\n", + "raw": "
\n Button (a.button)\n \n \n
", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn :active">Button (a.button)</a>\n <button class="c-btn :active">Button (button)</button>\n <input class="c-btn :active" type="button" value="Button (input.button)">\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "scss", + "settings": {}, + "description": "

EXAMPLE 1

\n", + "raw": "
\n Button (a.button)\n \n \n
", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn :focus">Button (a.button)</a>\n <button class="c-btn :focus">Button (button)</button>\n <input class="c-btn :focus" type="button" value="Button (input.button)">\n</div>" + } + } + ] + }, + "blockinfo": { + "comment": { + "start": 52, + "end": 53, + "type": "inline" + }, + "code": { + "start": 54, + "end": 56 + }, + "file": { + "path": "docs-parser/tests/cases/allthethings-scss.scss", + "start": 1, + "end": 239 + } + }, + "access": "public" + } + ] + } + ] + } + } + } + } +} diff --git a/tests/cases/allthethings-scss.scss b/tests/cases/allthethings-scss.scss new file mode 100644 index 0000000..af46c6d --- /dev/null +++ b/tests/cases/allthethings-scss.scss @@ -0,0 +1,239 @@ +//// +/// @name All the things test +/// @author Tyler Benton +/// @page components/buttons +//// + + +/// @name Buttons +/// @description Your standard form button. +/// +/// @state {:hover} - @state inline +/// +/// @markup EXAMPLE 1 +///
+/// Button (a.button) +/// +/// +///
+/// +/// @markup ***************************** EXAMPLE 2 ***************************** +///

THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

+///
+/// Button (a.button) +/// +/// +///
+.c-btn { + background: color(a); + border: none; + border-radius: get($config, 'border-radius'); + color: #fff; + display: inline-block; + font-size: 1em; + font-weight: bold; + line-height: 1em; + padding: em(13px) 1.5em; + text-align: center; + text-decoration: none; + transition: background 0.25s ease-out, color 0.25s ease-out; + vertical-align: middle; + width: auto; // this resets the input style of 100% + + &:hover, &:active, &:focus { + color: #fff; + text-decoration: none; + } + + &:hover { ///# @state (1) {:hover} + background: color(a, -2); + } + + ///# @state {:active} + ///# @state (0) {:focus} + &:active, &:focus { + background: color(a, 2); + } +} + +// @name Alerts +// @author Tyler Benton +// @page components/alerts +// +// @description +// Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. +// +// @markup **Example:** Basic +// +// +// +// +// +// +// @markup **Example:** With simple swipe-dismiss +// +// +// +// +// + +// +// @markup **Example:** With custom simple closing action +// +// +// @markup **Example:** With custom actions +// +.c-alert { + @include owl('off'); + align-items: center; + background-color: color(white); + border-radius: get($config, 'border-radius'); + border: 1px solid rgba(black, 0); + display: flex; + @include ie(9, 10) { // come onnnn ie! :unhappyjessica: + display: table; + } + flex-flow: row nowrap; + padding: get($config, 'spacing'); + position: relative; + overflow: hidden; + &:before{ + @include icon-styles; + bottom: -0.22em; + font-size: 7em; + left: -0.1em; + opacity: 0.2; + + // oh boy does this look terrible in ie 9/10 without these styles + @include ie(9, 10) { + font-size: 18px; + top: 0; + left: 0; + position: relative; + margin-right: .2em; + } + } + + @each $alert in map-keys($alert-settings) { + &--#{$alert} { + background: color($alert, -5, $namespace: 'messaging'); + color: color($alert, $namespace: 'messaging'); + &:before{ + @include icon-get(get($alert-settings, $alert, 'icon')); + @if $alert == 'success' { + background: color($alert, $namespace: 'messaging'); + border-radius: 50%; + color: color($alert, -5, $namespace: 'messaging'); + } + } + } + + @include media('print') { + &--#{$alert} { + // adds a border around the alert boxes so they're visible on print + border: 1px solid color($alert, -5, $namespace: 'messaging'); + } + } + } + + &__content { + flex: 1; + @include ie(9, 10) { // come onnnn ie! :unhappyjessica: + display: table-cell; + width: 100%; + } + } + + &__actions { + @include owl('off'); + @include ie(9, 10) { // come onnnn ie! :unhappyjessica: + display: table-cell; + width: 100%; + } + flex: 0 0 auto; + + * { + margin-top: 0; + } + + * ~ * { + margin-left: (get($config, 'spacing') / 2); + } + } + + // @name Dismissible Alerts (Depricated) + // @author Tyler Benton + // @page components/alerts + // + // @description + // Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. + // + // @markup **Example:** Basic (DEPRICATED) + // + // + // + // + // + // + // @note {!!!} - Requires Javascript + // @depricated `c-alert--dismissible` is Depricated! Use `js-mf-dismissible` instead. + &--dismissible { + $padding: 20px; + position: relative; + padding-right: em($padding * 2) + get($config, 'spacing'); + cursor: pointer; + .u-icon--close, .c-alert__actions { + position: absolute; + top: 0; + margin: 0; + right: 0; + padding: $padding; + color: inherit; + background: transparent; + @include icon-styles(); + } + } +} + +// @name Slide left/right +// @author Jessica Kennedy +// @page components/alerts +// +// @description +// Slides an item left or right with a swipe delete effect. This is used to make dismissibles & popups hide. +// There is site-level javascript to handle this for developers, but developers can also choose to +// add these classes to anything to make them slide to the left or right. +// +// @markup **Example:** Slide Left +// +// +// @markup **Example:** Slide Right +// +.u-slide { + transition: transform 0.2s; + &--left { + transform: translateX(-30em) scale(.2) !important; // "!important" is necessary as this overrides styles applied directly to the element in question (using javascript) + } + &--right { + transform: translateX(20em) scale(.2) !important; // "!important" is necessary as this overrides styles applied directly to the element in question (using javascript) + } +} + +html, +body, +canvas { + width: 100%; + height: 100%; + overflow: hidden; +} \ No newline at end of file diff --git a/tests/lib/js/test.js b/tests/cases/empty-file.js similarity index 100% rename from tests/lib/js/test.js rename to tests/cases/empty-file.js diff --git a/tests/cases/empty-file.json b/tests/cases/empty-file.json new file mode 100644 index 0000000..fc22cd6 --- /dev/null +++ b/tests/cases/empty-file.json @@ -0,0 +1,4 @@ +{ + "nav": [], + "pages": {} +} diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json new file mode 100644 index 0000000..f29e46d --- /dev/null +++ b/tests/cases/header-comment-only.json @@ -0,0 +1,41 @@ +{ + "nav": [ + { + "title": "Header Comment Only", + "href": "/header-comment-only", + "body": [], + "subpages": [] + } + ], + "pages": { + "header-comment-only": { + "page": { + "header": { + "name": "Header", + "author": [ + "Tyler Benton" + ], + "description": "

This test is for a file that only has a header comment.

\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/header-comment-only.scss", + "start": 1, + "end": 8 + } + }, + "access": "public" + }, + "body": [] + } + } + } +} diff --git a/tests/lib/edge-cases/header-comment-only.scss b/tests/cases/header-comment-only.scss similarity index 73% rename from tests/lib/edge-cases/header-comment-only.scss rename to tests/cases/header-comment-only.scss index 96ecb94..e564273 100644 --- a/tests/lib/edge-cases/header-comment-only.scss +++ b/tests/cases/header-comment-only.scss @@ -1,7 +1,7 @@ //// /// @name Header /// @author Tyler Benton -/// @page edge-cases/header-comment-only +/// @page header-comment-only /// @description /// This test is for a file that only has a header comment. -//// \ No newline at end of file +//// diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json new file mode 100644 index 0000000..df4ec93 --- /dev/null +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -0,0 +1,81 @@ +{ + "nav": [ + { + "title": "No Space Between Header And Body Comment", + "href": "/no-space-between-header-and-body-comment", + "body": [ + { + "title": "moz-only", + "href": "/no-space-between-header-and-body-comment#moz-only" + } + ], + "subpages": [] + } + ], + "pages": { + "no-space-between-header-and-body-comment": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/no-space-between-header-and-body-comments.scss", + "start": 1, + "end": 28 + } + }, + "access": "public" + }, + "body": [ + { + "name": "moz-only", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": { + "example": "'false'" + }, + "description": "

Example:

\n", + "raw": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}", + "escaped": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: "";\n}", + "raw_stateless": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}", + "escaped_stateless": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: "";\n}" + } + ], + "blockinfo": { + "comment": { + "start": 5, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 27 + }, + "file": { + "path": "docs-parser/tests/cases/no-space-between-header-and-body-comments.scss", + "start": 1, + "end": 28 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/lib/edge-cases/no-space-between-header-and-body-comments.scss b/tests/cases/no-space-between-header-and-body-comments.scss similarity index 80% rename from tests/lib/edge-cases/no-space-between-header-and-body-comments.scss rename to tests/cases/no-space-between-header-and-body-comments.scss index 2349e33..c3be0c2 100644 --- a/tests/lib/edge-cases/no-space-between-header-and-body-comments.scss +++ b/tests/cases/no-space-between-header-and-body-comments.scss @@ -1,11 +1,10 @@ //// /// @author Tyler Benton -/// @page edge-cases/no-space-between-header-and-body-comment +/// @page no-space-between-header-and-body-comment //// /// @name moz-only -/// @author Tyler Benton /// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** +/// @markup {scss} [example='false'] **Example:** /// @include moz-only(){ /// // removes the weird styling in firefox /// -moz-appearance: none; @@ -25,4 +24,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/cases/only-body-comments-no-page.json b/tests/cases/only-body-comments-no-page.json new file mode 100644 index 0000000..efe9133 --- /dev/null +++ b/tests/cases/only-body-comments-no-page.json @@ -0,0 +1,115 @@ +{ + "nav": [ + { + "title": "General", + "href": "/general", + "body": [ + { + "title": "Button group", + "href": "/general#button-group" + }, + { + "title": "Test", + "href": "/general#test" + } + ], + "subpages": [] + } + ], + "pages": { + "general": { + "page": { + "header": {}, + "body": [ + { + "name": "Button group", + "description": "

Used when there's a group of buttons that need to be on the same line.

\n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": {}, + "description": "", + "raw": "
\n Button (a.button)\n \n \n
", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>", + "raw_stateless": "
\n Button (a.button)\n \n \n
", + "escaped_stateless": "<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 10, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-body-comments-no-page.scss", + "start": 1, + "end": 21 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Test", + "states": { + "null": [ + { + "state": { + "0": { + "state": "", + "description": "

.state-1

\n" + } + }, + "markup": {} + }, + { + "state": { + "0": { + "state": "", + "description": "

.state-2

\n" + } + }, + "markup": {} + }, + { + "state": { + "0": { + "state": "", + "description": "

.state-3

\n" + } + }, + "markup": {} + } + ] + }, + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nQuasi omnis facilis vero architecto perferendis, debitis dignissimos tempore\ndolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis\niste nostrum vel, culpa iure. Adipisci.

\n", + "blockinfo": { + "comment": { + "start": 12, + "end": 20, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-body-comments-no-page.scss", + "start": 1, + "end": 21 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/cases/only-body-comments-no-page.scss b/tests/cases/only-body-comments-no-page.scss new file mode 100644 index 0000000..7c98ae3 --- /dev/null +++ b/tests/cases/only-body-comments-no-page.scss @@ -0,0 +1,20 @@ +/// @name Button group +/// @description +/// Used when there's a group of buttons that need to be on the same line. +/// +/// @markup +///
+/// Button (a.button) +/// +/// +///
+ +/// @name Test +/// @state .state-1 +/// @state .state-2 +/// @state .state-3 +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore +/// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis +/// iste nostrum vel, culpa iure. Adipisci. diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json new file mode 100644 index 0000000..18c81eb --- /dev/null +++ b/tests/cases/only-body-comments.json @@ -0,0 +1,153 @@ +{ + "nav": [ + { + "title": "Components", + "href": "/components", + "body": [], + "subpages": [ + { + "title": "Buttons", + "href": "/components/buttons", + "body": [], + "subpages": [] + } + ] + }, + { + "title": "General", + "href": "/general", + "body": [ + { + "title": "Button group", + "href": "/general#button-group" + }, + { + "title": "Test", + "href": "/general#test" + } + ], + "subpages": [] + } + ], + "pages": { + "components": { + "page": { + "header": {}, + "body": [] + }, + "buttons": { + "page": { + "header": {}, + "body": [ + { + "author": [ + "Tyler Benton" + ], + "description": "

Your standard form button.

\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-body-comments.scss", + "start": 1, + "end": 19 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + }, + "general": { + "page": { + "header": {}, + "body": [ + { + "name": "Button group", + "description": "

Used when there's a group of buttons that need to be on the same line.

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-body-comments.scss", + "start": 1, + "end": 19 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Test", + "states": { + "null": [ + { + "state": { + "0": { + "state": "", + "description": "

.state-1

\n" + } + }, + "markup": {} + }, + { + "state": { + "0": { + "state": "", + "description": "

.state-2

\n" + } + }, + "markup": {} + }, + { + "state": { + "0": { + "state": "", + "description": "

.state-3

\n" + } + }, + "markup": {} + } + ] + }, + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nQuasi omnis facilis vero architecto perferendis, debitis dignissimos tempore\ndolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis\niste nostrum vel, culpa iure. Adipisci.

\n", + "blockinfo": { + "comment": { + "start": 10, + "end": 18, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-body-comments.scss", + "start": 1, + "end": 19 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/cases/only-body-comments.scss b/tests/cases/only-body-comments.scss new file mode 100644 index 0000000..e40ea51 --- /dev/null +++ b/tests/cases/only-body-comments.scss @@ -0,0 +1,18 @@ +/// @author Tyler Benton +/// @page components/buttons +/// +/// @description Your standard form button. + +/// @name Button group +/// @description +/// Used when there's a group of buttons that need to be on the same line. + +/// @name Test +/// @state .state-1 +/// @state .state-2 +/// @state .state-3 +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore +/// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis +/// iste nostrum vel, culpa iure. Adipisci. diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json new file mode 100644 index 0000000..3373fc0 --- /dev/null +++ b/tests/cases/only-comments.json @@ -0,0 +1,110 @@ +{ + "nav": [ + { + "title": "Only Comments", + "href": "/only-comments", + "body": [ + { + "title": "moz-only", + "href": "/only-comments#moz-only" + }, + { + "title": "Test one", + "href": "/only-comments#test-one" + } + ], + "subpages": [] + } + ], + "pages": { + "only-comments": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-comments.scss", + "start": 1, + "end": 27 + } + }, + "access": "public" + }, + "body": [ + { + "name": "moz-only", + "author": [ + "Tyler Benton" + ], + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": { + "example": "'false'" + }, + "description": "

Example:

\n", + "raw": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}", + "escaped": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: "";\n}", + "raw_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}", + "escaped_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: "";\n}" + } + ], + "blockinfo": { + "comment": { + "start": 6, + "end": 19, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-comments.scss", + "start": 1, + "end": 27 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Test one", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nQuasi omnis facilis vero architecto perferendis, debitis dignissimos tempore\ndolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis\niste nostrum vel, culpa iure. Adipisci.

\n", + "blockinfo": { + "comment": { + "start": 21, + "end": 26, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/only-comments.scss", + "start": 1, + "end": 27 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/lib/edge-cases/only-comments.scss b/tests/cases/only-comments.scss similarity index 60% rename from tests/lib/edge-cases/only-comments.scss rename to tests/cases/only-comments.scss index e73fc62..7d37f0d 100644 --- a/tests/lib/edge-cases/only-comments.scss +++ b/tests/cases/only-comments.scss @@ -1,30 +1,26 @@ //// /// @author Tyler Benton -/// @page edge-cases/only-comments +/// @page only-comments //// /// @name moz-only /// @author Tyler Benton /// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ +/// @markup {scss} [example='false'] **Example:** +/// @include moz-only() { /// // removes the weird styling in firefox /// -moz-appearance: none; /// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; +/// top: nth-val(get($form-config, padding), 1) - .2em; +/// bottom: nth-val(get($form-config, padding), 3) - .2em; /// }; /// text-indent: 0.01px; /// text-overflow: ""; -/// } +/// } /// @name Test one -/// @page tests/all -/// @state .state-1 -/// @state .state-2 -/// @state .state-3 /// @description /// Lorem ipsum dolor sit amet, consectetur adipisicing elit. /// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore /// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis -/// iste nostrum vel, culpa iure. Adipisci. \ No newline at end of file +/// iste nostrum vel, culpa iure. Adipisci. diff --git a/tests/cases/preserves-blank-lines.json b/tests/cases/preserves-blank-lines.json new file mode 100644 index 0000000..6ab468f --- /dev/null +++ b/tests/cases/preserves-blank-lines.json @@ -0,0 +1,57 @@ +{ + "nav": [ + { + "title": "Preserve Blank Lines", + "href": "/preserve-blank-lines", + "body": [ + { + "title": "Preserve blank lines", + "href": "/preserve-blank-lines#preserve-blank-lines" + } + ], + "subpages": [] + } + ], + "pages": { + "preserve-blank-lines": { + "page": { + "header": {}, + "body": [ + { + "name": "Preserve blank lines", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": {}, + "description": "", + "raw": "Button (a.button)\n\n\n\n\n\n\n\n", + "escaped": "<a href="#" class="c-btn @state">Button (a.button)</a>\n\n\n\n<button class="c-btn @state">Button (button)</button>\n\n\n\n<input class="c-btn @state" type="button" value="Button (input.button)">", + "raw_stateless": "Button (a.button)\n\n\n\n\n\n\n\n", + "escaped_stateless": "<a href="#" class="c-btn @state">Button (a.button)</a>\n\n\n\n<button class="c-btn @state">Button (button)</button>\n\n\n\n<input class="c-btn @state" type="button" value="Button (input.button)">" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 12, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/preserves-blank-lines.scss", + "start": 1, + "end": 13 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/lib/edge-cases/preserves-blank-lines.scss b/tests/cases/preserves-blank-lines.scss similarity index 84% rename from tests/lib/edge-cases/preserves-blank-lines.scss rename to tests/cases/preserves-blank-lines.scss index 40f999b..2aaf5b3 100644 --- a/tests/lib/edge-cases/preserves-blank-lines.scss +++ b/tests/cases/preserves-blank-lines.scss @@ -1,4 +1,5 @@ /// @name Preserve blank lines +/// @page preserve-blank-lines /// @markup /// Button (a.button) /// @@ -8,4 +9,4 @@ /// /// /// -/// \ No newline at end of file +/// diff --git a/tests/cases/single-body-comment-no-code.json b/tests/cases/single-body-comment-no-code.json new file mode 100644 index 0000000..022f937 --- /dev/null +++ b/tests/cases/single-body-comment-no-code.json @@ -0,0 +1,46 @@ +{ + "nav": [ + { + "title": "Single Body Comment No Code", + "href": "/single-body-comment-no-code", + "body": [ + { + "title": "Single body comment", + "href": "/single-body-comment-no-code#single-body-comment" + } + ], + "subpages": [] + } + ], + "pages": { + "single-body-comment-no-code": { + "page": { + "header": {}, + "body": [ + { + "name": "Single body comment", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nQuasi omnis facilis vero architecto perferendis, debitis dignissimos tempore\ndolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis\niste nostrum vel, culpa iure. Adipisci.

\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/cases/single-body-comment-no-code.scss", + "start": 1, + "end": 8 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/lib/edge-cases/single-body-comment-no-code.scss b/tests/cases/single-body-comment-no-code.scss similarity index 70% rename from tests/lib/edge-cases/single-body-comment-no-code.scss rename to tests/cases/single-body-comment-no-code.scss index 2d2705f..e2f6635 100644 --- a/tests/lib/edge-cases/single-body-comment-no-code.scss +++ b/tests/cases/single-body-comment-no-code.scss @@ -1,11 +1,7 @@ /// @name Single body comment -/// -/// @state .state-1 -/// @state .state-2 -/// @state .state-3 -/// +/// @page single-body-comment-no-code /// @description /// Lorem ipsum dolor sit amet, consectetur adipisicing elit. /// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore /// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis -/// iste nostrum vel, culpa iure. Adipisci. \ No newline at end of file +/// iste nostrum vel, culpa iure. Adipisci. diff --git a/tests/cases/single-body-comment.json b/tests/cases/single-body-comment.json new file mode 100644 index 0000000..a352ea1 --- /dev/null +++ b/tests/cases/single-body-comment.json @@ -0,0 +1,63 @@ +{ + "nav": [ + { + "title": "Single Body Comment", + "href": "/single-body-comment", + "body": [ + { + "title": "moz-only", + "href": "/single-body-comment#moz-only" + } + ], + "subpages": [] + } + ], + "pages": { + "single-body-comment": { + "page": { + "header": {}, + "body": [ + { + "author": [ + "Tyler Benton" + ], + "name": "moz-only", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": { + "example": "'false'" + }, + "description": "

Example:

\n", + "raw": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "escaped": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "raw_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "escaped_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 15, + "type": "body" + }, + "code": { + "start": 16, + "end": 26 + }, + "file": { + "path": "docs-parser/tests/cases/single-body-comment.scss", + "start": 1, + "end": 27 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/cases/single-body-comment.scss b/tests/cases/single-body-comment.scss new file mode 100644 index 0000000..55d5a96 --- /dev/null +++ b/tests/cases/single-body-comment.scss @@ -0,0 +1,26 @@ +/// @author Tyler Benton +/// @page single-body-comment +/// @name moz-only +/// @description This allows you to write specific styles for mozilla firefox only +/// @markup {scss} [example='false'] **Example:** +/// @include moz-only() { +/// // removes the weird styling in firefox +/// -moz-appearance: none; +/// padding: { +/// top: nth-val(get($form-config, padding), 1) - .2em; +/// bottom: nth-val(get($form-config, padding), 3) - .2em; +/// }; +/// text-indent: 0.01px; +/// text-overflow: ''; +/// } +@mixin moz-only() { + $selector: &; + + @at-root { + @-moz-document url-prefix() { + #{$selector} { + @content; + } + } + } +} diff --git a/tests/cases/space-between-comment-and-code.json b/tests/cases/space-between-comment-and-code.json new file mode 100644 index 0000000..31efc8a --- /dev/null +++ b/tests/cases/space-between-comment-and-code.json @@ -0,0 +1,66 @@ +{ + "nav": [ + { + "title": "Space Between Comment And Code", + "href": "/space-between-comment-and-code", + "body": [ + { + "title": [ + "Space between comment bock and code block", + "moz-only" + ], + "href": "/space-between-comment-and-code#space-between-comment-bock-and-code-block-moz-only" + } + ], + "subpages": [] + } + ], + "pages": { + "space-between-comment-and-code": { + "page": { + "header": {}, + "body": [ + { + "name": [ + "Space between comment bock and code block", + "moz-only" + ], + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": { + "example": "'false'" + }, + "description": "

Example:

\n", + "raw": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "escaped": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "raw_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "escaped_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 15, + "type": "body" + }, + "code": { + "start": 17, + "end": 27 + }, + "file": { + "path": "docs-parser/tests/cases/space-between-comment-and-code.scss", + "start": 1, + "end": 28 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/cases/space-between-comment-and-code.scss b/tests/cases/space-between-comment-and-code.scss new file mode 100644 index 0000000..906be96 --- /dev/null +++ b/tests/cases/space-between-comment-and-code.scss @@ -0,0 +1,27 @@ +/// @name Space between comment bock and code block +/// @page space-between-comment-and-code +/// @name moz-only +/// @description This allows you to write specific styles for mozilla firefox only +/// @markup {scss} [example='false'] **Example:** +/// @include moz-only() { +/// // removes the weird styling in firefox +/// -moz-appearance: none; +/// padding: { +/// top: nth-val(get($form-config, padding), 1) - .2em; +/// bottom: nth-val(get($form-config, padding), 3) - .2em; +/// }; +/// text-indent: 0.01px; +/// text-overflow: ''; +/// } + +@mixin moz-only() { + $selector: &; + + @at-root { + @-moz-document url-prefix() { + #{$selector} { + @content; + } + } + } +} diff --git a/tests/cases/starts-and-ends-with-spaces.json b/tests/cases/starts-and-ends-with-spaces.json new file mode 100644 index 0000000..a70fb7b --- /dev/null +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -0,0 +1,63 @@ +{ + "nav": [ + { + "title": "Starts And Ends With Empty Lines", + "href": "/starts-and-ends-with-empty-lines", + "body": [ + { + "title": "Only block in body", + "href": "/starts-and-ends-with-empty-lines#only-block-in-body" + } + ], + "subpages": [] + } + ], + "pages": { + "starts-and-ends-with-empty-lines": { + "page": { + "header": {}, + "body": [ + { + "name": "Only block in body", + "author": [ + "Tyler Benton" + ], + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": { + "example": "'false'" + }, + "description": "

Example:

\n", + "raw": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}", + "escaped": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: "";\n}", + "raw_stateless": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}", + "escaped_stateless": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: "";\n}" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 22, + "type": "body" + }, + "code": { + "start": 23, + "end": 32 + }, + "file": { + "path": "docs-parser/tests/cases/starts-and-ends-with-spaces.scss", + "start": 1, + "end": 38 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } +} diff --git a/tests/lib/edge-cases/starts-and-ends-with-spaces.scss b/tests/cases/starts-and-ends-with-spaces.scss similarity index 83% rename from tests/lib/edge-cases/starts-and-ends-with-spaces.scss rename to tests/cases/starts-and-ends-with-spaces.scss index d4e2f75..88f57d6 100644 --- a/tests/lib/edge-cases/starts-and-ends-with-spaces.scss +++ b/tests/cases/starts-and-ends-with-spaces.scss @@ -1,15 +1,15 @@ -//// -/// @author Tyler Benton -/// @page edge-cases/starts-and-ends-with-empty-lines -//// + + /// @name Only block in body /// @author Tyler Benton +/// @page starts-and-ends-with-empty-lines +/// @author Tyler Benton /// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** +/// @markup {scss} [example='false'] **Example:** /// @include moz-only(){ /// // removes the weird styling in firefox /// -moz-appearance: none; @@ -33,3 +33,5 @@ + + diff --git a/tests/lib/c++/test.c b/tests/file-types/c++/test.c similarity index 80% rename from tests/lib/c++/test.c rename to tests/file-types/c++/test.c index 36752b8..e913e77 100755 --- a/tests/lib/c++/test.c +++ b/tests/file-types/c++/test.c @@ -3,9 +3,8 @@ /// @page tests/c++-file //// -/// @name main -/// @description -/// main method +/// @name one +/// @description Lorem ipsum dolor sit amet, consectetur adipisicing elit. #include int main(){ char name[50]; @@ -33,13 +32,16 @@ int main(){ // This is a normal single-line comment, and shouldn't start a new block -/// @name Something +/// @name Two /// @description -/// This is a normal multi-line comment. +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque non fugit, +/// aspernatur! Quos consequatur libero, fugiat tempora maxime maiores quia +/// aspernatur praesentium voluptatum incidunt! Tempora rem aperiam +/// consectetur aut, fugiat. #include struct s{ - char name[50]; - int height; + char name[50]; + int height; }; int main(){ struct s a[5],b[5]; @@ -63,7 +65,7 @@ int main(){ fclose(fptr); } -/// @name Something else +/// @name Three /// @description /// This is another normal multi-line comment. #include @@ -87,4 +89,4 @@ int main(){ } fclose(fptr); return 0; -} \ No newline at end of file +} diff --git a/tests/file-types/c++/test.json b/tests/file-types/c++/test.json new file mode 100644 index 0000000..70f3265 --- /dev/null +++ b/tests/file-types/c++/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "C File", + "href": "/tests/c++-file", + "body": [ + { + "title": "one", + "href": "/tests/c++-file#one" + }, + { + "title": "Two", + "href": "/tests/c++-file#two" + }, + { + "title": "Three", + "href": "/tests/c++-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "c++-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + }, + "access": "public" + }, + "body": [ + { + "name": "one", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 32 + }, + "file": { + "path": "docs-parser/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque non fugit,\naspernatur! Quos consequatur libero, fugiat tempora maxime maiores quia\naspernatur praesentium voluptatum incidunt! Tempora rem aperiam\nconsectetur aut, fugiat.

\n", + "blockinfo": { + "comment": { + "start": 35, + "end": 40, + "type": "body" + }, + "code": { + "start": 41, + "end": 66 + }, + "file": { + "path": "docs-parser/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 68, + "end": 70, + "type": "body" + }, + "code": { + "start": 71, + "end": 92 + }, + "file": { + "path": "docs-parser/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/c/test.c b/tests/file-types/c/test.c similarity index 96% rename from tests/lib/c/test.c rename to tests/file-types/c/test.c index 14eb622..58a8fe3 100755 --- a/tests/lib/c/test.c +++ b/tests/file-types/c/test.c @@ -3,7 +3,7 @@ /// @page tests/c-file //// -/// @name main +/// @name One /// @description /// main method #include @@ -31,7 +31,7 @@ int main(){ // This is a normal single-line comment, and shouldn't start a new block -/// @name Something +/// @name Two /// @description /// This is a normal multi-line comment. #include @@ -61,7 +61,7 @@ int main(){ fclose(fptr); } -/// @name Something else +/// @name Three /// @description /// This is another normal multi-line comment. #include @@ -85,4 +85,4 @@ int main(){ } fclose(fptr); return 0; -} \ No newline at end of file +} diff --git a/tests/file-types/c/test.json b/tests/file-types/c/test.json new file mode 100644 index 0000000..626fb1c --- /dev/null +++ b/tests/file-types/c/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "C File", + "href": "/tests/c-file", + "body": [ + { + "title": "One", + "href": "/tests/c-file#one" + }, + { + "title": "Two", + "href": "/tests/c-file#two" + }, + { + "title": "Three", + "href": "/tests/c-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "c-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/c/test.c", + "start": 1, + "end": 89 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 32 + }, + "file": { + "path": "docs-parser/tests/file-types/c/test.c", + "start": 1, + "end": 89 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 34, + "end": 36, + "type": "body" + }, + "code": { + "start": 37, + "end": 62 + }, + "file": { + "path": "docs-parser/tests/file-types/c/test.c", + "start": 1, + "end": 89 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 64, + "end": 66, + "type": "body" + }, + "code": { + "start": 67, + "end": 88 + }, + "file": { + "path": "docs-parser/tests/file-types/c/test.c", + "start": 1, + "end": 89 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/coffeescript/test.coffee b/tests/file-types/coffeescript/test.coffee similarity index 84% rename from tests/lib/coffeescript/test.coffee rename to tests/file-types/coffeescript/test.coffee index a2a24e1..fd31154 100755 --- a/tests/lib/coffeescript/test.coffee +++ b/tests/file-types/coffeescript/test.coffee @@ -4,7 +4,7 @@ ### -## @name main +## @name One ## @description ## main method outer = 1 @@ -14,7 +14,7 @@ changeNumbers = -> inner = changeNumbers() -## @name Something +## @name Two ## @description ## This is a normal multi-line comment. mood = greatlyImproved if singing @@ -28,7 +28,7 @@ else date = if friday then sue else jill -## @name Something else +## @name Three ## @description ## This is another normla multi-line comment. yearsOld = max: 10, ida: 9, tim: 11 @@ -36,4 +36,4 @@ yearsOld = max: 10, ida: 9, tim: 11 ages = for child, age of yearsOld "#{child} is #{age}" - # This a normal single-line comment. \ No newline at end of file +# This a normal single-line comment. diff --git a/tests/file-types/coffeescript/test.json b/tests/file-types/coffeescript/test.json new file mode 100644 index 0000000..0d046ea --- /dev/null +++ b/tests/file-types/coffeescript/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Coffee File", + "href": "/tests/coffee-file", + "body": [ + { + "title": "One", + "href": "/tests/coffee-file#one" + }, + { + "title": "Two", + "href": "/tests/coffee-file#two" + }, + { + "title": "Three", + "href": "/tests/coffee-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "coffee-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", + "start": 1, + "end": 40 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 7, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 14 + }, + "file": { + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", + "start": 1, + "end": 40 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 17, + "end": 19, + "type": "body" + }, + "code": { + "start": 20, + "end": 28 + }, + "file": { + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", + "start": 1, + "end": 40 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normla multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 31, + "end": 33, + "type": "body" + }, + "code": { + "start": 34, + "end": 39 + }, + "file": { + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", + "start": 1, + "end": 40 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/coldfusion/test.cfm b/tests/file-types/coldfusion/test.cfm similarity index 75% rename from tests/lib/coldfusion/test.cfm rename to tests/file-types/coldfusion/test.cfm index 8f91da4..836e998 100755 --- a/tests/lib/coldfusion/test.cfm +++ b/tests/file-types/coldfusion/test.cfm @@ -1,13 +1,13 @@ +-----> +----> @@ -16,10 +16,10 @@ main method +----> SELECT A.PRICE FROM ART A @@ -32,29 +32,29 @@ This is a normal multi-line coldfusion comment. +----> component extends="Fruit" output="false" { - property name="variety" type="string"; - public boolean function isGood() { - return true; - } - private void eat(required numeric bites) { - //do stuff - } + property name="variety" type="string"; + public boolean function isGood() { + return true; + } + private void eat(required numeric bites) { + //do stuff + } } +----> -list: #priceList#
-sum: #numberFormat(arraySum(priceArr))#
-avg: #numberFormat(arrayAvg(priceArr))#
+ list: #priceList#
+ sum: #numberFormat(arraySum(priceArr))#
+ avg: #numberFormat(arrayAvg(priceArr))#
diff --git a/tests/file-types/coldfusion/test.json b/tests/file-types/coldfusion/test.json new file mode 100644 index 0000000..73afd30 --- /dev/null +++ b/tests/file-types/coldfusion/test.json @@ -0,0 +1,158 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Cfm File", + "href": "/tests/cfm-file", + "body": [ + { + "title": "One", + "href": "/tests/cfm-file#one" + }, + { + "title": "Two", + "href": "/tests/cfm-file#two" + }, + { + "title": "Three", + "href": "/tests/cfm-file#three" + }, + { + "title": "Four", + "href": "/tests/cfm-file#four" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "cfm-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 16 + }, + "file": { + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line coldfusion comment.

\n", + "blockinfo": { + "comment": { + "start": 18, + "end": 22, + "type": "body" + }, + "code": { + "start": 23, + "end": 33 + }, + "file": { + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another multi-line normal Coldfusion\nScript comment made of single-line comments.

\n", + "blockinfo": { + "comment": { + "start": 34, + "end": 39, + "type": "body" + }, + "code": { + "start": 40, + "end": 49 + }, + "file": { + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Four", + "description": "

This is another normal multi-line coldfusion comment.

\n", + "blockinfo": { + "comment": { + "start": 51, + "end": 55, + "type": "body" + }, + "code": { + "start": 56, + "end": 60 + }, + "file": { + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/cs/test.cs b/tests/file-types/cs/test.cs new file mode 100644 index 0000000..a3ce180 --- /dev/null +++ b/tests/file-types/cs/test.cs @@ -0,0 +1,94 @@ +//// +/// @author Tyler Benton +/// @page tests/cs-file +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Eaque temporibus praesentium iure, qui dolorem blanditiis +/// error a reprehenderit voluptates debitis iusto, quibusdam. +//// + +/// @name One +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Eaque temporibus praesentium iure, qui dolorem blanditiis +/// error a reprehenderit voluptates debitis iusto, quibusdam. +#include +int main(){ + char name[50]; + int marks,i,n; + printf("Enter number of students: "); + scanf("%d",&n); + FILE *fptr; + fptr=(fopen("C:\\student.txt","w")); + if(fptr==NULL){ + printf("Error!"); + exit(1); + } + for(i=0;i +struct s{ + char name[50]; + int height; +}; +int main(){ + struct s a[5],b[5]; + FILE *fptr; + int i; + fptr=fopen("file.txt","wb"); + for(i=0;i<5;++i){ + fflush(stdin); + printf("Enter name: "); + gets(a[i].name); + printf("Enter height: "); + scanf("%d",&a[i].height); + } + fwrite(a,sizeof(a),1,fptr); + fclose(fptr); + fptr=fopen("file.txt","rb"); + fread(b,sizeof(b),1,fptr); + for(i=0;i<5;++i){ + printf("Name: %s\nHeight: %d",b[i].name,b[i].height); + } + fclose(fptr); +} + +/// @name Three +/// @description +/// This is another normal multi-line comment. +#include +int main(){ + char name[50]; + int marks,i,n; + printf("Enter number of students: "); + scanf("%d",&n); + FILE *fptr; + fptr=(fopen("C:\\student.txt","a")); + if(fptr==NULL){ + printf("Error!"); + exit(1); + } + for(i=0;iLorem ipsum dolor sit amet, consectetur adipisicing elit.\nEaque temporibus praesentium iure, qui dolorem blanditiis\nerror a reprehenderit voluptates debitis iusto, quibusdam.

\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 8, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/cs/test.cs", + "start": 1, + "end": 95 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nEaque temporibus praesentium iure, qui dolorem blanditiis\nerror a reprehenderit voluptates debitis iusto, quibusdam.

\n", + "blockinfo": { + "comment": { + "start": 10, + "end": 14, + "type": "body" + }, + "code": { + "start": 15, + "end": 38 + }, + "file": { + "path": "docs-parser/tests/file-types/cs/test.cs", + "start": 1, + "end": 95 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 40, + "end": 42, + "type": "body" + }, + "code": { + "start": 43, + "end": 68 + }, + "file": { + "path": "docs-parser/tests/file-types/cs/test.cs", + "start": 1, + "end": 95 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 70, + "end": 72, + "type": "body" + }, + "code": { + "start": 73, + "end": 94 + }, + "file": { + "path": "docs-parser/tests/file-types/cs/test.cs", + "start": 1, + "end": 95 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/css/test.css b/tests/file-types/css/test.css similarity index 100% rename from tests/lib/css/test.css rename to tests/file-types/css/test.css diff --git a/tests/file-types/css/test.json b/tests/file-types/css/test.json new file mode 100644 index 0000000..35c0b70 --- /dev/null +++ b/tests/file-types/css/test.json @@ -0,0 +1,106 @@ +{ + "nav": [ + { + "title": "Test", + "href": "/test", + "body": [], + "subpages": [ + { + "title": "Css File", + "href": "/test/css-file", + "body": [ + { + "title": "Base Styles", + "href": "/test/css-file#base-styles" + }, + { + "title": "Input", + "href": "/test/css-file#input" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "test": { + "page": { + "header": {}, + "body": [] + }, + "css-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/css/test.css", + "start": 1, + "end": 31 + } + }, + "access": "public" + }, + "body": [ + { + "name": "Base Styles", + "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 12, + "type": "body" + }, + "code": { + "start": 13, + "end": 17 + }, + "file": { + "path": "docs-parser/tests/file-types/css/test.css", + "start": 1, + "end": 31 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Input", + "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n", + "blockinfo": { + "comment": { + "start": 20, + "end": 26, + "type": "body" + }, + "code": { + "start": 27, + "end": 31 + }, + "file": { + "path": "docs-parser/tests/file-types/css/test.css", + "start": 1, + "end": 31 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/html/test.html b/tests/file-types/html/test.html new file mode 100755 index 0000000..6a9ddce --- /dev/null +++ b/tests/file-types/html/test.html @@ -0,0 +1,35 @@ + + + + Document + + + + + +
+ Home + My Account +
+ +
+ +
+ +
+ +
+ + diff --git a/tests/file-types/html/test.json b/tests/file-types/html/test.json new file mode 100644 index 0000000..47eb205 --- /dev/null +++ b/tests/file-types/html/test.json @@ -0,0 +1,107 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Header", + "href": "/tests/html-file", + "body": [ + { + "title": "Body Block 1", + "href": "/tests/html-file#body-block-1" + }, + { + "title": "Body Block 2", + "href": "/tests/html-file#body-block-2" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "html-file": { + "page": { + "header": { + "name": "Header", + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 11, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/html/test.html", + "start": 1, + "end": 36 + } + }, + "access": "public" + }, + "body": [ + { + "name": "Body Block 1", + "description": "

This is the main header of the site

\n", + "blockinfo": { + "comment": { + "start": 13, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 25 + }, + "file": { + "path": "docs-parser/tests/file-types/html/test.html", + "start": 1, + "end": 36 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Body Block 2", + "description": "

This is the main footer of the site

\n", + "blockinfo": { + "comment": { + "start": 26, + "end": 30, + "type": "body" + }, + "code": { + "start": 31, + "end": 33 + }, + "file": { + "path": "docs-parser/tests/file-types/html/test.html", + "start": 1, + "end": 36 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/jade/test.jade b/tests/file-types/jade/test.jade new file mode 100644 index 0000000..a48599f --- /dev/null +++ b/tests/file-types/jade/test.jade @@ -0,0 +1,15 @@ +//-// +//-/ @author Tyler Benton +//-/ @page tests/jade +//-// + + +//-/ @name One +//-/ @description +//-/ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem cum magni +//-/ laboriosam voluptate accusantium pariatur enim aspernatur quis laborum quam, +//-/ odit doloribus repellat maiores alias soluta deleniti, at dicta iure. +nav + ul + each val in [1, 2, 3, 4, 5] + li= val diff --git a/tests/file-types/jade/test.json b/tests/file-types/jade/test.json new file mode 100644 index 0000000..b49636d --- /dev/null +++ b/tests/file-types/jade/test.json @@ -0,0 +1,80 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Jade", + "href": "/tests/jade", + "body": [ + { + "title": "One", + "href": "/tests/jade#one" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "jade": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/jade/test.jade", + "start": 1, + "end": 16 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem cum magni\nlaboriosam voluptate accusantium pariatur enim aspernatur quis laborum quam,\nodit doloribus repellat maiores alias soluta deleniti, at dicta iure.

\n", + "blockinfo": { + "comment": { + "start": 7, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 15 + }, + "file": { + "path": "docs-parser/tests/file-types/jade/test.jade", + "start": 1, + "end": 16 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/java/test.java b/tests/file-types/java/test.java similarity index 90% rename from tests/lib/java/test.java rename to tests/file-types/java/test.java index 7d9cb71..d13d9d0 100755 --- a/tests/lib/java/test.java +++ b/tests/file-types/java/test.java @@ -3,7 +3,7 @@ /// @page tests/java-file //// -/// @name Body Block 1 +/// @name One /// @description /// A very simple class to print out `Hello World` class HelloWorldApp { @@ -14,7 +14,7 @@ public static void main(String[] args) { // This is a normal single-line comment, and shouldn't start a new block -/// @name Body Block 2 +/// @name Two /// @description /// This is a normal multi-line comment. class saySomething { @@ -23,7 +23,7 @@ public static void main(String[] args) { } } -/// @name Body Block 3 +/// @name Three /// @description /// This is another normal multi-line comment. class saySomethingElse { diff --git a/tests/file-types/java/test.json b/tests/file-types/java/test.json new file mode 100644 index 0000000..7e82ef2 --- /dev/null +++ b/tests/file-types/java/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Java File", + "href": "/tests/java-file", + "body": [ + { + "title": "One", + "href": "/tests/java-file#one" + }, + { + "title": "Two", + "href": "/tests/java-file#two" + }, + { + "title": "Three", + "href": "/tests/java-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "java-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/java/test.java", + "start": 1, + "end": 34 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

A very simple class to print out Hello World

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 15 + }, + "file": { + "path": "docs-parser/tests/file-types/java/test.java", + "start": 1, + "end": 34 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 17, + "end": 19, + "type": "body" + }, + "code": { + "start": 20, + "end": 24 + }, + "file": { + "path": "docs-parser/tests/file-types/java/test.java", + "start": 1, + "end": 34 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 26, + "end": 28, + "type": "body" + }, + "code": { + "start": 29, + "end": 33 + }, + "file": { + "path": "docs-parser/tests/file-types/java/test.java", + "start": 1, + "end": 34 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/js/test.js b/tests/file-types/js/test.js new file mode 100644 index 0000000..072804a --- /dev/null +++ b/tests/file-types/js/test.js @@ -0,0 +1,27 @@ +//// +/// @author Tyler Benton +/// @page tests/js +//// + +let annotations = {} + +/// @name @author +/// @alias @authors +/// @description Author of the documented item +/// @returns {string} +/// @markup Usage +/// /// @author Author's name +/// +/// /// @author Author One, Author Two +/// +/// /// @author Author One +/// /// @author Author Two +annotations.author = { + alias: [ 'authors' ], + parse() { + return multiple(this.annotation) + } +} + + +export default annotations diff --git a/tests/file-types/js/test.json b/tests/file-types/js/test.json new file mode 100644 index 0000000..66c024a --- /dev/null +++ b/tests/file-types/js/test.json @@ -0,0 +1,101 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Js", + "href": "/tests/js", + "body": [ + { + "title": "@author", + "href": "/tests/js#author" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "js": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/js/test.js", + "start": 1, + "end": 28 + } + }, + "access": "public" + }, + "body": [ + { + "name": "@author", + "alias": [ + "@authors" + ], + "description": "

Author of the documented item

\n", + "returns": { + "types": [ + "string" + ], + "description": "" + }, + "markup": [ + { + "id": "0", + "language": "js", + "settings": {}, + "description": "

Usage

\n", + "raw": "/// @author Author's name\n\n/// @author Author One, Author Two\n\n/// @author Author One\n/// @author Author Two", + "escaped": "/// @author Author's name\n\n/// @author Author One, Author Two\n\n/// @author Author One\n/// @author Author Two", + "raw_stateless": "/// @author Author's name\n\n/// @author Author One, Author Two\n\n/// @author Author One\n/// @author Author Two", + "escaped_stateless": "/// @author Author's name\n\n/// @author Author One, Author Two\n\n/// @author Author One\n/// @author Author Two" + } + ], + "blockinfo": { + "comment": { + "start": 8, + "end": 18, + "type": "body" + }, + "code": { + "start": 19, + "end": 27 + }, + "file": { + "path": "docs-parser/tests/file-types/js/test.js", + "start": 1, + "end": 28 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json new file mode 100644 index 0000000..a21bad8 --- /dev/null +++ b/tests/file-types/less/test.json @@ -0,0 +1,181 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Less Test", + "href": "/tests/less-test", + "body": [ + { + "title": "One", + "href": "/tests/less-test#one" + }, + { + "title": "Two", + "href": "/tests/less-test#two" + }, + { + "title": "Three", + "href": "/tests/less-test#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "less-test": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "type": { + "type": "color", + "description": "" + }, + "markup": [ + { + "id": "0", + "language": "less", + "settings": {}, + "description": "", + "raw": "\\@name", + "escaped": "\\@name", + "raw_stateless": "\\@name", + "escaped_stateless": "\\@name" + } + ], + "blockinfo": { + "comment": { + "start": 6, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 14 + }, + "file": { + "path": "docs-parser/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

A simple nav component, used to help with navigation

\n", + "markup": [ + { + "id": "0", + "language": "less", + "settings": {}, + "description": "", + "raw": "", + "escaped": "<nav>\n <a href="">One</a>\n <a href="">Two</a>\n <a href="">Three</a>\n</nav>", + "raw_stateless": "", + "escaped_stateless": "<nav>\n <a href="">One</a>\n <a href="">Two</a>\n <a href="">Three</a>\n</nav>" + } + ], + "blockinfo": { + "comment": { + "start": 16, + "end": 24, + "type": "body" + }, + "code": { + "start": 25, + "end": 41 + }, + "file": { + "path": "docs-parser/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

A mixin to help with opacity fallbacks

\n", + "arg": [ + { + "types": [ + "number" + ], + "name": "-", + "value": "", + "description": "

The opacity you to use, between 0.0 - 1.0

\n" + } + ], + "markup": [ + { + "id": "0", + "language": "less", + "settings": {}, + "description": "", + "raw": ".foo {\n .opacity(.3);\n}", + "escaped": ".foo {\n .opacity(.3);\n}", + "raw_stateless": ".foo {\n .opacity(.3);\n}", + "escaped_stateless": ".foo {\n .opacity(.3);\n}" + } + ], + "blockinfo": { + "comment": { + "start": 43, + "end": 50, + "type": "body" + }, + "code": { + "start": 51, + "end": 58 + }, + "file": { + "path": "docs-parser/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/less/test.less b/tests/file-types/less/test.less new file mode 100755 index 0000000..cfb5f8b --- /dev/null +++ b/tests/file-types/less/test.less @@ -0,0 +1,58 @@ +//// +/// @author Tyler Benton +/// @page tests/less-test +//// + +/// @name One +/// @type {color} +/// @markup +/// \@name +@name: #2d5e8b; + +main { + background-color: @name; +} + +/// @name Two +/// @description +/// A simple nav component, used to help with navigation +/// @markup +/// +.nav { + height: 40px; + width: 100%; + background: #455868; + border-bottom: 2px solid #283744; + + li { + width: 600px; + height: 40px; + + a { + color: #fff; + line-height: 40px; + text-shadow: 1px 1px 0px #283744; + } + } +} + +/// @name Three +/// @description +/// A mixin to help with opacity fallbacks +/// @arg {number} - The opacity you to use, between 0.0 - 1.0 +/// @markup {less} +/// .foo { +/// .opacity(.3); +/// } +.opacity(@opacity: 0.5){ + -webkit-opacity: @opacity; + -moz-opacity: @opacity; + opacity: @opacity; + @opperc: @opacity * 100; + -ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=@{opperc})"; + filter: ~"alpha(opacity=@{opperc})"; +} diff --git a/tests/file-types/markdown/mark.json b/tests/file-types/markdown/mark.json new file mode 100644 index 0000000..7889911 --- /dev/null +++ b/tests/file-types/markdown/mark.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mark", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mark", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mark.mark", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mark.mark b/tests/file-types/markdown/mark.mark new file mode 100644 index 0000000..468a00c --- /dev/null +++ b/tests/file-types/markdown/mark.mark @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/markdown.json b/tests/file-types/markdown/markdown.json new file mode 100644 index 0000000..f1d2f61 --- /dev/null +++ b/tests/file-types/markdown/markdown.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "markdown", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "markdown", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/markdown.markdown", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/markdown.markdown b/tests/file-types/markdown/markdown.markdown new file mode 100644 index 0000000..91d56d1 --- /dev/null +++ b/tests/file-types/markdown/markdown.markdown @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/md.json b/tests/file-types/markdown/md.json new file mode 100644 index 0000000..9375d1c --- /dev/null +++ b/tests/file-types/markdown/md.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "md", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "md", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/md.md", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/md.md b/tests/file-types/markdown/md.md new file mode 100644 index 0000000..0897e86 --- /dev/null +++ b/tests/file-types/markdown/md.md @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mdml.json b/tests/file-types/markdown/mdml.json new file mode 100644 index 0000000..16ac3c3 --- /dev/null +++ b/tests/file-types/markdown/mdml.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdml", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdml", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mdml.mdml", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mdml.mdml b/tests/file-types/markdown/mdml.mdml new file mode 100644 index 0000000..8cd8fe2 --- /dev/null +++ b/tests/file-types/markdown/mdml.mdml @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mdown.json b/tests/file-types/markdown/mdown.json new file mode 100644 index 0000000..eeeb1cc --- /dev/null +++ b/tests/file-types/markdown/mdown.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdown", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdown", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mdown.mdown", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mdown.mdown b/tests/file-types/markdown/mdown.mdown new file mode 100644 index 0000000..ec3e395 --- /dev/null +++ b/tests/file-types/markdown/mdown.mdown @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mdtext.json b/tests/file-types/markdown/mdtext.json new file mode 100644 index 0000000..ad7c10b --- /dev/null +++ b/tests/file-types/markdown/mdtext.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdtext", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdtext", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mdtext.mdtext", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mdtext.mdtext b/tests/file-types/markdown/mdtext.mdtext new file mode 100644 index 0000000..290b46f --- /dev/null +++ b/tests/file-types/markdown/mdtext.mdtext @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mdtxt.json b/tests/file-types/markdown/mdtxt.json new file mode 100644 index 0000000..54a907a --- /dev/null +++ b/tests/file-types/markdown/mdtxt.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdtxt", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdtxt", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mdtxt.mdtxt b/tests/file-types/markdown/mdtxt.mdtxt new file mode 100644 index 0000000..e9e4e0c --- /dev/null +++ b/tests/file-types/markdown/mdtxt.mdtxt @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mdwn.json b/tests/file-types/markdown/mdwn.json new file mode 100644 index 0000000..f5f13ec --- /dev/null +++ b/tests/file-types/markdown/mdwn.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdwn", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdwn", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mdwn.mdwn", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mdwn.mdwn b/tests/file-types/markdown/mdwn.mdwn new file mode 100644 index 0000000..20eafea --- /dev/null +++ b/tests/file-types/markdown/mdwn.mdwn @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mkd.json b/tests/file-types/markdown/mkd.json new file mode 100644 index 0000000..0db0d76 --- /dev/null +++ b/tests/file-types/markdown/mkd.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mkd", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mkd", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mkd.mkd b/tests/file-types/markdown/mkd.mkd new file mode 100644 index 0000000..c579968 --- /dev/null +++ b/tests/file-types/markdown/mkd.mkd @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/mkdn.json b/tests/file-types/markdown/mkdn.json new file mode 100644 index 0000000..d595fda --- /dev/null +++ b/tests/file-types/markdown/mkdn.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mkdn", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mkdn", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/mkdn.mkdn", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/mkdn.mkdn b/tests/file-types/markdown/mkdn.mkdn new file mode 100644 index 0000000..227b802 --- /dev/null +++ b/tests/file-types/markdown/mkdn.mkdn @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/markdown/text.json b/tests/file-types/markdown/text.json new file mode 100644 index 0000000..bf620d2 --- /dev/null +++ b/tests/file-types/markdown/text.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "text", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "text", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/markdown/text.text", + "start": 1, + "end": 21 + } + }, + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/markdown/text.text b/tests/file-types/markdown/text.text new file mode 100644 index 0000000..b8fa2fe --- /dev/null +++ b/tests/file-types/markdown/text.text @@ -0,0 +1,20 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` diff --git a/tests/file-types/php/test.json b/tests/file-types/php/test.json new file mode 100644 index 0000000..c33ed03 --- /dev/null +++ b/tests/file-types/php/test.json @@ -0,0 +1,133 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "PHP", + "href": "/tests/php-file", + "body": [ + { + "title": "One", + "href": "/tests/php-file#one" + }, + { + "title": "Two", + "href": "/tests/php-file#two" + }, + { + "title": "Three", + "href": "/tests/php-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "php-file": { + "page": { + "header": { + "name": "PHP", + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 2, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/php/test.php", + "start": 1, + "end": 37 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 9, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 12 + }, + "file": { + "path": "docs-parser/tests/file-types/php/test.php", + "start": 1, + "end": 37 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 14, + "end": 16, + "type": "body" + }, + "code": { + "start": 17, + "end": 25 + }, + "file": { + "path": "docs-parser/tests/file-types/php/test.php", + "start": 1, + "end": 37 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 27, + "end": 29, + "type": "body" + }, + "code": { + "start": 30, + "end": 35 + }, + "file": { + "path": "docs-parser/tests/file-types/php/test.php", + "start": 1, + "end": 37 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/php/test.php b/tests/file-types/php/test.php new file mode 100755 index 0000000..1cbfd5d --- /dev/null +++ b/tests/file-types/php/test.php @@ -0,0 +1,36 @@ +"; + echo "My house is " . $COLOR . "
"; + echo "My boat is " . $coLOR . "
"; + + // This is a normal single-line comment. +?> diff --git a/tests/file-types/python/test.json b/tests/file-types/python/test.json new file mode 100644 index 0000000..50b472f --- /dev/null +++ b/tests/file-types/python/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Py File", + "href": "/tests/py-file", + "body": [ + { + "title": "main", + "href": "/tests/py-file#main" + }, + { + "title": "something", + "href": "/tests/py-file#something" + }, + { + "title": "something else", + "href": "/tests/py-file#something-else" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "py-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/python/test.py", + "start": 1, + "end": 43 + } + }, + "access": "public" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 21 + }, + "file": { + "path": "docs-parser/tests/file-types/python/test.py", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "something", + "description": "

This is a normal multi-line comment made of single line comments.

\n", + "blockinfo": { + "comment": { + "start": 23, + "end": 25, + "type": "body" + }, + "code": { + "start": 27, + "end": 29 + }, + "file": { + "path": "docs-parser/tests/file-types/python/test.py", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "something else", + "description": "

This is another normal multi-line comment made of single line comments.

\n", + "blockinfo": { + "comment": { + "start": 32, + "end": 34, + "type": "body" + }, + "code": { + "start": 36, + "end": 43 + }, + "file": { + "path": "docs-parser/tests/file-types/python/test.py", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/python/test.py b/tests/file-types/python/test.py similarity index 100% rename from tests/lib/python/test.py rename to tests/file-types/python/test.py diff --git a/tests/file-types/ruby/test.json b/tests/file-types/ruby/test.json new file mode 100644 index 0000000..87e4681 --- /dev/null +++ b/tests/file-types/ruby/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Rb File", + "href": "/tests/rb-file", + "body": [ + { + "title": "One", + "href": "/tests/rb-file#one" + }, + { + "title": "Two", + "href": "/tests/rb-file#two" + }, + { + "title": "Three", + "href": "/tests/rb-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "rb-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 12 + }, + "file": { + "path": "docs-parser/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

This is a normal multi-line comment made of single line comments.

\n", + "blockinfo": { + "comment": { + "start": 15, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 21 + }, + "file": { + "path": "docs-parser/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur\nmollitia voluptas obcaecati numquam voluptatibus ex, enim vero, nemo\ncupiditate architecto dolore ipsum dolores, amet at porro quis. Quis,\nvoluptas consequuntur.

\n", + "blockinfo": { + "comment": { + "start": 24, + "end": 29, + "type": "body" + }, + "code": { + "start": 30, + "end": 34 + }, + "file": { + "path": "docs-parser/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/ruby/test.rb b/tests/file-types/ruby/test.rb new file mode 100755 index 0000000..d5387f7 --- /dev/null +++ b/tests/file-types/ruby/test.rb @@ -0,0 +1,42 @@ +### +## @author Tyler Benton +## @page tests/rb-file +### + +## @name One +## @description +## main method +for i in (1..4) + print i," " +end +print "\n" + + +## @name Two +## @description +## This is a normal multi-line comment made of single line comments. +for i in (1...4) + print i," " +end +print "\n" + + +## @name Three +## @description +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur +## mollitia voluptas obcaecati numquam voluptatibus ex, enim vero, nemo +## cupiditate architecto dolore ipsum dolores, amet at porro quis. Quis, +## voluptas consequuntur. +items = [ 'Mark', 12, 'goobers', 18.45 ] +for it in items + print it, " " +end +print "\n" + + + + +# This shouldn't be parsed +for i in (0...items.length) + print items[0..i].join(" "), "\n" +end diff --git a/tests/file-types/scss/inline.json b/tests/file-types/scss/inline.json new file mode 100644 index 0000000..a90c3e7 --- /dev/null +++ b/tests/file-types/scss/inline.json @@ -0,0 +1,172 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Scss File", + "href": "/tests/scss-file", + "body": [ + { + "title": "$colors", + "href": "/tests/scss-file#colors" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "scss-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + }, + "access": "public" + }, + "body": [ + { + "name": "$colors", + "type": { + "type": "map", + "description": "" + }, + "description": "

what up\nshoot

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 15 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + }, + "access": "public", + "inline": [ + { + "property": [ + { + "types": [ + "color" + ], + "name": "a", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 12, + "end": 12, + "type": "inline" + }, + "code": { + "start": 12, + "end": 12 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + }, + "access": "public" + }, + { + "property": [ + { + "types": [ + "color" + ], + "name": "b", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 13, + "end": 13, + "type": "inline" + }, + "code": { + "start": 13, + "end": 13 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + }, + "access": "public" + }, + { + "property": [ + { + "types": [ + "color" + ], + "name": "c", + "value": "", + "description": "

description

\n" + } + ], + "blockinfo": { + "comment": { + "start": 14, + "end": 14, + "type": "inline" + }, + "code": { + "start": 14, + "end": 14 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + }, + "access": "public" + } + ] + } + ] + } + } + } + } +} diff --git a/tests/file-types/scss/inline.scss b/tests/file-types/scss/inline.scss new file mode 100644 index 0000000..f12d392 --- /dev/null +++ b/tests/file-types/scss/inline.scss @@ -0,0 +1,15 @@ +//// +/// @author Tyler Benton +/// @page tests/scss-file +//// + +/// @name $colors +/// @type {map} +/// +/// @description what up +/// shoot +$colors: ( + 'a': #fff, ///# @property {color} a - description + 'b': #ccc, ///# @property {color} b - description + 'c': #000, ///# @property {color} c - description +); \ No newline at end of file diff --git a/tests/file-types/scss/test.json b/tests/file-types/scss/test.json new file mode 100644 index 0000000..57be791 --- /dev/null +++ b/tests/file-types/scss/test.json @@ -0,0 +1,145 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Scss File", + "href": "/tests/scss-file", + "body": [ + { + "title": "One", + "href": "/tests/scss-file#one" + }, + { + "title": "moz-only", + "href": "/tests/scss-file#moz-only" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "scss-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/test.scss", + "start": 1, + "end": 39 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "type": { + "type": "color", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 6, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/test.scss", + "start": 1, + "end": 39 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "moz-only", + "author": [ + "Tyler Benton" + ], + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "arg": [ + { + "types": [ + "function", + "object" + ], + "name": "callbacks", + "value": "something super sweet", + "description": "

Functions

\n" + }, + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "default value", + "description": "

description\n@content

\n" + } + ], + "markup": [ + { + "id": "0", + "language": "scss", + "settings": { + "example": "false" + }, + "description": "

Example:

\n", + "raw": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "escaped": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "raw_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}", + "escaped_stateless": "@include moz-only() {\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: '';\n}" + } + ], + "blockinfo": { + "comment": { + "start": 12, + "end": 28, + "type": "body" + }, + "code": { + "start": 29, + "end": 38 + }, + "file": { + "path": "docs-parser/tests/file-types/scss/test.scss", + "start": 1, + "end": 39 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/file-types/scss/test.scss b/tests/file-types/scss/test.scss new file mode 100755 index 0000000..d517563 --- /dev/null +++ b/tests/file-types/scss/test.scss @@ -0,0 +1,38 @@ +//// +/// @author Tyler Benton +/// @page tests/scss-file +//// + +/// @name One +/// @type {color} +$color: #2d5e8b; + + + +/// @name moz-only +/// @author Tyler Benton +/// @description This allows you to write specific styles for mozilla firefox only +/// @arg {function, object} callbacks [something super sweet] - Functions +/// @arg {type} name-of-variable [default value] - description +/// @content +/// @markup {scss} [example=false] **Example:** +/// @include moz-only() { +/// // removes the weird styling in firefox +/// -moz-appearance: none; +/// padding: { +/// top: nth-val(get($form-config, padding), 1) - .2em; +/// bottom: nth-val(get($form-config, padding), 3) - .2em; +/// }; +/// text-indent: 0.01px; +/// text-overflow: ''; +/// } +@mixin moz-only() { + $selector: &; + @at-root { + @-moz-document url-prefix() { + #{$selector}{ + @content; + } + } + } +} diff --git a/tests/file-types/stylus/test.json b/tests/file-types/stylus/test.json new file mode 100644 index 0000000..951f97f --- /dev/null +++ b/tests/file-types/stylus/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Styl File", + "href": "/tests/styl-file", + "body": [ + { + "title": "One", + "href": "/tests/styl-file#one" + }, + { + "title": "Two", + "href": "/tests/styl-file#two" + }, + { + "title": "Three", + "href": "/tests/styl-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "styl-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + }, + "access": "public" + }, + "body": [ + { + "name": "One", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco.

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 14 + }, + "file": { + "path": "docs-parser/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Two", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nQuasi omnis facilis vero architecto perferendis, debitis dignissimos tempore\ndolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis\niste nostrum vel, culpa iure. Adipisci.

\n", + "blockinfo": { + "comment": { + "start": 16, + "end": 21, + "type": "body" + }, + "code": { + "start": 22, + "end": 25 + }, + "file": { + "path": "docs-parser/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 27, + "end": 29, + "type": "body" + }, + "code": { + "start": 30, + "end": 34 + }, + "file": { + "path": "docs-parser/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/stylus/test.styl b/tests/file-types/stylus/test.styl similarity index 82% rename from tests/lib/stylus/test.styl rename to tests/file-types/stylus/test.styl index 517d140..4613c6c 100755 --- a/tests/lib/stylus/test.styl +++ b/tests/file-types/stylus/test.styl @@ -3,19 +3,17 @@ /// @page tests/styl-file //// -/// @name main -/// @description - +/// @name One +/// @description /// Lorem ipsum dolor sit amet, consectetur adipisicing elit, /// sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. /// Ut enim ad minim veniam, quis nostrud exercitation ullamco. -/// @markup {shitfuck} -/// asdfasdfasdfasdf a = 0 b = 1 !a and !b -/// @name Somethin +/// @name Two /// @description /// Lorem ipsum dolor sit amet, consectetur adipisicing elit. /// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore @@ -26,7 +24,7 @@ add(a, b) body padding add(10px, 5) -/// @name Something else +/// @name Three /// @description /// This is another normal multi-line comment. add(a, b) @@ -35,4 +33,4 @@ body else (error 'a and b must be units!') -// This is a normal single-line comment. \ No newline at end of file +// This is a normal single-line comment. diff --git a/tests/file-types/swift/test.json b/tests/file-types/swift/test.json new file mode 100644 index 0000000..a3ef8f0 --- /dev/null +++ b/tests/file-types/swift/test.json @@ -0,0 +1,132 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Swift File", + "href": "/tests/swift-file", + "body": [ + { + "title": "main", + "href": "/tests/swift-file#main" + }, + { + "title": "Something", + "href": "/tests/swift-file#something" + }, + { + "title": "Something else", + "href": "/tests/swift-file#something-else" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "swift-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs-parser/tests/file-types/swift/test.swift", + "start": 1, + "end": 49 + } + }, + "access": "public" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 20 + }, + "file": { + "path": "docs-parser/tests/file-types/swift/test.swift", + "start": 1, + "end": 49 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Something", + "description": "

This is a normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 23, + "end": 25, + "type": "body" + }, + "code": { + "start": 26, + "end": 31 + }, + "file": { + "path": "docs-parser/tests/file-types/swift/test.swift", + "start": 1, + "end": 49 + } + }, + "access": "public", + "inline": [] + }, + { + "name": "Something else", + "description": "

This is another normal multi-line comment.

\n", + "blockinfo": { + "comment": { + "start": 34, + "end": 36, + "type": "body" + }, + "code": { + "start": 37, + "end": 48 + }, + "file": { + "path": "docs-parser/tests/file-types/swift/test.swift", + "start": 1, + "end": 49 + } + }, + "access": "public", + "inline": [] + } + ] + } + } + } + } +} diff --git a/tests/lib/swift/test.swift b/tests/file-types/swift/test.swift similarity index 95% rename from tests/lib/swift/test.swift rename to tests/file-types/swift/test.swift index 56d27ea..1302442 100755 --- a/tests/lib/swift/test.swift +++ b/tests/file-types/swift/test.swift @@ -6,7 +6,6 @@ /// @name main /// @description /// main method - class Counter { var count = 0 func increment() { @@ -20,10 +19,10 @@ class Counter { } } + /// @name Something /// @description /// This is a normal multi-line comment. - class Counter2 { var count: Int = 0 func incrementBy(amount: Int, numberOfTimes: Int) { @@ -31,10 +30,10 @@ class Counter2 { } } + /// @name Something else /// @description /// This is another normal multi-line comment. - struct Point { var x = 0.0, y = 0.0 func isToTheRightOfX(x: Double) -> Bool { @@ -46,4 +45,4 @@ if somePoint.isToTheRightOfX(1.0) { println("This point is to the right of the line where x == 1.0") } -// This is a normal single-line comment. \ No newline at end of file +// This is a normal single-line comment. diff --git a/tests/gulpfile.js b/tests/gulpfile.js deleted file mode 100755 index 931117e..0000000 --- a/tests/gulpfile.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -var gulp = require("gulp"), - docs = require("docs"); - -// This is for the documentation -gulp.task("docs", function(){ - docs - .parse("lib/**/*") - .then(function(data){ - console.log(""); - console.log(""); - console.log(""); - console.log(""); - console.log("-------------------------------------------------------------------"); - console.log(data); - }) - // .write("test.json"); -}); - -gulp.task("default", ["docs"]); \ No newline at end of file diff --git a/tests/lib/c#/README.md b/tests/lib/c#/README.md deleted file mode 100755 index b238fd9..0000000 --- a/tests/lib/c#/README.md +++ /dev/null @@ -1,54 +0,0 @@ -## C`#` -*Reference: [https://msdn.microsoft.com/en-us/library/wfwda74e.aspx](https://msdn.microsoft.com/en-us/library/wfwda74e.aspx), [https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Style_Conventions/Comments](https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Style_Conventions/Comments), [http://rbwhitaker.wikidot.com/c-sharp-comments](http://rbwhitaker.wikidot.com/c-sharp-comments) - -In brief, there are 2 different ways to comment in C#: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### c#-type1.cs -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. Also, on each new line (for *file-level* and *normal*), there is a `*`. However, this is not necessary. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line C# comment with `/*` and `*/` : - - /***** - * - * stuff - * - *****/ - -A *normal* multi-line C# comment with `/*` and `*/` : - - /* - * stuff - */ - -Another *normal* multi-line C# comment with `/*` and `*/` : - - /* - stuff - */ - ----------------------------------- -### c#-type2.cs -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line C# comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line C# comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line C# comment with `/` : - - // stuff \ No newline at end of file diff --git a/tests/lib/c++/README.md b/tests/lib/c++/README.md deleted file mode 100755 index 2ab52ca..0000000 --- a/tests/lib/c++/README.md +++ /dev/null @@ -1,54 +0,0 @@ -## C++ -*Reference: [https://msdn.microsoft.com/en-us/library/wfwda74e.aspx](https://msdn.microsoft.com/en-us/library/wfwda74e.aspx), [https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Style_Conventions/Comments](https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Style_Conventions/Comments), [http://rbwhitaker.wikidot.com/c-sharp-comments](http://rbwhitaker.wikidot.com/c-sharp-comments) - -In brief, there are 2 different ways to comment in C++: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### c++-type1.c -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. Also, on each new line (for *file-level* and *normal*), there is a `*`. However, this is not necessary. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line C++ comment with `/*` and `*/` : - - /***** - * - * stuff - * - *****/ - -A *normal* multi-line C++ comment with `/*` and `*/` : - - /* - * stuff - */ - -Another *normal* multi-line C++ comment with `/*` and `*/` : - - /* - stuff - */ - ----------------------------------- -### c++-type2.c -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line C++ comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line C++ comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line C++ comment with `/` : - - // stuff \ No newline at end of file diff --git a/tests/lib/c/README.md b/tests/lib/c/README.md deleted file mode 100755 index 79516b2..0000000 --- a/tests/lib/c/README.md +++ /dev/null @@ -1,54 +0,0 @@ -## C -*Reference: [https://msdn.microsoft.com/en-us/library/wfwda74e.aspx](https://msdn.microsoft.com/en-us/library/wfwda74e.aspx), [https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Style_Conventions/Comments](https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Style_Conventions/Comments), [http://rbwhitaker.wikidot.com/c-sharp-comments](http://rbwhitaker.wikidot.com/c-sharp-comments) - -In brief, there are 2 different ways to comment in C: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### c-type1.c -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. Also, on each new line (for *file-level* and *normal*), there is a `*`. However, this is not necessary. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line C comment with `/*` and `*/` : - - /***** - * - * stuff - * - *****/ - -A *normal* multi-line C comment with `/*` and `*/` : - - /* - * stuff - */ - -Another *normal* multi-line C comment with `/*` and `*/` : - - /* - stuff - */ - ----------------------------------- -### c-type2.c -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line C comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line C comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line C comment with `/` : - - // stuff \ No newline at end of file diff --git a/tests/lib/coffeescript/README.md b/tests/lib/coffeescript/README.md deleted file mode 100755 index 171cb02..0000000 --- a/tests/lib/coffeescript/README.md +++ /dev/null @@ -1,46 +0,0 @@ -## CoffeeScript -*Reference: [http://stackoverflow.com/questions/7781685/coffeescript-how-to-comment-this-doesnt-work](http://stackoverflow.com/questions/7781685/coffeescript-how-to-comment-this-doesnt-work) - -In brief, there are 2 different ways to comment in CoffeeScript: - -1. type1: Using `###` -2. type2: Using multiple single-line comments, `#` - -These are explained in detail below. - -### coffeescript-type1.coffee -> For this type, comments *normally* begin with `###` and end with `###`. *File-level* comments contain five `#` instead of three. For style's sake, the `#` are on their own line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line CoffeeScript comment with `#` : - - ##### - stuff - ##### - -A *normal* multi-line CoffeeScript comment with `#` : - - ### - stuff - ### - ----------------------------------- -### coffeescript-type2.coffee -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line CoffeeScript comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal* multi-line CoffeeScript comment with `#` : - - ## - ## stuff - ## - -A *normal* single-line CoffeeScript comment with `#` : - - # stuff diff --git a/tests/lib/coldfusion/README.md b/tests/lib/coldfusion/README.md deleted file mode 100755 index 1a71abe..0000000 --- a/tests/lib/coldfusion/README.md +++ /dev/null @@ -1,61 +0,0 @@ -## Colfusion Script and HTML -*Reference: [http://www.learncfinaweek.com/week1/Commenting/](http://www.learncfinaweek.com/week1/Commenting/)* - -In brief, the following are ways to comment in Coldfusion: - -1. Coldfusion HTML: Using `` -2. Coldfusion Script type1: Using `/*` -3. Coldfusion Script type2: Using multiple single line comments, `//` - -### coldfusionHtml.cfm -> For this type, comments *normally* begin with ``. *File-level* comments contain six `-` instead of 3. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Coldfusion HTML comment: - - - -A *normal* multi-line Coldfusion HTML comment: - - - ----------------------------------- -### coldfusionScript-type1.cfm -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Coldfusion Script comment with `/*` and `*/` : - - /***** - stuff - *****/ - -A *normal* multi-line Coldfusion Script comment with `/*` and `*/`: - - /* - stuff - */ - ----------------------------------- -### coldfusionScript-type2.cfm -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by three `/` on each new line, and ended with five more `/` on a new line. *Normal* multiline comments also have three `/` instead of the normal two. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Coldfusion Script comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Coldfusion Script comment with `/`: - - /// - /// stuff - /// - -A *normal* single-line Colfusion Script comment with `/`: - - // stuff diff --git a/tests/lib/edge-cases/4-blank-lines-between-code-blocks.scss b/tests/lib/edge-cases/4-blank-lines-between-code-blocks.scss deleted file mode 100644 index 77c64af..0000000 --- a/tests/lib/edge-cases/4-blank-lines-between-code-blocks.scss +++ /dev/null @@ -1,47 +0,0 @@ -//// -/// @author Tyler Benton -/// @page edge-cases/4-blank-lines-between-code-blocks -//// - -/// @name moz-only -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} - - - -.nav{ - height: 40px; - width: 100%; - background: #455868; - border-bottom: 2px solid #283744; - li{ - width: 600px; - height: 40px; - a{ - color: #fff; - line-height: 40px; - text-shadow: 1px 1px 0px #283744; - } - } -} \ No newline at end of file diff --git a/tests/lib/edge-cases/ends-with-empty-lines.scss b/tests/lib/edge-cases/ends-with-empty-lines.scss deleted file mode 100644 index 3f81cc3..0000000 --- a/tests/lib/edge-cases/ends-with-empty-lines.scss +++ /dev/null @@ -1,34 +0,0 @@ -//// -/// @author Tyler Benton -/// @page edge-cases/ends-with-empty-lines -//// - -/// @name Only block in body -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} - - - - - diff --git a/tests/lib/edge-cases/only-body-comments.scss b/tests/lib/edge-cases/only-body-comments.scss deleted file mode 100644 index d345f51..0000000 --- a/tests/lib/edge-cases/only-body-comments.scss +++ /dev/null @@ -1,52 +0,0 @@ -/// @author Tyler Benton -/// @page components/buttons -/// -/// @description Your standard form button. -/// -/// @state :hover -/// @state :active -/// @state :disabled - Dims the button when disabled. -/// @state .c-btn--mini - A mini button -/// @state .c-btn--tiny - A tiny button -/// @state .c-btn--medium - A medium button -/// @state .c-btn--large - A large button -/// @state .c-btn--primary - Primary action -/// @state .c-btn--primary:hover -/// @state .c-btn--primary:active -/// @state .c-btn--secondary - Secondary action -/// @state .c-btn--secondary:hover -/// @state .c-btn--secondary:active -/// @state .c-btn--tertiary - Tertiary action -/// @state .c-btn--tertiary:hover -/// @state .c-btn--tertiary:active -/// @state .c-btn--text - It's a text link as a button -/// @state .c-btn--text:hover -/// @state .c-btn--text:active -/// -/// @markup -///
-/// Button (a.button) -/// -/// -///
- -/// @name Button group -/// @description -/// Used when there's a group of buttons that need to be on the same line. -/// -/// @markup -///
-/// Button (a.button) -/// -/// -///
- -/// @name Test -/// @state .state-1 -/// @state .state-2 -/// @state .state-3 -/// @description -/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. -/// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore -/// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis -/// iste nostrum vel, culpa iure. Adipisci. \ No newline at end of file diff --git a/tests/lib/edge-cases/single-body-comment.scss b/tests/lib/edge-cases/single-body-comment.scss deleted file mode 100644 index 4063797..0000000 --- a/tests/lib/edge-cases/single-body-comment.scss +++ /dev/null @@ -1,24 +0,0 @@ -/// @name moz-only -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} \ No newline at end of file diff --git a/tests/lib/edge-cases/space-between-comment-and-code.scss b/tests/lib/edge-cases/space-between-comment-and-code.scss deleted file mode 100644 index 72f615e..0000000 --- a/tests/lib/edge-cases/space-between-comment-and-code.scss +++ /dev/null @@ -1,57 +0,0 @@ -//// -/// @author Tyler Benton -/// @page edge-cases/ends-with-empty-lines -//// - -/// @name Space between comment bock and code block -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } - -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} - - - -/// @name No space between -/// @description -/// A simple nav component, used to help with navigation -/// @markup -/// -.nav{ - height: 40px; - width: 100%; - background: #455868; - border-bottom: 2px solid #283744; - li{ - width: 600px; - height: 40px; - a{ - color: #fff; - line-height: 40px; - text-shadow: 1px 1px 0px #283744; - } - } -} \ No newline at end of file diff --git a/tests/lib/edge-cases/starts-with-empty-lines.scss b/tests/lib/edge-cases/starts-with-empty-lines.scss deleted file mode 100644 index 79d9a0d..0000000 --- a/tests/lib/edge-cases/starts-with-empty-lines.scss +++ /dev/null @@ -1,32 +0,0 @@ - - - -//// -/// @author Tyler Benton -/// @page edge-cases/starts-with-empty-lines -//// - -/// @name Only block in body -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} \ No newline at end of file diff --git a/tests/lib/html/README.md b/tests/lib/html/README.md deleted file mode 100755 index daa602e..0000000 --- a/tests/lib/html/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## HTML -Reference: [http://www.w3schools.com/html/html_comments.asp](http://www.w3schools.com/html/html_comments.asp) - -In brief, there one way to comment in HTML: - -1. type1: Using `` - -This are explained in detail below. - -### html-type1.html -> For this type, comments *normally* begin with ``. *File-level* comments contain five `-` instead of two. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line HTML comment with ``: - - - -A *normal* multi-line HTML comment with ``: - - diff --git a/tests/lib/html/test.html b/tests/lib/html/test.html deleted file mode 100755 index 43c0a0d..0000000 --- a/tests/lib/html/test.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - Document - - - - - -
- Home - My Account -
- -
- -
- -
- -
- - diff --git a/tests/lib/java/README.md b/tests/lib/java/README.md deleted file mode 100755 index 32dba2d..0000000 --- a/tests/lib/java/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## Java -*Reference: [http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html](http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html) - -In brief, there are 2 different ways to comment in Java: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single line comments, `//` - -These are explained in detail below. - -### java-type1.java -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments have five `*` instead of one. For style's sake, usually you put a `*` to begin each new comment line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Java comment with `/*` and `*/` : - - /***** - * stuff - * more stuff - * even more stuff - *****/ - -A *normal* multi-line Java comment with `/*` and `*/` : - - /* - * stuff - */ - ----------------------------------- -### java-type2.java -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Java comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Java comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Java comment with `/` : - - // stuff \ No newline at end of file diff --git a/tests/lib/less/README.md b/tests/lib/less/README.md deleted file mode 100755 index edc1136..0000000 --- a/tests/lib/less/README.md +++ /dev/null @@ -1,46 +0,0 @@ -## Less -*Reference: [http://www.ibm.com/developerworks/library/wa-less/](http://www.ibm.com/developerworks/library/wa-less/) - -In brief, there are 2 different ways to comment in Less: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single line comments, `//` - -These are explained in detail below. - -### less-type1.less -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Less comment with `/*` and `*/`: - - /***** - stuff - *****/ - -A *normal* multi-line Less comment with `/*` and `*/`: - - /* - stuff - */ - ----------------------------------- -### less-type2.less -> For this type, comments are composed of several single lined comments, which are made from `/`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Less comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Less comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Less comment with `/` : - - // stuff diff --git a/tests/lib/less/test.less b/tests/lib/less/test.less deleted file mode 100755 index 267dfb7..0000000 --- a/tests/lib/less/test.less +++ /dev/null @@ -1,217 +0,0 @@ -//// -/// @author Tyler Benton -/// @page tests/less-test -//// - -/// @name base color -/// @type {color} -@color-base: #2d5e8b; - -main{ - background-color: @color-base; -} - -/// @name Nav -/// @description -/// A simple nav component, used to help with navigation -/// @markup -/// -.nav{ - height: 40px; - width: 100%; - background: #455868; - border-bottom: 2px solid #283744; - li{ - width: 600px; - height: 40px; - a{ - color: #fff; - line-height: 40px; - text-shadow: 1px 1px 0px #283744; - } - } -} - -/// @author Tyler Benton -/// @page components/buttons -/// -/// @description Your standard form button. -/// -/// @state :hover -/// @state :active -/// @state :disabled - Dims the button when disabled. -/// @state .c-btn--mini - A mini button -/// @state .c-btn--tiny - A tiny button -/// @state .c-btn--medium - A medium button -/// @state .c-btn--large - A large button -/// @state .c-btn--primary - Primary action -/// @state .c-btn--primary:hover -/// @state .c-btn--primary:active -/// @state .c-btn--secondary - Secondary action -/// @state .c-btn--secondary:hover -/// @state .c-btn--secondary:active -/// @state .c-btn--tertiary - Tertiary action -/// @state .c-btn--tertiary:hover -/// @state .c-btn--tertiary:active -/// @state .c-btn--text - It's a text link as a button -/// @state .c-btn--text:hover -/// @state .c-btn--text:active -/// -/// @markup -///
-/// Button (a.button) -/// -/// -///
-.c-btn{ - background: color(a); - border: none; - border-radius: 6px; - color: #fff; - display: inline-block; - font-size: 1em; - font-weight: bold; - line-height: 1em; - padding: 13px 1.5em; - text-align: center; - text-decoration: none; - transition: background .25s ease-out, color .25s ease-out; - vertical-align: middle; - width: auto; // this resets the input style of 100% - &:hover, &:active, &:focus{ // had to write it like this to over ride the styles on the anchor tags without using important - color: #fff; - text-decoration: none; - } - &:hover{ - background: color(a, -2); - } - &:active, &:focus{ - background: color(a, 2); - } - &:disabled{ - opacity: .5; - } - - &--mini{ - font-size: .8rem; - padding: .6em .8em; - } - - &--tiny{ - font-size: .875rem; - padding: .6em .8em; - } - - &--small{ - font-size: .875rem; - } - - &--medium{ - font-size: 1rem; - } - - &--large{ - font-size: 1.125rem; - } - - &--primary{ - background: color(f); - &:hover{ - background: color(f, -2); - } - &:active, &:focus{ - background: color(f, 2); - } - .c-badge{ - color: color(f); - } - } - - &--secondary{ - background: color(b); - &:hover{ - background: color(b, -2); - } - &:active, &:focus{ - background: color(b, 2); - } - .c-badge{ - color: color(b); - } - } - - &--tertiary{ - background: color(a, -7); - &, &:hover, &:active, &:focus{ - color: color(a, 3); - } - &:hover{ - background: color(a, -5); - } - &:active, &:focus{ - background: color(a, -3); - } - .c-badge{ - color: color(a); - } - } - - &--text{ - color: color(b, 0); - &, &:hover, &:active, &:focus{ - background: none; - } - &:hover{ - color: color(b, -2); - } - &:active, &:focus{ - color: color(b, 2); - } - - .c-badge{ - color: color(b); - } - } - - .c-badge{ - background: #fff; - } - - /// @name Button group - /// @description - /// Used when there's a group of buttons that need to be on the same line. - /// - /// @markup - ///
- /// Button (a.button) - /// - /// - ///
- &-group{ - > *{ - margin-top: 0; - } - } -} - - -/// @name Opacity -/// @description -/// A mixin to help with opacity fallbacks -/// @arg {number} - The opacity you to use, between 0.0 - 1.0 -/// @markup {less} -/// .foo{ -/// .opacity(.3); -/// } -.opacity(@opacity: 0.5){ - -webkit-opacity: @opacity; - -moz-opacity: @opacity; - opacity: @opacity; - @opperc: @opacity * 100; - -ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=@{opperc})"; - filter: ~"alpha(opacity=@{opperc})"; -} \ No newline at end of file diff --git a/tests/lib/php/README.md b/tests/lib/php/README.md deleted file mode 100755 index 5802539..0000000 --- a/tests/lib/php/README.md +++ /dev/null @@ -1,69 +0,0 @@ -## php -*Reference: [http://php.net/manual/en/language.basic-syntax.comments.php](http://php.net/manual/en/language.basic-syntax.comments.php) - -In brief, there are 3 different ways to comment in php: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` -3. type3: Using multiple single-line comments, `#` - -These are explained in detail below. - -### php-type1.php -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line php comment with `/*` and `*/` : - - /***** - stuff - *****/ - -A *normal* multi-line php comment with `/*` and `*/`: - - /* - stuff - */ - ----------------------------------- -### php-type2.php -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line php comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line php comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line php comment with `/` : - - // stuff - ----------------------------------- -### php-type3.php -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line php comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal* multi-line php comment with `#` : - - ## - ## stuff - ## - -A *normal* single-line php comment with `#` : - - # stuff diff --git a/tests/lib/php/test.php b/tests/lib/php/test.php deleted file mode 100755 index e9afcaa..0000000 --- a/tests/lib/php/test.php +++ /dev/null @@ -1,36 +0,0 @@ -"; - echo "My house is " . $COLOR . "
"; - echo "My boat is " . $coLOR . "
"; - - // This is a normal single-line comment. -?> \ No newline at end of file diff --git a/tests/lib/python/README.md b/tests/lib/python/README.md deleted file mode 100755 index e9c4b25..0000000 --- a/tests/lib/python/README.md +++ /dev/null @@ -1,63 +0,0 @@ -## Python -*Reference: [http://www.pythonforbeginners.com/comments/comments-in-python](http://www.pythonforbeginners.com/comments/comments-in-python), [http://www.afterhoursprogramming.com/tutorial/Python/Comments/](http://www.afterhoursprogramming.com/tutorial/Python/Comments/) - -In brief, there are 3 different ways to comment in Python: - -1. type1: Using `"""` -2. type2: Using `'''` -3. type3: Using multiple single line comments, `#` - -These are explained in detail below. - -### python-type1.py -> For this type, comments *normally* begin with `"""` and end with `"""`. *File-level* comments contain five `"` instead of three. For style's sake, the `"` are on their own line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Python comment with `"` : - - """"" - stuff - """"" - -A *normal* multi-line Python comment with `"` : - - """ - stuff - """ - ----------------------------------- -### python-type2.py -> For this type, comments normally begin with `'''` and end with `'''`. *File-level* comments contain five `'` instead of three. For style's sake, the `'` are on their own line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Python comment with `'` : - - ''''' - stuff - ''''' - -A *normal* multi-line Python comment with `'` : - - ''' - stuff - ''' - ----------------------------------- -### python-type3.py -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Python comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal* multi-line Python comment with `#` : - - ## - ## stuff - ## - -A *normal* single-line Python comment with `#` : - - # stuff diff --git a/tests/lib/ruby/README.md b/tests/lib/ruby/README.md deleted file mode 100755 index e34d902..0000000 --- a/tests/lib/ruby/README.md +++ /dev/null @@ -1,47 +0,0 @@ -## Ruby -Reference: [http://www.tutorialspoint.com/ruby/ruby_comments.htm](http://www.tutorialspoint.com/ruby/ruby_comments.htm) - -In brief, there are 2 different ways to comment in Ruby: - -1. type1: Using `=begin` `=end` -2. type2: Using multiple single line comments, `#` - -These are explained in detail below. - -### ruby-type1.rb -> For this type, comments *normally* begin with `=begin` and end with `=end`. *File-level* comments contain five `=` after `begin`. It is important to note that `=begin` and `=end` both start on a new line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Ruby comment with `=begin` and `=end`: - - =begin===== - stuff - =end - -A *normal* multi-line Ruby comment with `=begin` and `=end`: - - =begin - stuff - =end - ----------------------------------- -### ruby-type2.rb -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - - -A *file-level multi-line* Ruby comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal multi-line* Ruby comment with `#` : - - ## - ## stuff - ## - -A *normal single-line* Ruby comment with `#` : - - # stuff diff --git a/tests/lib/ruby/test.rb b/tests/lib/ruby/test.rb deleted file mode 100755 index 991e4aa..0000000 --- a/tests/lib/ruby/test.rb +++ /dev/null @@ -1,37 +0,0 @@ -### -## @author Tyler Benton -## @page tests/rb-file -### - -## @name main -## @description -## main method - -for i in (1..4) - print i," " -end -print "\n" - -## @name Something -## @description -## This is a normal multi-line comment made of single line comments. - -for i in (1...4) - print i," " -end -print "\n" - -## @name Something else -## @description -## This is another normal multi-line comment made of single line comments. - -items = [ 'Mark', 12, 'goobers', 18.45 ] -for it in items - print it, " " -end -print "\n" - -# A simple single line comment -for i in (0...items.length) - print items[0..i].join(" "), "\n" -end \ No newline at end of file diff --git a/tests/lib/scss/test.scss b/tests/lib/scss/test.scss deleted file mode 100755 index c50e811..0000000 --- a/tests/lib/scss/test.scss +++ /dev/null @@ -1,44 +0,0 @@ -//// -/// @author Tyler Benton -/// @page tests/scss-file -//// - -/// @name moz-only -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} - -/// @name Test one -/// @page tests/all -/// @state .state-1 -/// @state .state-2 -/// @state .state-3 -/// @description -/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. -/// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore -/// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis -/// iste nostrum vel, culpa iure. Adipisci. -.foo{ - -} - diff --git a/tests/lib/stylus/README.md b/tests/lib/stylus/README.md deleted file mode 100755 index 59129cc..0000000 --- a/tests/lib/stylus/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## Stylus -*Reference: [https://learnboost.github.io/stylus/docs/comments.html](https://learnboost.github.io/stylus/docs/comments.html) - -In brief, there are 2 different ways to comment in Stylus: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### stylus-type1.styl -> For this type, comments *normally* begin with `/*` and end with `*/`, with `*` on each new line in between. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Stylus comment with `/*` and `*/`: - - /***** - * - * stuff - * - *****/ - -A *normal* multi-line Stylus comment with `/*` and `*/`: - - /* - * stuff - */ - ----------------------------------- -### stylus-type2.styl -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Stylus comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Stylus comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Stylus comment with `/` : - - // stuff diff --git a/tests/lib/swift/README.md b/tests/lib/swift/README.md deleted file mode 100755 index dfa38a6..0000000 --- a/tests/lib/swift/README.md +++ /dev/null @@ -1,47 +0,0 @@ -## Swift -*Reference: [https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html) - -In brief, there are 2 different ways to comment in Swift: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### swift-type1.swift -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Swift comment with `/*` and `*/` : - - /***** - stuff - *****/ - -A *normal* multi-line Swift comment with `/*` and `*/` : - - /* - stuff - */ - ----------------------------------- -### swift-type2.swift -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Swift comment with `/` : - - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Swift comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Swift comment with `/` : - - // stuff diff --git a/tests/package.json b/tests/package.json deleted file mode 100644 index e377110..0000000 --- a/tests/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "docs", - "dependencies": { - "docs": "file:../" - }, - "engines": { - "node": ">=0.10.0" - }, - "devDependencies": { - "gulp": "^3.8.11" - } -} diff --git a/tests/run.test.js b/tests/run.test.js new file mode 100644 index 0000000..af54bcf --- /dev/null +++ b/tests/run.test.js @@ -0,0 +1,118 @@ +/* eslint-disable no-loop-func */ +import path from 'path' +import docs from '../dist/index.js' +import Tokenizer from '../dist/parser/tokenizer.js' +import { fs, glob } from '../dist/utils' +import assert from 'core-assert' +import { map } from 'async-array-methods' +import asyncSuite from '../tools/async-suite' + +const test_defaults = { + debug: false, + timestamps: false, + warning: false, + ignore: '.*' +} + + +addSuite('cases', async ({ paths, expected }) => { + const actual = await map(paths, (files) => docs({ files, ...test_defaults })) + return () => { + for (let i = 0; i < paths.length; i++) { + test(`${i}: ${paths[i]}`, () => { + assert.deepStrictEqual( + actual[i], + expected[i] + ) + }) + } + } +}) + + +addSuite('file-types', async ({ paths, expected }) => { + const actual = await map(paths, (files) => docs({ files, ...test_defaults })) + return () => { + for (let i = 0; i < paths.length; i++) { + test(`${i}: ${paths[i]}`, () => { + assert.deepStrictEqual( + actual[i], + expected[i] + ) + }) + } + } +}) + + +addSuite('annotations', async ({ paths, expected }) => { + const actual = await map(paths, (files) => docs({ files, raw: true, ...test_defaults })) + + return () => { + for (let i = 0; i < paths.length; i++) { + let _path = paths[i] + test(`${i}: ${_path}`, () => { + assert.deepStrictEqual( + actual[i][_path], + expected[i] + ) + }) + } + } +}) + + +import tokenizerHelper from '../tools/tokenizer-helper.js' +addSuite('Tokenizer', async ({ paths, expected }) => { + const actual = await map(paths, async (file) => { + try { + const obj = await tokenizerHelper(file) + return new Tokenizer(obj.str, obj.comment) + } catch (e) { + console.trace(e) + } + }) + + return () => { + for (let i = 0; i < paths.length; i++) { + test(`${i}: ${paths[i]}`, () => { + assert.deepStrictEqual( + actual[i], + expected[i] + ) + }) + } + } +}) + + +const mochaAsync = (fn) => { // eslint-disable-line + return async (done) => { + try { + await fn() + done() + } catch (err) { + done(err) + } + } +} + +function addSuite(name, folder, callback) { + if (arguments.length === 2) { + callback = folder + folder = name + } + + return asyncSuite( + name, + async () => { + folder = path.join(__dirname, folder) + const paths = await glob(path.join(folder, '**', '*'), [ path.join(folder, '**', '*.json') ]) + return { + paths, + expected: await map(paths, (file) => fs.readJson(file.replace(path.extname(file), '.json'))) + } + }, + callback + ) +} diff --git a/tests/test.json b/tests/test.json deleted file mode 100644 index c8ce055..0000000 --- a/tests/test.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "scss": [ - { - "author": "Tyler Benton\n", - "page": "tests/scss-file", - "name": "moz-only", - "description": "

This allows you to write specific styles for mozilla firefox only

\n", - "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" - }, - { - "author": "Tyler Benton\n", - "page": "tests/all", - "name": "Test one", - "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.\nQuasi omnis facilis vero architecto perferendis, debitis dignissimos tempore\ndolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis\niste nostrum vel, culpa iure. Adipisci.

\n" - } - ], - "js": [], - "css": [ - { - "author": "Tyler Benton\n", - "page": "test/css-file", - "name": "Base Styles", - "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n" - }, - { - "author": "Tyler Benton\n", - "page": "test/css-file", - "name": "Input", - "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n" - } - ] -} \ No newline at end of file diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json new file mode 100644 index 0000000..a1a020f --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json @@ -0,0 +1,33 @@ +[ + { + "comment": { + "contents": [ + "@name @author", + "@alias @authors", + "@description Author of the documented item", + "@returns {string}", + "@markup Usage", + "/// @author Author's name", + "", + "/// @author Author One, Author Two", + "", + "/// @author Author One", + "/// @author Author Two" + ], + "start": 3, + "end": 13 + }, + "code": { + "contents": [ + "annotations.author = {", + " alias: [ 'authors' ],", + " parse: @(annotation) {", + " return multiple(annotation)", + " }", + "}" + ], + "start": 14, + "end": 19 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl new file mode 100644 index 0000000..c2bc4ad --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl @@ -0,0 +1,20 @@ +annotations = {} + +/// @name @author +/// @alias @authors +/// @description Author of the documented item +/// @returns {string} +/// @markup Usage +/// /// @author Author's name +/// +/// /// @author Author One, Author Two +/// +/// /// @author Author One +/// /// @author Author Two +annotations.author = { + alias: [ 'authors' ], + parse: @(annotation) { + return multiple(annotation) + } +} + diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json new file mode 100644 index 0000000..d11050e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 6, + "end": 8 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 10, + "end": 14 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 15, + "end": 17 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 19, + "end": 23 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 24, + "end": 26 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss new file mode 100644 index 0000000..2e418b9 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss @@ -0,0 +1,26 @@ +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..d11050e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 6, + "end": 8 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 10, + "end": 14 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 15, + "end": 17 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 19, + "end": 23 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 24, + "end": 26 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..bba75d6 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,26 @@ +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..acecfeb --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss new file mode 100644 index 0000000..1048da4 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss @@ -0,0 +1,6 @@ +/// foo +/// bar +/// baz +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block.json b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.json new file mode 100644 index 0000000..acecfeb --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss new file mode 100644 index 0000000..3349402 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss @@ -0,0 +1,6 @@ +/// foo +/// bar +/// baz +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..efb6713 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 8, + "end": 12 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 15, + "end": 19 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..924da91 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,19 @@ +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. + + +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. + + +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. diff --git a/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss new file mode 100644 index 0000000..dc2db2d --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss @@ -0,0 +1,3 @@ +/// foo +/// bar +/// baz diff --git a/tests/tokenizer/css-like/multi-single-line/single-block.json b/tests/tokenizer/css-like/multi-single-line/single-block.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line/single-block.scss b/tests/tokenizer/css-like/multi-single-line/single-block.scss new file mode 100644 index 0000000..a87e3a7 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block.scss @@ -0,0 +1,3 @@ +/// foo +/// bar +/// baz \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json new file mode 100644 index 0000000..71cfbf1 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'prop value 1'," + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "'baz': 'prop value 2'," + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "'qux': 'prop value 3'," + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss new file mode 100644 index 0000000..08b1307 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss @@ -0,0 +1,5 @@ +$foo: ( + 'bar': 'prop value 1', ///# one + 'baz': 'prop value 2', ///# two + 'qux': 'prop value 3', ///# three +); diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..19b63bd --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,14 @@ +///# one +.foo { + background: blue; +} + +///# two +.foo { + background: blue; +} + +///# three +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss new file mode 100644 index 0000000..215239f --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss @@ -0,0 +1,14 @@ +///# one +.foo { + background: blue; +} + +///# two +.foo { + background: blue; +} + +///# three +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss new file mode 100644 index 0000000..ca5add6 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); ///# bock 1 diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss new file mode 100644 index 0000000..788870d --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); ///# bock 1 \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..3774e72 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'baz'" + ], + "start": 2, + "end": 2 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss new file mode 100644 index 0000000..3427fbd --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss @@ -0,0 +1,3 @@ +$foo: ( + 'bar': 'baz' ///# bock 1 +); \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss new file mode 100644 index 0000000..a2a0c3b --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss @@ -0,0 +1,4 @@ +///# @name single line slash +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line.json b/tests/tokenizer/css-like/single-line-with-code/single-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line.scss b/tests/tokenizer/css-like/single-line-with-code/single-line.scss new file mode 100644 index 0000000..e611f5a --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line.scss @@ -0,0 +1,4 @@ +///# @name single line slash +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..d88595d --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,5 @@ +///# one + +///# two + +///# three diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments.json b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss new file mode 100644 index 0000000..2dc54b8 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss @@ -0,0 +1,5 @@ +///# one + +///# two + +///# three \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss new file mode 100644 index 0000000..4dd5f2d --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss @@ -0,0 +1 @@ +///# @name single line slash diff --git a/tests/tokenizer/css-like/single-line/single-line.json b/tests/tokenizer/css-like/single-line/single-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/single-line.scss b/tests/tokenizer/css-like/single-line/single-line.scss new file mode 100644 index 0000000..1cab960 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line.scss @@ -0,0 +1 @@ +///# @name single line slash \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..3e26412 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,7 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss new file mode 100644 index 0000000..08601d2 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss @@ -0,0 +1,7 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..319fc47 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 10, + "end": 12 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 13, + "end": 15 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 16, + "end": 18 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..ee94771 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,18 @@ +//// +/// Block 1 +//// +.foo { + background: blue; +} +//// +/// Block 2 +//// +.foo { + background: blue; +} +//// +/// Block 3 +//// +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..10915b8 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,23 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss new file mode 100644 index 0000000..c8dde22 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss @@ -0,0 +1,23 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss new file mode 100644 index 0000000..fe4f0f6 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss @@ -0,0 +1,9 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block.json b/tests/tokenizer/css-like/start-end-with-code/single-block.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block.scss b/tests/tokenizer/css-like/start-end-with-code/single-block.scss new file mode 100644 index 0000000..3951dc4 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block.scss @@ -0,0 +1,9 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..5c60db7 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,4 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end.json b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss new file mode 100644 index 0000000..61adfa5 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss @@ -0,0 +1,4 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..35c23fe --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,9 @@ +//// +/// Block 1 +//// +//// +/// Block 2 +//// +//// +/// Block 3 +//// \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..11127c7 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,14 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks.json b/tests/tokenizer/css-like/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks.scss b/tests/tokenizer/css-like/start-end/multiple-blocks.scss new file mode 100644 index 0000000..8691bd2 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks.scss @@ -0,0 +1,14 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss new file mode 100644 index 0000000..19e2ab2 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss @@ -0,0 +1,6 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// diff --git a/tests/tokenizer/css-like/start-end/single-block.json b/tests/tokenizer/css-like/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/single-block.scss b/tests/tokenizer/css-like/start-end/single-block.scss new file mode 100644 index 0000000..77bdd38 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block.scss @@ -0,0 +1,6 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json new file mode 100644 index 0000000..71cfbf1 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'prop value 1'," + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "'baz': 'prop value 2'," + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "'qux': 'prop value 3'," + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss new file mode 100644 index 0000000..2dbd038 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss @@ -0,0 +1,5 @@ +$foo: ( + 'bar': 'prop value 1', /*# one */ + 'baz': 'prop value 2', /*# two */ + 'qux': 'prop value 3', /*# three */ +); diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..fe33023 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,14 @@ +/*# one */ +.foo { + background: blue; +} + +/*# two */ +.foo { + background: blue; +} + +/*# three */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss new file mode 100644 index 0000000..a4f5d4a --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss @@ -0,0 +1,14 @@ +/*# one */ +.foo { + background: blue; +} + +/*# two */ +.foo { + background: blue; +} + +/*# three */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss new file mode 100644 index 0000000..7121080 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); /*# bock 1 */ diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss new file mode 100644 index 0000000..bbcd7b4 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); /*# bock 1 */ \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..3774e72 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'baz'" + ], + "start": 2, + "end": 2 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss new file mode 100644 index 0000000..97eb705 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss @@ -0,0 +1,3 @@ +$foo: ( + 'bar': 'baz' /*# bock 1 */ +); \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss new file mode 100644 index 0000000..17d713a --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss @@ -0,0 +1,4 @@ +/*# @name single line slash */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/single-line-with-code/single-line.json b/tests/tokenizer/css/single-line-with-code/single-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line.scss b/tests/tokenizer/css/single-line-with-code/single-line.scss new file mode 100644 index 0000000..abd8f81 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line.scss @@ -0,0 +1,4 @@ +/*# @name single line slash */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..bd5f617 --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,5 @@ +/*# one */ + +/*# two */ + +/*# three */ diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments.json b/tests/tokenizer/css/single-line/multiple-single-line-comments.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments.scss b/tests/tokenizer/css/single-line/multiple-single-line-comments.scss new file mode 100644 index 0000000..13f8ec9 --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments.scss @@ -0,0 +1,5 @@ +/*# one */ + +/*# two */ + +/*# three */ \ No newline at end of file diff --git a/tests/tokenizer/css/single-line/single-line-with-trailing-line.json b/tests/tokenizer/css/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/single-line-with-trailing-line.scss b/tests/tokenizer/css/single-line/single-line-with-trailing-line.scss new file mode 100644 index 0000000..343fcd3 --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line-with-trailing-line.scss @@ -0,0 +1 @@ +/*# @name single line slash */ diff --git a/tests/tokenizer/css/single-line/single-line.json b/tests/tokenizer/css/single-line/single-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/single-line.scss b/tests/tokenizer/css/single-line/single-line.scss new file mode 100644 index 0000000..165e32b --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line.scss @@ -0,0 +1 @@ +/*# @name single line slash */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..be7323e --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,7 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss new file mode 100644 index 0000000..b533ed6 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss @@ -0,0 +1,7 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..319fc47 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 10, + "end": 12 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 13, + "end": 15 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 16, + "end": 18 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..0b4010e --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,18 @@ +/* + * Block 1 + */ +.foo { + background: blue; +} +/* + * Block 2 + */ +.foo { + background: blue; +} +/* + * Block 3 + */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..e5337d8 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,23 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks.json b/tests/tokenizer/css/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks.scss b/tests/tokenizer/css/start-end-with-code/multiple-blocks.scss new file mode 100644 index 0000000..289a42f --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks.scss @@ -0,0 +1,23 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss new file mode 100644 index 0000000..b0d7ea8 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss @@ -0,0 +1,9 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/start-end-with-code/single-block.json b/tests/tokenizer/css/start-end-with-code/single-block.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/single-block.scss b/tests/tokenizer/css/start-end-with-code/single-block.scss new file mode 100644 index 0000000..0ef32c3 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block.scss @@ -0,0 +1,9 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..66c5304 --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,4 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end.json b/tests/tokenizer/css/start-end/comments-after-start-and-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end.scss b/tests/tokenizer/css/start-end/comments-after-start-and-end.scss new file mode 100644 index 0000000..cc0b4dd --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end.scss @@ -0,0 +1,4 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..a8d2f89 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,9 @@ +/* + * Block 1 + */ +/* + * Block 2 + */ +/* + * Block 3 + */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..03dad6e --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,14 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ diff --git a/tests/tokenizer/css/start-end/multiple-blocks.json b/tests/tokenizer/css/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/multiple-blocks.scss b/tests/tokenizer/css/start-end/multiple-blocks.scss new file mode 100644 index 0000000..1694249 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks.scss @@ -0,0 +1,14 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/single-block-with-trailing-line.json b/tests/tokenizer/css/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/single-block-with-trailing-line.scss b/tests/tokenizer/css/start-end/single-block-with-trailing-line.scss new file mode 100644 index 0000000..769571a --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block-with-trailing-line.scss @@ -0,0 +1,6 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ diff --git a/tests/tokenizer/css/start-end/single-block.json b/tests/tokenizer/css/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/single-block.scss b/tests/tokenizer/css/start-end/single-block.scss new file mode 100644 index 0000000..923547f --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block.scss @@ -0,0 +1,6 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee new file mode 100644 index 0000000..a2520a0 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee @@ -0,0 +1,32 @@ +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json new file mode 100644 index 0000000..3acfe1a --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json @@ -0,0 +1,74 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 6, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 12, + "end": 16 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 17, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 23, + "end": 27 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 28, + "end": 32 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..a63a083 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,32 @@ +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..3acfe1a --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,74 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 6, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 12, + "end": 16 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 17, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 23, + "end": 27 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 28, + "end": 32 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..9093164 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee @@ -0,0 +1,8 @@ +## foo +## bar +## baz +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..20cfa86 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json @@ -0,0 +1,24 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 4, + "end": 8 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee new file mode 100644 index 0000000..d8ccbe6 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee @@ -0,0 +1,8 @@ +## foo +## bar +## baz +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json new file mode 100644 index 0000000..20cfa86 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json @@ -0,0 +1,24 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 4, + "end": 8 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..d66c52e --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,19 @@ +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. + + +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. + + +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. diff --git a/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..efb6713 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 8, + "end": 12 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 15, + "end": 19 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..898e97d --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee @@ -0,0 +1,3 @@ +## foo +## bar +## baz diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block.coffee b/tests/tokenizer/hash-style/multi-single-line/single-block.coffee new file mode 100644 index 0000000..6580104 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block.coffee @@ -0,0 +1,3 @@ +## foo +## bar +## baz \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block.json b/tests/tokenizer/hash-style/multi-single-line/single-block.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee new file mode 100644 index 0000000..108ad9c --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee @@ -0,0 +1,5 @@ +$foo = { + 'bar': 'prop value 1', ##$ one + 'baz': 'prop value 2', ##$ two + 'qux': 'prop value 3', ##$ three +} diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json new file mode 100644 index 0000000..71cfbf1 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'prop value 1'," + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "'baz': 'prop value 2'," + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "'qux': 'prop value 3'," + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee new file mode 100644 index 0000000..543c7e4 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee @@ -0,0 +1,20 @@ +##$ one +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ two +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ three +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..b8a9a93 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,62 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 8, + "end": 8 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 9, + "end": 13 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 15, + "end": 15 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 16, + "end": 20 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee new file mode 100644 index 0000000..0e4bcc5 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee @@ -0,0 +1,20 @@ +##$ one +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ two +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ three +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json new file mode 100644 index 0000000..b8a9a93 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json @@ -0,0 +1,62 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 8, + "end": 8 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 9, + "end": 13 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 15, + "end": 15 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 16, + "end": 20 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee new file mode 100644 index 0000000..af445ae --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee @@ -0,0 +1 @@ +$foo = { 'bar': 'baz' }; ##$ bock 1 diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json new file mode 100644 index 0000000..829f525 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo = { 'bar': 'baz' };" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee new file mode 100644 index 0000000..01c4dc6 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee @@ -0,0 +1 @@ +$foo = { 'bar': 'baz' }; ##$ bock 1 \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json new file mode 100644 index 0000000..829f525 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo = { 'bar': 'baz' };" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee new file mode 100644 index 0000000..465b756 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee @@ -0,0 +1,3 @@ +$foo = { + 'bar': 'baz' ##$ bock 1 +}; \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..3774e72 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'baz'" + ], + "start": 2, + "end": 2 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee new file mode 100644 index 0000000..e06127b --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee @@ -0,0 +1,6 @@ +##$ @name single line slash +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..3ded535 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line.coffee new file mode 100644 index 0000000..c0a6796 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line.coffee @@ -0,0 +1,6 @@ +##$ @name single line slash +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line.json b/tests/tokenizer/hash-style/single-line-with-code/single-line.json new file mode 100644 index 0000000..3ded535 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee new file mode 100644 index 0000000..7e53ce3 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee @@ -0,0 +1,5 @@ +##$ one + +##$ two + +##$ three diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee new file mode 100644 index 0000000..317cb63 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee @@ -0,0 +1,5 @@ +##$ one + +##$ two + +##$ three \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee new file mode 100644 index 0000000..d47a914 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee @@ -0,0 +1 @@ +##$ @name single line slash diff --git a/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/single-line.coffee b/tests/tokenizer/hash-style/single-line/single-line.coffee new file mode 100644 index 0000000..8a1674f --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line.coffee @@ -0,0 +1 @@ +##$ @name single line slash \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line/single-line.json b/tests/tokenizer/hash-style/single-line/single-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee new file mode 100644 index 0000000..53e9788 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee @@ -0,0 +1,9 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..8e4380a --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee new file mode 100644 index 0000000..ee4b3fd --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee @@ -0,0 +1,9 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json new file mode 100644 index 0000000..8e4380a --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee new file mode 100644 index 0000000..0ec7d73 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee @@ -0,0 +1,24 @@ +### +## Block 1 +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() +### +## Block 2 +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() +### +## Block 3 +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e0de964 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,62 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 4, + "end": 8 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 9, + "end": 11 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 12, + "end": 16 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 17, + "end": 19 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 20, + "end": 24 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..efc32c0 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,29 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..ba10743 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,65 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 15, + "end": 19 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 21, + "end": 24 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 25, + "end": 29 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee new file mode 100644 index 0000000..2574b84 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee @@ -0,0 +1,29 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..ba10743 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json @@ -0,0 +1,65 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 15, + "end": 19 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 21, + "end": 24 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 25, + "end": 29 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..e5e903f --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee @@ -0,0 +1,11 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..9d1d9b0 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 7, + "end": 11 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block.coffee b/tests/tokenizer/hash-style/start-end-with-code/single-block.coffee new file mode 100644 index 0000000..e6cf56d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block.coffee @@ -0,0 +1,11 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block.json b/tests/tokenizer/hash-style/start-end-with-code/single-block.json new file mode 100644 index 0000000..9d1d9b0 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 7, + "end": 11 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee new file mode 100644 index 0000000..fc6c463 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee @@ -0,0 +1,4 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee new file mode 100644 index 0000000..afc40d4 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee @@ -0,0 +1,4 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee new file mode 100644 index 0000000..056de77 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee @@ -0,0 +1,9 @@ +### +## Block 1 +### +### +## Block 2 +### +### +## Block 3 +### \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..7ea0d57 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,14 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks.coffee b/tests/tokenizer/hash-style/start-end/multiple-blocks.coffee new file mode 100644 index 0000000..f65134d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks.coffee @@ -0,0 +1,14 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks.json b/tests/tokenizer/hash-style/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..777d073 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee @@ -0,0 +1,6 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### diff --git a/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/single-block.coffee b/tests/tokenizer/hash-style/start-end/single-block.coffee new file mode 100644 index 0000000..89988b7 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block.coffee @@ -0,0 +1,6 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/single-block.json b/tests/tokenizer/hash-style/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html new file mode 100644 index 0000000..7d2be29 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html @@ -0,0 +1,7 @@ +
    +
  • List Item 1
  • + +
  • List Item 2
  • + +
  • List Item 3
  • +
\ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json new file mode 100644 index 0000000..9259b00 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 4, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 6, + "end": 6 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html new file mode 100644 index 0000000..e65a9b2 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html @@ -0,0 +1,5 @@ +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json new file mode 100644 index 0000000..2a5478f --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html new file mode 100644 index 0000000..29c3e88 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html @@ -0,0 +1,8 @@ +
      + +
    • List Item 1
    • + +
    • List Item 2
    • + +
    • List Item 3
    • +
    diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json new file mode 100644 index 0000000..82d052b --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 5, + "end": 5 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 7, + "end": 7 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line.html new file mode 100644 index 0000000..4ef069a --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line.html @@ -0,0 +1,8 @@ +
      + +
    • List Item 1
    • + +
    • List Item 2
    • + +
    • List Item 3
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line.json new file mode 100644 index 0000000..82d052b --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 5, + "end": 5 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 7, + "end": 7 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html new file mode 100644 index 0000000..105b761 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html @@ -0,0 +1,3 @@ +
      +
    • List Item 1
    • +
    diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json new file mode 100644 index 0000000..c044d13 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 1, + "end": 3 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html new file mode 100644 index 0000000..65707c1 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html @@ -0,0 +1,3 @@ +
      +
    • List Item 1
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..c044d13 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 1, + "end": 3 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html new file mode 100644 index 0000000..56dd87d --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html @@ -0,0 +1,4 @@ + +
      +
    • List Item 1
    • +
    diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..c536fb6 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line.html b/tests/tokenizer/html/single-line-with-code/single-line.html new file mode 100644 index 0000000..9d954ca --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line.html @@ -0,0 +1,4 @@ + +
      +
    • List Item 1
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/single-line.json b/tests/tokenizer/html/single-line-with-code/single-line.json new file mode 100644 index 0000000..c536fb6 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html new file mode 100644 index 0000000..842f400 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json new file mode 100644 index 0000000..f669684 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html new file mode 100644 index 0000000..3199b38 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json new file mode 100644 index 0000000..f669684 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html new file mode 100644 index 0000000..636145e --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json new file mode 100644 index 0000000..4b4de85 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line.html b/tests/tokenizer/html/single-line/multiple-single-line.html new file mode 100644 index 0000000..b8b2f08 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/tokenizer/html/single-line/multiple-single-line.json b/tests/tokenizer/html/single-line/multiple-single-line.json new file mode 100644 index 0000000..4b4de85 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/single-line-with-trailing-line.html b/tests/tokenizer/html/single-line/single-line-with-trailing-line.html new file mode 100644 index 0000000..898f7cd --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line-with-trailing-line.html @@ -0,0 +1 @@ + diff --git a/tests/tokenizer/html/single-line/single-line-with-trailing-line.json b/tests/tokenizer/html/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..aa9253d --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/single-line.html b/tests/tokenizer/html/single-line/single-line.html new file mode 100644 index 0000000..b87d3c8 --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/tokenizer/html/single-line/single-line.json b/tests/tokenizer/html/single-line/single-line.json new file mode 100644 index 0000000..aa9253d --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html new file mode 100644 index 0000000..fa59f4a --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html @@ -0,0 +1,10 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json new file mode 100644 index 0000000..5ea0c4f --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html new file mode 100644 index 0000000..3588fba --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html @@ -0,0 +1,10 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json new file mode 100644 index 0000000..5ea0c4f --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html new file mode 100644 index 0000000..1519dbf --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html @@ -0,0 +1,27 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..7a28995 --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,65 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 4, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 10, + "end": 12 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 13, + "end": 18 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 19, + "end": 21 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 22, + "end": 27 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html new file mode 100644 index 0000000..178ac77 --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html @@ -0,0 +1,32 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..e61b55a --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 12, + "end": 15 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 16, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 23, + "end": 26 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 27, + "end": 32 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks.html b/tests/tokenizer/html/start-end-with-code/multiple-blocks.html new file mode 100644 index 0000000..26c0c5e --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks.html @@ -0,0 +1,32 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks.json b/tests/tokenizer/html/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..e61b55a --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 12, + "end": 15 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 16, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 23, + "end": 26 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 27, + "end": 32 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html new file mode 100644 index 0000000..4cb666b --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html @@ -0,0 +1,12 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    diff --git a/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..eff603e --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 7, + "end": 12 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/single-block.html b/tests/tokenizer/html/start-end-with-code/single-block.html new file mode 100644 index 0000000..bec20d3 --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block.html @@ -0,0 +1,12 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/single-block.json b/tests/tokenizer/html/start-end-with-code/single-block.json new file mode 100644 index 0000000..eff603e --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 7, + "end": 12 + } + } +] diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html new file mode 100644 index 0000000..786b52d --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html @@ -0,0 +1,4 @@ + diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end.html b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.html new file mode 100644 index 0000000..bd80aa8 --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.html @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end.json b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html new file mode 100644 index 0000000..81b44e8 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html new file mode 100644 index 0000000..d981a16 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html @@ -0,0 +1,14 @@ + + + + + diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/multiple-blocks.html b/tests/tokenizer/html/start-end/multiple-blocks.html new file mode 100644 index 0000000..c9b183f --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks.html @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/multiple-blocks.json b/tests/tokenizer/html/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/single-block-with-trailing-line.html b/tests/tokenizer/html/start-end/single-block-with-trailing-line.html new file mode 100644 index 0000000..df8589b --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block-with-trailing-line.html @@ -0,0 +1,6 @@ + diff --git a/tests/tokenizer/html/start-end/single-block-with-trailing-line.json b/tests/tokenizer/html/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/single-block.html b/tests/tokenizer/html/start-end/single-block.html new file mode 100644 index 0000000..2fd83fa --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/single-block.json b/tests/tokenizer/html/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/unit/config.test.js b/tests/unit/config.test.js new file mode 100644 index 0000000..d9958a4 --- /dev/null +++ b/tests/unit/config.test.js @@ -0,0 +1,38 @@ +/* eslint-disable no-unused-vars */ +import assert from 'core-assert' +import asyncSuite from '../../tools/async-suite.js' +import getConfig, { + parseLanguages, + default_options, +} from '../../app/config' + +asyncSuite('config', () => { + return () => { + test('parseLanguages empty', () => { + assert.deepStrictEqual( + parseLanguages({ + test: {} + }).test, + default_options.languages.default + ) + }) + + test('parseLanguages extend', () => { + let test = parseLanguages({ + rb: { + header: { start: '###', line: '##', end: '###' }, + body: { line: '#' } + }, + py: { + extend: 'rb' + } + }) + assert.equal(test.rb.header.start, test.py.header.start) + assert.equal(test.rb.header.line, test.py.header.line) + assert.equal(test.rb.header.end, test.py.header.end) + assert.equal(test.rb.body.start, test.py.body.start) + assert.equal(test.rb.body.line, test.py.body.line) + assert.equal(test.rb.body.end, test.py.body.end) + }) + } +}) diff --git a/tests/lib/c#/test.cs b/tests/unit/crappy_file_saved_on_windows.cs old mode 100755 new mode 100644 similarity index 100% rename from tests/lib/c#/test.cs rename to tests/unit/crappy_file_saved_on_windows.cs diff --git a/tests/unit/utils/glob.test.js b/tests/unit/utils/glob.test.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/utils/info.test.js b/tests/unit/utils/info.test.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/utils/is.test.js b/tests/unit/utils/is.test.js new file mode 100644 index 0000000..5f8550f --- /dev/null +++ b/tests/unit/utils/is.test.js @@ -0,0 +1,129 @@ +import is from '../../../app/utils/is.js' +import assert from 'core-assert' +import asyncSuite from '../../../tools/async-suite.js' + + +asyncSuite.wrap('is', () => { + test('is.false', () => { + assert.ok(!is.false('foo'), + 'should return false if a string is passed') + assert.ok(!is.false(0), + 'should return false if a number is passed') + assert.ok(is.false(false), + 'should return true if false is pased to it') + }) + + test('is.fn', () => { + assert.ok(is.fn(test), + 'should return true if it is passed a function') + assert.ok(!is.fn('foo'), + 'should return false if passed a string') + }) + + test('is.in', () => { + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } + const string = 'onetwothree' + assert.ok(is.in(array, 'two'), + 'should return true when the item is in the array') + assert.ok(!is.in(array, 'four'), + 'should return false when the item is not in the array') + assert.ok(is.in(object, 'two'), + 'should return true when the item is in the object') + assert.ok(!is.in(object, 'four'), + 'should return false when the item is not in the object') + assert.ok(is.in(string, 'two'), + 'should return true when the item is in the string') + assert.ok(!is.in(string, 'four'), + 'should return false when the item is not in the string') + }) + + test('is.all.in', () => { + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } + const string = 'onetwothree' + assert.ok(is.all.in(array, 'one', 'two'), + 'should return true because all items are in the array') + assert.ok(!is.all.in(array, 'one', 'four'), + 'should return false because one item isn\'t in the array') + assert.ok(is.all.in(object, 'one', 'two'), + 'should return true because all items are in the object') + assert.ok(!is.all.in(object, 'one', 'four'), + 'should return false because one item isn\'t in the object') + assert.ok(is.all.in(string, 'one', 'two'), + 'should return true because all items are in the string') + assert.ok(!is.all.in(string, 'one', 'four'), + 'should return false because one item isn\'t in the string') + }) + + test('is.any.in', () => { + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } + const string = 'onetwothree' + assert.ok(is.any.in(array, 'one', 'four'), + 'should return true because one is in the array') + assert.ok(!is.any.in(array, 'four', 'five'), + 'should return false because none of the passed arguments are in the array') + assert.ok(is.any.in(object, 'one', 'four'), + 'should return true because one is in the object') + assert.ok(!is.any.in(object, 'four', 'five'), + 'should return false because none of the passed arguments are in the object') + assert.ok(is.any.in(string, 'one', 'four'), + 'should return true because one is in the string') + assert.ok(!is.any.in(string, 'four', 'five'), + 'should return false because none of the passed arguments are in the string') + }) + + test('is.plainObject', () => { + assert.ok(is.plainObject({}), + 'should return true if passed a {}') + assert.ok(!is.plainObject([]), + 'should return false if passed a []') + assert.ok(!is.plainObject(''), + 'should return false if passed a string') + assert.ok(!is.plainObject(test), + 'should return false if passed a function') + }) + + test('is.between', () => { + assert.ok(is.between(200), + 'should return true because 200 is between 0 and Infinity') + assert.ok(is.between(0), + 'should return true because 0 is between 0 and Infinity') + assert.ok(is.between(-100, -1000), + 'should return true because -100 is between -1000 and infinity') + assert.ok(!is.between(-1), + 'should return false because -1 is not between 0 and infinity') + }) + + test('is.promise', () => { + async function something_async() { + return await Promise.resolve('some cool stuff') + } + assert.ok(!is.promise('foo'), + 'should return false because a string is not a promise') + assert.ok(!is.promise(test), + 'should return false because tape is not a promise') + assert.ok(is.promise(something_async()), + 'should return true because something_async is an async function') + assert.ok(is.promise(Promise.resolve('')), + 'should return true because it is a promise') + }) + + test('is.buffer', () => { + const string = 'foo bar' + const some_buffer = new Buffer(string) + assert.ok(is.buffer(some_buffer), + 'should return true because it is a buffer') + assert.ok(!is.buffer(string), + 'should return false because a string is not a buffer') + }) + + test('is.symbol', () => { + const string = 'foo bar' + assert.ok(is.symbol(Symbol(string)), + 'should return true because it is a symbol') + assert.ok(!is.symbol(string), + 'should return false because it is a string') + }) +}) diff --git a/tests/unit/utils/log.test.js b/tests/unit/utils/log.test.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js new file mode 100644 index 0000000..8a839c9 --- /dev/null +++ b/tests/unit/utils/to.test.js @@ -0,0 +1,308 @@ +import to from '../../../app/utils/to.js' +import asyncSuite from '../../../tools/async-suite.js' +import fs from 'fs-extra' +import promisify from 'es6-promisify' +fs.readFile = promisify(fs.readFile) +import assert from 'core-assert' +const string = 'yo this is a string' +const array = [ 'one', 'two', 'three' ] +const object = { one: 1, two: 2, three: 3 } +const buffer = new Buffer(string) +const number = 4 +const boolean = false +const file = `${process.cwd()}/tests/file-types/coffeescript/test.coffee` + +asyncSuite.wrap('to', () => { + test('to.string', async () => { + assert.strictEqual(typeof to.string(string), 'string', + '`string` should be converted to a typeof string') + assert.strictEqual(typeof to.string(array), 'string', + '`array` should be converted to a typeof string') + assert.strictEqual(typeof to.string(buffer), 'string', + '`buffer` should be converted to a typeof string') + assert.strictEqual(typeof to.string(await fs.readFile(file)), 'string', + '`read file` should be converted to a typeof string') + assert.strictEqual(typeof to.string(object), 'string', + '`object` should be converted to a typeof string') + assert.strictEqual(typeof to.string(number), 'string', + '`number` should be converted to a typeof string') + assert.strictEqual(typeof to.string(boolean), 'string', + '`boolean` should be converted to a typeof string') + }) + + test('to.random', () => { + let array_test = [ 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray' ] + + for (let i = 0; i < 1000; i++) { + let random_array_item = to.random(array_test) + assert.ok(array_test.indexOf(random_array_item) > -1) + } + + for (let i = -1000; i < 1000; i++) { + let random_number = to.random(i, 1000) + assert.ok(random_number >= i && random_number <= 1000) + } + }) + + + test('to.normalString', async () => { + let result + try { + // this file has some stupid ass characters in it + // that need to be removed in order to become like the + // rest of the fucking world. #microsoftBlowsAtStandards + const crappy_windows_file = await fs.readFile(file) + result = to.normalString(crappy_windows_file).match(/\r/g) + assert.equal(result, null, + 'should be a normal string') + } catch (err) { + assert.fail(result, null, 'the file didn\'t load') + console.log(err.stack) + } + }) + + + test('to.type', () => { + assert.strictEqual(to.type(string), 'string') + assert.strictEqual(to.type(array), 'array') + assert.strictEqual(to.type(object), 'object') + assert.strictEqual(to.type(buffer), 'buffer') + assert.strictEqual(to.type(number), 'number') + assert.strictEqual(to.type(boolean), 'boolean') + }) + + + test('to.keys', () => { + const keys = to.keys(object) + assert.strictEqual(keys[0], 'one', 'should return one') + assert.strictEqual(keys[1], 'two', 'should return two') + assert.strictEqual(keys[2], 'three', 'should return three') + }) + + test('to.values', () => { + assert.deepStrictEqual(to.values(object), [ 1, 2, 3 ]) + assert.deepStrictEqual(to.values(object, '!one'), [ 2, 3 ]) + assert.deepStrictEqual(to.values(object, 'one', 'two'), [ 1, 2 ]) + }) + + + test('to.entries', () => { + for (const [ i, item ] of to.entries(array)) { + assert.ok(typeof i, 'number', '`i` should be a number') + assert.ok(typeof item, 'string', '`i` should be a string') + } + }) + + + test('to.objectEntries', () => { + for (const { key, one, two, three } of to.objectEntries({ test: object })) { + assert.strictEqual(key, 'test', 'The key should be `test`') + assert.strictEqual(one, 1, '`one` should equal 1') + assert.strictEqual(two, 2, '`two` should equal 2') + assert.strictEqual(three, 3, '`three` should equal 3') + } + }) + + + test('to.normalize', () => { + const actual = ` + .foo { + background: blue; + } + ` + const expected = [ '.foo {', ' background: blue;', '}' ].join('\n') + + assert.strictEqual(to.normalize(actual), expected, 'all whitespace should be stripped') + assert.ok(actual.split('\n')[2].length > 19, 'should be greater than 19') + assert.strictEqual(to.normalize(actual).split('\n')[1].length, 19, 'should be 19') + }) + + + test('to.extend', () => { + const temp = to.extend({}, object) + assert.deepEqual(object, object, + 'should equal each other, because they\'re the same') + assert.deepEqual(temp, object, + 'should be the same as the first object') + assert.strictEqual(to.extend(temp, { one: 3 }).one, 3, + '`one` should be equal to 3') + }) + + + test('to.clone', () => { + const actual = { one: { two: { three: { four: { five: 'whatup' } } } } } + const expected = { one: { two: { three: { four: { five: 'whatup' } } } } } + const test_one = to.clone(actual) + test_one.test = 'yo' + assert.ok(actual.test === undefined, + '`acutal.test` should not be defined') + assert.ok(test_one.test === 'yo', + '`test_one.test` should equal yo') + assert.deepEqual(actual, expected, + 'the actual object should remain the same as the expected object') + }) + + + test('to.merge', () => { + const a = { + foo: { + bar: '1', + baz: [ '3', '4' ], + qux: 'one', + quux: { garply: { waldo: 'one' } }, waldo: '' + } + } + const b = { + foo: { + bar: '2', + baz: [ '5', '6' ], + qux: [ 'two', 'three' ], + quux: { garply: { waldo: 'two' } }, + waldo() { + return this + }, + garply: 'item' + } + } + assert.strictEqual(a.foo.bar, '1', 'a.foo.bar should be 1') + to.merge(a, b) + assert.ok(Array.isArray(a.foo.bar), 'a.foo.bar should be an array') + assert.ok(Array.isArray(a.foo.baz), 'a.foo.baz should be an array') + assert.ok(Array.isArray(a.foo.quux.garply.waldo), + 'a.foo.quux.garply.waldo should be an array') + }) + + test('to.filter', () => { + assert.deepStrictEqual( + to.filter(array, (obj) => obj !== 'one'), + [ 'two', 'three' ] + ) + assert.deepStrictEqual( + to.filter(array, (obj) => obj !== 'two'), + [ 'one', 'three' ] + ) + assert.deepStrictEqual( + to.filter(object, ({ key }) => key !== 'one'), + { two: 2, three: 3 } + ) + assert.deepStrictEqual( + to.filter(object, ({ value }) => value !== 1), + { two: 2, three: 3 } + ) + }) + + test('to.map', () => { + assert.deepStrictEqual( + to.map(array, (item) => item + ' test'), + [ 'one test', 'two test', 'three test' ] + ) + assert.deepStrictEqual( + to.map(object, ({ key, value }) => { + return { [`${key} test`]: value } + }), + { 'one test': 1, 'two test': 2, 'three test': 3 } + ) + }) + + test('to.reduce', () => { + assert.deepStrictEqual( + to.reduce([ object, object, object ], (previous, next) => to.extend(previous, next), {}), + object + ) + + assert.deepStrictEqual( + to.reduce(object, (previous, { key }) => { + return [ ...previous, key ] + }, []), + array + ) + }) + + + test('to.object', async () => { + try { + const json = await fs.readFile(`${process.cwd()}/package.json`) + assert.ok(to.object(json).author, + 'the passed json should now be an object') + } catch (err) { + console.log(err.stack) + } + }) + + + test('to.json', () => { + const obj = { foo: 'foo', bar: 'foo' } + assert.strictEqual(typeof obj, 'object', + 'the test object should be an object') + assert.strictEqual(typeof to.json(obj), 'string', + 'should be a json string') + }) + + + test('to.array', () => { + assert.ok(Array.isArray(array), + 'array should should be an array') + assert.ok(Array.isArray(to.array(array)), + 'array should be be returned with no changes') + assert.ok(!Array.isArray(string), + 'string should not be an array') + assert.ok(Array.isArray(to.array(string)), + 'string should be converted to a type of array') + assert.ok(!Array.isArray(object), + 'object should not be an array') + assert.ok(Array.isArray(to.array(object)), + 'object should be converted to a type of array') + assert.ok(!Array.isArray(number), + 'number should not be an array') + assert.ok(Array.isArray(to.array(number)), + 'number should be converted to a type of array') + }) + + + test('to.flatten', () => { + assert.strictEqual(to.flatten([ [ [ array ] ] ])[0], 'one', + 'the array should be flattend and the first value should be one') + }) + + + test('to.unique', () => { + assert.strictEqual(to.unique([ 'one', 'one', 'two', 'two' ]).length, 2, + 'should have a length of 2') + }) + + + test('to.sort', () => { + const acutal_object = { + c: 1, + b: 2, + a: 3 + } + const actual_array = [ 3, 2, 1 ] + + assert.strictEqual(Object.keys(acutal_object)[0], 'c', + 'c should be the first key in the object') + assert.strictEqual(Object.keys(to.sort(acutal_object))[0], 'a', + 'a should be the first key in the object after it\'s sorted') + + assert.strictEqual(actual_array[0], 3) + assert.strictEqual(to.sort(actual_array)[0], 1) + }) + + + test('to.number', () => { + assert.strictEqual(to.number(4), 4, + 'should be 4') + assert.strictEqual(to.number([ 'a', 'b', 'c' ]), 3, + 'should be 3') + assert.strictEqual(to.number({ a: 1, b: 2, c: 3 }), 3, + 'should be 3') + assert.strictEqual(to.number('foo'), 0, + 'should be 0') + assert.strictEqual(to.number('10'), 10, + 'should be 10') + assert.strictEqual(to.number(false), 0, + 'should be 0') + assert.strictEqual(to.number(true), 1, + 'should be 1') + }) +}) diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..7e2f6ab --- /dev/null +++ b/tools/README.md @@ -0,0 +1,3 @@ +# Tools + +This folder contains files that are used to help with the development/testing process. None of these files are used in the app it's self. diff --git a/tools/async-suite.js b/tools/async-suite.js new file mode 100644 index 0000000..9fa09ea --- /dev/null +++ b/tools/async-suite.js @@ -0,0 +1,31 @@ +/// @name Async Suite +/// @description +/// This is function is used to create async suites for mocha +/// @arg {string} name - the name of the suite +async function asyncSuite(name, ...callbacks) { + let result + + try { + for (let callback of callbacks) { + callback = callback(result) + + result = await (callback && callback.then ? callback : Promise.resolve(callback)) // eslint-disable-line + // if (callback) { + // } else {} + } + } catch (err) { + console.log(err) + } + + suite(name, result) + + // run mocha-tests + run() // eslint-disable-line +} + +asyncSuite.wrap = (name, callback) => { + asyncSuite(name, () => callback) +} + + +export default asyncSuite diff --git a/tools/generate-test.js b/tools/generate-test.js new file mode 100755 index 0000000..d5de721 --- /dev/null +++ b/tools/generate-test.js @@ -0,0 +1,125 @@ +#!/usr/bin/env node +/* eslint-disable prefer-arrow-callback, func-names, no-shadow, babel/object-shorthand */ +'use strict' + + +var docs = require('..').default +var Tokenizer = require('../dist/parser/tokenizer.js').default +var path = require('path') +var clor = require('clor') +var utils = require('../dist/utils') +var argv = process.argv.slice(2) +const root = process.cwd() + +utils.glob(argv, [ 'tests/**/*.json' ]) + .then(function(files) { + var promises = [] + for (var i = 0; i < files.length; i++) { + promises.push(sortTest(path.join(root, files[i]))) + } + + return Promise.all(promises) + }) + .then(function(parsed) { + for (var i = 0; i < parsed.length; i++) { + console.log(' ', (i + 1) + ':', parsed[i]) + } + }) + + + +function sortTest(file) { + var type = file.match(/(?:tests\/)([a-z\-]*)/)[1] + + switch (type) { + case 'cases': + case 'file-types': + return caseTest(file) + case 'tokenizer': + return tokenizerTest(file) + case 'annotations': + return annotationTest(file) + default: + return Promise.resolve(clor.yellow(file + " isn't a test")) + } +} + +function output(file, data) { + return utils.fs.outputJson( + file.replace(path.extname(file), '.json'), + data, + { spaces: 2 } + ) +} + + +function annotationTest(file) { + return new Promise(function(resolve) { + docs({ + files: file, + warning: false, + debug: false, + timestamps: false, + raw: true, + ignore: '.*' + }) + .then(function(parsed) { + return output(file, parsed[file]) + }) + .then(function() { + resolve(clor.green(file) + '') + }) + .catch(function(err) { + console.trace(err) + resolve(clor.red(file) + '') + }) + }) +} + + + +function caseTest(file) { + return new Promise(function(resolve) { + docs({ + files: file, + warning: false, + debug: false, + timestamps: false, + ignore: '.*' + }) + .then(function(parsed) { + return output(file, parsed) + }) + .then(function() { + resolve(clor.green(file) + '') + }) + .catch(function(err) { + console.trace(err) + resolve(clor.red(file) + '') + }) + }) +} + + +var tokenizerHelper = require('../tools/tokenizer-helper.js') +function tokenizerTest(file) { + return new Promise(function(resolve) { + tokenizerHelper(file) + .then(function(obj) { + let result + try { + result = new Tokenizer(obj.str, obj.comment) + } catch (e) { + console.trace(e.stack) + } + return output(file, result) + }) + .then(function() { + resolve(clor.green(file) + '') + }) + .catch(function(err) { + console.trace(err) + resolve(clor.red(file) + '') + }) + }) +} diff --git a/tools/tokenizer-helper.js b/tools/tokenizer-helper.js new file mode 100644 index 0000000..bcddc5b --- /dev/null +++ b/tools/tokenizer-helper.js @@ -0,0 +1,90 @@ +// this file is disabled because it has to use es5 syntax because it doesn't get compiled. +/* eslint-disable */ + +// This holds the different comment types to be used by the `tokenizer`. +// It's based off the folder path for example +// `comment_types['single-line'].slash` is for `tests/tokenizer/single-line/slash` +// If you need to add new tests with different comment types just add it to this +// object and create the folder path if needed, or just add your test to the correct +// folder and then generate them. +var comment_types = { + 'css-like': { + 'multi-single-line': { + comment: { start: '', line: '///', end: '' } + }, + 'single-line': { + comment: { start: '', line: '///#', end: '' } + }, + 'start-end': { + comment: { start: '////', line: '///', end: '////' } + }, + }, + 'css': { + 'single-line': { + comment: { start: '/*#', line: '', end: '*/' } + }, + 'start-end': { + comment: { start: '/*', line: '*', end: '*/' } + }, + }, + 'hash-style': { + 'multi-single-line': { + comment: { start: '', line: '##', end: '' } + }, + 'single-line': { + comment: { start: '', line: '##$', end: '' } + }, + 'start-end': { + comment: { start: '###', line: '##', end: '###' } + }, + }, + 'html': { + 'start-end': { + comment: { start: '' } + }, + 'single-line': { + comment: { start: '' } + } + }, + 'js': { + 'single-line': { + comment: { start: '', line: '///', end: '' } + }, + 'start-end': { + comment: { start: '////', line: '///', end: '////' } + }, + }, +} +var path = require('path') +var fs = require('fs') + +function getTokenizerOption(file) { + var type = file.split(/tests\//).pop().split(path.sep).slice(1, -1) + var comment = type.reduce(function(prev, current) { + var result = (prev || {})[current] + if (!result) { + return (prev || {})[current.replace('-with-code', '')] + } + + return result + }, comment_types) + + return comment || {} +} + +module.exports = exports = function tokenizerHelper(file) { + return new Promise(function(resolve, reject) { + fs.readFile(file, function(err, str) { + if (err) { + console.trace(err) + reject(err) + } + str += '' + + resolve({ + str: str, + comment: getTokenizerOption(file) + }) + }) + }) +}