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${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 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": ".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": ".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": ".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": ".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": ".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": ".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": ".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": ".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": ".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": ".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": ".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": "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": "Modifier state for example 1, state 1
\n\nHover state for example 1, state 1
\nModifier 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": "Modifier state for example 1, state 2
\n\nFocus state for example 1, state 2
\nModifier 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": "Modifier state for example 1, state 3
\n\nActive state for example 1, state 3
\nModifier 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": "Modifier state for example 2, state 1
\n\nHover state for example 2, state 1
\nModifier 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": "Modifier state for example 2, state 2
\n\nFocus state for example 2, state 2
\nModifier 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": "Modifier state for example 2, state 3
\n\nActive state for example 2, state 3
\nModifier 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": "Example 2
\n", + "raw": "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": "Modifier state for example 1, state 1
\n\nHover state for example 1, state 1
\nModifier 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": "Modifier state for example 1, state 2
\n\nFocus state for example 1, state 2
\nModifier 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": "Modifier state for example 1, state 3
\n\nActive state for example 1, state 3
\nModifier 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": "Modifier state for example 2, state 1
\n\nHover state for example 2, state 1
\nModifier 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": "Modifier state for example 2, state 2
\n\nFocus state for example 2, state 2
\nModifier 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": "Modifier state for example 2, state 3
\n\nActive state for example 2, state 3
\nModifier 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": "Example 2
\n", + "raw": "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": "Modifier state for example 1, state 1
\n\nHover state for example 1, state 1
\nModifier 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": "Modifier state for example 1, state 2
\n\nFocus state for example 1, state 2
\nModifier 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": "Modifier state for example 1, state 3
\n\nActive state for example 1, state 3
\nModifier 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": "Modifier state for example 2, state 1
\n\nHover state for example 2, state 1
\nModifier 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": "Modifier state for example 2, state 2
\n\nFocus state for example 2, state 2
\nModifier 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": "Modifier state for example 2, state 3
\n\nActive state for example 2, state 3
\nModifier 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": "Example 2
\n", + "raw": "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": "Modifier state for example 1, state 1
\n\nHover state for example 1, state 1
\nModifier 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": "Modifier state for example 1, state 2
\n\nFocus state for example 1, state 2
\nModifier 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": "Modifier state for example 1, state 3
\n\nActive state for example 1, state 3
\nModifier 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": "Modifier state for example 2, state 1
\n\nHover state for example 2, state 1
\nModifier 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": "Modifier state for example 2, state 2
\n\nFocus state for example 2, state 2
\nModifier 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": "Modifier state for example 2, state 3
\n\nActive state for example 2, state 3
\nModifier 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": "Example 2
\n", + "raw": "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": "Modifier state for example 1, state 1
\n\nHover state for example 1, state 1
\nModifier 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": "Modifier state for example 1, state 2
\n\nFocus state for example 1, state 2
\nModifier 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": "Modifier state for example 1, state 3
\n\nActive state for example 1, state 3
\nModifier 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": "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": "Modifier state
\n\nHover state for .something-super-awesome__item
\nModifier 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": "Modifier state
\n\nFocus state for .something-super-awesome__item
\nModifier 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": "Modifier state
\n\nActive state for .something-super-awesome__item
\nModifier 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": "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": "Modifier state
\n\nHover state for .something-super-awesome__item
\nModifier 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": "Hover state for example 1
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "Example 1
\n", + "raw": "Hover state for example 1
\n\nHover 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": "Focus state for example 1
\n\nFocus 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": "Hover state for example 2
\n\nHover 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": "Focus state for example 2
\n\nFocus state for example 2
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "Example 1
\n", + "raw": "Example 2
\n", + "raw": "Some super awesome description for the hover state
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "Example 1
\n", + "raw": "Some super awesome description for the focus state
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "Example 1
\n", + "raw": "Example 1
\n", + "raw": "Example 2
\n", + "raw": "Some super awesome description for the hover state
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description for the hover state
\n\nSome 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": "Some super awesome description for the focus state
\n\nSome 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": "Some super awesome description for the active state
\n\nSome super awesome description for the active state
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description for the hover state
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description for the hover state
\n\nSome 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": "Some super awesome description for the focus state
\n\nSome 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": "Some super awesome description for the active state
\n\nSome super awesome description for the active state
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description for the hover state
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description for the hover state
\n\nSome 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": "Some super awesome description for the focus state
\n\nSome 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": "Some super awesome description for the active state
\n\nSome super awesome description for the active state
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description
\n\nSome super awesome description
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description
\n\nSome super awesome description
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description
\n" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "Some super awesome description
\n\nSome super awesome description
\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "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": "EXAMPLE 1
\n", + "raw": "* EXAMPLE 2 *
\n", + "raw": "THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)
\nTHIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)
\n* EXAMPLE 2 *
\n", + "raw": "THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)
\nEXAMPLE 1
\n", + "raw": "EXAMPLE 1
\n", + "raw": "THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)
+///Success message with a single action
+// +//Success message with multiple actions
+//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": ".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 +///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. #includeLorem 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 #includemain 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 @@ +-----> +---->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. +#includeLorem 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": "appearance set to searchfield in Safari 5 and Chrome.box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).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
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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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": "| Attribute | \nValue | \n
|---|---|
| Description | \nName of the documented item | \n
| Multiple | \nfalse | \n
| Default | \n- | \n
| Aliases | \n- | \n
| Autofilled | \n- | \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 . "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 -///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": "appearance set to searchfield in Safari 5 and Chrome.box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).