From f9fe2b3ee0d97ddb7e71c7650131398b110487e8 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 5 Aug 2015 20:14:30 -0400 Subject: [PATCH 001/273] Updated documentation in utils, and added case functions --- app/utils.js | 459 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 294 insertions(+), 165 deletions(-) diff --git a/app/utils.js b/app/utils.js index 58549a2..003e9e7 100644 --- a/app/utils.js +++ b/app/utils.js @@ -79,33 +79,132 @@ export let to = { /// @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} + /// @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} + + case: { + /// @name to.case.clean + /// @description + /// Remove any starting case from a `string`, like camel or snake, but keep + /// spaces and punctuation that may be important otherwise. + /// + /// @arg {string} + /// @return {string} + clean: (str) => { + let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? " " + next : ""), + uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + " " + uppers.toLowerCase().split(" ").join(" ")); + + // a) has spaces + // b) has separator + return (/\s/.test(str) ? str : /[\W_]/.test(str) ? (unseparate(str) || str) : uncamelize(str)).toLowerCase(); + }, + + /// @name to.case.title + /// @description Converts a string to title case + /// @arg {string} + /// @returns {string} + title: (str) => { + // https://github.com/gouch/to-title-case/blob/master/to-title-case.js + var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; + + return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){ + if(index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" && (title.charAt(index + match.length) !== "-" || title.charAt(index - 1) === "-") && title.charAt(index - 1).search(/[^\s-]/) < 0){ + return match.toLowerCase(); + } + + if(match.substr(1).search(/[A-Z]|\../) > -1){ + return match; + } + + return match.charAt(0).toUpperCase() + match.substr(1); + }); + }, + + /// @name to.case.lower + /// @description Converts a string to lower case(aka `str.toLowerCase()`) + /// @arg {string} + /// @returns {string} + lower: (str) => str.toLowerCase(), + + /// @name to.case.upper + /// @description Converts a string to upper case(aka `str.toUpperCase()`) + /// @arg {string} + /// @returns {string} + upper: (str) => str.toUpperCase(), + + /// @name to.case.sentence + /// @description Converts a string to sentence case + /// @arg {string} + /// @returns {string} + sentence: (str) => to.case.clean(str).replace(/[a-z]/i, (letter) => letter.toUpperCase()), + + /// @name to.case.space + /// @description Replaces camel case, dot, and dash cases with a space + /// @arg {string} + /// @returns {string} + space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? " " + match : ""), + + /// @name to.case.snake + /// @description Converts a string to snake case + /// @arg {string} + /// @returns {string} + snake: (str) => to.case.space(str).replace(/\s/g, "_"), + + /// @name to.case.dash + /// @description Converts a string to dash case + /// @arg {string} + /// @returns {string} + dash: (str) => to.case.space(str).replace(/\s/g, "-"), + + /// @name to.case.dot + /// @description Converts a string to dot case + /// @arg {string} + /// @returns {string} + dot: (str) => to.case.space(str).replace(/\s/g, "."), + + /// @name to.case.swap + /// @description Converts capital letters to lower case and vice versa + /// @arg {string} + /// @returns {string} + swap: (str) => { + str.split("").map((c) => { + let u = letter.toUpperCase(); + return c === u ? c.toLowerCase() : u; + }).join(""); + } + }, + + + /// @name to.normal_string + /// @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 + normal_string: (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} + /// @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 @@ -132,7 +231,7 @@ export let to = { .join("\n").replace(/[^\S\r\n]+$/gm, ""); // convert to string and remove all trailing white spaces }, - /// @name extend + /// @name to.extend /// @description /// Extend object `b` onto `a` /// http://jsperf.com/deep-extend-comparison @@ -241,13 +340,13 @@ export let to = { 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] : [], + /// @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] : [], @@ -263,11 +362,11 @@ export let to = { 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 + /// @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; @@ -286,56 +385,56 @@ export let to = { return result; }, - // @name to.regex - // @description - // Converts `...args` to regex - // @returns {string} - // - // @markup {js} - // new RegExp(":((" + to.regex(")|(", "link", "visited", "hover") + "))", "gi"); + /// @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} + /// @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} + /// @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} + /// @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} + /// @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} +/// @name to.array.flat +/// @description +/// Flattens an array, and arrays inside of it into a single array +/// @arg {array} +/// @returnes {array} - single dimensional to.array.flat = (arg) => [].concat.apply([], to.array(arg)); -// @name to.array.unique -// @description -// Removes duplicate values from an array -// @arg {array} -// @returns {array} +/// @name to.array.unique +/// @description +/// Removes duplicate values from an array +/// @arg {array} +/// @returns {array} - without duplicates to.array.unique = (arg) => { let o = {}, r = []; @@ -348,55 +447,59 @@ to.array.unique = (arg) => { 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 + /// @name is.argument + /// @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 + /// @name is.regex + /// @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 + /// @name is.function + /// @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 + /// @name is.array + /// @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 + /// @name is.boolean + /// @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 + /// @name is.object + /// @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 + /// @name is.json + /// @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 + /// @name is.empty + /// @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)){ @@ -411,101 +514,127 @@ export let is = { } }, - // @description is a given value existy? - // @arg {*} arg - The item to check - // @returns {boolean} - The result of the test + /// @name is.exsity + /// @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 + /// @name is.string + /// @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} + /// @name is.undefined + /// @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} + /// @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` + /// @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} + /// @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} 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} + /// @name is.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} + /// @name is.truthy + /// @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} + /// @name is.falsy + /// @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 + /// @name is.nan + /// @description NaN is number, also it is the only arg which does not equal itself + /// @arg {*} arg + /// @returns {boolean} nan: (arg) => arg !== arg, - // @description is given arg a number? - // @arg {*} arg - // @returns {boolean} + /// @name is.number + /// @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? + /// @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} 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} + /// @name is.positive + /// @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} + /// @name is.negative + /// @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} + /// @name is.above + /// @description is a given number above minimum parameter? + /// @arg {*} arg + /// @arg {number} min [-1] + /// @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} + /// @name is.under + /// @description is a given number above maximum parameter? + /// @arg {*} arg + /// @arg {number} max [100] + /// @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} + /// @name is.null + /// @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) + /// @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} + promise: (arg) => arg && is.function(arg.then), + + /// @name is.stream + /// @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), + + /// @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} + buffer: (arg) => Buffer.isBuffer(arg) }; // included method does not support `all` and `any` interfaces From 3da88a2f399dce08d9006be13c2e127802880557 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 5 Aug 2015 21:15:36 -0400 Subject: [PATCH 002/273] Updated parser to reduce one level of data This Is to reduce the nesting of the data so there doesn't have to be as many for loops to loop over each data set --- app/parser.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/parser.js b/app/parser.js index aafb376..ea678d3 100644 --- a/app/parser.js +++ b/app/parser.js @@ -361,13 +361,11 @@ export default function(file_path, settings, api){ delete file.contents; resolve({ - [file.type]: { - [file.path]: { - file, - header, - body - } - } + [file.type]: [{ + file, + header, + body + }] }); }) .catch(err => { From e3d4668b6a4b4b2b01abd5bf8a1aeeb610b24027 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 5 Aug 2015 21:18:59 -0400 Subject: [PATCH 003/273] Updated `to.merge` This adds a check to see if an object exists in the first item in the array. --- app/utils.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/utils.js b/app/utils.js index 003e9e7..764723d 100644 --- a/app/utils.js +++ b/app/utils.js @@ -301,7 +301,7 @@ export let to = { /// garply: "item" // didn't exist before so it stays as a string /// } /// } - merge: (a, b, unique = true) => { + merge: (a, b, unique = true, flat = true) => { // a) Don't touch `null` or `undefined` objects. if(!a || !b){ return a; @@ -329,9 +329,17 @@ export let to = { 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])); + // a) is array + if(is.array(a[k])){ + // a) Flatten the array + if(flat){ + a[k] = to.array.flat(a[k]); + } + + // a) Filter out duplicates + if(unique && !is.object(a[k][0])){ + a[k] = to.array.unique(a[k]); + } } } From 748b8fc361cd2f41c5e5e44b4cd7237b26a5108c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 5 Aug 2015 21:19:19 -0400 Subject: [PATCH 004/273] Removed `path` because it's not used in the file --- app/docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/docs.js b/app/docs.js index 2b4e2a8..f64da8c 100755 --- a/app/docs.js +++ b/app/docs.js @@ -1,5 +1,5 @@ "use strict"; -import {info, fs, path, is, to} from "./utils.js"; +import {info, fs, is, to} from "./utils.js"; import paths from "./paths.js"; import AnnotationApi from "./annotation"; import parser from "./parser.js"; From 4611e935989e8570b08d46929274c9b0b25dad08 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 5 Aug 2015 21:19:41 -0400 Subject: [PATCH 005/273] Changed to use `to.merge` instead of `to.extend` --- app/docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/docs.js b/app/docs.js index f64da8c..2691dbd 100755 --- a/app/docs.js +++ b/app/docs.js @@ -131,7 +131,7 @@ var docs = (function(){ // Loop through the parsed files and update the // json data that was stored. for(let data in parsed_files){ - to.extend(json, parsed_files[data]); + to.merge(json, parsed_files[data], false); } resolve(json); From 8fda439d73a45d2dc4a83b811ea1cea8641dc2ae Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 6 Aug 2015 10:05:08 -0400 Subject: [PATCH 006/273] Updated `to.keys` to get symbols as well --- app/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/utils.js b/app/utils.js index 764723d..1a5c68b 100644 --- a/app/utils.js +++ b/app/utils.js @@ -195,10 +195,11 @@ export let to = { /// @name to.keys /// @description - /// Converts an object to an array of it's key names + /// 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) => is.object(arg) && Object.getOwnPropertyNames(arg), + keys: (arg) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), /// @name to.json /// @description From 196b5ede07912b411c08f85be4d639fc8f7c63cd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 6 Aug 2015 10:07:24 -0400 Subject: [PATCH 007/273] Added `to.entries` This fuction uses the `Symbol.interator` functionality which is pretty bad ass. It allows you to make looping over objects, and arrays 100x easier. --- app/utils.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/app/utils.js b/app/utils.js index 1a5c68b..90fa7f8 100644 --- a/app/utils.js +++ b/app/utils.js @@ -201,6 +201,67 @@ export let to = { /// @returns {array} keys: (arg) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + /// @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) => { + if(is.array(obj)){ + return obj.entries(); + } + + let index = 0, + // 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. + keys = to.keys(obj); + + return { + [Symbol.iterator](){ + return this; + }, + next(){ + if(index < keys.length){ + let key = keys[index]; + index++; + return { + value: [key, obj[key]] + }; + }else{ + return { + done: true + }; + } + } + }; + }, + /// @name to.json /// @description /// Converts an object to a json string From 857c9dbd8af5d599ad812e7b4e74634aea6db2b4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 6 Aug 2015 10:07:46 -0400 Subject: [PATCH 008/273] Added `is.symbol` just incase --- app/utils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/utils.js b/app/utils.js index 90fa7f8..c22afa0 100644 --- a/app/utils.js +++ b/app/utils.js @@ -560,6 +560,12 @@ export let is = { /// @returns {boolean} - The result of the test object: arg => typeof arg === "object" && !!arg && arg !== null, + /// @name is.symbol + /// @description is a given arg a symbol? + /// @arg {*} arg - The item to check + /// @returns {boolean} - The result of the test + symbol: (arg) => typeof arg === "symbol", + /// @name is.json /// @description is given value a pure JSON object? /// @arg {*} arg - The item to check From 10d43924cf51e3758981deceb7f4be97d9bdf664 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 6 Aug 2015 10:09:10 -0400 Subject: [PATCH 009/273] Added a catch to the `_.parser` return promise. --- app/docs.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/docs.js b/app/docs.js index 2691dbd..4668d90 100755 --- a/app/docs.js +++ b/app/docs.js @@ -175,6 +175,10 @@ var docs = (function(){ reject({}); throw new Error(err); }); + }) + .catch((err) => { + reject({}); + throw new Error(err); }); }; From f912bc7cd95ad9e601f1775cd7feeac2a5eb1ec6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 6 Aug 2015 19:21:23 -0400 Subject: [PATCH 010/273] Renamed key in return object for parser --- app/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/parser.js b/app/parser.js index ea678d3..eda116b 100644 --- a/app/parser.js +++ b/app/parser.js @@ -362,7 +362,7 @@ export default function(file_path, settings, api){ resolve({ [file.type]: [{ - file, + info: file, header, body }] From e708040321925e61cab389bd017049b6cdfc7615 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 6 Aug 2015 19:23:33 -0400 Subject: [PATCH 011/273] Added the sorter function This isn't complete, it's just the start of the sorter function. This function will sort the blocks out into their respective files and create the navigation --- app/docs.js | 7 ++++++- app/sorter.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/sorter.js diff --git a/app/docs.js b/app/docs.js index 4668d90..cac189a 100755 --- a/app/docs.js +++ b/app/docs.js @@ -3,6 +3,7 @@ import {info, fs, is, to} from "./utils.js"; import paths from "./paths.js"; import AnnotationApi from "./annotation"; import parser from "./parser.js"; +import sorter from "./sorter.js"; //// /// @name docs.js @@ -15,7 +16,8 @@ var docs = (function(){ let _ = { is, to, - annotation: new AnnotationApi() + annotation: new AnnotationApi(), + sorter }; // the settings object that holds the file specific settings as well as the base settings @@ -148,6 +150,9 @@ var docs = (function(){ }) .then((json) => { console.timeEnd("total-runtime"); // ends the timer for the total runtime + + _.sorter(json); + resolve({ /// @name parse().data /// @description Placeholder for the data so if it's manipulated the updated data will be in the other functions diff --git a/app/sorter.js b/app/sorter.js new file mode 100644 index 0000000..67718e2 --- /dev/null +++ b/app/sorter.js @@ -0,0 +1,35 @@ +import {info, fs, path, is, to} from "./utils.js"; + +/// @name sort +/// @description +/// Sorts the parsed data into pages and creates the navigation +/// @arg {object} +/// @returns {object} +export default function(json){ + to.log("SORT /////////////////////////////////////////////////////////////////////////"); + let result = {}, + _settings = { + // todo: true, // create a todo page with ALL the todo comments listed + }; + + // loop over each filetype in the json object + for(let [filetype, files] of to.entries(json)){ + if(filetype === "less"){ + // loop over each file in the filetype object + for(let file of files){ + + // a) set the page to be the filepath + if(is.undefined(file.header.page)){ + + } + + // loop over each block in the body of the file + for(let block of file.body){ + + } + } + } + } + // to.log(""); + return json; +}; \ No newline at end of file From 2394042ccad6aaa6223eb00dc3792561baed340a Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 7 Aug 2015 16:12:52 -0400 Subject: [PATCH 012/273] Ensures header is always defined in the data set This way I don't have to check for it. --- app/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/parser.js b/app/parser.js index eda116b..ec7f4a6 100644 --- a/app/parser.js +++ b/app/parser.js @@ -363,7 +363,7 @@ export default function(file_path, settings, api){ resolve({ [file.type]: [{ info: file, - header, + header: header || {}, body }] }); From 434513cebc4a92cef4c030e4fef24a56ea49ad3b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 7 Aug 2015 23:28:09 -0400 Subject: [PATCH 013/273] Updated `sorter` Figured out the best way to create the data without having to loop over it multiple times. This still isn't complete but a big piece of it is complete. --- app/docs.js | 8 +++- app/sorter.js | 102 +++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 96 insertions(+), 14 deletions(-) diff --git a/app/docs.js b/app/docs.js index cac189a..3e306b5 100755 --- a/app/docs.js +++ b/app/docs.js @@ -149,9 +149,13 @@ var docs = (function(){ }); }) .then((json) => { + console.time("sorter-runtime"); + return Promise.resolve(_.sorter(json)); + }) + .then((json) => { + console.timeEnd("sorter-runtime"); console.timeEnd("total-runtime"); // ends the timer for the total runtime - _.sorter(json); resolve({ /// @name parse().data @@ -178,11 +182,13 @@ var docs = (function(){ }) .catch((err) => { reject({}); + to.log(err); throw new Error(err); }); }) .catch((err) => { reject({}); + to.log(err); throw new Error(err); }); }; diff --git a/app/sorter.js b/app/sorter.js index 67718e2..0bdf7c1 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -6,30 +6,106 @@ import {info, fs, path, is, to} from "./utils.js"; /// @arg {object} /// @returns {object} export default function(json){ - to.log("SORT /////////////////////////////////////////////////////////////////////////"); - let result = {}, + let obj = {}, + result = { + nav: {}, // holds the navigation for the pages + pages: {} // holds the pages of documentation + }, _settings = { + header: { + // This can be file "type", "", false if you always + // want to go with what's declared in the page. + prepend_type: true + }, + body: { + // same as `header.page_prepend` but this is for body comment blocks + prepend_type: false + } // todo: true, // create a todo page with ALL the todo comments listed + }, + // @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 schema = obj, + path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings + length = path_list.length - 1; + + for(var i = 0; i < length; i++){ + var elem = path_list[i]; + if(!schema[elem]){ + schema[elem] = { + page: { + header: {}, + body: [] + } + }; + } + schema = schema[elem]; + } + + // a) Define the default data set(can't use `page` because it will be overwritten) + if(!schema[path_list[length]]){ + schema[path_list[length]] = { + header: {}, + body: [] + }; + } + + if(type === "header"){ + schema[path_list[length]].header = to.merge(schema[path_list[length]].header, value); + }else{ + schema[path_list[length]].body.push(value); + } }; + // loop over each filetype in the json object for(let [filetype, files] of to.entries(json)){ - if(filetype === "less"){ - // loop over each file in the filetype object - for(let file of files){ + // loop over each file in the filetype object + for(let file of files){ + // a) Ensures there's only one page defined in the header + // b) There wasn't a page defined so set it to general + file.header.page = file.header.page ? file.header.page[0] : "general"; - // a) set the page to be the filepath - if(is.undefined(file.header.page)){ + // a) Prepend the filetype to the page + if(is.truthy(_settings.header.prepend_type)){ + file.header.page = path.join(file.info.type, file.header.page); + } - } + // set the header for the file + set(file.header.page, "header", file.header); - // loop over each block in the body of the file - for(let block of file.body){ - + // console.log(file.header.page); + // loop over each block in the body of the file + for(let block of file.body){ + // a) loop over each page in the block, + // and add the block to that page. + if(block.page){ + for(let page of block.page){ + if(page !== file.header.page){ + set(page, "body", block); + } + } } + + // add the block to the page + set(file.header.page, "body", block); } } } - // to.log(""); - return json; + + console.log(to.json(obj)); + + return obj; }; \ No newline at end of file From 01d9710c41d2ce7e8dd6b5c32eae8f5ff3ec02e9 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 7 Aug 2015 23:29:30 -0400 Subject: [PATCH 014/273] Updated `page` annotation to always return an array This makes it easier to loop over the result data. --- app/annotation/annotations/page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/annotation/annotations/page.js b/app/annotation/annotations/page.js index 4209fd0..5da39c8 100644 --- a/app/annotation/annotations/page.js +++ b/app/annotation/annotations/page.js @@ -6,7 +6,7 @@ export default { page: { alias: ["group"], callback: function(){ - return this.annotation.line; + return [this.annotation.line]; } } }; From 56452cbb8795cf39cbe2caebc6969d8b9279a3dc Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 8 Aug 2015 10:14:57 -0400 Subject: [PATCH 015/273] Added a fix to ensure a name is defined for the header --- app/sorter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/sorter.js b/app/sorter.js index 0bdf7c1..13f2e73 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -83,6 +83,11 @@ export default function(json){ file.header.page = path.join(file.info.type, file.header.page); } + // a) Set the name in the header to be the name of the file + if(is.falsy(file.header.name)){ + file.header.name = to.case.title(file.info.name); + } + // set the header for the file set(file.header.page, "header", file.header); From 6c238b66514df1fe20c4e7c08aa9d1fa1c38d73b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 8 Aug 2015 10:15:25 -0400 Subject: [PATCH 016/273] Fixed to put the declared value in a page object --- app/sorter.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/sorter.js b/app/sorter.js index 13f2e73..4c93735 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -55,17 +55,19 @@ export default function(json){ } // a) Define the default data set(can't use `page` because it will be overwritten) - if(!schema[path_list[length]]){ - schema[path_list[length]] = { - header: {}, - body: [] + if(!_pages[path_list[length]]){ + _pages[path_list[length]] = { + page: { + header: {}, + body: [] + } }; } if(type === "header"){ - schema[path_list[length]].header = to.merge(schema[path_list[length]].header, value); + _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); }else{ - schema[path_list[length]].body.push(value); + _pages[path_list[length]].page.body.push(value); } }; From f1795bac7cb7cb1c4ae3152c0fe450240b405982 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 8 Aug 2015 11:03:07 -0400 Subject: [PATCH 017/273] Added `fs` to the output --- app/docs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/docs.js b/app/docs.js index 3e306b5..c682ab9 100755 --- a/app/docs.js +++ b/app/docs.js @@ -17,7 +17,8 @@ var docs = (function(){ is, to, annotation: new AnnotationApi(), - sorter + sorter, + fs }; // the settings object that holds the file specific settings as well as the base settings From 5903e0f6eb8d004edde4990041407f5b5b569d24 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 8 Aug 2015 11:06:08 -0400 Subject: [PATCH 018/273] Updated variable names to match the data that's being added to it. --- app/sorter.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/sorter.js b/app/sorter.js index 4c93735..dec85e3 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -6,11 +6,8 @@ import {info, fs, path, is, to} from "./utils.js"; /// @arg {object} /// @returns {object} export default function(json){ - let obj = {}, - result = { - nav: {}, // holds the navigation for the pages - pages: {} // holds the pages of documentation - }, + let nav = {}, // holds the navigation for the pages + pages = {}, // holds the pages of documentation _settings = { header: { // This can be file "type", "", false if you always @@ -37,21 +34,22 @@ export default function(json){ // won't get added to the data delete value.page; - let schema = obj, + let _pages = pages, + _nav = nav, path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings length = path_list.length - 1; for(var i = 0; i < length; i++){ var elem = path_list[i]; - if(!schema[elem]){ - schema[elem] = { + if(!_pages[elem]){ + _pages[elem] = { page: { header: {}, body: [] } }; } - schema = schema[elem]; + _pages = _pages[elem]; } // a) Define the default data set(can't use `page` because it will be overwritten) @@ -112,7 +110,8 @@ export default function(json){ } } - console.log(to.json(obj)); - - return obj; + return { + nav, + pages + }; }; \ No newline at end of file From 0c6a4e87e8a0588e19456f8370c0148a756960d7 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 8 Aug 2015 20:29:13 -0400 Subject: [PATCH 019/273] Added better error handling --- .jscsrc | 1 - app/docs.js | 64 ++++++++++++++++++++-------------------------------- app/utils.js | 59 ++++++++++++++++++++++++++++++++++++++++++++---- package.json | 1 + 4 files changed, 79 insertions(+), 46 deletions(-) diff --git a/.jscsrc b/.jscsrc index e6b7096..febfa26 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,5 +1,4 @@ { - "disallowEmptyBlocks": true, "disallowIdentifierNames": ["foo", "bar", "baz", "qux"], "disallowKeywords": ["with"], "disallowMixedSpacesAndTabs": "smart", diff --git a/app/docs.js b/app/docs.js index c682ab9..d7f218e 100755 --- a/app/docs.js +++ b/app/docs.js @@ -1,5 +1,11 @@ "use strict"; -import {info, fs, is, to} from "./utils.js"; + +process.on("uncaughtException", function(err){ + log.error("An uncaughtException was found:", err.stack); + process.exit(1); +}); + +import {info, fs, is, to, log} from "./utils.js"; import paths from "./paths.js"; import AnnotationApi from "./annotation"; import parser from "./parser.js"; @@ -109,27 +115,27 @@ var docs = (function(){ /// @promise /// @returns {object} - the data that was parsed _.parse = (files, changed) => { - console.time("total-runtime"); // starts the timer for the total runtime - + log.time("paths"); + log.time("total"); // starts the timer for the total runtime return new Promise((resolve, reject) => { paths(files, changed) .then((file_paths) => { - console.log("FILE_PATHS:", file_paths.length); - console.time("parsing-runtime"); + let length = file_paths.length, + s = length > 1 ? "s" : ""; + log.timeEnd("paths", `%s completed after %dms with ${length} file${s} to parse`); + log.time("parser"); // Converts the `file_paths` into an array of parsing files. // Onces they're all parsed then return the array of parsed files. return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))); }) .then((parsed_files) => { - console.timeEnd("parsing-runtime"); + log.timeEnd("parser"); // get the stored data file if it exists, or return an empty object return new Promise((resolve, reject) => { fs.readJson(info.temp.file) .then((json) => json) - .catch((err) => { - return {}; - }) + .catch((err) => Promise.resolve({})) .then((json) => { // Loop through the parsed files and update the // json data that was stored. @@ -150,47 +156,25 @@ var docs = (function(){ }); }) .then((json) => { - console.time("sorter-runtime"); - return Promise.resolve(_.sorter(json)); + log.time("sorter"); + return [json, Promise.resolve(_.sorter(json))]; }) - .then((json) => { - console.timeEnd("sorter-runtime"); - console.timeEnd("total-runtime"); // ends the timer for the total runtime - - + .then((raw, sorted) => { + log.timeEnd("sorter"); + log.timeEnd("total"); resolve({ - /// @name parse().data - /// @description Placeholder for the data so if it's manipulated the updated data will be in the other functions - data: json, - - /// @name parse().write - /// @description Helper function to write out the data to a json file - /// @arg {string} location - The location to write the file too - /// @arg {number,\t,\s} spacing [1] - The spacing you want the file to have. - /// @returns {this} - write(location, spacing){ - fs.writeJson(temp_file, this.data, (err) => err && console.error(err)); - return this; - }, - - // @todo {tylerb} - Add a way to documentize the files - // This should be apart of it's own code base so it doesn't pollute this one. - // @returns {this} - documentize(){ - console.log("documentize"); - } + raw, + sorted }); }) .catch((err) => { reject({}); - to.log(err); - throw new Error(err); + log.error(err.stack); }); }) .catch((err) => { reject({}); - to.log(err); - throw new Error(err); + log.error(err.stack); }); }; diff --git a/app/utils.js b/app/utils.js index c22afa0..b96ff14 100644 --- a/app/utils.js +++ b/app/utils.js @@ -67,11 +67,6 @@ const to_string = arg => Object.prototype.toString.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 @@ -807,3 +802,57 @@ const not = (func) => () => !func.apply(null, array_slice(arguments)), } } })(); + + + + +import {format as _format} from "util"; +import chalk from "chalk"; + +let _times = {}, + chevron = "\xBB", + check = "\u2713", + warning = "\u26A0", + error = "\u2326"; + +// @name Log +// @description +// A better console.log +export function log(...args){ + console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)); +}; + +log.warning = (...args) => { + console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow("[WARNING]"))} ${args.shift()}`, ...args), "\n"); +}; + +log.error = (...args) => { + console.log(_format(`${chalk.red(error, chalk.bold.red("[ERROR]"))} ${args.shift()}`, ...args), "\n"); +}; + +log.time = (label) => { + _times[label] = Date.now(); +}; + +log.timeEnd = (label, format = "%s completed after %dms") => { + let time = _times[label]; + + if(!time){ + throw new Error(`No such label: ${label}`); + } + + let duration = Date.now() - time; + console.log(_format(`${chalk.green(check)} ${format}`, label, duration)); +}; + +log.debug = (...args) => { + args = args.map(f => { + if(f instanceof Function){ + return f(); + } + + return f; + }); + + console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), "\n"); +}; \ No newline at end of file diff --git a/package.json b/package.json index c7facdb..f6b2d0f 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "url": "https://github.com/tjbenton/docs/issues" }, "dependencies": { + "chalk": "^1.1.0", "fs-extra": "^0.22.1", "glob": "^5.0.6", "marked": "^0.3.3" From 247a9339778810430e5f0175df8dee8aeeb49f44 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 10 Aug 2015 09:46:54 -0400 Subject: [PATCH 020/273] Added documentation and fixed a simple bug. --- app/docs.js | 5 +++-- app/paths.js | 3 --- app/sorter.js | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/docs.js b/app/docs.js index d7f218e..37233b1 100755 --- a/app/docs.js +++ b/app/docs.js @@ -157,9 +157,10 @@ var docs = (function(){ }) .then((json) => { log.time("sorter"); - return [json, Promise.resolve(_.sorter(json))]; + return [json, _.sorter(json)]; }) - .then((raw, sorted) => { + .then((data) => { + let [raw, sorted] = data; log.timeEnd("sorter"); log.timeEnd("total"); resolve({ diff --git a/app/paths.js b/app/paths.js index 721f300..5c1d23f 100644 --- a/app/paths.js +++ b/app/paths.js @@ -8,8 +8,6 @@ import {Deferred, fs, path, info, glob, is, to} from "./utils.js"; // @args {array, string} // @returns {array} - Filtered file paths export default function paths(globs, changed = true){ - console.time("paths-runtime"); - globs = to.array(globs); // Converts globs into an array if it's not already. // @name get_paths @@ -97,7 +95,6 @@ export default function paths(globs, changed = true){ get_paths(globs) .then(files => filter(files)) .then(filtered_files => resolve(filtered_files)) - .then(() => console.timeEnd("paths-runtime")) .catch((err) => { throw err; }); diff --git a/app/sorter.js b/app/sorter.js index dec85e3..b63ea47 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -37,19 +37,27 @@ export default function(json){ let _pages = pages, _nav = nav, path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings + // 1 less than the link so the last item in the `path_list` is what + // the passed value will be set to length = path_list.length - 1; - for(var i = 0; i < length; i++){ - var elem = path_list[i]; - if(!_pages[elem]){ - _pages[elem] = { + // 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 = 0; i < length; i++){ + let page = path_list[i]; + if(!_pages[page]){ + _pages[page] = { page: { header: {}, body: [] } + // { + // page: "Home", + // link: "" + // } }; } - _pages = _pages[elem]; + _pages = _pages[page]; } // a) Define the default data set(can't use `page` because it will be overwritten) From f72949a1774a40f8a1cefc0fafefb47ef544b63d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 18 Aug 2015 10:22:20 -0400 Subject: [PATCH 021/273] Updated sorter to include the nav creation Also reorganized it to seperate out the pages, and nav --- app/sorter.js | 248 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 162 insertions(+), 86 deletions(-) diff --git a/app/sorter.js b/app/sorter.js index b63ea47..6a6eba8 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -1,4 +1,4 @@ -import {info, fs, path, is, to} from "./utils.js"; +import {info, fs, path, is, to, log} from "./utils.js"; /// @name sort /// @description @@ -6,8 +6,7 @@ import {info, fs, path, is, to} from "./utils.js"; /// @arg {object} /// @returns {object} export default function(json){ - let nav = {}, // holds the navigation for the pages - pages = {}, // holds the pages of documentation + let nav, pages, _settings = { header: { // This can be file "type", "", false if you always @@ -19,104 +18,181 @@ export default function(json){ prepend_type: false } // todo: true, // create a todo page with ALL the todo comments listed - }, - // @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 _pages = pages, - _nav = nav, - path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings - // 1 less than the link so the last item in the `path_list` is what - // the passed value will be set to - 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 = 0; i < length; i++){ - let page = path_list[i]; - if(!_pages[page]){ - _pages[page] = { - page: { - header: {}, - body: [] - } - // { - // page: "Home", - // link: "" - // } - }; - } - _pages = _pages[page]; - } + }; - // a) Define the default data set(can't use `page` because it will be overwritten) - if(!_pages[path_list[length]]){ - _pages[path_list[length]] = { - page: { - header: {}, - body: [] - } - }; - } + /// @name pages + /// @description + /// This function loops over the json that was passed and creates a organized structure + /// based on the `@pages` annotations that were passed. + pages = (() => { + let result = {}; + // @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 + function set(path, type, value){ + // ensures values won't change in the passed value + value = to.clone(value); - if(type === "header"){ - _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); - }else{ - _pages[path_list[length]].page.body.push(value); - } - }; + // deletes the page from the value so it + // won't get added to the data + delete value.page; + let _pages = result, + path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings + // 1 less than the link so the last item in the `path_list` is what + // the passed value will be set to + length = path_list.length - 1; - // loop over each filetype in the json object - for(let [filetype, files] of to.entries(json)){ - // loop over each file in the filetype object - for(let file of files){ - // a) Ensures there's only one page defined in the header - // b) There wasn't a page defined so set it to general - file.header.page = file.header.page ? file.header.page[0] : "general"; + // 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 = 0; i < length; i++){ + let page = path_list[i]; + if(!_pages[page]){ + _pages[page] = { + page: { + header: {}, + body: [] + } + }; + } + _pages = _pages[page]; + } - // a) Prepend the filetype to the page - if(is.truthy(_settings.header.prepend_type)){ - file.header.page = path.join(file.info.type, file.header.page); + // a) Define the default data set(can't use `page` because it will be overwritten) + if(!_pages[path_list[length]]){ + _pages[path_list[length]] = { + page: { + header: {}, + body: [] + } + }; } - // a) Set the name in the header to be the name of the file - if(is.falsy(file.header.name)){ - file.header.name = to.case.title(file.info.name); + if(type === "header"){ + _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); + }else{ + _pages[path_list[length]].page.body.push(value); } + }; + + // loop over each filetype in the json object to create the pages structure + for(let [filetype, files] of to.entries(json)){ + // loop over each file in the filetype object + for(let file of files){ + // a) Ensures there's only one page defined in the header + // b) There wasn't a page defined so set it to general + file.header.page = file.header.page ? file.header.page[0] : "general"; - // set the header for the file - set(file.header.page, "header", file.header); - - // console.log(file.header.page); - // loop over each block in the body of the file - for(let block of file.body){ - // a) loop over each page in the block, - // and add the block to that page. - if(block.page){ - for(let page of block.page){ - if(page !== file.header.page){ - set(page, "body", block); + // a) Prepend the filetype to the page + if(is.truthy(_settings.header.prepend_type)){ + file.header.page = path.join(file.info.type, file.header.page); + } + + // a) Set the name in the header to be the name of the file + if(is.falsy(file.header.name)){ + file.header.name = to.case.title(file.info.name); + } + + // set the header for the file + set(file.header.page, "header", file.header); + + // loop over each block in the body of the file + for(let block of file.body){ + // a) loop over each page in the block, + // and add the block to that page. + if(block.page){ + for(let page of block.page){ + if(page !== file.header.page){ + set(page, "body", block); + } } } + + // add the block to the page + set(file.header.page, "body", block); } + } + } + + return result; + })(); - // add the block to the page - set(file.header.page, "body", block); + /// @name nav + /// @description + /// This function builds the navigation based of how the pages were built. + nav = ((pages) => { + let result = []; // placeholder to store the result + + /// @name body_names + /// @description Helper function to get the name of each block in the body + /// @arg {string} - the href to append the `name` of the block to + /// @arg {array} - the body of the page + /// @returns {array} + function body_names(href, body){ + let body_names = []; + // loop over each block in the body + for(let block of body){ + // a) Add the name to the body_names + if(is.existy(block.name)){ + body_names.push({ + title: block.name, + href: `${href}#${to.case.dash(block.name)}` + }); + } } + + return body_names; } - } + + + /// @name set + /// @description + /// This is a helper function that recursivly goes through the + /// structure(`a`) creating the navigation structure for + /// the passed item. + /// @arg {object} - This is the top level object to continue to drill down. + /// @arg {object} - The inner structure to continue to loop over. + /// @returns {object} + function set(a, b){ + for(let [key, value] of to.entries(b)){ + if(key !== "page"){ + let nav_item = { + title: is.truthy(value.page.header.name) ? value.page.header.name : to.case.title(to.case.space(key)), + href: `${a.href}/${key}`, + body: [], + subpages: [] + }; + + // add the name of each block in the body + nav_item.body = body_names(nav_item.href, value.page.body); + + // a) Call `set` again because it's not the last level + if(to.keys(value).length > 1){ // the reason it's `> 1` is because `page` will always be defined. + nav_item = set(nav_item, value); + } + + a.subpages.push(nav_item); + } + } + + return a; + }; + + // loop over the pages structure to create the navigation + for(let [key, value] of to.entries(pages)){ + result.push(set({ + title: to.case.title(to.case.space(key)), + href: `/${key}`, + body: body_names(`/${key}`, value.page.body), + subpages: [] + }, value)); + } + + return result; + })(pages); return { nav, From 9cfe150a8cb054a7194dedf7f6b5c92f1d6ba8f2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 27 Sep 2015 19:24:49 -0400 Subject: [PATCH 022/273] Updated normalize --- app/utils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/utils.js b/app/utils.js index b96ff14..683da28 100644 --- a/app/utils.js +++ b/app/utils.js @@ -266,7 +266,7 @@ export let to = { /// @name to.normalize /// @description - /// Removes trailing blank lines. Removes extra whitespace before all the lines that + /// 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 @@ -274,10 +274,11 @@ export let to = { normalize: (content) => { content = to.array(content); // this allows arrays and strings to be passed + // remove leading blank lines + while(!!!content[0].trim().length) content.shift(); + // remove trailing blank lines - for(let i = content.length; i-- && content[i].length === 0;){ - content.pop(); - }; + while(!!!content[content.length - 1].trim().length) content.pop(); return content .map(line => line.slice( @@ -285,7 +286,7 @@ export let to = { .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 + .join("\n").replace(/[^\S\r\n]+$/gm, ""); // convert to string and remove all trailing white spaces from each line }, /// @name to.extend From 1e63a87597937e7cf7fdbb063dddab579fda6bdd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 29 Sep 2015 08:32:40 -0400 Subject: [PATCH 023/273] Updated code formatting - changed from 1 space to 2 spaces - added spaces before if, else, else if, for, while - added space before opening curly bracket --- .babelrc | 2 +- .jscsrc | 49 +- app/annotation/annotations/access.js | 8 +- app/annotation/annotations/alias.js | 8 +- app/annotation/annotations/arg.js | 14 +- app/annotation/annotations/author.js | 2 +- app/annotation/annotations/chainable.js | 8 +- app/annotation/annotations/construct.js | 10 +- app/annotation/annotations/deprecated.js | 10 +- app/annotation/annotations/description.js | 8 +- app/annotation/annotations/export.js | 0 app/annotation/annotations/index.js | 4 +- app/annotation/annotations/markup.js | 10 +- app/annotation/annotations/name.js | 6 +- app/annotation/annotations/note.js | 10 +- app/annotation/annotations/page.js | 10 +- app/annotation/annotations/readonly.js | 8 +- app/annotation/annotations/requires.js | 12 +- app/annotation/annotations/returns.js | 12 +- app/annotation/annotations/since.js | 10 +- app/annotation/annotations/state.js | 14 +- app/annotation/annotations/todo.js | 12 +- app/annotation/annotations/type.js | 10 +- app/annotation/annotations/version.js | 10 +- app/annotation/index.js | 230 ++-- app/docs.js | 308 ++--- app/parser.js | 694 +++++------ app/paths.js | 166 +-- app/sorter.js | 348 +++--- app/utils.js | 1370 ++++++++++----------- 30 files changed, 1681 insertions(+), 1682 deletions(-) create mode 100644 app/annotation/annotations/export.js diff --git a/.babelrc b/.babelrc index 31b2172..ce840ab 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "stage": 1 + "stage": 0 } \ No newline at end of file diff --git a/.jscsrc b/.jscsrc index febfa26..e735ebe 100644 --- a/.jscsrc +++ b/.jscsrc @@ -12,20 +12,27 @@ "with" ], "disallowQuotedKeysInObjects": "allButReserved", - "disallowSpaceAfterKeywords": [ - "if", - "else if", - "for", - "while", - "do", - "switch", - "try", - "catch" + "requireSpaceAfterKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "void", + "while", + "with", + "return", + "typeof" ], + "requireSpaceBeforeKeywords": [ + "catch", + "else" + ], + "requireParenthesesAroundArrowParam": true, "disallowSpaceBeforeKeywords": [ - "if", - "else", - "else if", "for", "while", "catch" @@ -33,8 +40,6 @@ "requireCurlyBraces": [ "if", "else", - "for", - "while", "do", "try", "catch", @@ -47,20 +52,16 @@ "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!", "!!", "~~"], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true + "beforeOpeningRoundBrace": true }, "disallowSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true + "beforeOpeningRoundBrace": true }, "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true + "beforeOpeningRoundBrace": true }, "disallowSpacesInFunction": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true + "beforeOpeningRoundBrace": true }, "disallowSpacesInCallExpression": true, "requireSpacesInConditionalExpression": true, @@ -76,7 +77,6 @@ "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"], @@ -84,9 +84,10 @@ "mark": "\"", "escape": true }, + "requireSpaceBeforeBlockStatements": true, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", - "validateIndentation": 1, + "validateIndentation": 2, "validateParameterSeparator": ", ", "excludeFiles": [ "node_modules/**/*" diff --git a/app/annotation/annotations/access.js b/app/annotation/annotations/access.js index 4b7055d..bd68fda 100644 --- a/app/annotation/annotations/access.js +++ b/app/annotation/annotations/access.js @@ -3,9 +3,9 @@ /// @description Access of the documented item /// @returns {string} export default { - access: { - callback: function(){ - return this.annotation.line; + access: { + callback() { + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/alias.js b/app/annotation/annotations/alias.js index 2e537e2..a663ca5 100644 --- a/app/annotation/annotations/alias.js +++ b/app/annotation/annotations/alias.js @@ -3,9 +3,9 @@ /// @description Whether the documented item is an alias of another item /// @returns {string} export default { - alias: { - callback: function(){ - return this.annotation.line; + alias: { + callback() { + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/arg.js b/app/annotation/annotations/arg.js index 8e714ee..a039ad4 100644 --- a/app/annotation/annotations/arg.js +++ b/app/annotation/annotations/arg.js @@ -4,12 +4,12 @@ /// @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; + arg: { + alias: ["argument", "param", "parameter"], + callback() { // + // 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 index 4d3b5ae..b0b1a93 100644 --- a/app/annotation/annotations/author.js +++ b/app/annotation/annotations/author.js @@ -3,5 +3,5 @@ /// @description Author of the documented item /// @returns {string} export default { - author: {} + author: {} }; diff --git a/app/annotation/annotations/chainable.js b/app/annotation/annotations/chainable.js index d92f2d0..6ec862e 100644 --- a/app/annotation/annotations/chainable.js +++ b/app/annotation/annotations/chainable.js @@ -3,9 +3,9 @@ /// @description Used to notate that a function is chainable /// @returns {boolean} export default { - chainable: { - callback: function(){ - return this.annotation.line; + chainable: { + callback() { + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/construct.js b/app/annotation/annotations/construct.js index 49203c2..35d7ba9 100644 --- a/app/annotation/annotations/construct.js +++ b/app/annotation/annotations/construct.js @@ -3,10 +3,10 @@ /// @description Describes the type of a variable /// @returns {boolean} export default { - construct: { - alias: ["constructor"], - callback: function(){ - return this.annotation.line; + construct: { + alias: ["constructor"], + callback() { + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/deprecated.js b/app/annotation/annotations/deprecated.js index a69ad32..1d6be08 100644 --- a/app/annotation/annotations/deprecated.js +++ b/app/annotation/annotations/deprecated.js @@ -3,10 +3,10 @@ /// @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; + deprecated: { + callback() { + // add regex for `{version} - description` + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/description.js b/app/annotation/annotations/description.js index 45b8aff..e8cb5d8 100644 --- a/app/annotation/annotations/description.js +++ b/app/annotation/annotations/description.js @@ -5,9 +5,9 @@ import {to} from "../../utils.js"; /// @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); + description: { + callback() { + return to.markdown(this.annotation.line ? this.annotation.line + "\n" + this.annotation.contents : this.annotation.contents); + } } - } }; diff --git a/app/annotation/annotations/export.js b/app/annotation/annotations/export.js new file mode 100644 index 0000000..e69de29 diff --git a/app/annotation/annotations/index.js b/app/annotation/annotations/index.js index 6888206..bac1b6a 100644 --- a/app/annotation/annotations/index.js +++ b/app/annotation/annotations/index.js @@ -24,8 +24,8 @@ let result = {}, require("./version.js"), ]; -for(let i in annotations){ - to.extend(result, annotations[i]); +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 index daa1e7b..7841e3a 100644 --- a/app/annotation/annotations/markup.js +++ b/app/annotation/annotations/markup.js @@ -4,10 +4,10 @@ /// @note Description is parsed as markdown /// @returns {object} export default { - markup: { - callback: function(){ - // add regex for `{language} [settings] - description` - return this.annotation.contents; + markup: { + callback() { + // add regex for `{language} [settings] - description` + return this.annotation.contents; + } } - } }; diff --git a/app/annotation/annotations/name.js b/app/annotation/annotations/name.js index f109fc8..4790398 100644 --- a/app/annotation/annotations/name.js +++ b/app/annotation/annotations/name.js @@ -3,7 +3,7 @@ /// @description Name of the documented item /// @returns {string} export default { - name: { - alias: ["title", "heading"] - } + name: { + alias: ["title", "heading"] + } }; diff --git a/app/annotation/annotations/note.js b/app/annotation/annotations/note.js index 27c2569..2f75525 100644 --- a/app/annotation/annotations/note.js +++ b/app/annotation/annotations/note.js @@ -3,10 +3,10 @@ /// @description A note about the documented item /// @returns {object} export default { - note: { - callback: function(){ - // add regex for `{7} - A note` - return this.annotation.line; + note: { + callback() { + // add regex for `{7} - A note` + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/page.js b/app/annotation/annotations/page.js index 5da39c8..1f9e231 100644 --- a/app/annotation/annotations/page.js +++ b/app/annotation/annotations/page.js @@ -3,10 +3,10 @@ /// @description The page you want the documented item to be on /// @returns {string} export default { - page: { - alias: ["group"], - callback: function(){ - return [this.annotation.line]; + page: { + alias: ["group"], + callback() { + return [this.annotation.line]; + } } - } }; diff --git a/app/annotation/annotations/readonly.js b/app/annotation/annotations/readonly.js index 40f2c1e..c77bab0 100644 --- a/app/annotation/annotations/readonly.js +++ b/app/annotation/annotations/readonly.js @@ -3,9 +3,9 @@ /// @description To note that a property is readonly /// @returns {boolean} export default { - readonly: { - callback: function(){ - return this.annotation.line; + readonly: { + callback() { + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/requires.js b/app/annotation/annotations/requires.js index 5c826f1..eae3a4b 100644 --- a/app/annotation/annotations/requires.js +++ b/app/annotation/annotations/requires.js @@ -3,11 +3,11 @@ /// @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; + requires: { + alias: ["require"], + callback() { + // add regex for {type} item - description + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/returns.js b/app/annotation/annotations/returns.js index 202fbde..fe12bd9 100644 --- a/app/annotation/annotations/returns.js +++ b/app/annotation/annotations/returns.js @@ -3,11 +3,11 @@ /// @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; + returns: { + alias: ["return"], + callback() { // 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 index c25db64..df03719 100644 --- a/app/annotation/annotations/since.js +++ b/app/annotation/annotations/since.js @@ -3,10 +3,10 @@ /// @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; + since: { + callback() { + // add regex for `{type} - description` + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/state.js b/app/annotation/annotations/state.js index b65ce4d..8d7034c 100644 --- a/app/annotation/annotations/state.js +++ b/app/annotation/annotations/state.js @@ -3,12 +3,12 @@ /// @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; + state: { + callback() { + // 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 index 8608c1d..e74e1f0 100644 --- a/app/annotation/annotations/todo.js +++ b/app/annotation/annotations/todo.js @@ -3,11 +3,11 @@ /// @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; + todo: { + callback() { + // 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 index 3a1f442..a562504 100644 --- a/app/annotation/annotations/type.js +++ b/app/annotation/annotations/type.js @@ -3,10 +3,10 @@ /// @description Describes the type of a variable /// @returns {string} export default { - type: { - callback: function(){ - // add regex for `{type} - description` - return this.annotation.line; + type: { + callback() { + // add regex for `{type} - description` + return this.annotation.line; + } } - } }; diff --git a/app/annotation/annotations/version.js b/app/annotation/annotations/version.js index 451d178..49b3b02 100644 --- a/app/annotation/annotations/version.js +++ b/app/annotation/annotations/version.js @@ -3,10 +3,10 @@ /// @description Describes the type of a variable /// @returns {string} export default { - version: { - callback: function(){ - // add regex for `{type} - description` - return this.annotation.line; + version: { + callback() { + // add regex for `{type} - description` + return this.annotation.line; + } } - } }; diff --git a/app/annotation/index.js b/app/annotation/index.js index 4d995aa..a897707 100644 --- a/app/annotation/index.js +++ b/app/annotation/index.js @@ -4,23 +4,23 @@ 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); + 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 @@ -73,100 +73,100 @@ export default class AnnotationApi{ /// 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 + 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() { + 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 }; - } - 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); + + // 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 + }; } - 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; + 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]); - } + add_annotations(annotations) { + for (let name in annotations) { + this.add(name, annotations[name]); + } }; /// @name list @@ -174,24 +174,24 @@ export default class AnnotationApi{ /// 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; + 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; + 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; + 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/docs.js b/app/docs.js index 37233b1..b5cde82 100755 --- a/app/docs.js +++ b/app/docs.js @@ -1,8 +1,8 @@ "use strict"; -process.on("uncaughtException", function(err){ - log.error("An uncaughtException was found:", err.stack); - process.exit(1); +process.on("uncaughtException", function(err) { + log.error("An uncaughtException was found:", err.stack); + process.exit(1); }); import {info, fs, is, to, log} from "./utils.js"; @@ -17,169 +17,169 @@ import sorter from "./sorter.js"; /// @description /// This is used to parse any filetype that you want to and gets the documentation for it and returns an {} of the document data //// -var docs = (function(){ - // the main object to return - let _ = { - is, - to, - annotation: new AnnotationApi(), - sorter, - fs - }; +var docs = (function() { + // the main object to return + let _ = { + is, + to, + annotation: new AnnotationApi(), + sorter, + fs + }; - // the settings object that holds the file specific settings as well as the base settings - _.file_specific_settings = { - css: { - header: { - start: "/***", - line: "*", - end: "***/" - }, - body: { - start: "/**", - line: "*", - end: "**/" - } - }, - rb: { - header: { - start: "###", - line: "##", - end: "###" - }, - body: { - line: "##" - } - }, - html: { - header: { - start: "" - }, - body: { - start: "" - } - }, - cfm: { - header: { - start: "" - }, - body: { - start: "" - } - } - }; - _.file_specific_settings.py = _.file_specific_settings.rb; - // _.file_specific_settings.coffee = _.file_specific_settings.rb; + // the settings object that holds the file specific settings as well as the base settings + _.file_specific_settings = { + css: { + header: { + start: "/***", + line: "*", + end: "***/" + }, + body: { + start: "/**", + line: "*", + end: "**/" + } + }, + rb: { + header: { + start: "###", + line: "##", + end: "###" + }, + body: { + line: "##" + } + }, + html: { + header: { + start: "" + }, + body: { + start: "" + } + }, + cfm: { + header: { + start: "" + }, + body: { + start: "" + } + } + }; + _.file_specific_settings.py = _.file_specific_settings.rb; + // _.file_specific_settings.coffee = _.file_specific_settings.rb; - /// @name settings - /// @description Merges the default settings with the file specific settings - /// @arg {string} filetype - the current filetype that is being parsed - /// @returns {object} the settings to use - _.settings = filetype => { - let defaults = { - header: { // file level comment block identifier - start: "////", - line: "///", - end: "////" - }, - body: { // block level comment block identifier - start: "", - line: "///", - end: "" - }, - blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. - annotation_prefix: "@", // annotation identifier(this should probably never be changed) - single_line_prefix: "#" // single line prefix for comments inside of the code below the comment block + /// @name settings + /// @description Merges the default settings with the file specific settings + /// @arg {string} filetype - the current filetype that is being parsed + /// @returns {object} the settings to use + _.settings = (filetype) => { + let defaults = { + header: { // file level comment block identifier + start: "////", + line: "///", + end: "////" + }, + body: { // block level comment block identifier + start: "", + line: "///", + end: "" + }, + blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. + annotation_prefix: "@", // annotation identifier(this should probably never be changed) + single_line_prefix: "#" // single line prefix for comments inside of the code below the comment block + }; + return !is.undefined(_.file_specific_settings[filetype]) ? to.extend(defaults, _.file_specific_settings[filetype]) : defaults; }; - return !is.undefined(_.file_specific_settings[filetype]) ? to.extend(defaults, _.file_specific_settings[filetype]) : defaults; - }; - /// @name setting - /// @description Allows you to specify settings for specific file types - /// @arg {string} extention - the file extention you want to target - /// @arg {object} obj - the settings you want to adjust for this file type - _.setting = (extention, obj) => { - return to.extend(_.file_specific_settings, { - [extention]: obj - }); - }; + /// @name setting + /// @description Allows you to specify settings for specific file types + /// @arg {string} extention - the file extention you want to target + /// @arg {object} obj - the settings you want to adjust for this file type + _.setting = (extention, obj) => { + return to.extend(_.file_specific_settings, { + [extention]: obj + }); + }; - /// @name parse - /// @description Takes the contents of a file and parses it - /// @arg {string, array} files - file paths to parse - /// @arg {boolean} changed [true] - If true it will only parse changed files - /// @promise - /// @returns {object} - the data that was parsed - _.parse = (files, changed) => { - log.time("paths"); - log.time("total"); // starts the timer for the total runtime - return new Promise((resolve, reject) => { - paths(files, changed) - .then((file_paths) => { - let length = file_paths.length, - s = length > 1 ? "s" : ""; - log.timeEnd("paths", `%s completed after %dms with ${length} file${s} to parse`); - log.time("parser"); + /// @name parse + /// @description Takes the contents of a file and parses it + /// @arg {string, array} files - file paths to parse + /// @arg {boolean} changed [true] - If true it will only parse changed files + /// @promise + /// @returns {object} - the data that was parsed + _.parse = (files, changed) => { + log.time("paths"); + log.time("total"); // starts the timer for the total runtime + return new Promise((resolve, reject) => { + paths(files, changed) + .then((file_paths) => { + let length = file_paths.length, + s = length > 1 ? "s" : ""; + log.timeEnd("paths", `%s completed after %dms with ${length} file${s} to parse`); + log.time("parser"); - // Converts the `file_paths` into an array of parsing files. - // Onces they're all parsed then return the array of parsed files. - return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))); - }) - .then((parsed_files) => { - log.timeEnd("parser"); - // get the stored data file if it exists, or return an empty object - return new Promise((resolve, reject) => { - fs.readJson(info.temp.file) - .then((json) => json) - .catch((err) => Promise.resolve({})) - .then((json) => { - // Loop through the parsed files and update the - // json data that was stored. - for(let data in parsed_files){ - to.merge(json, parsed_files[data], false); - } + // Converts the `file_paths` into an array of parsing files. + // Onces they're all parsed then return the array of parsed files. + return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))); + }) + .then((parsed_files) => { + log.timeEnd("parser"); + // get the stored data file if it exists, or return an empty object + return new Promise((resolve, reject) => { + fs.readJson(info.temp.file) + .then((json) => json) + .catch((err) => Promise.resolve({})) + .then((json) => { + // Loop through the parsed files and update the + // json data that was stored. + for (let data in parsed_files) { + to.merge(json, parsed_files[data], false); + } - resolve(json); + resolve(json); - // Update the temp json data. Even though this returns a promise - // it's not returned below because there's no need to wait for it - // to finish writing out the json file before moving on. Because the - // `json` object has already been updated. - fs.outputJson(info.temp.file, json, { - spaces: 2 - }, 1); - }); - }); - }) - .then((json) => { - log.time("sorter"); - return [json, _.sorter(json)]; - }) - .then((data) => { - let [raw, sorted] = data; - log.timeEnd("sorter"); - log.timeEnd("total"); - resolve({ - raw, - sorted - }); + // Update the temp json data. Even though this returns a promise + // it's not returned below because there's no need to wait for it + // to finish writing out the json file before moving on. Because the + // `json` object has already been updated. + fs.outputJson(info.temp.file, json, { + spaces: 2 + }, 1); + }); + }); + }) + .then((json) => { + log.time("sorter"); + return [json, _.sorter(json)]; + }) + .then((data) => { + let [raw, sorted] = data; + log.timeEnd("sorter"); + log.timeEnd("total"); + resolve({ + raw, + sorted + }); + }) + .catch((err) => { + reject({}); + log.error(err.stack); + }); }) .catch((err) => { - reject({}); - log.error(err.stack); + reject({}); + log.error(err.stack); }); - }) - .catch((err) => { - reject({}); - log.error(err.stack); - }); - }; + }; - return _; + return _; })(); diff --git a/app/parser.js b/app/parser.js index ec7f4a6..5f9b444 100644 --- a/app/parser.js +++ b/app/parser.js @@ -5,372 +5,372 @@ import {info, fs, path, is, to} from "./utils.js"; /// Parses a single file /// @arg {string} - The path to the file you're wanting to parse /// @returns {array} - Array of parsed blocks -export default function(file_path, settings, api){ - let filetype = path.extname(file_path).replace(".", ""), // the filetype of the current file - setting = settings(filetype), - annotations = api.list(filetype), // gets the annotations to use on this file - annotation_keys = to.keys(annotations), // stores the annotation names for this file in an array - file = {}, // placeholder to hold the file information that is defined in the return promise - debug = { - get_blocks: {}, - parse_blocks: {} - }; - debug.get_blocks.self = false; - debug.get_blocks.result = false; - debug.parse_blocks.self = false; - debug.parse_blocks.result = false; - - // @name get_blocks - // @description Parses the file and returns the comment blocks in an array - // @returns {array} of the comment blocks - // @todo {5} - add a line offest argument to this so that you can call parse content on other language types. - function get_blocks(content, config, restrict = true, start_at = 0){ - start_at = is.number(start_at) ? start_at : 0; - let lines = to.array(content), - parsed_blocks = [], - block_info, - is_start_and_end = is.all.truthy(config.start, config.end), - in_comment = false, // used to determin that you are in a comment - in_code = false; // used to determin if you are in the code after the comment block - // a) The file doesn't contain any header level comments, or body level comments - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - // debug.get_blocks.self && console.log("file =", to.json(file)); - debug.get_blocks.self && console.log("start_at =", start_at); - debug.get_blocks.self && console.log("starting line =", lines[start_at]); - debug.get_blocks.self && console.log("is_start_and_end =", is_start_and_end); - debug.get_blocks.self && console.log("config.start check =", is.in(file.contents, config.start)); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log("test 1:", is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); - debug.get_blocks.self && console.log("test 2:", !is.between(start_at, 0, lines.length - 1)); - - if((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)){ - debug.get_blocks.self && console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); - return []; - } - - for(let i = start_at, l = lines.length; i < l; i++){ - let line = lines[i], - comment_index = { - start: is_start_and_end ? is.included(line, config.start) : false, - line: is.included(line, config.line), - end: is_start_and_end ? is.included(line, config.end) : false - }; - debug.get_blocks.self && console.log("line", i, "=", line); - debug.get_blocks.self && console.log("length"); - // a) The line isn't empty so parse it. - if(!is.empty(line)){ - // a) is the start and end style or there was an instance of a comment line - if(is_start_and_end && (!is.false(comment_index.start) || in_comment) || !is.false(comment_index.line)){ - debug.get_blocks.self && console.log("IN COMMENT", "{", "start:", comment_index.start, ", line:", comment_index.line, ", end:", comment_index.end, "}"); - - // a) is the start of a new block - if(!is.false(comment_index.start) || !is_start_and_end && !in_comment){ - debug.get_blocks.self && console.log("START OF A NEW BLOCK ---------------------------------------------------------------"); - in_code = false; - - // a) There was block that has already been processed - if(!is.undefined(block_info)){ // holds the current block information - debug.get_blocks.self && console.log("BLOCK WAS PUSHED TO PARSED_BLOCKS"); - block_info.code.end = i - 1; // @todo check to make sure this is correct - parsed_blocks.push(block_info); - - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if(restrict){ - debug.get_blocks.self && console.log("IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); - block_info.comment.end = i; - return parsed_blocks; - } - } - - // reset the `block_info` to use on the new block - block_info = { - comment: { - contents: [], - start: i, - end: -1 - }, - code: { - contents: [], - start: -1, - end: -1 - }, - file +export default function(file_path, settings, api) { + let filetype = path.extname(file_path).replace(".", ""), // the filetype of the current file + setting = settings(filetype), + annotations = api.list(filetype), // gets the annotations to use on this file + annotation_keys = to.keys(annotations), // stores the annotation names for this file in an array + file = {}, // placeholder to hold the file information that is defined in the return promise + debug = { + get_blocks: {}, + parse_blocks: {} }; - - in_comment = true; - } - - // a) check for the end comment - if(is_start_and_end && block_info.comment.start !== i && !is.false(comment_index.end)){ - debug.get_blocks.self && console.log("LAST LINE IN COMMENT"); - in_comment = false; - block_info.comment.end = i; // sets the end line in the comment block - - // @todo might need to remove this - i++; // skips end comment line - line = lines[i]; // updates to be the next line - comment_index.end = is.included(config.end); // updates the index - } - - // a) adds this line to block_info comment contents - if(in_comment && is.false(comment_index.start) && is.false(comment_index.end)){ - debug.get_blocks.self && console.log("LINE ADDED TO BLOCK COMMENT CONTENTS"); - // a) removes the `config.line` from the line. - if(!is.false(comment_index.line)){ - line = line.slice(comment_index.line + config.line.length); - } - - block_info.comment.contents.push(line); - } - - // a) check the next line for an instance of the a line comment - if(!is_start_and_end && is.false(is.included(lines[i + 1], config.line))){ - debug.get_blocks.self && console.log("NEXT 'LINE' IS A COMMENT && NOT START AND END STYLE"); - in_comment = false; - block_info.comment.end = i; // sets the end line in the comment block - i++; // skips end comment line // @todo why does this need to be skipped? - line = lines[i]; // updates to be the next line - } - - // a) The last line in the file is a commment - if(in_comment && (is_start_and_end && !is.false(comment_index.end) ? i === l : i === l - 1)){ - debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS A COMMENT"); - block_info.comment.end = is_start_and_end ? i - 1 : i; - parsed_blocks.push(block_info); - break; // ensures that the loop stops because it's the last line in the file - } + debug.get_blocks.self = false; + debug.get_blocks.result = false; + debug.parse_blocks.self = false; + debug.parse_blocks.result = false; + + // @name get_blocks + // @description Parses the file and returns the comment blocks in an array + // @returns {array} of the comment blocks + // @todo {5} - add a line offest argument to this so that you can call parse content on other language types. + function get_blocks(content, config, restrict = true, start_at = 0) { + start_at = is.number(start_at) ? start_at : 0; + let lines = to.array(content), + parsed_blocks = [], + block_info, + is_start_and_end = is.all.truthy(config.start, config.end), + in_comment = false, // used to determin that you are in a comment + in_code = false; // used to determin if you are in the code after the comment block + // a) The file doesn't contain any header level comments, or body level comments + debug.get_blocks.self && console.log(""); + debug.get_blocks.self && console.log(""); + debug.get_blocks.self && console.log(""); + debug.get_blocks.self && console.log(""); + // debug.get_blocks.self && console.log("file =", to.json(file)); + debug.get_blocks.self && console.log("start_at =", start_at); + debug.get_blocks.self && console.log("starting line =", lines[start_at]); + debug.get_blocks.self && console.log("is_start_and_end =", is_start_and_end); + debug.get_blocks.self && console.log("config.start check =", is.in(file.contents, config.start)); + debug.get_blocks.self && console.log(""); + debug.get_blocks.self && console.log("test 1:", is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); + debug.get_blocks.self && console.log("test 2:", !is.between(start_at, 0, lines.length - 1)); + + if ((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)) { + debug.get_blocks.self && console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); + return []; } - // a) add code to current block_info - if(!in_comment && is.false(comment_index.end) && !is.undefined(block_info)){ - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if(restrict){ - debug.get_blocks.self && console.log("IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); - parsed_blocks.push(block_info); - break; - } - debug.get_blocks.self && console.log("IN CODE"); - // a) The previous line was a comment - if(!in_code){ - debug.get_blocks.self && console.log("THE PREVIOUS LINE WAS A COMMENT"); - in_code = true; - block_info.code.start = i; - } - - // adds this line to block code contents - block_info.code.contents.push(line); - - // a) pushes the last block onto the body - if(i === l - 1){ - debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS CODE"); - block_info.code.end = i; - parsed_blocks.push(block_info); - } - } - } - // the last line in the file was an empty line. - else if(i === l - 1 && is.truthy(block_info)){ - block_info[is.between(block_info.comment.end) ? "comment" : "code"].end = i; - parsed_blocks.push(block_info); - debug.get_blocks.self && console.log("LINE WAS EMPTY"); - } - - debug.get_blocks.self && console.log(""); - } // end loop - - return parsed_blocks; - }; - - // @name this.run_annotation - // @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) - function run_annotation(annotation, block = {}){ - // removes the first line because it's the "line" of the annotation - annotation.contents.shift(); - - // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents); - - // normalizes the current annotation line - annotation.line = to.normalize(annotation.line); - - // Merges the data together so it can be used to run all the annotations - let result = to.extend({ - annotation: annotation, // sets the annotation block information to be in it's own namespace of `annotation` - - /// @name this.add - /// @page annotation - /// @description Allows you to add a different annotation from within a annotation - /// @arg {string} name - the name of the annotation you want to add - /// @arg {string} str - information that is passed to the annotation - add: (name, str) => { - str = str.split("\n"); - return run_annotation({ - name: name, - line: to.normalize(str[0]), - contents: str, - start: null, - end: null - }); - } - }, block); - - // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if(is.truthy(api.file_list[filetype] && api.file_list[filetype][annotation.name]) && is.truthy(api.file_list.default[annotation.name])){ - result.default = api.file_list.default[annotation.name].call(result); - } - - - result = annotations[annotation.name].callback.call(result); - - return result; - }; - - // @name parsed_blocks - // @description - // Used to parse an array of blocks and runs the annotations function and returns the result - // @arg {array} - The block/blocks you want to have parsed - // @returns {array} of parsed blocks - function parse_blocks(blocks){ - if(is.empty(blocks)){ - return []; - } - // if it's an object then convert it to an array. - // blocks = to.array(blocks); - - let parsed_blocks = []; - - // @name parse_block - // @description - // This parses the content passed to it seperates out each annotation - // parses and figures out the annotation line, and the content after it. - // Then once it has all the information it calls the annotation function(the annotation one it found) - // for this file type or the default function. - // @arg {object} - The blocks to parse - const parse_block = (block, prefix = setting.annotation_prefix, restrict_lines = false) => { - let contents = to.array(block.comment.contents), - block_annotations = {}, - current = {}; // holds the current annotation - - // loop over each line in the comment block - for(let i = 0, l = contents.length; i < l; i++){ - let line = contents[i], - prefix_index = line.indexOf(prefix); - - // a) there is an index of the annotation prefix - if(prefix_index >= 0){ - let first_space = line.indexOf(" ", prefix_index), - name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length); - - // a) the name is one of the annotation names - if(annotation_keys.indexOf(name_of_annotation) >= 0){ - // a) parse the current annotation - if(!is.empty(current)){ - current.end = i - 1; - - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [current.name]: run_annotation(current, block) - }); + for (let i = start_at, l = lines.length; i < l; i++) { + let line = lines[i], + comment_index = { + start: is_start_and_end ? is.included(line, config.start) : false, + line: is.included(line, config.line), + end: is_start_and_end ? is.included(line, config.end) : false + }; + debug.get_blocks.self && console.log("line", i, "=", line); + debug.get_blocks.self && console.log("length"); + // a) The line isn't empty so parse it. + if (!is.empty(line)) { + // a) is the start and end style or there was an instance of a comment line + if (is_start_and_end && (!is.false(comment_index.start) || in_comment) || !is.false(comment_index.line)) { + debug.get_blocks.self && console.log("IN COMMENT", "{", "start:", comment_index.start, ", line:", comment_index.line, ", end:", comment_index.end, "}"); + + // a) is the start of a new block + if (!is.false(comment_index.start) || !is_start_and_end && !in_comment) { + debug.get_blocks.self && console.log("START OF A NEW BLOCK ---------------------------------------------------------------"); + in_code = false; + + // a) There was block that has already been processed + if (!is.undefined(block_info)) { // holds the current block information + debug.get_blocks.self && console.log("BLOCK WAS PUSHED TO PARSED_BLOCKS"); + block_info.code.end = i - 1; // @todo check to make sure this is correct + parsed_blocks.push(block_info); + + // Stops the loop after the first comment block + // has been parsed. This is for file header comments + if (restrict) { + debug.get_blocks.self && console.log("IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); + block_info.comment.end = i; + return parsed_blocks; + } + } + + // reset the `block_info` to use on the new block + block_info = { + comment: { + contents: [], + start: i, + end: -1 + }, + code: { + contents: [], + start: -1, + end: -1 + }, + file + }; + + in_comment = true; + } + + // a) check for the end comment + if (is_start_and_end && block_info.comment.start !== i && !is.false(comment_index.end)) { + debug.get_blocks.self && console.log("LAST LINE IN COMMENT"); + in_comment = false; + block_info.comment.end = i; // sets the end line in the comment block + + // @todo might need to remove this + i++; // skips end comment line + line = lines[i]; // updates to be the next line + comment_index.end = is.included(config.end); // updates the index + } + + // a) adds this line to block_info comment contents + if (in_comment && is.false(comment_index.start) && is.false(comment_index.end)) { + debug.get_blocks.self && console.log("LINE ADDED TO BLOCK COMMENT CONTENTS"); + // a) removes the `config.line` from the line. + if (!is.false(comment_index.line)) { + line = line.slice(comment_index.line + config.line.length); + } + + block_info.comment.contents.push(line); + } + + // a) check the next line for an instance of the a line comment + if (!is_start_and_end && is.false(is.included(lines[i + 1], config.line))) { + debug.get_blocks.self && console.log("NEXT 'LINE' IS A COMMENT && NOT START AND END STYLE"); + in_comment = false; + block_info.comment.end = i; // sets the end line in the comment block + i++; // skips end comment line // @todo why does this need to be skipped? + line = lines[i]; // updates to be the next line + } + + // a) The last line in the file is a commment + if (in_comment && (is_start_and_end && !is.false(comment_index.end) ? i === l : i === l - 1)) { + debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS A COMMENT"); + block_info.comment.end = is_start_and_end ? i - 1 : i; + parsed_blocks.push(block_info); + break; // ensures that the loop stops because it's the last line in the file + } + } + + // a) add code to current block_info + if (!in_comment && is.false(comment_index.end) && !is.undefined(block_info)) { + // Stops the loop after the first comment block + // has been parsed. This is for file header comments + if (restrict) { + debug.get_blocks.self && console.log("IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); + parsed_blocks.push(block_info); + break; + } + debug.get_blocks.self && console.log("IN CODE"); + // a) The previous line was a comment + if (!in_code) { + debug.get_blocks.self && console.log("THE PREVIOUS LINE WAS A COMMENT"); + in_code = true; + block_info.code.start = i; + } + + // adds this line to block code contents + block_info.code.contents.push(line); + + // a) pushes the last block onto the body + if (i === l - 1) { + debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS CODE"); + block_info.code.end = i; + parsed_blocks.push(block_info); + } + } + } + // the last line in the file was an empty line. + else if (i === l - 1 && is.truthy(block_info)) { + block_info[is.between(block_info.comment.end) ? "comment" : "code"].end = i; + parsed_blocks.push(block_info); + debug.get_blocks.self && console.log("LINE WAS EMPTY"); } - // redefines resets the current annotation to be blank - current = { - name: name_of_annotation, // sets the current annotation name - line: line.slice(prefix_index + 1 + name_of_annotation.length), // removes the current annotation name and it's prefix from the first line - contents: [], - start: i, // sets the starting line of the annotation - end: 0 - }; - } - } - - // a) adds the current line to the contents - if(!is.empty(current) && restrict_lines === false){ - current.contents.push(line); - } - - // a) is the last line in the comment block - if(i === l - 1 && !is.empty(current)){ - current.end = i; - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [current.name]: run_annotation(current, block) - }); - } - } // end block loop + debug.get_blocks.self && console.log(""); + } // end loop - return block_annotations; + return parsed_blocks; }; + // @name this.run_annotation + // @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) + function run_annotation(annotation, block = {}) { + // removes the first line because it's the "line" of the annotation + annotation.contents.shift(); + + // normalizes the current annotation contents + annotation.contents = to.normalize(annotation.contents); + + // normalizes the current annotation line + annotation.line = to.normalize(annotation.line); + + // Merges the data together so it can be used to run all the annotations + let result = to.extend({ + annotation: annotation, // sets the annotation block information to be in it's own namespace of `annotation` + + /// @name this.add + /// @page annotation + /// @description Allows you to add a different annotation from within a annotation + /// @arg {string} name - the name of the annotation you want to add + /// @arg {string} str - information that is passed to the annotation + add: (name, str) => { + str = str.split("\n"); + return run_annotation({ + name: name, + line: to.normalize(str[0]), + contents: str, + start: null, + end: null + }); + } + }, block); - // loop over each block - for(let i in blocks){ - let block = blocks[i]; - - block.comment.contents = to.normalize(block.comment.contents); - block.code.contents = to.normalize(block.code.contents); - - let parsed_block = parse_block(block); + // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed + if (is.truthy(api.file_list[filetype] && api.file_list[filetype][annotation.name]) && is.truthy(api.file_list.default[annotation.name])) { + result.default = api.file_list.default[annotation.name].call(result); + } - if(!is.empty(parsed_block)){ - parsed_blocks.push(parsed_block); - } - } // end blocks loop - debug.parse_blocks.self && console.log("parsed_blocks", parsed_blocks); + result = annotations[annotation.name].callback.call(result); - return parsed_blocks; - }; + return result; + }; - return new Promise((resolve, reject) => { - fs.readFile(file_path) - .then(contents => { - contents = to.normal_string(to.string(contents)); // normalize the file - file = { - contents, // all of the contents of the file - path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, "." + filetype), // name of the file - type: filetype, // filetype of the file - start: 0, // starting point of the file - end: to.array(contents).length - 1 // ending point of the file + // @name parsed_blocks + // @description + // Used to parse an array of blocks and runs the annotations function and returns the result + // @arg {array} - The block/blocks you want to have parsed + // @returns {array} of parsed blocks + function parse_blocks(blocks) { + if (is.empty(blocks)) { + return []; + } + // if it's an object then convert it to an array. + // blocks = to.array(blocks); + + let parsed_blocks = []; + + // @name parse_block + // @description + // This parses the content passed to it seperates out each annotation + // parses and figures out the annotation line, and the content after it. + // Then once it has all the information it calls the annotation function(the annotation one it found) + // for this file type or the default function. + // @arg {object} - The blocks to parse + const parse_block = (block, prefix = setting.annotation_prefix, restrict_lines = false) => { + let contents = to.array(block.comment.contents), + block_annotations = {}, + current = {}; // holds the current annotation + + // loop over each line in the comment block + for (let i = 0, l = contents.length; i < l; i++) { + let line = contents[i], + prefix_index = line.indexOf(prefix); + + // a) there is an index of the annotation prefix + if (prefix_index >= 0) { + let first_space = line.indexOf(" ", prefix_index), + name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length); + + // a) the name is one of the annotation names + if (annotation_keys.indexOf(name_of_annotation) >= 0) { + // a) parse the current annotation + if (!is.empty(current)) { + current.end = i - 1; + + // run the annotation function and merge it with the other annotations in the block + to.merge(block_annotations, { + [current.name]: run_annotation(current, block) + }); + } + + // redefines resets the current annotation to be blank + current = { + name: name_of_annotation, // sets the current annotation name + line: line.slice(prefix_index + 1 + name_of_annotation.length), // removes the current annotation name and it's prefix from the first line + contents: [], + start: i, // sets the starting line of the annotation + end: 0 + }; + } + } + + // a) adds the current line to the contents + if (!is.empty(current) && restrict_lines === false) { + current.contents.push(line); + } + + // a) is the last line in the comment block + if (i === l - 1 && !is.empty(current)) { + current.end = i; + // run the annotation function and merge it with the other annotations in the block + to.merge(block_annotations, { + [current.name]: run_annotation(current, block) + }); + } + } // end block loop + + return block_annotations; }; - debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); - let header = get_blocks(contents, setting.header); - debug.get_blocks.result && console.log("get_blocks(header) =", !is.empty(header) ? header[0].comment.contents : "no header for this file"); debug.get_blocks.result && console.log(""); debug.get_blocks.result && console.log(""); + // loop over each block + for (let i in blocks) { + let block = blocks[i]; - let body = get_blocks(contents, setting.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0); - debug.get_blocks.result && console.log("get_blocks(body) =", body); + block.comment.contents = to.normalize(block.comment.contents); + block.code.contents = to.normalize(block.code.contents); - debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); + let parsed_block = parse_block(block); - header = parse_blocks(header)[0]; - debug.parse_blocks.result && console.log("parse_blocks(header) =", header); debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && console.log(""); + if (!is.empty(parsed_block)) { + parsed_blocks.push(parsed_block); + } + } // end blocks loop - body = parse_blocks(body); - debug.parse_blocks.result && console.log("parse_blocks(body) =", body); + debug.parse_blocks.self && console.log("parsed_blocks", parsed_blocks); - // removes the contents from the file info because it's - // not something that is needed in the returned data. - delete file.contents; + return parsed_blocks; + }; - resolve({ - [file.type]: [{ - info: file, - header: header || {}, - body - }] - }); - }) - .catch(err => { - console.log(err); - reject({}); - }); - }); -}; + return new Promise((resolve, reject) => { + fs.readFile(file_path) + .then((contents) => { + contents = to.normal_string(to.string(contents)); // normalize the file + file = { + contents, // all of the contents of the file + path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file + name: path.basename(file_path, "." + filetype), // name of the file + type: filetype, // filetype of the file + start: 0, // starting point of the file + end: to.array(contents).length - 1 // ending point of the file + }; + + debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); + + let header = get_blocks(contents, setting.header); + debug.get_blocks.result && console.log("get_blocks(header) =", !is.empty(header) ? header[0].comment.contents : "no header for this file"); debug.get_blocks.result && console.log(""); debug.get_blocks.result && console.log(""); + + let body = get_blocks(contents, setting.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0); + debug.get_blocks.result && console.log("get_blocks(body) =", body); + + debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); + + header = parse_blocks(header)[0]; + debug.parse_blocks.result && console.log("parse_blocks(header) =", header); debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && console.log(""); + + body = parse_blocks(body); + debug.parse_blocks.result && console.log("parse_blocks(body) =", body); + + // removes the contents from the file info because it's + // not something that is needed in the returned data. + delete file.contents; + + resolve({ + [file.type]: [{ + info: file, + header: header || {}, + body + }] + }); + }) + .catch((err) => { + console.log(err); + reject({}); + }); + }); +}; \ No newline at end of file diff --git a/app/paths.js b/app/paths.js index 5c1d23f..942996f 100644 --- a/app/paths.js +++ b/app/paths.js @@ -7,96 +7,96 @@ import {Deferred, fs, path, info, glob, is, to} from "./utils.js"; // @promise // @args {array, string} // @returns {array} - Filtered file paths -export default function paths(globs, changed = true){ - globs = to.array(globs); // Converts globs into an array if it's not already. +export default function paths(globs, changed = true) { + globs = to.array(globs); // Converts globs into an array if it's not already. - // @name get_paths - // @description - // This gets the file paths to check - // @arg {array} - of file path globs - // @promise - // @returns {array} - the filepaths to return - function get_paths(files){ - return new Promise((resolve, reject) => { - let globs = []; - // get the files paths using glob - for(let i = 0, l = files.length; i < l; i++){ - globs.push(glob(files[i])); - } + // @name get_paths + // @description + // This gets the file paths to check + // @arg {array} - of file path globs + // @promise + // @returns {array} - the filepaths to return + function get_paths(files) { + return new Promise((resolve, reject) => { + let globs = []; + // get the files paths using glob + for (let i = 0, l = files.length; i < l; i++) { + globs.push(glob(files[i])); + } - Promise.all(globs) - .then((result) => resolve(to.array.flat(result))) - .catch(err => { - throw err; + Promise.all(globs) + .then((result) => resolve(to.array.flat(result))) + .catch((err) => { + throw err; + }); }); - }); - }; + }; - // @name check - // @description - // checks the status of the file to see if it has changed or not. - // @arg {string} - path to file - // @promise - // @returns {string} - this will be the filepath or an empty string - function check(file){ - var source = path.join(info.root, file), - target = path.join(info.temp.folder, file); - return new Promise((resolve, reject) => { - Promise.all([fs.stat(source), fs.stat(target)]) - .then(function(stats){ - // a) copies source file into the target directory because it's newer - if(stats[0].mtime > stats[1].mtime){ - resolve(source); - fs.fake_copy(source, target); // copies new files over. - }else{ - resolve(Promise.resolve("")); - } - }) - .catch((err) => { - fs.fake_copy(source, target); // copies new files over. - resolve(source); - }); - }); - }; + // @name check + // @description + // checks the status of the file to see if it has changed or not. + // @arg {string} - path to file + // @promise + // @returns {string} - this will be the filepath or an empty string + function check(file) { + var source = path.join(info.root, file), + target = path.join(info.temp.folder, file); + return new Promise((resolve, reject) => { + Promise.all([fs.stat(source), fs.stat(target)]) + .then(function(stats) { + // a) copies source file into the target directory because it's newer + if (stats[0].mtime > stats[1].mtime) { + resolve(source); + fs.fake_copy(source, target); // copies new files over. + } else { + resolve(Promise.resolve("")); + } + }) + .catch((err) => { + fs.fake_copy(source, target); // copies new files over. + resolve(source); + }); + }); + }; - // @name filter - // @description - // Filters out - // - changed files if `changed` is true, - // - `.md`, and `.` files(always) - // - any paths that aren't files - // - // @arg {array} of globs - // @promise - // @returns {array} - Array of file paths - function filter(files){ - files = files.filter(obj => { - let ext = path.extname(obj).toLowerCase(); - return ext !== ".md" && ext.charAt(0) === "."; - }); + // @name filter + // @description + // Filters out + // - changed files if `changed` is true, + // - `.md`, and `.` files(always) + // - any paths that aren't files + // + // @arg {array} of globs + // @promise + // @returns {array} - Array of file paths + function filter(files) { + files = files.filter((obj) => { + let ext = path.extname(obj).toLowerCase(); + return ext !== ".md" && ext.charAt(0) === "."; + }); - // a) Return all the files that were passed except - // the `.md`, and `.` files. - if(!changed){ - return Promise.resolve(files); - } + // a) Return all the files that were passed except + // the `.md`, and `.` files. + if (!changed) { + return Promise.resolve(files); + } - return new Promise((resolve, reject) => { - Promise.all(files.map((file) => check(file))) - .then(to_filter => resolve(to.array.unique(to.array(to_filter)))) - .catch((err) => { - resolve([]); - throw err; + return new Promise((resolve, reject) => { + Promise.all(files.map((file) => check(file))) + .then((to_filter) => resolve(to.array.unique(to.array(to_filter)))) + .catch((err) => { + resolve([]); + throw err; + }); }); - }); - }; + }; - return new Promise((resolve, reject) => { - get_paths(globs) - .then(files => filter(files)) - .then(filtered_files => resolve(filtered_files)) - .catch((err) => { - throw err; - }); - }); + return new Promise((resolve, reject) => { + get_paths(globs) + .then((files) => filter(files)) + .then((filtered_files) => resolve(filtered_files)) + .catch((err) => { + throw err; + }); + }); }; diff --git a/app/sorter.js b/app/sorter.js index 6a6eba8..b863a59 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -5,197 +5,197 @@ import {info, fs, path, is, to, log} from "./utils.js"; /// Sorts the parsed data into pages and creates the navigation /// @arg {object} /// @returns {object} -export default function(json){ - let nav, pages, +export default function(json) { + let nav, pages, _settings = { - header: { - // This can be file "type", "", false if you always - // want to go with what's declared in the page. - prepend_type: true - }, - body: { - // same as `header.page_prepend` but this is for body comment blocks - prepend_type: false - } - // todo: true, // create a todo page with ALL the todo comments listed + header: { + // This can be file "type", "", false if you always + // want to go with what's declared in the page. + prepend_type: true + }, + body: { + // same as `header.page_prepend` but this is for body comment blocks + prepend_type: false + } + // todo: true, // create a todo page with ALL the todo comments listed }; - /// @name pages - /// @description - /// This function loops over the json that was passed and creates a organized structure - /// based on the `@pages` annotations that were passed. - pages = (() => { - let result = {}; - // @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 - function 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 _pages = result, - path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings - // 1 less than the link so the last item in the `path_list` is what - // the passed value will be set to - 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 = 0; i < length; i++){ - let page = path_list[i]; - if(!_pages[page]){ - _pages[page] = { - page: { - header: {}, - body: [] + /// @name pages + /// @description + /// This function loops over the json that was passed and creates a organized structure + /// based on the `@pages` annotations that were passed. + pages = (() => { + let result = {}; + // @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 + function 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 _pages = result, + path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings + // 1 less than the link so the last item in the `path_list` is what + // the passed value will be set to + 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 = 0; i < length; i++) { + let page = path_list[i]; + if (!_pages[page]) { + _pages[page] = { + page: { + header: {}, + body: [] + } + }; + } + _pages = _pages[page]; } - }; - } - _pages = _pages[page]; - } - - // a) Define the default data set(can't use `page` because it will be overwritten) - if(!_pages[path_list[length]]){ - _pages[path_list[length]] = { - page: { - header: {}, - body: [] - } - }; - } - if(type === "header"){ - _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); - }else{ - _pages[path_list[length]].page.body.push(value); - } - }; + // a) Define the default data set(can't use `page` because it will be overwritten) + if (!_pages[path_list[length]]) { + _pages[path_list[length]] = { + page: { + header: {}, + body: [] + } + }; + } - // loop over each filetype in the json object to create the pages structure - for(let [filetype, files] of to.entries(json)){ - // loop over each file in the filetype object - for(let file of files){ - // a) Ensures there's only one page defined in the header - // b) There wasn't a page defined so set it to general - file.header.page = file.header.page ? file.header.page[0] : "general"; - - // a) Prepend the filetype to the page - if(is.truthy(_settings.header.prepend_type)){ - file.header.page = path.join(file.info.type, file.header.page); - } + if (type === "header") { + _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); + } else { + _pages[path_list[length]].page.body.push(value); + } + }; - // a) Set the name in the header to be the name of the file - if(is.falsy(file.header.name)){ - file.header.name = to.case.title(file.info.name); + // loop over each filetype in the json object to create the pages structure + for (let [filetype, files] of to.entries(json)) { + // loop over each file in the filetype object + for (let file of files) { + // a) Ensures there's only one page defined in the header + // b) There wasn't a page defined so set it to general + file.header.page = file.header.page ? file.header.page[0] : "general"; + + // a) Prepend the filetype to the page + if (is.truthy(_settings.header.prepend_type)) { + file.header.page = path.join(file.info.type, file.header.page); + } + + // a) Set the name in the header to be the name of the file + if (is.falsy(file.header.name)) { + file.header.name = to.case.title(file.info.name); + } + + // set the header for the file + set(file.header.page, "header", file.header); + + // loop over each block in the body of the file + for (let block of file.body) { + // a) loop over each page in the block, + // and add the block to that page. + if (block.page) { + for (let page of block.page) { + if (page !== file.header.page) { + set(page, "body", block); + } + } + } + + // add the block to the page + set(file.header.page, "body", block); + } + } } - // set the header for the file - set(file.header.page, "header", file.header); - - // loop over each block in the body of the file - for(let block of file.body){ - // a) loop over each page in the block, - // and add the block to that page. - if(block.page){ - for(let page of block.page){ - if(page !== file.header.page){ - set(page, "body", block); - } + return result; + })(); + + /// @name nav + /// @description + /// This function builds the navigation based of how the pages were built. + nav = ((pages) => { + let result = []; // placeholder to store the result + + /// @name body_names + /// @description Helper function to get the name of each block in the body + /// @arg {string} - the href to append the `name` of the block to + /// @arg {array} - the body of the page + /// @returns {array} + function body_names(href, body) { + let body_names = []; + // loop over each block in the body + for (let block of body) { + // a) Add the name to the body_names + if (is.existy(block.name)) { + body_names.push({ + title: block.name, + href: `${href}#${to.case.dash(block.name)}` + }); + } } - } - // add the block to the page - set(file.header.page, "body", block); + return body_names; } - } - } - - return result; - })(); - - /// @name nav - /// @description - /// This function builds the navigation based of how the pages were built. - nav = ((pages) => { - let result = []; // placeholder to store the result - - /// @name body_names - /// @description Helper function to get the name of each block in the body - /// @arg {string} - the href to append the `name` of the block to - /// @arg {array} - the body of the page - /// @returns {array} - function body_names(href, body){ - let body_names = []; - // loop over each block in the body - for(let block of body){ - // a) Add the name to the body_names - if(is.existy(block.name)){ - body_names.push({ - title: block.name, - href: `${href}#${to.case.dash(block.name)}` - }); - } - } - - return body_names; - } - - /// @name set - /// @description - /// This is a helper function that recursivly goes through the - /// structure(`a`) creating the navigation structure for - /// the passed item. - /// @arg {object} - This is the top level object to continue to drill down. - /// @arg {object} - The inner structure to continue to loop over. - /// @returns {object} - function set(a, b){ - for(let [key, value] of to.entries(b)){ - if(key !== "page"){ - let nav_item = { - title: is.truthy(value.page.header.name) ? value.page.header.name : to.case.title(to.case.space(key)), - href: `${a.href}/${key}`, - body: [], - subpages: [] - }; - // add the name of each block in the body - nav_item.body = body_names(nav_item.href, value.page.body); + /// @name set + /// @description + /// This is a helper function that recursivly goes through the + /// structure(`a`) creating the navigation structure for + /// the passed item. + /// @arg {object} - This is the top level object to continue to drill down. + /// @arg {object} - The inner structure to continue to loop over. + /// @returns {object} + function set(a, b) { + for (let [key, value] of to.entries(b)) { + if (key !== "page") { + let nav_item = { + title: is.truthy(value.page.header.name) ? value.page.header.name : to.case.title(to.case.space(key)), + href: `${a.href}/${key}`, + body: [], + subpages: [] + }; + + // add the name of each block in the body + nav_item.body = body_names(nav_item.href, value.page.body); + + // a) Call `set` again because it's not the last level + if (to.keys(value).length > 1) { // the reason it's `> 1` is because `page` will always be defined. + nav_item = set(nav_item, value); + } + + a.subpages.push(nav_item); + } + } - // a) Call `set` again because it's not the last level - if(to.keys(value).length > 1){ // the reason it's `> 1` is because `page` will always be defined. - nav_item = set(nav_item, value); - } + return a; + }; - a.subpages.push(nav_item); + // loop over the pages structure to create the navigation + for (let [key, value] of to.entries(pages)) { + result.push(set({ + title: to.case.title(to.case.space(key)), + href: `/${key}`, + body: body_names(`/${key}`, value.page.body), + subpages: [] + }, value)); } - } - return a; - }; + return result; + })(pages); - // loop over the pages structure to create the navigation - for(let [key, value] of to.entries(pages)){ - result.push(set({ - title: to.case.title(to.case.space(key)), - href: `/${key}`, - body: body_names(`/${key}`, value.page.body), - subpages: [] - }, value)); - } - - return result; - })(pages); - - return { - nav, - pages - }; + return { + nav, + pages + }; }; \ No newline at end of file diff --git a/app/utils.js b/app/utils.js index 683da28..4722713 100644 --- a/app/utils.js +++ b/app/utils.js @@ -23,30 +23,31 @@ export {info}; // @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)); - }); - }; +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()); - }); + 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 @@ -61,432 +62,428 @@ export {fs}; let glob = denodeify(require("glob")); export {glob}; -const to_string = arg => Object.prototype.toString.call(arg), - array_slice = arg => Array.prototype.slice.call(arg); +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.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 + "", - - - case: { - /// @name to.case.clean + /// @name to.markdown /// @description - /// Remove any starting case from a `string`, like camel or snake, but keep - /// spaces and punctuation that may be important otherwise. - /// - /// @arg {string} - /// @return {string} - clean: (str) => { - let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? " " + next : ""), - uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + " " + uppers.toLowerCase().split(" ").join(" ")); - - // a) has spaces - // b) has separator - return (/\s/.test(str) ? str : /[\W_]/.test(str) ? (unseparate(str) || str) : uncamelize(str)).toLowerCase(); - }, + /// 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.case.title - /// @description Converts a string to title case - /// @arg {string} + /// @name to.string + /// @description + /// Converts an object, array, number, or boolean to a string + /// @arg {string, object, array, number, boolean} /// @returns {string} - title: (str) => { - // https://github.com/gouch/to-title-case/blob/master/to-title-case.js - var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; + 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 + "", + + case: { + /// @name to.case.clean + /// @description + /// Remove any starting case from a `string`, like camel or snake, but keep + /// spaces and punctuation that may be important otherwise. + /// + /// @arg {string} + /// @return {string} + clean(str) { + let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? " " + next : ""), + uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + " " + uppers.toLowerCase().split(" ").join(" ")); + + // a) has spaces + // b) has separator + return (/\s/.test(str) ? str : /[\W_]/.test(str) ? (unseparate(str) || str) : uncamelize(str)).toLowerCase(); + }, + + /// @name to.case.title + /// @description Converts a string to title case + /// @arg {string} + /// @returns {string} + title(str) { + // https://github.com/gouch/to-title-case/blob/master/to-title-case.js + var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; + + return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) { + if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" && (title.charAt(index + match.length) !== "-" || title.charAt(index - 1) === "-") && title.charAt(index - 1).search(/[^\s-]/) < 0) { + return match.toLowerCase(); + } - return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){ - if(index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" && (title.charAt(index + match.length) !== "-" || title.charAt(index - 1) === "-") && title.charAt(index - 1).search(/[^\s-]/) < 0){ - return match.toLowerCase(); - } + if (match.substr(1).search(/[A-Z]|\../) > -1) { + return match; + } + + return match.charAt(0).toUpperCase() + match.substr(1); + }); + }, + + /// @name to.case.lower + /// @description Converts a string to lower case(aka `str.toLowerCase()`) + /// @arg {string} + /// @returns {string} + lower: (str) => str.toLowerCase(), + + /// @name to.case.upper + /// @description Converts a string to upper case(aka `str.toUpperCase()`) + /// @arg {string} + /// @returns {string} + upper: (str) => str.toUpperCase(), + + /// @name to.case.sentence + /// @description Converts a string to sentence case + /// @arg {string} + /// @returns {string} + sentence: (str) => to.case.clean(str).replace(/[a-z]/i, (letter) => letter.toUpperCase()), + + /// @name to.case.space + /// @description Replaces camel case, dot, and dash cases with a space + /// @arg {string} + /// @returns {string} + space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? " " + match : ""), + + /// @name to.case.snake + /// @description Converts a string to snake case + /// @arg {string} + /// @returns {string} + snake: (str) => to.case.space(str).replace(/\s/g, "_"), + + /// @name to.case.dash + /// @description Converts a string to dash case + /// @arg {string} + /// @returns {string} + dash: (str) => to.case.space(str).replace(/\s/g, "-"), + + /// @name to.case.dot + /// @description Converts a string to dot case + /// @arg {string} + /// @returns {string} + dot: (str) => to.case.space(str).replace(/\s/g, "."), + + /// @name to.case.swap + /// @description Converts capital letters to lower case and vice versa + /// @arg {string} + /// @returns {string} + swap: (str) => str.split("").map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join("") + }, + + + /// @name to.normal_string + /// @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 + normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/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) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), - if(match.substr(1).search(/[A-Z]|\../) > -1){ - return match; + /// @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) => { + if (is.array(obj)) { + return obj.entries(); } - return match.charAt(0).toUpperCase() + match.substr(1); - }); + let index = 0, + // 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. + keys = to.keys(obj); + + return { + [Symbol.iterator]() { + return this; + }, + next() { + if (index < keys.length) { + let key = keys[index]; + index++; + return { + value: [key, obj[key]] + }; + } else { + return { + done: true + }; + } + } + }; }, - /// @name to.case.lower - /// @description Converts a string to lower case(aka `str.toLowerCase()`) - /// @arg {string} - /// @returns {string} - lower: (str) => str.toLowerCase(), + /// @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.case.upper - /// @description Converts a string to upper case(aka `str.toUpperCase()`) - /// @arg {string} - /// @returns {string} - upper: (str) => str.toUpperCase(), + /// @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 + /// @returns {string} - The normalized string + normalize: (content) => { + content = to.array(content); // this allows arrays and strings to be passed + + // remove leading blank lines + while (content.length && !!!content[0].trim().length) content.shift(); + + // remove trailing blank lines + while (content.length && !!!(content[content.length - 1].trim()).length) 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 from each line + }, - /// @name to.case.sentence - /// @description Converts a string to sentence case - /// @arg {string} - /// @returns {string} - sentence: (str) => to.case.clean(str).replace(/[a-z]/i, (letter) => letter.toUpperCase()), + /// @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; + } - /// @name to.case.space - /// @description Replaces camel case, dot, and dash cases with a space - /// @arg {string} - /// @returns {string} - space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? " " + match : ""), + let k = to.keys(b); - /// @name to.case.snake - /// @description Converts a string to snake case - /// @arg {string} - /// @returns {string} - snake: (str) => to.case.space(str).replace(/\s/g, "_"), + for (let i = 0, l = k.length; i < l; i++) { + a[k[i]] = is.object(b[k[i]]) ? is.object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] : b[k[i]]; + } - /// @name to.case.dash - /// @description Converts a string to dash case - /// @arg {string} - /// @returns {string} - dash: (str) => to.case.space(str).replace(/\s/g, "-"), + // 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]; + // } - /// @name to.case.dot - /// @description Converts a string to dot case - /// @arg {string} - /// @returns {string} - dot: (str) => to.case.space(str).replace(/\s/g, "."), + return a; + }, - /// @name to.case.swap - /// @description Converts capital letters to lower case and vice versa - /// @arg {string} - /// @returns {string} - swap: (str) => { - str.split("").map((c) => { - let u = letter.toUpperCase(); - return c === u ? c.toLowerCase() : u; - }).join(""); - } - }, - - - /// @name to.normal_string - /// @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 - normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/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) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), - - /// @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) => { - if(is.array(obj)){ - return obj.entries(); - } + /// @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], - let index = 0, - // 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. - keys = to.keys(obj); - - return { - [Symbol.iterator](){ - return this; - }, - next(){ - if(index < keys.length){ - let key = keys[index]; - index++; - return { - value: [key, obj[key]] - }; - }else{ - return { - done: true - }; + /// @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, flat = true) => { + // a) Don't touch `null` or `undefined` objects. + if (!a || !b) { + return a; } - } - }; - }, - - /// @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/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 - /// @returns {string} - The normalized string - normalize: (content) => { - content = to.array(content); // this allows arrays and strings to be passed - - // remove leading blank lines - while(!!!content[0].trim().length) content.shift(); - - // remove trailing blank lines - while(!!!content[content.length - 1].trim().length) 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 from each line - }, - - /// @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){ - a[k] = is.object(b[k]) ? is.object(a[k]) ? to.extend(a[k], b[k]) : b[k] : b[k]; - } + // 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) is array + if (is.array(a[k])) { + // a) Flatten the array + if (flat) { + a[k] = to.array.flat(a[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, flat = true) => { - // a) Don't touch `null` or `undefined` objects. - if(!a || !b){ - return a; - } + // a) Filter out duplicates + if (unique && !is.object(a[k][0])) { + a[k] = to.array.unique(a[k]); + } + } + } + + 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) is array - if(is.array(a[k])){ - // a) Flatten the array - if(flat){ - a[k] = to.array.flat(a[k]); + 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(); + } } - // a) Filter out duplicates - if(unique && !is.object(a[k][0])){ - a[k] = to.array.unique(a[k]); + 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; + }, - 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(); - } - } + /// @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), - 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.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 @@ -502,211 +499,210 @@ to.array.flat = (arg) => [].concat.apply([], to.array(arg)); /// @arg {array} /// @returns {array} - without duplicates 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; + let o = {}, + r = []; + for (let i in arg) { + o[arg[i]] = arg[i]; + } + for (let i in o) { + r.push(o[i]); + } + + return r; }; export let is = { - // placeholder for the interfaces - not: {}, - all: {}, - any: {}, - - /// @name is.argument - /// @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)), - - /// @name is.regex - /// @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]", - - /// @name is.function - /// @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", - - /// @name is.array - /// @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]", - - /// @name is.boolean - /// @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]", - - /// @name is.object - /// @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, - - /// @name is.symbol - /// @description is a given arg a symbol? - /// @arg {*} arg - The item to check - /// @returns {boolean} - The result of the test - symbol: (arg) => typeof arg === "symbol", - - /// @name is.json - /// @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]", - - /// @name is.empty - /// @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 === ""; - } - }, - - /// @name is.exsity - /// @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, - - /// @name is.string - /// @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]", - - /// @name is.undefined - /// @description is a given arg undefined? - /// @arg {*} arg - The item to check - /// @returns {boolean} - undefined: arg => arg === void 0, - - /// @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` - /// @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, - - /// @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} - in: (obj, value) => is.included(is.object(obj) ? to.keys(obj) : obj, value) !== false, - - /// @name is.false - /// @description is a given arg false - /// @arg {*} arg - arg to check if it is false - /// @returns {boolean} - false: arg => arg === false, - - /// @name is.truthy - /// @description is a given arg truthy? - /// @arg {*} arg - /// @returns {boolean} - truthy: arg => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== "" && arg !== 0, - - /// @name is.falsy - /// @description is given arg falsy? - /// @arg {*} arg - /// @returns {boolean} - falsy: arg => !is.truthy(arg), - - /// @name is.nan - /// @description NaN is number, also it is the only arg which does not equal itself - /// @arg {*} arg - /// @returns {boolean} - nan: (arg) => arg !== arg, - - /// @name is.number - /// @description is given arg a number? - /// @arg {*} arg - /// @returns {boolean} - number: (arg) => is.not.nan(arg) && to_string(arg) === "[object Number]", - - /// @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} - between: (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max), - - /// @name is.positive - /// @description is a given number positive? - /// @arg {*} arg - /// @returns {boolean} - positive: (arg) => is.number(arg) && arg > 0, - - /// @name is.negative - /// @description is a given number negative? - /// @arg {*} arg - /// @returns {boolean} - negative: (arg) => is.number(arg) && arg < 0, - - /// @name is.above - /// @description is a given number above minimum parameter? - /// @arg {*} arg - /// @arg {number} min [-1] - /// @returns {boolean} - above: (arg, min = -1) => is.all.number(arg, min) && arg > min, - - /// @name is.under - /// @description is a given number above maximum parameter? - /// @arg {*} arg - /// @arg {number} max [100] - /// @returns {boolean} - under: (arg, max = 100) => is.all.number(arg, max) && arg < max, - - /// @name is.null - /// @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, - - /// @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} - promise: (arg) => arg && is.function(arg.then), - - /// @name is.stream - /// @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), - - /// @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} - buffer: (arg) => Buffer.isBuffer(arg) + // placeholder for the interfaces + not: {}, + all: {}, + any: {}, + + /// @name is.argument + /// @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)), + + /// @name is.regex + /// @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]", + + /// @name is.function + /// @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", + + /// @name is.array + /// @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]", + + /// @name is.boolean + /// @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]", + + /// @name is.object + /// @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, + + /// @name is.symbol + /// @description is a given arg a symbol? + /// @arg {*} arg - The item to check + /// @returns {boolean} - The result of the test + symbol: (arg) => typeof arg === "symbol", + + /// @name is.json + /// @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]", + + /// @name is.empty + /// @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 === ""; + } + }, + + /// @name is.exsity + /// @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, + + /// @name is.string + /// @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]", + + /// @name is.undefined + /// @description is a given arg undefined? + /// @arg {*} arg - The item to check + /// @returns {boolean} + undefined: (arg) => arg === void 0, + + /// @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` + /// @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, + + /// @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} + in: (obj, value) => is.included(is.object(obj) ? to.keys(obj) : obj, value) !== false, + + /// @name is.false + /// @description is a given arg false + /// @arg {*} arg - arg to check if it is false + /// @returns {boolean} + false: (arg) => arg === false, + + /// @name is.truthy + /// @description is a given arg truthy? + /// @arg {*} arg + /// @returns {boolean} + truthy: (arg) => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== "" && arg !== 0, + + /// @name is.falsy + /// @description is given arg falsy? + /// @arg {*} arg + /// @returns {boolean} + falsy: (arg) => !is.truthy(arg), + + /// @name is.nan + /// @description NaN is number, also it is the only arg which does not equal itself + /// @arg {*} arg + /// @returns {boolean} + nan: (arg) => arg !== arg, + + /// @name is.number + /// @description is given arg a number? + /// @arg {*} arg + /// @returns {boolean} + number: (arg) => is.not.nan(arg) && to_string(arg) === "[object Number]", + + /// @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} + between: (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max), + + /// @name is.positive + /// @description is a given number positive? + /// @arg {*} arg + /// @returns {boolean} + positive: (arg) => is.number(arg) && arg > 0, + + /// @name is.negative + /// @description is a given number negative? + /// @arg {*} arg + /// @returns {boolean} + negative: (arg) => is.number(arg) && arg < 0, + + /// @name is.above + /// @description is a given number above minimum parameter? + /// @arg {*} arg + /// @arg {number} min [-1] + /// @returns {boolean} + above: (arg, min = -1) => is.all.number(arg, min) && arg > min, + + /// @name is.under + /// @description is a given number above maximum parameter? + /// @arg {*} arg + /// @arg {number} max [100] + /// @returns {boolean} + under: (arg, max = 100) => is.all.number(arg, max) && arg < max, + + /// @name is.null + /// @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, + + /// @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} + promise: (arg) => arg && is.function(arg.then), + + /// @name is.stream + /// @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), + + /// @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} + buffer: (arg) => Buffer.isBuffer(arg) }; // included method does not support `all` and `any` interfaces @@ -725,83 +721,84 @@ 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; + values = to.array.flat(values); + for (let i in values) { + if (!is.in(obj, values[i])) { + return false; + } } - } - return true; + 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; + values = to.array.flat(values); + for (let i in values) { + if (is.in(obj, values[i])) { + return true; + } } - } - return false; + return false; }; const not = (func) => () => !func.apply(null, array_slice(arguments)), all = (func) => { - return function(){ - let parameters = array_slice(arguments), - length = parameters.length; + 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; - } + // 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; - } - } + for (let i = 0, l = length; i < length; i++) { + if (!func.call(null, parameters[i])) { + return false; + } + } - return true; - }; + return true; + }; }, any = (func) => { - return function(){ - let parameters = array_slice(arguments), + 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; + } - // 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; + } + } - for(var i = 0, l = length; i < l; i++){ - if(func.call(null, parameters[i])){ - return true; - } - } - return false; - }; + 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]); + 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]); + } + } } - if(interfaces[i] === "any"){ - is.any[option] = any(is[option]); - } - } } - } })(); @@ -819,41 +816,42 @@ let _times = {}, // @name Log // @description // A better console.log -export function log(...args){ - console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)); +export function log(...args) { + console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)); }; log.warning = (...args) => { - console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow("[WARNING]"))} ${args.shift()}`, ...args), "\n"); + console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow("[WARNING]"))} ${args.shift()}`, ...args), "\n"); }; log.error = (...args) => { - console.log(_format(`${chalk.red(error, chalk.bold.red("[ERROR]"))} ${args.shift()}`, ...args), "\n"); + console.trace(...args); + console.log(_format(`${chalk.red(error, chalk.bold.red("[ERROR]"))} ${args.shift()}`, ...args), "\n"); }; log.time = (label) => { - _times[label] = Date.now(); + _times[label] = Date.now(); }; log.timeEnd = (label, format = "%s completed after %dms") => { - let time = _times[label]; + let time = _times[label]; - if(!time){ - throw new Error(`No such label: ${label}`); - } + if (!time) { + throw new Error(`No such label: ${label}`); + } - let duration = Date.now() - time; - console.log(_format(`${chalk.green(check)} ${format}`, label, duration)); + let duration = Date.now() - time; + console.log(_format(`${chalk.green(check)} ${format}`, label, duration)); }; log.debug = (...args) => { - args = args.map(f => { - if(f instanceof Function){ - return f(); - } + args = args.map((f) => { + if (f instanceof Function) { + return f(); + } - return f; - }); + return f; + }); - console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), "\n"); + console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), "\n"); }; \ No newline at end of file From 18e5df606b4bb18ce2c094b8ed729d0dd0726324 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 1 Oct 2015 13:27:43 -0400 Subject: [PATCH 024/273] Updated test files --- tests/gulpfile.js | 23 +- tests/test.json | 1440 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 1420 insertions(+), 43 deletions(-) diff --git a/tests/gulpfile.js b/tests/gulpfile.js index 931117e..7e8d204 100755 --- a/tests/gulpfile.js +++ b/tests/gulpfile.js @@ -1,21 +1,18 @@ "use strict"; var gulp = require("gulp"), - docs = require("docs"); + docs = require("docs"), + path = require("path"); // 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("docs", function() { + docs.parse("lib/**/*") + .then(function(result) { + console.log(docs.to.json(result.sorted)); + docs.fs.outputJson("./test.json", result.sorted, { + spaces: 2 + }, 1); + }); }); gulp.task("default", ["docs"]); \ No newline at end of file diff --git a/tests/test.json b/tests/test.json index c8ce055..6deb177 100644 --- a/tests/test.json +++ b/tests/test.json @@ -1,32 +1,1412 @@ { - "scss": [ - { - "author": "Tyler Benton\n", - "page": "tests/scss-file", - "name": "moz-only", - "description": "

This allows you to write specific styles for mozilla firefox only

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

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

\n" + "nav": [ + { + "title": "C", + "href": "/c", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/c/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/c/tests/c-file", + "body": [ + { + "title": "main", + "href": "/c/tests/c-file#main" + }, + { + "title": "Something", + "href": "/c/tests/c-file#something" + }, + { + "title": "Something else", + "href": "/c/tests/c-file#something-else" + } + ], + "subpages": [] + }, + { + "title": "Test", + "href": "/c/tests/c++-file", + "body": [ + { + "title": "main", + "href": "/c/tests/c++-file#main" + }, + { + "title": "Something", + "href": "/c/tests/c++-file#something" + }, + { + "title": "Something else", + "href": "/c/tests/c++-file#something-else" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Cs", + "href": "/cs", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/cs/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/cs/tests/c#-file", + "body": [ + { + "title": "main", + "href": "/cs/tests/c#-file#main" + }, + { + "title": "Something", + "href": "/cs/tests/c#-file#something" + }, + { + "title": "Something else", + "href": "/cs/tests/c#-file#something-else" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Coffee", + "href": "/coffee", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/coffee/general", + "body": [], + "subpages": [] + } + ] + }, + { + "title": "Cfm", + "href": "/cfm", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/cfm/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/cfm/tests/cfm-file", + "body": [ + { + "title": "main", + "href": "/cfm/tests/cfm-file#main" + }, + { + "title": "John Doe", + "href": "/cfm/tests/cfm-file#john-doe" + }, + { + "title": "Something else", + "href": "/cfm/tests/cfm-file#something-else" + }, + { + "title": "Bob", + "href": "/cfm/tests/cfm-file#bob" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Css", + "href": "/css", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/css/test", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/css/test/css-file", + "body": [ + { + "title": "Base Styles", + "href": "/css/test/css-file#base-styles" + }, + { + "title": "Input", + "href": "/css/test/css-file#input" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Scss", + "href": "/scss", + "body": [], + "subpages": [ + { + "title": "Edge Cases", + "href": "/scss/edge-cases", + "body": [], + "subpages": [ + { + "title": "4-Blank-Lines-Between-Code-Blocks", + "href": "/scss/edge-cases/4-blank-lines-between-code-blocks", + "body": [ + { + "title": "moz-only", + "href": "/scss/edge-cases/4-blank-lines-between-code-blocks#moz-only" + } + ], + "subpages": [] + }, + { + "title": [ + "Ends-With-Empty-Lines", + "Space-Between-Comment-and-Code" + ], + "href": "/scss/edge-cases/ends-with-empty-lines", + "body": [ + { + "title": "Only block in body", + "href": "/scss/edge-cases/ends-with-empty-lines#only-block-in-body" + }, + { + "title": "Space between comment bock and code block", + "href": "/scss/edge-cases/ends-with-empty-lines#space-between-comment-bock-and-code-block" + }, + { + "title": "No space between", + "href": "/scss/edge-cases/ends-with-empty-lines#no-space-between" + } + ], + "subpages": [] + }, + { + "title": "Header", + "href": "/scss/edge-cases/header-comment-only", + "body": [], + "subpages": [] + }, + { + "title": "No-Space-Between-Header-and-Body-Comments", + "href": "/scss/edge-cases/no-space-between-header-and-body-comment", + "body": [ + { + "title": "moz-only", + "href": "/scss/edge-cases/no-space-between-header-and-body-comment#moz-only" + } + ], + "subpages": [] + }, + { + "title": "Only-Comments", + "href": "/scss/edge-cases/only-comments", + "body": [ + { + "title": "moz-only", + "href": "/scss/edge-cases/only-comments#moz-only" + } + ], + "subpages": [] + }, + { + "title": "Starts-and-Ends-With-Spaces", + "href": "/scss/edge-cases/starts-and-ends-with-empty-lines", + "body": [ + { + "title": "Only block in body", + "href": "/scss/edge-cases/starts-and-ends-with-empty-lines#only-block-in-body" + } + ], + "subpages": [] + }, + { + "title": "Starts-With-Empty-Lines", + "href": "/scss/edge-cases/starts-with-empty-lines", + "body": [ + { + "title": "Only block in body", + "href": "/scss/edge-cases/starts-with-empty-lines#only-block-in-body" + } + ], + "subpages": [] + } + ] + }, + { + "title": [ + "Empty-File", + "Only-Body-Comments", + "Preserves-Blank-Lines", + "Single-Body-Comment-No-Code", + "Single-Body-Comment" + ], + "href": "/scss/general", + "body": [ + { + "title": "Button group", + "href": "/scss/general#button-group" + }, + { + "title": "moz-only", + "href": "/scss/general#moz-only" + } + ], + "subpages": [] + }, + { + "title": "Tests", + "href": "/scss/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/scss/tests/scss-file", + "body": [ + { + "title": "moz-only", + "href": "/scss/tests/scss-file#moz-only" + }, + { + "title": "Test one", + "href": "/scss/tests/scss-file#test-one" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Components", + "href": "/components", + "body": [], + "subpages": [ + { + "title": "Buttons", + "href": "/components/buttons", + "body": [], + "subpages": [] + } + ] + }, + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "All", + "href": "/tests/all", + "body": [ + { + "title": "Test one", + "href": "/tests/all#test-one" + } + ], + "subpages": [] + } + ] + }, + { + "title": "Html", + "href": "/html", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/html/tests", + "body": [], + "subpages": [ + { + "title": "Header", + "href": "/html/tests/html-file", + "body": [ + { + "title": "Body Block 1", + "href": "/html/tests/html-file#body-block-1" + }, + { + "title": "Body Block 2", + "href": "/html/tests/html-file#body-block-2" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Java", + "href": "/java", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/java/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/java/tests/java-file", + "body": [ + { + "title": "Body Block 1", + "href": "/java/tests/java-file#body-block-1" + }, + { + "title": "Body Block 2", + "href": "/java/tests/java-file#body-block-2" + }, + { + "title": "Body Block 3", + "href": "/java/tests/java-file#body-block-3" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Js", + "href": "/js", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/js/general", + "body": [], + "subpages": [] + } + ] + }, + { + "title": "Less", + "href": "/less", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/less/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/less/tests/less-test", + "body": [ + { + "title": "base color", + "href": "/less/tests/less-test#base-color" + }, + { + "title": "Nav", + "href": "/less/tests/less-test#nav" + }, + { + "title": "Button group", + "href": "/less/tests/less-test#button-group" + }, + { + "title": "Opacity", + "href": "/less/tests/less-test#opacity" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Php", + "href": "/php", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/php/tests", + "body": [], + "subpages": [ + { + "title": "Header", + "href": "/php/tests/php-file", + "body": [ + { + "title": "Body block 1", + "href": "/php/tests/php-file#body-block-1" + }, + { + "title": "Body block 2", + "href": "/php/tests/php-file#body-block-2" + }, + { + "title": "Body block 3", + "href": "/php/tests/php-file#body-block-3" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Py", + "href": "/py", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/py/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/py/tests/py-file", + "body": [ + { + "title": "main", + "href": "/py/tests/py-file#main" + }, + { + "title": "something", + "href": "/py/tests/py-file#something" + }, + { + "title": "something else", + "href": "/py/tests/py-file#something-else" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Rb", + "href": "/rb", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/rb/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/rb/tests/rb-file", + "body": [ + { + "title": "main", + "href": "/rb/tests/rb-file#main" + }, + { + "title": "Something", + "href": "/rb/tests/rb-file#something" + }, + { + "title": "Something else", + "href": "/rb/tests/rb-file#something-else" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Styl", + "href": "/styl", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/styl/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/styl/tests/styl-file", + "body": [ + { + "title": "main", + "href": "/styl/tests/styl-file#main" + }, + { + "title": "Somethin", + "href": "/styl/tests/styl-file#somethin" + }, + { + "title": "Something else", + "href": "/styl/tests/styl-file#something-else" + } + ], + "subpages": [] + } + ] + } + ] + }, + { + "title": "Swift", + "href": "/swift", + "body": [], + "subpages": [ + { + "title": "Tests", + "href": "/swift/tests", + "body": [], + "subpages": [ + { + "title": "Test", + "href": "/swift/tests/swift-file", + "body": [ + { + "title": "main", + "href": "/swift/tests/swift-file#main" + }, + { + "title": "Something", + "href": "/swift/tests/swift-file#something" + }, + { + "title": "Something else", + "href": "/swift/tests/swift-file#something-else" + } + ], + "subpages": [] + } + ] + } + ] + } + ], + "pages": { + "c": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "c-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n" + }, + { + "name": "Something", + "description": "

This is a normal multi-line comment.

\n" + }, + { + "name": "Something else", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + }, + "c++-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n" + }, + { + "name": "Something", + "description": "

This is a normal multi-line comment.

\n" + }, + { + "name": "Something else", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + } + } + }, + "cs": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "c#-file": { + "page": { + "header": { + "author": "Tyler Benton", + "description": "

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

\n", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

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

\n" + }, + { + "name": "Something", + "description": "

This is a normal multi-line comment.

\n" + }, + { + "name": "Something else", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + } + } + }, + "coffee": { + "page": { + "header": {}, + "body": [] + }, + "general": { + "page": { + "header": { + "name": "Test" + }, + "body": [] + } + } + }, + "cfm": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "cfm-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n" + }, + { + "name": "John Doe", + "description": "

This is a normal multi-line coldfusion comment.

\n" + }, + { + "name": "Something else", + "description": "

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

\n" + }, + { + "name": "Bob", + "description": "

This is another normal multi-line coldfusion comment.

\n" + } + ] + } + } + } + }, + "css": { + "page": { + "header": {}, + "body": [] + }, + "test": { + "page": { + "header": {}, + "body": [] + }, + "css-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "Base Styles", + "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n" + }, + { + "name": "Input", + "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n" + } + ] + } + } + } + }, + "scss": { + "page": { + "header": {}, + "body": [] + }, + "edge-cases": { + "page": { + "header": {}, + "body": [] + }, + "4-blank-lines-between-code-blocks": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "4-Blank-Lines-Between-Code-Blocks" + }, + "body": [ + { + "name": "moz-only", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + } + ] + } + }, + "ends-with-empty-lines": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "name": [ + "Ends-With-Empty-Lines", + "Space-Between-Comment-and-Code" + ] + }, + "body": [ + { + "name": "Only block in body", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + }, + { + "name": "Space between comment bock and code block", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + }, + { + "name": "No space between", + "description": "

A simple nav component, used to help with navigation

\n", + "markup": "" + } + ] + } + }, + "header-comment-only": { + "page": { + "header": { + "name": "Header", + "author": "Tyler Benton", + "description": "

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

\n" + }, + "body": [] + } + }, + "no-space-between-header-and-body-comment": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "No-Space-Between-Header-and-Body-Comments" + }, + "body": [ + { + "name": "moz-only", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

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

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + } + ] + } + }, + "starts-and-ends-with-empty-lines": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Starts-and-Ends-With-Spaces" + }, + "body": [ + { + "name": "Only block in body", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + } + ] + } + }, + "starts-with-empty-lines": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Starts-With-Empty-Lines" + }, + "body": [ + { + "name": "Only block in body", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + } + ] + } + } + }, + "general": { + "page": { + "header": { + "name": [ + "Empty-File", + "Only-Body-Comments", + "Preserves-Blank-Lines", + "Single-Body-Comment-No-Code", + "Single-Body-Comment" + ] + }, + "body": [ + { + "author": "Tyler Benton", + "description": "

Your standard form button.

\n", + "state": [ + ":hover", + ":active", + ":disabled - Dims the button when disabled.", + ".c-btn--mini - A mini button", + ".c-btn--tiny - A tiny button", + ".c-btn--medium - A medium button", + ".c-btn--large - A large button", + ".c-btn--primary - Primary action", + ".c-btn--primary:hover", + ".c-btn--primary:active", + ".c-btn--secondary - Secondary action", + ".c-btn--secondary:hover", + ".c-btn--secondary:active", + ".c-btn--tertiary - Tertiary action", + ".c-btn--tertiary:hover", + ".c-btn--tertiary:active", + ".c-btn--text - It's a text link as a button", + ".c-btn--text:hover", + ".c-btn--text:active" + ], + "markup": "
\n Button (a.button)\n \n \n
" + }, + { + "name": "Button group", + "description": "

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

\n", + "markup": "
\n Button (a.button)\n \n \n
" + }, + { + "name": "moz-only", + "author": "Tyler Benton", + "description": "

This allows you to write specific styles for mozilla firefox only

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

This allows you to write specific styles for mozilla firefox only

\n", + "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" + }, + { + "name": "Test one", + "state": [ + ".state-1", + ".state-2", + ".state-3" + ], + "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" + } + ] + } + } + } + }, + "components": { + "page": { + "header": {}, + "body": [] + }, + "buttons": { + "page": { + "header": {}, + "body": [ + { + "author": "Tyler Benton", + "description": "

Your standard form button.

\n", + "state": [ + ":hover", + ":active", + ":disabled - Dims the button when disabled.", + ".c-btn--mini - A mini button", + ".c-btn--tiny - A tiny button", + ".c-btn--medium - A medium button", + ".c-btn--large - A large button", + ".c-btn--primary - Primary action", + ".c-btn--primary:hover", + ".c-btn--primary:active", + ".c-btn--secondary - Secondary action", + ".c-btn--secondary:hover", + ".c-btn--secondary:active", + ".c-btn--tertiary - Tertiary action", + ".c-btn--tertiary:hover", + ".c-btn--tertiary:active", + ".c-btn--text - It's a text link as a button", + ".c-btn--text:hover", + ".c-btn--text:active" + ], + "markup": "
\n Button (a.button)\n \n \n
" + }, + { + "author": "Tyler Benton", + "description": "

Your standard form button.

\n", + "state": [ + ":hover", + ":active", + ":disabled - Dims the button when disabled.", + ".c-btn--mini - A mini button", + ".c-btn--tiny - A tiny button", + ".c-btn--medium - A medium button", + ".c-btn--large - A large button", + ".c-btn--primary - Primary action", + ".c-btn--primary:hover", + ".c-btn--primary:active", + ".c-btn--secondary - Secondary action", + ".c-btn--secondary:hover", + ".c-btn--secondary:active", + ".c-btn--tertiary - Tertiary action", + ".c-btn--tertiary:hover", + ".c-btn--tertiary:active", + ".c-btn--text - It's a text link as a button", + ".c-btn--text:hover", + ".c-btn--text:active" + ], + "markup": "
\n Button (a.button)\n \n \n
" + } + ] + } + } + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "all": { + "page": { + "header": {}, + "body": [ + { + "name": "Test one", + "state": [ + ".state-1", + ".state-2", + ".state-3" + ], + "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" + } + ] + } + } + }, + "html": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "html-file": { + "page": { + "header": { + "name": "Header", + "author": "Tyler Benton" + }, + "body": [ + { + "name": "Body Block 1", + "description": "

This is the main header of the site

\n" + }, + { + "name": "Body Block 2", + "description": "

This is the main footer of the site

\n" + } + ] + } + } + } + }, + "java": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "java-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "Body Block 1", + "description": "

A very simple class to print out Hello World

\n" + }, + { + "name": "Body Block 2", + "description": "

This is a normal multi-line comment.

\n" + }, + { + "name": "Body Block 3", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + } + } + }, + "js": { + "page": { + "header": {}, + "body": [] + }, + "general": { + "page": { + "header": { + "name": "Test" + }, + "body": [] + } + } + }, + "less": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "less-test": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "base color", + "type": "{color}" + }, + { + "name": "Nav", + "description": "

A simple nav component, used to help with navigation

\n", + "markup": "" + }, + { + "author": "Tyler Benton", + "description": "

Your standard form button.

\n", + "state": [ + ":hover", + ":active", + ":disabled - Dims the button when disabled.", + ".c-btn--mini - A mini button", + ".c-btn--tiny - A tiny button", + ".c-btn--medium - A medium button", + ".c-btn--large - A large button", + ".c-btn--primary - Primary action", + ".c-btn--primary:hover", + ".c-btn--primary:active", + ".c-btn--secondary - Secondary action", + ".c-btn--secondary:hover", + ".c-btn--secondary:active", + ".c-btn--tertiary - Tertiary action", + ".c-btn--tertiary:hover", + ".c-btn--tertiary:active", + ".c-btn--text - It's a text link as a button", + ".c-btn--text:hover", + ".c-btn--text:active" + ], + "markup": "
\n Button (a.button)\n \n \n
" + }, + { + "name": "Button group", + "description": "

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

\n", + "markup": "
\n Button (a.button)\n \n \n
" + }, + { + "name": "Opacity", + "description": "

A mixin to help with opacity fallbacks

\n", + "arg": "{number} - The opacity you to use, between 0.0 - 1.0", + "markup": ".foo{\n .opacity(.3);\n}" + } + ] + } + } + } + }, + "php": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "php-file": { + "page": { + "header": { + "name": "Header", + "author": "Tyler Benton" + }, + "body": [ + { + "name": "Body block 1", + "description": "

main method

\n" + }, + { + "name": "Body block 2", + "description": "

This is a normal multi-line comment.

\n" + }, + { + "name": "Body block 3", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + } + } + }, + "py": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "py-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n" + }, + { + "name": "something", + "description": "

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

\n" + }, + { + "name": "something else", + "description": "

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

\n" + } + ] + } + } + } + }, + "rb": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "rb-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n" + }, + { + "name": "Something", + "description": "

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

\n" + }, + { + "name": "Something else", + "description": "

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

\n" + } + ] + } + } + } + }, + "styl": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "styl-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

-\nLorem 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", + "markup": "asdfasdfasdfasdf" + }, + { + "name": "Somethin", + "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" + }, + { + "name": "Something else", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + } + } + }, + "swift": { + "page": { + "header": {}, + "body": [] + }, + "tests": { + "page": { + "header": {}, + "body": [] + }, + "swift-file": { + "page": { + "header": { + "author": "Tyler Benton", + "name": "Test" + }, + "body": [ + { + "name": "main", + "description": "

main method

\n" + }, + { + "name": "Something", + "description": "

This is a normal multi-line comment.

\n" + }, + { + "name": "Something else", + "description": "

This is another normal multi-line comment.

\n" + } + ] + } + } + } + } } - ], - "js": [], - "css": [ - { - "author": "Tyler Benton\n", - "page": "test/css-file", - "name": "Base Styles", - "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n" - }, - { - "author": "Tyler Benton\n", - "page": "test/css-file", - "name": "Input", - "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n" - } - ] -} \ No newline at end of file +} From b8a7bcfe42b7a0f5589ba9780391275ed19ee745 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:11:07 -0400 Subject: [PATCH 025/273] Added cli support --- app/cli.js | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ bin/docs | 6 +++ package.json | 6 ++- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 app/cli.js create mode 100755 bin/docs diff --git a/app/cli.js b/app/cli.js new file mode 100644 index 0000000..47d5250 --- /dev/null +++ b/app/cli.js @@ -0,0 +1,115 @@ +let doc = ` +Usage: + sassdoc - [options] + sassdoc ... [options] +Arguments: + Path to your Sass folder. +Options: + -h, --help Bring help. + --version Show version. + -v, --verbose Enable verbose mode. + -d, --dest= Documentation folder. + -c, --config= Path to JSON/YAML configuration file. + -t, --theme= Theme to use. + -p, --parse Parse the input and output JSON data to stdout. + --no-update-notifier Disable update notifier check. + --strict Turn warnings into errors. + --debug Output debugging information. +`; + +// import Environment from './environment'; +// import Logger from './logger'; +// import sassdoc, { parse } from './sassdoc'; +// import * as errors from './errors'; +// import source from 'vinyl-source-stream'; + +import pkg from '../package.json'; +import path from 'path'; +import {info} from './utils.js'; +import program from 'commander'; +import config from './config.js'; + +export default function cli(argv) { + program + .version(pkg.version) + .usage('docs [options]') + .description('Parse all your documentation, and output a json file') + .option('-c, --config=', 'Path to configuration file (default is `./docs.js`)') + .option('-f, --files ', 'The files to be parsed', function(val) { + return val.split(','); + }) + .option('-d, --dest=', 'Documentation folder.') + .parse(process.argv); + + // + // if (!options['-'] && !options[''].length) { + // // Trigger help display. + // docopt(doc, { version: pkg.version, argv: ['--help'] }); + // } + // + // let logger = new Logger(options['--verbose'], options['--debug'] || process.env.SASSDOC_DEBUG); + // let env = new Environment(logger, options['--strict']); + // + // logger.debug('argv:', () => JSON.stringify(argv)); + // + // env.on('error', error => { + // if (error instanceof errors.Warning) { + // process.exit(2); + // } + // + // process.exit(1); + // }); + // + // env.load(options['--config']); + // + // // Ensure CLI options. + // ensure(env, options, { + // dest: '--dest', + // theme: '--theme', + // noUpdateNotifier: '--no-update-notifier', + // }); + // + // env.postProcess(); + // + // // Run update notifier if not explicitely disabled. + // if (!env.noUpdateNotifier) { + // require('./notifier')(pkg, logger); + // } + // + // let handler, cb; + // + // // Whether to parse only or to documentize. + // if (!options['--parse']) { + // handler = sassdoc; + // cb = () => {}; + // } else { + // handler = parse; + // cb = data => console.log(JSON.stringify(data, null, 2)); + // } + // + // if (options['-']) { + // return process.stdin + // .pipe(source()) + // .pipe(handler(env)) + // .on('data', cb); + // } + // + // handler(options[''], env).then(cb); +} + +/** + * Ensure that CLI options take precedence over configuration values. + * + * For each name/option tuple, if the option is set, override configuration + * value. + */ +function ensure(env, options, names) { + for (let k of Object.keys(names)) { + let v = names[k]; + + if (options[v]) { + env[k] = options[v]; + env[k + 'Cwd'] = true; + } + } +} \ No newline at end of file diff --git a/bin/docs b/bin/docs new file mode 100755 index 0000000..9abe760 --- /dev/null +++ b/bin/docs @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +'use strict'; + +require('../dist/cli.js')(process.argv.slice(2)); + diff --git a/package.json b/package.json index f6b2d0f..d89ac62 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,13 @@ "bugs": { "url": "https://github.com/tjbenton/docs/issues" }, + "bin": { + "docs": "bin/docs" + }, "dependencies": { "chalk": "^1.1.0", - "fs-extra": "^0.22.1", + "commander": "^2.8.1", + "fs-extra": "^0.24.0", "glob": "^5.0.6", "marked": "^0.3.3" }, From 2c21b2e73814c1f9c7b812d27ecae406240ce80f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:12:29 -0400 Subject: [PATCH 026/273] Removed the Makefile and put them in the package.json --- Makefile | 60 ---------------------------------------------------- package.json | 7 ++++-- 2 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 Makefile 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/package.json b/package.json index d89ac62..df1e504 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,11 @@ "author": { "name": "Tyler Benton", "email": "tjbenton21@gmail.com" + "scripts": { + "watch": "babel app/ -d ./dist --stage 0 --optional runtime --watch", + "deploy": "npm run test && git push origin master && npm publish", + "build": "babel app/ -d ./dist --optional runtime --stage 0", + "prepublish": "npm run build" }, "version": "0.1.0", "license": { @@ -73,7 +78,5 @@ "devDependencies": { "babel": "^5.5.4" }, - "scripts": { - "postinstall": "make postinstall" } } From 15bfe343da6202716542a60a36f7f4d01e8238f5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:12:51 -0400 Subject: [PATCH 027/273] Added `app/` to the npm ignore file --- .npmignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 3d0dbe4..92f6bc6 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,2 @@ -tests/ \ No newline at end of file +tests/ +app/ \ No newline at end of file From 26f30cc9d1dd8ad51e52c98fb5648264695a55a7 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:13:45 -0400 Subject: [PATCH 028/273] Changed `build` to `dist` --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e58098a..51ad94c 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules/ **/nmp-debug.log -build/ -build.zip +dist/ .tmp .DS_Store .sass-cache From bc67720ab59f83b4d64dfe3e17dbf3adb448f41f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:14:10 -0400 Subject: [PATCH 029/273] Moved `index.js` to `app/index.js` --- app/index.js | 18 ++++++++++++++++++ index.js | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 app/index.js delete mode 100644 index.js diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..1ffb1cb --- /dev/null +++ b/app/index.js @@ -0,0 +1,18 @@ +var docs = require('./dist/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/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 From 4a15cfbaf228ef2d81ca991c1ef0733393ec0f65 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:14:27 -0400 Subject: [PATCH 030/273] Removed babelrc because it's not needed --- .babelrc | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index ce840ab..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "stage": 0 -} \ No newline at end of file From 96776f772766349679e7c0034dba20f9120a5323 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:14:46 -0400 Subject: [PATCH 031/273] Updated a few jcsc settings --- .jscsrc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.jscsrc b/.jscsrc index e735ebe..11a1993 100644 --- a/.jscsrc +++ b/.jscsrc @@ -20,7 +20,6 @@ "switch", "case", "try", - "catch", "void", "while", "with", @@ -34,8 +33,7 @@ "requireParenthesesAroundArrowParam": true, "disallowSpaceBeforeKeywords": [ "for", - "while", - "catch" + "while" ], "requireCurlyBraces": [ "if", @@ -46,7 +44,6 @@ "case", "default" ], - "requireMultipleVarDecl": true, "requireLineBreakAfterVariableAssignment": true, "disallowSpaceAfterObjectKeys": "ignoreSingleLine", "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!", "!!", "~~"], @@ -72,16 +69,14 @@ "disallowYodaConditions": true, "requireOperatorBeforeLineBreak": ["?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<="], "requireSpaceBeforeBinaryOperators": true, - "requirePaddingNewLinesInObjects": true, "requireSpaceBeforeObjectValues": true, "requireSpaceBetweenArguments": true, - "requireSemicolons": true, "requireSpaceAfterBinaryOperators": true, "disallowSpacesInsideObjectBrackets": null, "safeContextKeyword": ["$obj", "obj", "$that", "that", "$elem", "elem", "_this", "self", "_self", "_", "$parent", "parent", "instance", "result", "context"], "fileExtensions": [".js", "jscs"], "validateQuoteMarks": { - "mark": "\"", + "mark": "'", "escape": true }, "requireSpaceBeforeBlockStatements": true, From 12b772366e0d88da0677e7e2d7a201ead654a435 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:16:26 -0400 Subject: [PATCH 032/273] Added a config file The purpose of this file is to return a complete configuration of the documentation. Now you can add settings via `docs.js` at the root of the project. --- app/config.js | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 app/config.js diff --git a/app/config.js b/app/config.js new file mode 100644 index 0000000..b2b1b04 --- /dev/null +++ b/app/config.js @@ -0,0 +1,110 @@ +import {info, fs, is, to, log} from './utils.js' + +// changed by `options` key +const default_options = { + files: 'app/**/*', // files to search + ignore: ['.*','node_modules/', 'bower_components/', 'jspm_packages/'], // files to be ignored + changed: true, // determins if only changed files should be parsed or not + blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. + annotations: {} +} + +const default_comment = { + prefix: '@', // annotation identifier(this should probably never be changed) + inline_prefix: '#', // @todo add support for this single line prefix for comments inside of the code below the comment block + // file level comment block identifier + header: { start: '////', line: '///', end: '////' }, + // block level comment block identifier + body: { start: '', line: '///', end: '' } +} + +// some defaults for common languages +let comments = { + _: default_comment, + css: { + header: { start: '/***', line: '*', end: '***/' }, + body: { start: '/**', line: '*', end: '**/' } + }, + 'rb, py': { + header: { start: '###', line: '##', end: '###' }, + body: { line: '#' } + }, + html: { + header: { start: '' }, + body: { start: '' } + }, + cfm: { + header: { start: '' }, + body: { start: '' } + } +} + +export default function config(options = `${info.root}/dos.js`) { + let base_config = { + ...default_options, + comments + } + + // try to get the docs file from the passed filepath + if (is.string(options)) { + try { + options = require(options) + + // ensures `ignore` is always an array + if (options.ignore) { + options.ignore = to.array(options.ignore) + } + } catch(err) { + options = {} + } + } + + if (is.object(options)) { + // merge the default options with the user options + options = to.extend(base_config, ensure_valid_config(options)) + + let comments = {}; + for (let [option, value] of to.entries(options.comments)){ + // converts option into an array so multiple languages can be declared at the same time + option = option.replace(/\s/g, '').split(','); + + for (let lang in option) comments[option[lang]] = value; + } + + options.comments = comments; + + + return options; + } else { + log.error(`config only accepts path to config file, or '{}' of the options`) + } +} + + +let valid_options = to.keys(default_options); +let valid_comment_options = to.keys(default_comment); + +/// @name ensure_valid_config +/// @description +/// Ensures that the user set's a valid config +/// @access private +function ensure_valid_config(user_config) { + for (let key in user_config) { + if (!is.included(valid_options, key)) { + log.warn(`'${key}' is not a valid option, see docs options for more details`); //# @todo add link to the doc options + } + } + + // ensures the newly added language has the correct comment format + if (user_config.comments) { + for (let lang in user_config.comments) { + for (let type in lang) { + if (!is.included(valid_comment_options, type)) { + log.warn(`'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`); + } + } + } + } + + return user_config; +} \ No newline at end of file From ffbef0bbd8e8c7a425ddb345f985da3d8c7986e6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:16:46 -0400 Subject: [PATCH 033/273] changed the name of a function --- app/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils.js b/app/utils.js index 4722713..a468961 100644 --- a/app/utils.js +++ b/app/utils.js @@ -820,7 +820,7 @@ export function log(...args) { console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)); }; -log.warning = (...args) => { +log.warn = (...args) => { console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow("[WARNING]"))} ${args.shift()}`, ...args), "\n"); }; From 497c3213306763142a8e960070e14e4af7fc33b0 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:17:11 -0400 Subject: [PATCH 034/273] Added support for generators and async functions --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index df1e504..5e4a6a7 100644 --- a/package.json +++ b/package.json @@ -78,5 +78,6 @@ "devDependencies": { "babel": "^5.5.4" }, + "babel-runtime": "^5.8.25" } } From 3330da165f5d9c229bf647c4d8d5b5ac4896f159 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:17:44 -0400 Subject: [PATCH 035/273] General updates to `package.json` --- package.json | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 5e4a6a7..92b7880 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,27 @@ { "name": "docs", - "description": "Documentation chameleon, addapts to any language and will help you document all the things.", - "author": { - "name": "Tyler Benton", - "email": "tjbenton21@gmail.com" + "description": "Documentation chameleon, adapts to any language and will help you document all the things.", + "author": "Tyler Benton", + "version": "0.0.0beta1", "scripts": { "watch": "babel app/ -d ./dist --stage 0 --optional runtime --watch", "deploy": "npm run test && git push origin master && npm publish", "build": "babel app/ -d ./dist --optional runtime --stage 0", "prepublish": "npm run build" }, - "version": "0.1.0", + "main": "dist/index.js", + "files": [ + "dist/", + "bin/", + "LICENSE" + ], "license": { "type": "MIT", "url": "http://opensource.org/licenses/MIT" }, "repository": { "type": "git", - "url": "https://github.com/tjbenton/docs" + "url": "git+https://github.com/tjbenton/docs.git" }, "bugs": { "url": "https://github.com/tjbenton/docs/issues" @@ -76,8 +80,7 @@ "node": ">=0.10.0" }, "devDependencies": { - "babel": "^5.5.4" - }, + "babel": "^5.8.23", "babel-runtime": "^5.8.25" } } From 22c536c0361273cdb5407099d7d2ef1e52c9f7cf Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 19:18:34 -0400 Subject: [PATCH 036/273] Added an event emmiter --- app/utils/emmiter.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/utils/emmiter.js diff --git a/app/utils/emmiter.js b/app/utils/emmiter.js new file mode 100644 index 0000000..165664b --- /dev/null +++ b/app/utils/emmiter.js @@ -0,0 +1,22 @@ +export default class Emitter { + constructor() { + this.events = [] + } + + /// @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, obj) { + (this.events[name] || []).forEach((event) => event.call(this, obj)) + return this + } +} \ No newline at end of file From 355a1375411a68333f2512d12ce08c1dfab257a6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 11 Oct 2015 21:49:54 -0400 Subject: [PATCH 037/273] Fixed config --- app/config.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/config.js b/app/config.js index b2b1b04..94e2484 100644 --- a/app/config.js +++ b/app/config.js @@ -39,7 +39,7 @@ let comments = { } } -export default function config(options = `${info.root}/dos.js`) { +export default function config(options = `${info.root}/docs.js`) { let base_config = { ...default_options, comments @@ -49,17 +49,17 @@ export default function config(options = `${info.root}/dos.js`) { if (is.string(options)) { try { options = require(options) - - // ensures `ignore` is always an array - if (options.ignore) { - options.ignore = to.array(options.ignore) - } } catch(err) { options = {} } } if (is.object(options)) { + // ensures `ignore` is always an array + if (options.ignore) { + options.ignore = to.array(options.ignore) + } + // merge the default options with the user options options = to.extend(base_config, ensure_valid_config(options)) From 03b1d8c15686059e72cafefce2a7a911ded58e93 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 10:31:57 -0400 Subject: [PATCH 038/273] updated jscs settings --- .jscsrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.jscsrc b/.jscsrc index 11a1993..cac4809 100644 --- a/.jscsrc +++ b/.jscsrc @@ -36,12 +36,11 @@ "while" ], "requireCurlyBraces": [ - "if", "else", + "else if", "do", "try", "catch", - "case", "default" ], "requireLineBreakAfterVariableAssignment": true, From 26b85bc49a81927a580b37a4917397114ce54062 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 10:32:16 -0400 Subject: [PATCH 039/273] Updated `cli.js` to be more flexible --- app/cli.js | 135 ++++++++++++----------------------------------------- 1 file changed, 30 insertions(+), 105 deletions(-) diff --git a/app/cli.js b/app/cli.js index 47d5250..61108d1 100644 --- a/app/cli.js +++ b/app/cli.js @@ -1,115 +1,40 @@ -let doc = ` -Usage: - sassdoc - [options] - sassdoc ... [options] -Arguments: - Path to your Sass folder. -Options: - -h, --help Bring help. - --version Show version. - -v, --verbose Enable verbose mode. - -d, --dest= Documentation folder. - -c, --config= Path to JSON/YAML configuration file. - -t, --theme= Theme to use. - -p, --parse Parse the input and output JSON data to stdout. - --no-update-notifier Disable update notifier check. - --strict Turn warnings into errors. - --debug Output debugging information. -`; - -// import Environment from './environment'; -// import Logger from './logger'; -// import sassdoc, { parse } from './sassdoc'; -// import * as errors from './errors'; -// import source from 'vinyl-source-stream'; - -import pkg from '../package.json'; -import path from 'path'; -import {info} from './utils.js'; -import program from 'commander'; -import config from './config.js'; +import pkg from '../package.json' +import path from 'path' +import {info, fs} from './utils.js' +import program from 'commander' +import docs from './docs.js' +import {base_config} from './config.js' export default function cli(argv) { + // helper functions to parse passed options + const to_list = (str) => str.replace(/\s/g, '').split(',') + const to_boolean = (str) => str !== 'false' ? true : false + const to_number = (str) => ~~str + program .version(pkg.version) .usage('docs [options]') .description('Parse all your documentation, and output a json file') - .option('-c, --config=', 'Path to configuration file (default is `./docs.js`)') - .option('-f, --files ', 'The files to be parsed', function(val) { - return val.split(','); - }) - .option('-d, --dest=', 'Documentation folder.') - .parse(process.argv); + .option('-c, --config [path]', `Path to configuration file (default is \`${base_config.config}\`)`) + .option('-f, --files ', `Paths to parsed (default \`${base_config.config}\`)`, to_list) + .option('-i, --ignore ', `Paths to ignore (default \`${base_config.ignore}\`)`, to_list) + .option('-a, --changed [boolean]', `Parse changed files (default \`${base_config.changed}\`)`, to_boolean) + .option('-b, --blank-lines [number]', `Stops parsing lines after consecutive blank lines (default \`${base_config.blank_lines}\`)`, to_number) + .option('-d, --dest [path]', 'Documentation folder. (default `./docs/docs.json`)') + .parse(process.argv) - // - // if (!options['-'] && !options[''].length) { - // // Trigger help display. - // docopt(doc, { version: pkg.version, argv: ['--help'] }); - // } - // - // let logger = new Logger(options['--verbose'], options['--debug'] || process.env.SASSDOC_DEBUG); - // let env = new Environment(logger, options['--strict']); - // - // logger.debug('argv:', () => JSON.stringify(argv)); - // - // env.on('error', error => { - // if (error instanceof errors.Warning) { - // process.exit(2); - // } - // - // process.exit(1); - // }); - // - // env.load(options['--config']); - // - // // Ensure CLI options. - // ensure(env, options, { - // dest: '--dest', - // theme: '--theme', - // noUpdateNotifier: '--no-update-notifier', - // }); - // - // env.postProcess(); - // - // // Run update notifier if not explicitely disabled. - // if (!env.noUpdateNotifier) { - // require('./notifier')(pkg, logger); - // } - // - // let handler, cb; - // - // // Whether to parse only or to documentize. - // if (!options['--parse']) { - // handler = sassdoc; - // cb = () => {}; - // } else { - // handler = parse; - // cb = data => console.log(JSON.stringify(data, null, 2)); - // } - // - // if (options['-']) { - // return process.stdin - // .pipe(source()) - // .pipe(handler(env)) - // .on('data', cb); - // } - // - // handler(options[''], env).then(cb); -} + let { + dest = `${info.root}/docs/docs.json`, + config = base_config.config, + files = base_config.files, + ignore = base_config.ignore, + changed = base_config.changed, + blankLines: blank_lines = base_config.blank_lines + } = program -/** - * Ensure that CLI options take precedence over configuration values. - * - * For each name/option tuple, if the option is set, override configuration - * value. - */ -function ensure(env, options, names) { - for (let k of Object.keys(names)) { - let v = names[k]; + let cli_options = { config, files, ignore, changed, blank_lines } - if (options[v]) { - env[k] = options[v]; - env[k + 'Cwd'] = true; - } - } + // @todo update docs function to work like this + // docs({ config, files, ignore, changed, blank_lines }) + // .then((parsed) => fs.outputJson(dest, parsed)) } \ No newline at end of file From 56697d446bc673ff6cb11a232706008371d4156d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 11:16:44 -0400 Subject: [PATCH 040/273] Updated to use `commander` to set the defaults --- app/cli.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/app/cli.js b/app/cli.js index 61108d1..4fddf9b 100644 --- a/app/cli.js +++ b/app/cli.js @@ -7,34 +7,35 @@ import {base_config} from './config.js' export default function cli(argv) { // helper functions to parse passed options - const to_list = (str) => str.replace(/\s/g, '').split(',') + const to_list = (str) => str.replace(/\s/g, '').split(',').filter(Boolean) const to_boolean = (str) => str !== 'false' ? true : false const to_number = (str) => ~~str program .version(pkg.version) .usage('docs [options]') - .description('Parse all your documentation, and output a json file') - .option('-c, --config [path]', `Path to configuration file (default is \`${base_config.config}\`)`) - .option('-f, --files ', `Paths to parsed (default \`${base_config.config}\`)`, to_list) - .option('-i, --ignore ', `Paths to ignore (default \`${base_config.ignore}\`)`, to_list) - .option('-a, --changed [boolean]', `Parse changed files (default \`${base_config.changed}\`)`, to_boolean) - .option('-b, --blank-lines [number]', `Stops parsing lines after consecutive blank lines (default \`${base_config.blank_lines}\`)`, to_number) - .option('-d, --dest [path]', 'Documentation folder. (default `./docs/docs.json`)') - .parse(process.argv) - - let { - dest = `${info.root}/docs/docs.json`, - config = base_config.config, - files = base_config.files, - ignore = base_config.ignore, - changed = base_config.changed, - blankLines: blank_lines = base_config.blank_lines - } = program + .description(` + Parse all your documentation, and output a json file. - let cli_options = { config, files, ignore, changed, blank_lines } + Note: + If you want to select \`.*\` file by it's self you have to add + quotes around it, or a trailing comma. This is a issue with 'commander'. + `) + .option('-c, --config [path]', `Path to configuration file`, base_config.config) + .option('-f, --files ', `Paths to parsed`, to_list, base_config.files) + .option('-i, --ignore ', `Paths to ignore`, to_list, base_config.ignore) + .option('-a, --changed [boolean]', `Parse changed files`, to_boolean, base_config.changed) + .option('-b, --blank-lines ', `Stops parsing lines after consecutive blank lines`, to_number, base_config.blank_lines) + .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) + .parse(process.argv) // @todo update docs function to work like this - // docs({ config, files, ignore, changed, blank_lines }) + // docs({ + // config, + // files, + // ignore, + // changed, + // blankLines: blank_lines + // } = program) // .then((parsed) => fs.outputJson(dest, parsed)) } \ No newline at end of file From 13e14fa447958f83e1489755950bf1f731fc6203 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 11:18:20 -0400 Subject: [PATCH 041/273] Updated config to only accept a structure --- app/config.js | 81 ++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/app/config.js b/app/config.js index 94e2484..acb780b 100644 --- a/app/config.js +++ b/app/config.js @@ -2,8 +2,9 @@ import {info, fs, is, to, log} from './utils.js' // changed by `options` key const default_options = { - files: 'app/**/*', // files to search - ignore: ['.*','node_modules/', 'bower_components/', 'jspm_packages/'], // files to be ignored + config: `${info.root}/docsfile.js`, + files: ['app/**/*'], // files to search + ignore: ['.*', 'node_modules/', 'bower_components/', 'jspm_packages/'], // files to be ignored changed: true, // determins if only changed files should be parsed or not blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. annotations: {} @@ -19,7 +20,7 @@ const default_comment = { } // some defaults for common languages -let comments = { +const comments = { _: default_comment, css: { header: { start: '/***', line: '*', end: '***/' }, @@ -39,50 +40,56 @@ let comments = { } } -export default function config(options = `${info.root}/docs.js`) { - let base_config = { - ...default_options, - comments - } - // try to get the docs file from the passed filepath - if (is.string(options)) { - try { - options = require(options) - } catch(err) { - options = {} - } - } +export const base_config = { + ...default_options, + comments +} - if (is.object(options)) { - // ensures `ignore` is always an array - if (options.ignore) { - options.ignore = to.array(options.ignore) - } +export default function config(options = {}) { + let config_file = (options.config ? options : base_config).config + // try to get the `docsfile.js` so the user config can be merged + try { // merge the default options with the user options - options = to.extend(base_config, ensure_valid_config(options)) + config_file = require(config_file) + } catch(err) { + config_file = {} + } - let comments = {}; - for (let [option, value] of to.entries(options.comments)){ - // converts option into an array so multiple languages can be declared at the same time - option = option.replace(/\s/g, '').split(','); + // merge config file with passed options + options = to.extend(options, ensure_valid_config(config_file)) - for (let lang in option) comments[option[lang]] = value; - } + // merge options with base_config so there's a complete list of settings + options = to.extend(to.clone(base_config), options) + + // ensures `files`, `ignore` is always an array this way no + // more checks have to happen for it + options.files = to.array(options.files) + options.ignore = to.array(options.ignore) + + // ensures blank_lines is a number to avoid errors + options.blank_lines = to.number(options.blank_lines) - options.comments = comments; + let comments = {} + // ensures comments are a normal structure (aka not `'rb, py': {...}`) + for (let [option, value] of to.entries(options.comments)){ + // converts option into an array so multiple languages can be declared at the same time + option = option.replace(/\s/g, '').split(',') - return options; - } else { - log.error(`config only accepts path to config file, or '{}' of the options`) + for (let lang in option) comments[option[lang]] = value } + + options.comments = comments + + + return options } -let valid_options = to.keys(default_options); -let valid_comment_options = to.keys(default_comment); +let valid_options = to.keys(default_options) +let valid_comment_options = to.keys(default_comment) /// @name ensure_valid_config /// @description @@ -91,7 +98,7 @@ let valid_comment_options = to.keys(default_comment); function ensure_valid_config(user_config) { for (let key in user_config) { if (!is.included(valid_options, key)) { - log.warn(`'${key}' is not a valid option, see docs options for more details`); //# @todo add link to the doc options + log.warn(`'${key}' is not a valid option, see docs options for more details`) //# @todo add link to the doc options } } @@ -100,11 +107,11 @@ function ensure_valid_config(user_config) { for (let lang in user_config.comments) { for (let type in lang) { if (!is.included(valid_comment_options, type)) { - log.warn(`'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`); + log.warn(`'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`) } } } } - return user_config; + return user_config } \ No newline at end of file From f4fe34ffe8d09a80860fbe7a9c3c8d0e8ece9656 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 12:02:33 -0400 Subject: [PATCH 042/273] Fixed jscs errors --- app/paths.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/paths.js b/app/paths.js index 942996f..817e77f 100644 --- a/app/paths.js +++ b/app/paths.js @@ -1,12 +1,12 @@ -"use strict"; -import {Deferred, fs, path, info, glob, is, to} from "./utils.js"; +'use strict'; +import {Deferred, fs, path, info, glob, is, to} from './utils.js'; // @name paths // @description // Filters out changed files, `.md` files, and paths that aren't files // @promise // @args {array, string} -// @returns {array} - Filtered file paths +// @returns {promise, array} - Filtered file paths export default function paths(globs, changed = true) { globs = to.array(globs); // Converts globs into an array if it's not already. @@ -49,7 +49,7 @@ export default function paths(globs, changed = true) { resolve(source); fs.fake_copy(source, target); // copies new files over. } else { - resolve(Promise.resolve("")); + resolve(Promise.resolve('')); } }) .catch((err) => { @@ -72,7 +72,7 @@ export default function paths(globs, changed = true) { function filter(files) { files = files.filter((obj) => { let ext = path.extname(obj).toLowerCase(); - return ext !== ".md" && ext.charAt(0) === "."; + return ext !== '.md' && ext.charAt(0) === '.'; }); // a) Return all the files that were passed except From 8e95e711f112c0db510147cf3f3c6171f3141c58 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 14:16:02 -0400 Subject: [PATCH 043/273] Added new `to.flat_array` Also created a better glob function --- app/utils.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/app/utils.js b/app/utils.js index a468961..4a3bc7c 100644 --- a/app/utils.js +++ b/app/utils.js @@ -59,8 +59,54 @@ 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}; +let _glob = denodeify(require('glob')); + +import co from 'co' + +export let glob = co.wrap(function *(globs, ignored_globs = []) { + globs = to.array(globs) + ignored_globs = to.array(ignored_globs) + + let matched_globs = [] + + // get the files paths using glob + for (let [i, file] of to.entries(globs)) { + if (file.substr(0, 1) !== '!') { + matched_globs.push(_glob(file).then((data) => data)) + } else { + ignored_globs.push(file) + } + } + + let matched_ignored_globs = [] + // get the ignored_globs file paths + for (let [i, file] of to.entries(ignored_globs)) { + matched_ignored_globs.push(_glob(file.replace(/!/, ''))) + } + + matched_globs = yield Promise.all(matched_globs).then((result) => to.flat_array(result)) + matched_ignored_globs = yield Promise.all(matched_ignored_globs).then((result) => to.flat_array(result)) + + console.log('matched_globs:', matched_globs); + console.log('matched_ignored_globs:', matched_ignored_globs); + console.log(''); + + // prevents extra functions from running if they don't need to + if (!matched_ignored_globs.length) { + return matched_globs; + } + + // return filtered files + return matched_globs.filter((file) => { + for (let i in matched_ignored_globs) { + if (file.indexOf(matched_ignored_globs[i]) > -1) { + return false; + break; + } + } + return true; + }) +}); const to_string = (arg) => Object.prototype.toString.call(arg), array_slice = (arg) => Array.prototype.slice.call(arg); @@ -425,6 +471,13 @@ export let to = { return result; }, + /// @name to.flat_array + /// @description + /// Flattens an array, and arrays inside of it into a single array + /// @arg {array} + /// @returnes {array} - single dimensional + flat_array: (arg) => is.array(arg) ? [].concat(...arg.map(to.flat_array)) : arg, + /// @name to.sort /// @description /// Sorts an array or object based off your callback function. If one is provided. From 87e658757aee27c1e1bc72e48f375e83f04e5f18 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 15:00:40 -0400 Subject: [PATCH 044/273] Added `co` for generator support --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 92b7880..218c941 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "dependencies": { "chalk": "^1.1.0", + "co": "^4.6.0", "commander": "^2.8.1", "fs-extra": "^0.24.0", "glob": "^5.0.6", From 26f667a1d4ae44f64a8ea1096aa7facd11d748a3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 15:01:12 -0400 Subject: [PATCH 045/273] Removed `console.log`s from glob --- app/utils.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/utils.js b/app/utils.js index 4a3bc7c..9741dcf 100644 --- a/app/utils.js +++ b/app/utils.js @@ -63,7 +63,7 @@ let _glob = denodeify(require('glob')); import co from 'co' -export let glob = co.wrap(function *(globs, ignored_globs = []) { +export const glob = co.wrap(function *(globs, ignored_globs = []) { globs = to.array(globs) ignored_globs = to.array(ignored_globs) @@ -87,10 +87,6 @@ export let glob = co.wrap(function *(globs, ignored_globs = []) { matched_globs = yield Promise.all(matched_globs).then((result) => to.flat_array(result)) matched_ignored_globs = yield Promise.all(matched_ignored_globs).then((result) => to.flat_array(result)) - console.log('matched_globs:', matched_globs); - console.log('matched_ignored_globs:', matched_ignored_globs); - console.log(''); - // prevents extra functions from running if they don't need to if (!matched_ignored_globs.length) { return matched_globs; @@ -106,7 +102,7 @@ export let glob = co.wrap(function *(globs, ignored_globs = []) { } return true; }) -}); +}) const to_string = (arg) => Object.prototype.toString.call(arg), array_slice = (arg) => Array.prototype.slice.call(arg); From 131fb9640f2156ac079f4f5e1a75874bae4cfd35 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 15:12:20 -0400 Subject: [PATCH 046/273] Fixed JSCS errors --- app/utils.js | 104 +++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/app/utils.js b/app/utils.js index 9741dcf..b672884 100644 --- a/app/utils.js +++ b/app/utils.js @@ -1,6 +1,6 @@ // import and export `path` so all general // utils can be imported from this file -import path from "path"; +import path from 'path'; export {path}; // Stores the project directory to use later @@ -11,8 +11,8 @@ info.dir = info.root.split(path.sep); // splits the project dir by the system sp 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"); +info.temp.folder = path.join(info.root, '.tmp'); +info.temp.file = path.join(info.temp.folder, 'data.json'); export {info}; // @name denodeify @@ -33,7 +33,7 @@ export function denodeify(func) { // File System -import * as fs from "fs-extra"; +import * as fs from 'fs-extra'; // @name fs.fake_copy // @description @@ -46,7 +46,7 @@ fs.fake_copy = (source, target, callback) => { // 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()); + fs.writeFile(path.join(target.dir, target.base), '', () => callback && callback()); }); }; @@ -63,7 +63,7 @@ let _glob = denodeify(require('glob')); import co from 'co' -export const glob = co.wrap(function *(globs, ignored_globs = []) { +export const glob = co.wrap(function*(globs, ignored_globs = []) { globs = to.array(globs) ignored_globs = to.array(ignored_globs) @@ -107,7 +107,7 @@ export const glob = co.wrap(function *(globs, ignored_globs = []) { const to_string = (arg) => Object.prototype.toString.call(arg), array_slice = (arg) => Array.prototype.slice.call(arg); -import markdown from "marked"; +import markdown from 'marked'; export let to = { /// @name to.markdown @@ -122,7 +122,7 @@ export let to = { /// 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 + "", + 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 + '', case: { /// @name to.case.clean @@ -133,8 +133,8 @@ export let to = { /// @arg {string} /// @return {string} clean(str) { - let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? " " + next : ""), - uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + " " + uppers.toLowerCase().split(" ").join(" ")); + let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? ' ' + next : ''), + uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + ' ' + uppers.toLowerCase().split(' ').join(' ')); // a) has spaces // b) has separator @@ -150,7 +150,7 @@ export let to = { var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) { - if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" && (title.charAt(index + match.length) !== "-" || title.charAt(index - 1) === "-") && title.charAt(index - 1).search(/[^\s-]/) < 0) { + if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) { return match.toLowerCase(); } @@ -184,31 +184,31 @@ export let to = { /// @description Replaces camel case, dot, and dash cases with a space /// @arg {string} /// @returns {string} - space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? " " + match : ""), + space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? ' ' + match : ''), /// @name to.case.snake /// @description Converts a string to snake case /// @arg {string} /// @returns {string} - snake: (str) => to.case.space(str).replace(/\s/g, "_"), + snake: (str) => to.case.space(str).replace(/\s/g, '_'), /// @name to.case.dash /// @description Converts a string to dash case /// @arg {string} /// @returns {string} - dash: (str) => to.case.space(str).replace(/\s/g, "-"), + dash: (str) => to.case.space(str).replace(/\s/g, '-'), /// @name to.case.dot /// @description Converts a string to dot case /// @arg {string} /// @returns {string} - dot: (str) => to.case.space(str).replace(/\s/g, "."), + dot: (str) => to.case.space(str).replace(/\s/g, '.'), /// @name to.case.swap /// @description Converts capital letters to lower case and vice versa /// @arg {string} /// @returns {string} - swap: (str) => str.split("").map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join("") + swap: (str) => str.split('').map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join('') }, @@ -223,7 +223,7 @@ export let to = { /// /// @arg {*} /// @returns {string} That has microsoft crap removed from it - normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/g, "\n"), + normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/g, '\n'), /// @name to.keys /// @description @@ -318,11 +318,11 @@ export let to = { while (content.length && !!!(content[content.length - 1].trim()).length) content.pop(); return content.map((line) => line.slice( - content.join("\n") // converts content to string to string + 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 from each line + .join('\n').replace(/[^\S\r\n]+$/gm, ''); // convert to string and remove all trailing white spaces from each line }, /// @name to.extend @@ -453,7 +453,7 @@ export let to = { /// @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", + 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); @@ -571,49 +571,49 @@ export let is = { /// 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)), + argument: (arg) => !is.null(arg) && (to_string.call(arg) === '[object Arguments]' || (typeof arg === 'object' && 'callee' in arg)), /// @name is.regex /// @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]", + regex: (value) => to_string.call(value) === '[object RegExp]', /// @name is.function /// @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", + function: (arg) => to_string(arg) === '[object Function]' || typeof arg === 'function', /// @name is.array /// @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]", + array: (arg) => to_string(arg) === '[object Array]', /// @name is.boolean /// @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]", + boolean: (arg) => arg === true || arg === false || to_string(arg) === '[object Boolean]', /// @name is.object /// @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, + object: (arg) => typeof arg === 'object' && !!arg && arg !== null, /// @name is.symbol /// @description is a given arg a symbol? /// @arg {*} arg - The item to check /// @returns {boolean} - The result of the test - symbol: (arg) => typeof arg === "symbol", + symbol: (arg) => typeof arg === 'symbol', /// @name is.json /// @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]", + json: (arg) => to_string(arg) === '[object Object]', /// @name is.empty /// @description is a given arg empty? Objects, arrays, strings @@ -623,11 +623,11 @@ export let is = { var type = typeof arg; if (is.falsy(arg)) { return true; - } else if (type === "function" || type === "object" && !!arg) { + } 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 === ""; + return arg === ''; } }, @@ -641,7 +641,7 @@ export let is = { /// @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]", + string: (arg) => to_string(arg) === '[object String]', /// @name is.undefined /// @description is a given arg undefined? @@ -675,7 +675,7 @@ export let is = { /// @description is a given arg truthy? /// @arg {*} arg /// @returns {boolean} - truthy: (arg) => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== "" && arg !== 0, + truthy: (arg) => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== '' && arg !== 0, /// @name is.falsy /// @description is given arg falsy? @@ -693,7 +693,7 @@ export let is = { /// @description is given arg a number? /// @arg {*} arg /// @returns {boolean} - number: (arg) => is.not.nan(arg) && to_string(arg) === "[object Number]", + number: (arg) => is.not.nan(arg) && to_string(arg) === '[object Number]', /// @name is.between /// @description is a given number within minimum and maximum parameters? @@ -755,19 +755,19 @@ export let is = { }; // included method does not support `all` and `any` interfaces -is.included.api = ["not"]; +is.included.api = ['not']; // within method does not support `all` and `any` interfaces -is.between.api = ["not"]; +is.between.api = ['not']; // `above` method does not support `all` and `any` interfaces -is.above.api = ["not"]; +is.above.api = ['not']; // least method does not support `all` and `any` interfaces -is.under.api = ["not"]; +is.under.api = ['not']; -is.in.api = ["not"]; +is.in.api = ['not']; is.all.in = (obj, ...values) => { values = to.array.flat(values); @@ -834,15 +834,15 @@ const not = (func) => () => !func.apply(null, array_slice(arguments)), 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"]; + var interfaces = options[option].api || ['not', 'all', 'any']; for (let i in interfaces) { - if (interfaces[i] === "not") { + if (interfaces[i] === 'not') { is.not[option] = not(is[option]); } - if (interfaces[i] === "all") { + if (interfaces[i] === 'all') { is.all[option] = all(is[option]); } - if (interfaces[i] === "any") { + if (interfaces[i] === 'any') { is.any[option] = any(is[option]); } } @@ -853,14 +853,14 @@ const not = (func) => () => !func.apply(null, array_slice(arguments)), -import {format as _format} from "util"; -import chalk from "chalk"; +import {format as _format} from 'util'; +import chalk from 'chalk'; let _times = {}, - chevron = "\xBB", - check = "\u2713", - warning = "\u26A0", - error = "\u2326"; + chevron = '\xBB', + check = '\u2713', + warning = '\u26A0', + error = '\u2326'; // @name Log // @description @@ -870,19 +870,19 @@ export function log(...args) { }; log.warn = (...args) => { - console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow("[WARNING]"))} ${args.shift()}`, ...args), "\n"); + console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]'))} ${args.shift()}`, ...args), '\n'); }; log.error = (...args) => { console.trace(...args); - console.log(_format(`${chalk.red(error, chalk.bold.red("[ERROR]"))} ${args.shift()}`, ...args), "\n"); + console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]'))} ${args.shift()}`, ...args), '\n'); }; log.time = (label) => { _times[label] = Date.now(); }; -log.timeEnd = (label, format = "%s completed after %dms") => { +log.timeEnd = (label, format = '%s completed after %dms') => { let time = _times[label]; if (!time) { @@ -902,5 +902,5 @@ log.debug = (...args) => { return f; }); - console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), "\n"); + console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n'); }; \ No newline at end of file From c8787880c58dcbb672e90476b95b9fbdfc53198f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 17:03:19 -0400 Subject: [PATCH 047/273] Moved utilities into it's own folder --- app/cli.js | 4 +- app/config.js | 2 +- app/docs.js | 2 +- app/parser.js | 3 +- app/paths.js | 3 +- app/sorter.js | 2 +- app/utils.js | 906 ----------------------------------------- app/utils/denodeify.js | 15 + app/utils/fs.js | 27 ++ app/utils/glob.js | 48 +++ app/utils/index.js | 8 + app/utils/info.js | 14 + app/utils/is.js | 299 ++++++++++++++ app/utils/log.js | 54 +++ app/utils/to.js | 456 +++++++++++++++++++++ 15 files changed, 930 insertions(+), 913 deletions(-) delete mode 100644 app/utils.js create mode 100644 app/utils/denodeify.js create mode 100644 app/utils/fs.js create mode 100644 app/utils/glob.js create mode 100644 app/utils/index.js create mode 100644 app/utils/info.js create mode 100644 app/utils/is.js create mode 100644 app/utils/log.js create mode 100644 app/utils/to.js diff --git a/app/cli.js b/app/cli.js index 4fddf9b..15d4998 100644 --- a/app/cli.js +++ b/app/cli.js @@ -1,8 +1,8 @@ import pkg from '../package.json' import path from 'path' -import {info, fs} from './utils.js' +import {info, fs} from './utils' import program from 'commander' -import docs from './docs.js' +// import docs from './docs.js' import {base_config} from './config.js' export default function cli(argv) { diff --git a/app/config.js b/app/config.js index acb780b..97479d1 100644 --- a/app/config.js +++ b/app/config.js @@ -1,4 +1,4 @@ -import {info, fs, is, to, log} from './utils.js' +import {info, fs, is, to, log} from './utils' // changed by `options` key const default_options = { diff --git a/app/docs.js b/app/docs.js index b5cde82..7aebc22 100755 --- a/app/docs.js +++ b/app/docs.js @@ -5,7 +5,7 @@ process.on("uncaughtException", function(err) { process.exit(1); }); -import {info, fs, is, to, log} from "./utils.js"; +import {info, fs, is, to, log} from "./utils"; import paths from "./paths.js"; import AnnotationApi from "./annotation"; import parser from "./parser.js"; diff --git a/app/parser.js b/app/parser.js index 5f9b444..83cfb95 100644 --- a/app/parser.js +++ b/app/parser.js @@ -1,4 +1,5 @@ -import {info, fs, path, is, to} from "./utils.js"; +import {info, fs, is, to} from "./utils" +import path from 'path' /// @name parse_file /// @description diff --git a/app/paths.js b/app/paths.js index 817e77f..73a52d0 100644 --- a/app/paths.js +++ b/app/paths.js @@ -1,5 +1,6 @@ 'use strict'; -import {Deferred, fs, path, info, glob, is, to} from './utils.js'; +import {fs, info, glob, is, to} from './utils' +import path from 'path' // @name paths // @description diff --git a/app/sorter.js b/app/sorter.js index b863a59..9d4328c 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -1,4 +1,4 @@ -import {info, fs, path, is, to, log} from "./utils.js"; +import {info, fs, path, is, to, log} from "./utils"; /// @name sort /// @description diff --git a/app/utils.js b/app/utils.js deleted file mode 100644 index b672884..0000000 --- a/app/utils.js +++ /dev/null @@ -1,906 +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')); - -import co from 'co' - -export const glob = co.wrap(function*(globs, ignored_globs = []) { - globs = to.array(globs) - ignored_globs = to.array(ignored_globs) - - let matched_globs = [] - - // get the files paths using glob - for (let [i, file] of to.entries(globs)) { - if (file.substr(0, 1) !== '!') { - matched_globs.push(_glob(file).then((data) => data)) - } else { - ignored_globs.push(file) - } - } - - let matched_ignored_globs = [] - // get the ignored_globs file paths - for (let [i, file] of to.entries(ignored_globs)) { - matched_ignored_globs.push(_glob(file.replace(/!/, ''))) - } - - matched_globs = yield Promise.all(matched_globs).then((result) => to.flat_array(result)) - matched_ignored_globs = yield Promise.all(matched_ignored_globs).then((result) => to.flat_array(result)) - - // prevents extra functions from running if they don't need to - if (!matched_ignored_globs.length) { - return matched_globs; - } - - // return filtered files - return matched_globs.filter((file) => { - for (let i in matched_ignored_globs) { - if (file.indexOf(matched_ignored_globs[i]) > -1) { - return false; - break; - } - } - return true; - }) -}) - -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.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 + '', - - case: { - /// @name to.case.clean - /// @description - /// Remove any starting case from a `string`, like camel or snake, but keep - /// spaces and punctuation that may be important otherwise. - /// - /// @arg {string} - /// @return {string} - clean(str) { - let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? ' ' + next : ''), - uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + ' ' + uppers.toLowerCase().split(' ').join(' ')); - - // a) has spaces - // b) has separator - return (/\s/.test(str) ? str : /[\W_]/.test(str) ? (unseparate(str) || str) : uncamelize(str)).toLowerCase(); - }, - - /// @name to.case.title - /// @description Converts a string to title case - /// @arg {string} - /// @returns {string} - title(str) { - // https://github.com/gouch/to-title-case/blob/master/to-title-case.js - var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; - - return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) { - if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) { - return match.toLowerCase(); - } - - if (match.substr(1).search(/[A-Z]|\../) > -1) { - return match; - } - - return match.charAt(0).toUpperCase() + match.substr(1); - }); - }, - - /// @name to.case.lower - /// @description Converts a string to lower case(aka `str.toLowerCase()`) - /// @arg {string} - /// @returns {string} - lower: (str) => str.toLowerCase(), - - /// @name to.case.upper - /// @description Converts a string to upper case(aka `str.toUpperCase()`) - /// @arg {string} - /// @returns {string} - upper: (str) => str.toUpperCase(), - - /// @name to.case.sentence - /// @description Converts a string to sentence case - /// @arg {string} - /// @returns {string} - sentence: (str) => to.case.clean(str).replace(/[a-z]/i, (letter) => letter.toUpperCase()), - - /// @name to.case.space - /// @description Replaces camel case, dot, and dash cases with a space - /// @arg {string} - /// @returns {string} - space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? ' ' + match : ''), - - /// @name to.case.snake - /// @description Converts a string to snake case - /// @arg {string} - /// @returns {string} - snake: (str) => to.case.space(str).replace(/\s/g, '_'), - - /// @name to.case.dash - /// @description Converts a string to dash case - /// @arg {string} - /// @returns {string} - dash: (str) => to.case.space(str).replace(/\s/g, '-'), - - /// @name to.case.dot - /// @description Converts a string to dot case - /// @arg {string} - /// @returns {string} - dot: (str) => to.case.space(str).replace(/\s/g, '.'), - - /// @name to.case.swap - /// @description Converts capital letters to lower case and vice versa - /// @arg {string} - /// @returns {string} - swap: (str) => str.split('').map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join('') - }, - - - /// @name to.normal_string - /// @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 - normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/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) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), - - /// @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) => { - if (is.array(obj)) { - return obj.entries(); - } - - let index = 0, - // 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. - keys = to.keys(obj); - - return { - [Symbol.iterator]() { - return this; - }, - next() { - if (index < keys.length) { - let key = keys[index]; - index++; - return { - value: [key, obj[key]] - }; - } else { - return { - done: true - }; - } - } - }; - }, - - /// @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/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 - /// @returns {string} - The normalized string - normalize: (content) => { - content = to.array(content); // this allows arrays and strings to be passed - - // remove leading blank lines - while (content.length && !!!content[0].trim().length) content.shift(); - - // remove trailing blank lines - while (content.length && !!!(content[content.length - 1].trim()).length) 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 from each line - }, - - /// @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; - } - - let k = to.keys(b); - - for (let i = 0, l = k.length; i < l; i++) { - a[k[i]] = is.object(b[k[i]]) ? is.object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] : b[k[i]]; - } - - // 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, flat = 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) is array - if (is.array(a[k])) { - // a) Flatten the array - if (flat) { - a[k] = to.array.flat(a[k]); - } - - // a) Filter out duplicates - if (unique && !is.object(a[k][0])) { - a[k] = to.array.unique(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.flat_array - /// @description - /// Flattens an array, and arrays inside of it into a single array - /// @arg {array} - /// @returnes {array} - single dimensional - flat_array: (arg) => is.array(arg) ? [].concat(...arg.map(to.flat_array)) : arg, - - /// @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} - single dimensional -to.array.flat = (arg) => [].concat.apply([], to.array(arg)); - -/// @name to.array.unique -/// @description -/// Removes duplicate values from an array -/// @arg {array} -/// @returns {array} - without duplicates -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; -}; - -export let is = { - // placeholder for the interfaces - not: {}, - all: {}, - any: {}, - - /// @name is.argument - /// @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)), - - /// @name is.regex - /// @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]', - - /// @name is.function - /// @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', - - /// @name is.array - /// @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]', - - /// @name is.boolean - /// @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]', - - /// @name is.object - /// @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, - - /// @name is.symbol - /// @description is a given arg a symbol? - /// @arg {*} arg - The item to check - /// @returns {boolean} - The result of the test - symbol: (arg) => typeof arg === 'symbol', - - /// @name is.json - /// @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]', - - /// @name is.empty - /// @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 === ''; - } - }, - - /// @name is.exsity - /// @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, - - /// @name is.string - /// @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]', - - /// @name is.undefined - /// @description is a given arg undefined? - /// @arg {*} arg - The item to check - /// @returns {boolean} - undefined: (arg) => arg === void 0, - - /// @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` - /// @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, - - /// @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} - in: (obj, value) => is.included(is.object(obj) ? to.keys(obj) : obj, value) !== false, - - /// @name is.false - /// @description is a given arg false - /// @arg {*} arg - arg to check if it is false - /// @returns {boolean} - false: (arg) => arg === false, - - /// @name is.truthy - /// @description is a given arg truthy? - /// @arg {*} arg - /// @returns {boolean} - truthy: (arg) => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== '' && arg !== 0, - - /// @name is.falsy - /// @description is given arg falsy? - /// @arg {*} arg - /// @returns {boolean} - falsy: (arg) => !is.truthy(arg), - - /// @name is.nan - /// @description NaN is number, also it is the only arg which does not equal itself - /// @arg {*} arg - /// @returns {boolean} - nan: (arg) => arg !== arg, - - /// @name is.number - /// @description is given arg a number? - /// @arg {*} arg - /// @returns {boolean} - number: (arg) => is.not.nan(arg) && to_string(arg) === '[object Number]', - - /// @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} - between: (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max), - - /// @name is.positive - /// @description is a given number positive? - /// @arg {*} arg - /// @returns {boolean} - positive: (arg) => is.number(arg) && arg > 0, - - /// @name is.negative - /// @description is a given number negative? - /// @arg {*} arg - /// @returns {boolean} - negative: (arg) => is.number(arg) && arg < 0, - - /// @name is.above - /// @description is a given number above minimum parameter? - /// @arg {*} arg - /// @arg {number} min [-1] - /// @returns {boolean} - above: (arg, min = -1) => is.all.number(arg, min) && arg > min, - - /// @name is.under - /// @description is a given number above maximum parameter? - /// @arg {*} arg - /// @arg {number} max [100] - /// @returns {boolean} - under: (arg, max = 100) => is.all.number(arg, max) && arg < max, - - /// @name is.null - /// @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, - - /// @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} - promise: (arg) => arg && is.function(arg.then), - - /// @name is.stream - /// @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), - - /// @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} - 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]); - } - } - } - } - })(); - - - - -import {format as _format} from 'util'; -import chalk from 'chalk'; - -let _times = {}, - chevron = '\xBB', - check = '\u2713', - warning = '\u26A0', - error = '\u2326'; - -// @name Log -// @description -// A better console.log -export function log(...args) { - console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)); -}; - -log.warn = (...args) => { - console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]'))} ${args.shift()}`, ...args), '\n'); -}; - -log.error = (...args) => { - console.trace(...args); - console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]'))} ${args.shift()}`, ...args), '\n'); -}; - -log.time = (label) => { - _times[label] = Date.now(); -}; - -log.timeEnd = (label, format = '%s completed after %dms') => { - let time = _times[label]; - - if (!time) { - throw new Error(`No such label: ${label}`); - } - - let duration = Date.now() - time; - console.log(_format(`${chalk.green(check)} ${format}`, label, duration)); -}; - -log.debug = (...args) => { - args = args.map((f) => { - if (f instanceof Function) { - return f(); - } - - return f; - }); - - console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n'); -}; \ No newline at end of file diff --git a/app/utils/denodeify.js b/app/utils/denodeify.js new file mode 100644 index 0000000..2c7405e --- /dev/null +++ b/app/utils/denodeify.js @@ -0,0 +1,15 @@ +// @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 default function denodeify(func) { + return function(...args) { + return new Promise((resolve, reject) => { + func(...args, (err, ...args) => err ? reject(err) : resolve(...args)) + }) + } +} \ No newline at end of file diff --git a/app/utils/fs.js b/app/utils/fs.js new file mode 100644 index 0000000..6a10c58 --- /dev/null +++ b/app/utils/fs.js @@ -0,0 +1,27 @@ +// File System +import path from 'path' +import denodeify from './denodeify.js' +import 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 default fs \ No newline at end of file diff --git a/app/utils/glob.js b/app/utils/glob.js new file mode 100644 index 0000000..62c447a --- /dev/null +++ b/app/utils/glob.js @@ -0,0 +1,48 @@ +// can't use `import` from es6 because it +// returns an error saying "glob" is read only +import to from './to.js' +import denodeify from './denodeify' +import co from 'co' + +let _glob = denodeify(require('glob')) + +export default co.wrap(function*(globs, ignored_globs = []) { + globs = to.array(globs) + ignored_globs = to.array(ignored_globs) + + let matched_globs = [] + + // get the files paths using glob + for (let [i, file] of to.entries(globs)) { + if (file.substr(0, 1) !== '!') { + matched_globs.push(_glob(file).then((data) => data)) + } else { + ignored_globs.push(file) + } + } + + let matched_ignored_globs = [] + // get the ignored_globs file paths + for (let [i, file] of to.entries(ignored_globs)) { + matched_ignored_globs.push(_glob(file.replace(/!/, ''))) + } + + matched_globs = yield Promise.all(matched_globs).then((result) => to.flat_array(result)) + matched_ignored_globs = yield Promise.all(matched_ignored_globs).then((result) => to.flat_array(result)) + + // prevents extra functions from running if they don't need to + if (!matched_ignored_globs.length) { + return matched_globs + } + + // return filtered files + return matched_globs.filter((file) => { + for (let i in matched_ignored_globs) { + if (file.indexOf(matched_ignored_globs[i]) > -1) { + return false + break + } + } + return true + }) +}) \ No newline at end of file diff --git a/app/utils/index.js b/app/utils/index.js new file mode 100644 index 0000000..f6eaf93 --- /dev/null +++ b/app/utils/index.js @@ -0,0 +1,8 @@ +export denodeify from './denodeify.js' +export emmitter from './emmiter.js' +export fs from './fs.js' +export glob from './glob.js' +export info from './info.js' +export is from './is.js' +export log from './log.js' +export to from './to.js' \ No newline at end of file diff --git a/app/utils/info.js b/app/utils/info.js new file mode 100644 index 0000000..eeb570c --- /dev/null +++ b/app/utils/info.js @@ -0,0 +1,14 @@ +import path from '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 default info \ No newline at end of file diff --git a/app/utils/is.js b/app/utils/is.js new file mode 100644 index 0000000..3519dda --- /dev/null +++ b/app/utils/is.js @@ -0,0 +1,299 @@ +const to_string = (arg) => Object.prototype.toString.call(arg) +const array_slice = (arg) => Array.prototype.slice.call(arg) + +import to from './to.js' + +let is = { + // placeholder for the interfaces + not: {}, + all: {}, + any: {}, + + /// @name is.argument + /// @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)), + + /// @name is.regex + /// @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]', + + /// @name is.function + /// @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', + + /// @name is.array + /// @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]', + + /// @name is.boolean + /// @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]', + + /// @name is.object + /// @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, + + /// @name is.symbol + /// @description is a given arg a symbol? + /// @arg {*} arg - The item to check + /// @returns {boolean} - The result of the test + symbol: (arg) => typeof arg === 'symbol', + + /// @name is.json + /// @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]', + + /// @name is.empty + /// @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 === '' + } + }, + + /// @name is.exsity + /// @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, + + /// @name is.string + /// @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]', + + /// @name is.undefined + /// @description is a given arg undefined? + /// @arg {*} arg - The item to check + /// @returns {boolean} + undefined: (arg) => arg === void 0, + + /// @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` + /// @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, + + /// @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} + in: (obj, value) => is.included(is.object(obj) ? to.keys(obj) : obj, value) !== false, + + /// @name is.false + /// @description is a given arg false + /// @arg {*} arg - arg to check if it is false + /// @returns {boolean} + false: (arg) => arg === false, + + /// @name is.truthy + /// @description is a given arg truthy? + /// @arg {*} arg + /// @returns {boolean} + truthy: (arg) => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== '' && arg !== 0, + + /// @name is.falsy + /// @description is given arg falsy? + /// @arg {*} arg + /// @returns {boolean} + falsy: (arg) => !is.truthy(arg), + + /// @name is.nan + /// @description NaN is number, also it is the only arg which does not equal itself + /// @arg {*} arg + /// @returns {boolean} + nan: (arg) => arg !== arg, + + /// @name is.number + /// @description is given arg a number? + /// @arg {*} arg + /// @returns {boolean} + number: (arg) => is.not.nan(arg) && to_string(arg) === '[object Number]', + + /// @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} + between: (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max), + + /// @name is.positive + /// @description is a given number positive? + /// @arg {*} arg + /// @returns {boolean} + positive: (arg) => is.number(arg) && arg > 0, + + /// @name is.negative + /// @description is a given number negative? + /// @arg {*} arg + /// @returns {boolean} + negative: (arg) => is.number(arg) && arg < 0, + + /// @name is.above + /// @description is a given number above minimum parameter? + /// @arg {*} arg + /// @arg {number} min [-1] + /// @returns {boolean} + above: (arg, min = -1) => is.all.number(arg, min) && arg > min, + + /// @name is.under + /// @description is a given number above maximum parameter? + /// @arg {*} arg + /// @arg {number} max [100] + /// @returns {boolean} + under: (arg, max = 100) => is.all.number(arg, max) && arg < max, + + /// @name is.null + /// @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, + + /// @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} + promise: (arg) => arg && is.function(arg.then), + + /// @name is.stream + /// @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), + + /// @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} + 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)) + +const all = (func) => { + return function() { + let parameters = array_slice(arguments) + let 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 + } +} + +const any = (func) => { + return function() { + let parameters = array_slice(arguments) + let 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 + } +} + +;(function setInterfaces() { + let 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]) + } + } + } + } +})() + +export default is \ No newline at end of file diff --git a/app/utils/log.js b/app/utils/log.js new file mode 100644 index 0000000..ff39546 --- /dev/null +++ b/app/utils/log.js @@ -0,0 +1,54 @@ +import {format as _format} from 'util' +import chalk from 'chalk' + +let _times = {} +let chevron = '\xBB' +let check = '\u2713' +let warning = '\u26A0' +let error = '\u2326' + +// @name Log +// @description +// A better console.log +function log(...args) { + console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)) +} + +log.warn = (...args) => { + console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]'))} ${args.shift()}`, ...args), '\n') +} + +log.error = (...args) => { + console.trace(...args) + console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]'))} ${args.shift()}`, ...args), '\n') +} + +log.time = (label) => { + _times[label] = Date.now() +} + +log.timeEnd = (label, format = '%s completed after %dms') => { + let time = _times[label] + + if (!time) { + throw new Error(`No such label: ${label}`) + } + + let duration = Date.now() - time + console.log(_format(`${chalk.green(check)} ${format}`, label, duration)) +} + +log.debug = (...args) => { + args = args.map((f) => { + if (f instanceof Function) { + return f() + } + + return f + }) + + console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n') +} + + +export default log \ No newline at end of file diff --git a/app/utils/to.js b/app/utils/to.js new file mode 100644 index 0000000..a26a21e --- /dev/null +++ b/app/utils/to.js @@ -0,0 +1,456 @@ +const to_string = (arg) => Object.prototype.toString.call(arg) +const array_slice = (arg) => Array.prototype.slice.call(arg) + +import markdown from 'marked' +import is from './is.js' + +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, + + /// @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 + '', + + case: { + /// @name to.case.clean + /// @description + /// Remove any starting case from a `string`, like camel or snake, but keep + /// spaces and punctuation that may be important otherwise. + /// + /// @arg {string} + /// @return {string} + clean(str) { + let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? ' ' + next : '') + let uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + ' ' + uppers.toLowerCase().split(' ').join(' ')) + + // a) has spaces + // b) has separator + return (/\s/.test(str) ? str : /[\W_]/.test(str) ? (unseparate(str) || str) : uncamelize(str)).toLowerCase() + }, + + /// @name to.case.title + /// @description Converts a string to title case + /// @arg {string} + /// @returns {string} + title(str) { + // https://github.com/gouch/to-title-case/blob/master/to-title-case.js + var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i + + return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) { + if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) { + return match.toLowerCase() + } + + if (match.substr(1).search(/[A-Z]|\../) > -1) { + return match + } + + return match.charAt(0).toUpperCase() + match.substr(1) + }) + }, + + /// @name to.case.lower + /// @description Converts a string to lower case(aka `str.toLowerCase()`) + /// @arg {string} + /// @returns {string} + lower: (str) => str.toLowerCase(), + + /// @name to.case.upper + /// @description Converts a string to upper case(aka `str.toUpperCase()`) + /// @arg {string} + /// @returns {string} + upper: (str) => str.toUpperCase(), + + /// @name to.case.sentence + /// @description Converts a string to sentence case + /// @arg {string} + /// @returns {string} + sentence: (str) => to.case.clean(str).replace(/[a-z]/i, (letter) => letter.toUpperCase()), + + /// @name to.case.space + /// @description Replaces camel case, dot, and dash cases with a space + /// @arg {string} + /// @returns {string} + space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? ' ' + match : ''), + + /// @name to.case.snake + /// @description Converts a string to snake case + /// @arg {string} + /// @returns {string} + snake: (str) => to.case.space(str).replace(/\s/g, '_'), + + /// @name to.case.dash + /// @description Converts a string to dash case + /// @arg {string} + /// @returns {string} + dash: (str) => to.case.space(str).replace(/\s/g, '-'), + + /// @name to.case.dot + /// @description Converts a string to dot case + /// @arg {string} + /// @returns {string} + dot: (str) => to.case.space(str).replace(/\s/g, '.'), + + /// @name to.case.swap + /// @description Converts capital letters to lower case and vice versa + /// @arg {string} + /// @returns {string} + swap: (str) => str.split('').map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join('') + }, + + + /// @name to.normal_string + /// @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 + normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/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) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + + /// @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) => { + if (is.array(obj)) { + return obj.entries() + } + + let index = 0, + // 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. + keys = to.keys(obj) + + return { + [Symbol.iterator]() { + return this + }, + next() { + if (index < keys.length) { + let key = keys[index] + index++ + return { + value: [key, obj[key]] + } + } else { + return { + done: true + } + } + } + } + }, + + /// @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/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 + /// @returns {string} - The normalized string + normalize: (content) => { + content = to.array(content) // this allows arrays and strings to be passed + + // remove leading blank lines + while (content.length && !!!content[0].trim().length) content.shift() + + // remove trailing blank lines + while (content.length && !!!(content[content.length - 1].trim()).length) 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 from each line + }, + + /// @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 + } + + let k = to.keys(b) + + for (let i = 0, l = k.length; i < l; i++) { + a[k[i]] = is.object(b[k[i]]) ? is.object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] : b[k[i]] + } + + // 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: "" } } + /// 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) => { + // 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) is array + if (is.array(a[k])) { + // a) Flatten the array + if (flat) { + a[k] = to.array.flat(a[k]) + } + + // a) Filter out duplicates + if (unique && !is.object(a[k][0])) { + a[k] = to.array.unique(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' + let 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] : [] + let 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.flat_array + /// @description + /// Flattens an array, and arrays inside of it into a single array + /// @arg {array} + /// @returnes {array} - single dimensional + flat_array: (arg) => is.array(arg) ? [].concat(...arg.map(to.flat_array)) : arg, + + /// @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() + let result + if (is.object(arg)) { + let sorted = {} + let 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} - single dimensional +to.array.flat = (arg) => [].concat.apply([], to.array(arg)) + +/// @name to.array.unique +/// @description +/// Removes duplicate values from an array +/// @arg {array} +/// @returns {array} - without duplicates +to.array.unique = (arg) => { + let o = {} + let r = [] + + for (let i in arg) o[arg[i]] = arg[i] + + for (let i in o) r.push(o[i]) + + return r +} + +export default to \ No newline at end of file From e6f462c6268f830603bdb0850f4b693f9bfef67b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 12 Oct 2015 17:03:54 -0400 Subject: [PATCH 048/273] Added `rm -rf ./dist` to the dev scritps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 218c941..a3203c5 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "author": "Tyler Benton", "version": "0.0.0beta1", "scripts": { - "watch": "babel app/ -d ./dist --stage 0 --optional runtime --watch", + "watch": "rm -rf ./dist; babel app/ -d ./dist --stage 0 --optional runtime --watch", "deploy": "npm run test && git push origin master && npm publish", - "build": "babel app/ -d ./dist --optional runtime --stage 0", + "build": "rm -rf ./dist; babel app/ -d ./dist --optional runtime --stage 0", "prepublish": "npm run build" }, "main": "dist/index.js", From 530b34855a3cac6cd5fe029c9727e38ff35c1606 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:39:08 -0400 Subject: [PATCH 049/273] Changed `is.function` to `is.func` It was throwing off the syntax highlighting :thumbsdown: --- app/annotation/index.js | 2 +- app/utils/is.js | 10 +++++----- app/utils/to.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/annotation/index.js b/app/annotation/index.js index a897707..bf1e26d 100644 --- a/app/annotation/index.js +++ b/app/annotation/index.js @@ -123,7 +123,7 @@ export default class AnnotationApi{ alias: config }; } - else if (is.function(config)) { + else if (is.func(config)) { config = { callback: config }; diff --git a/app/utils/is.js b/app/utils/is.js index 3519dda..eae7902 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -22,11 +22,11 @@ let is = { /// @returns {boolean} - The result of the test regex: (value) => to_string.call(value) === '[object RegExp]', - /// @name is.function + /// @name is.func /// @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', + func: (arg) => to_string(arg) === '[object Function]' || typeof arg === 'function', /// @name is.array /// @description is a given arg Array? @@ -182,13 +182,13 @@ let is = { /// @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), + promise: (arg) => arg && is.func(arg.then), /// @name is.stream /// @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), + stream: (arg) => arg && is.func(arg.pipe), /// @name is.buffer /// @description is a given arg a stream? @@ -279,7 +279,7 @@ const any = (func) => { ;(function setInterfaces() { let options = is for (var option in options) { - if (hasOwnProperty.call(options, option) && is.function(options[option])) { + if (hasOwnProperty.call(options, option) && is.func(options[option])) { var interfaces = options[option].api || ['not', 'all', 'any'] for (let i in interfaces) { if (interfaces[i] === 'not') { diff --git a/app/utils/to.js b/app/utils/to.js index a26a21e..29719c5 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -311,7 +311,7 @@ let to = { // 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])) { + if (is.func(b[k]) || is.func(a[k]) || is.undefined(a[k])) { a[k] = b[k] } else if (is.array(a[k])) { a[k].push(b[k]) @@ -375,7 +375,7 @@ let to = { /// @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() + let run_sort = (obj) => is.func(callback) ? obj.sort.apply(null, callback) : obj.sort() let result if (is.object(arg)) { let sorted = {} From a8816ae606043dc35c248a0ae9fc035d0133f396 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:39:32 -0400 Subject: [PATCH 050/273] Added some sweet functions to help out with async arrays --- app/utils/array.js | 192 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 app/utils/array.js diff --git a/app/utils/array.js b/app/utils/array.js new file mode 100644 index 0000000..ce0fe55 --- /dev/null +++ b/app/utils/array.js @@ -0,0 +1,192 @@ +'use strict'; + +export default function async_array(array){ + return new AsyncArray(array); +} + + +class AsyncArray { + constructor(array){ + this.array = to_object(array) + } + + /// @description + /// Iterate through an array of values raising a callback for each in parallel. + /// + /// @arg {function} callback - The function to be applied to each value. + /// @arg {any} receiver - The `this` value in the callback. + *for_each(callback, receiver) { + yield promise_all_map(this.array, callback, receiver); + } + + /// @description + /// Iterate through an array of values raising a callback for each. + /// + /// @arg {function} callback - The function to be applied to each value. + /// @arg {any} receiver - The `this` value in the callback. + *for_each_stepped(callback, receiver) { + for (let i = 0; i < this.array.length; i++) { + if (i in obj) { + yield call(callback, receiver, this.array[i], i, this.array) + } + } + } + + /// @description + /// Uses a callback to sequentially map an array of values in parallel. + /// + /// @arg {array} array The set of values to map over. + /// @arg {function} callback - The function to be applied to each value. + /// @arg {any} receiver - The `this` value in the callback. + /// @return {array} - The mapped array. + *map(callback, receiver) { + return yield promise_all_map(this.array, callback, receiver) + } + + /// @description + /// Uses a callback to sequentially map an array of values. + /// + /// @arg {array} array - The set of values to map over. + /// @arg {function} callback - The function to be applied to each value. + /// @arg {any} receiver - The `this` value in the callback. + /// @return {array} - The mapped array. + *map_stepped(callback, receiver) { + let result = []; + + for (let i = 0; i < this.array.length; i++) { + if (i in obj) { + result.push(yield call(callback, receiver, this.array[i], i, this.array)); + } + } + + return result; + } + + /// @description + /// Uses a callback to sequentially filter an array of values in parallel. + /// + /// @arg {function} callback - The function to filter the values. + /// @arg {any} receiver - The `this` value in the callback. + /// @return {array} - The filtered array. + *filter(callback, receiver) { + const results = yield promise_all_map(this.array, callback, receiver) + return _filter(this.array, function(_, i) { + return results[i] + }) + } + + /// @description + /// Uses a callback to sequentially filter an array of values. + /// + /// @arg {function} callback - The function to filter the values. + /// @arg {any} receiver - The `this` value in the callback. + /// @return {array} - The filtered array. + *filter_stepped(callback, receiver) { + const result = [] + + for (let i = 0; i < this.array.length; i++) { + if (i in obj) { + const item = this.array[i] + if (yield call(callback, receiver, item, i, this.array)) { + result[result.length] = item + } + } + } + + return result + } + + /// @description + /// Uses a callback to reduce a set of values. + /// + /// @arg {function} callback - The function to be applied to each value. + /// @arg {any} receiver - The `this` value in the callback. + /// @return {any} - The accumulated value. + *reduce(callback, initial) { + const obj = this.array; + const len = ~~this.array.length; + let accum = initial; + let start = 0; + + if (arguments.length < 3) { + for (; start < len; start++) { + if (start in obj) { + accum = obj[start++]; + break; + } + } + } + + for (let i = start; i < len; i++) { + if (i in obj) { + accum = yield callback(accum, obj[i], i, array); + } + } + + return accum; + } + + /// @description + /// Returns true the first time a callback returns a truthy value against a set + /// of values, otherwise returns false. + /// + /// @arg {function} callback - The function to test each value. + /// @arg {any} receiver - The `this` value in the callback. + /// @return Boolean + *some(callback, receiver) { + for (let i = 0; i < this.array.length; i++) { + if (i in obj && (yield call(callback, receiver, this.array[i], i, this.array))) { + return true; + } + } + + return false; + } + + /// @description + /// Returns false the first time a callback returns a falsey value against a set + /// of values, otherwise returns true. + /// + /// @arg {function} callback - The function to test each value. + /// @arg {any} receiver - The `this` value in the callback. + /// @return Boolean + *every(callback, receiver) { + for (let i = 0; i < this.array.length; i++) { + if (i in this.array && !(yield call(callback, receiver, this.array[i], i, this.array))) { + return false; + } + } + + return true; + } +} + +function promise_map(array, callback, receiver) { + const obj = to_object(array); + const len = ~~obj.length; + const promises = []; + + for (let i = 0; i < len; i++) { + if (i in obj) { + promises[promises.length] = call(callback, receiver, obj[i], i, array); + } + } + + return promises; +} + +function promise_all_map(array, callback, receiver) { + return Promise.all(promise_map(array, callback, receiver)); +} + +const callbind = Function.prototype.bind.bind(Function.prototype.call); +const call = callbind(Function.prototype.call); +const apply = callbind(Function.prototype.apply); +const _filter = callbind(Array.prototype.filter); + +function to_object(value) { + if (value == null) { + throw new TypeError(`Can't convert ${value} to obj`); + } + return Object(value); +} \ No newline at end of file From c9b3d55e6ec86b1f5fd82b5590189ee2d0ec96dd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:40:45 -0400 Subject: [PATCH 051/273] Fixed jscs errors --- app/annotation/annotations/description.js | 4 +-- app/annotation/annotations/index.js | 42 +++++++++++------------ app/annotation/index.js | 16 ++++----- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/annotation/annotations/description.js b/app/annotation/annotations/description.js index e8cb5d8..7e85e29 100644 --- a/app/annotation/annotations/description.js +++ b/app/annotation/annotations/description.js @@ -1,4 +1,4 @@ -import {to} from "../../utils.js"; +import markdown from 'marked' /// @name description /// @page annotations /// @description Description of the documented item @@ -7,7 +7,7 @@ import {to} from "../../utils.js"; export default { description: { callback() { - return to.markdown(this.annotation.line ? this.annotation.line + "\n" + this.annotation.contents : this.annotation.contents); + return 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 index bac1b6a..94f5f3c 100644 --- a/app/annotation/annotations/index.js +++ b/app/annotation/annotations/index.js @@ -1,27 +1,27 @@ -import {to} from "../../utils"; +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"), + 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) { diff --git a/app/annotation/index.js b/app/annotation/index.js index bf1e26d..78f2bc8 100644 --- a/app/annotation/index.js +++ b/app/annotation/index.js @@ -1,7 +1,7 @@ -"use strict"; +'use strict'; -import annotations from "./annotations"; -import {is, to} from "../utils.js"; +import annotations from './annotations'; +import {is, to} from '../utils'; export default class AnnotationApi{ constructor() { @@ -79,7 +79,7 @@ export default class AnnotationApi{ // the name of the annotation is always the key const base_config = { // this declares where this annotation get's applied - filetypes: ["default"], + filetypes: ['default'], // holds an array of aliases for the given annotation alias: [], @@ -110,7 +110,7 @@ export default class AnnotationApi{ // a) throw an error if (!is.string(name)) { - throw new Error("name must be a string"); + throw new Error('name must be a string'); return; } @@ -133,13 +133,13 @@ export default class AnnotationApi{ // 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); + 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"); + throw new Error('config must be a function or object'); return; } @@ -151,7 +151,7 @@ export default class AnnotationApi{ // 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]]: { + [is.falsy(base_config.filetypes[filetype]) ? 'default' : base_config.filetypes[filetype]]: { [name]: base_config } }); From 77570bde4beeaf9492e0534d7f2323d7c9577d95 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:41:33 -0400 Subject: [PATCH 052/273] Updated globs to support a async filter :thumbsup: --- app/utils/glob.js | 75 ++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/app/utils/glob.js b/app/utils/glob.js index 62c447a..cf58c54 100644 --- a/app/utils/glob.js +++ b/app/utils/glob.js @@ -1,48 +1,51 @@ -// can't use `import` from es6 because it -// returns an error saying "glob" is read only -import to from './to.js' +import to from './to' +import is from './is' +import array from './array' import denodeify from './denodeify' import co from 'co' +// can't use `import` from es6 because it +// returns an error saying "glob" is read only let _glob = denodeify(require('glob')) -export default co.wrap(function*(globs, ignored_globs = []) { - globs = to.array(globs) - ignored_globs = to.array(ignored_globs) - let matched_globs = [] +// @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 +const glob = co.wrap(function*(files, ignore = [], filter) { + files = array(to.array(files)).map((file) => _glob(file)); + ignore = array(to.array(ignore)).map((file) => _glob(file.replace(/!/, ''))) + + files = to.flat_array(yield files) + ignore = to.flat_array(yield ignore) + + // removed any files that are supposed to be ignored + if (ignore.length) { + files = files.filter((file) => { + for (let i in ignore) { + if (file.indexOf(ignore[i]) > -1) { + return false + break + } + } + return true + }) + } - // get the files paths using glob - for (let [i, file] of to.entries(globs)) { - if (file.substr(0, 1) !== '!') { - matched_globs.push(_glob(file).then((data) => data)) - } else { - ignored_globs.push(file) + if (is.func(filter)) { + if (is.promise(filter())) { + return yield array(files).filter(filter) } - } - let matched_ignored_globs = [] - // get the ignored_globs file paths - for (let [i, file] of to.entries(ignored_globs)) { - matched_ignored_globs.push(_glob(file.replace(/!/, ''))) + return files.filter(filter) } - matched_globs = yield Promise.all(matched_globs).then((result) => to.flat_array(result)) - matched_ignored_globs = yield Promise.all(matched_ignored_globs).then((result) => to.flat_array(result)) - - // prevents extra functions from running if they don't need to - if (!matched_ignored_globs.length) { - return matched_globs - } + return files +}) - // return filtered files - return matched_globs.filter((file) => { - for (let i in matched_ignored_globs) { - if (file.indexOf(matched_ignored_globs[i]) > -1) { - return false - break - } - } - return true - }) -}) \ No newline at end of file +export default glob \ No newline at end of file From b8137812398f4caf1840aed3997de63da15b648f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:43:09 -0400 Subject: [PATCH 053/273] Removed `.js` from imports/exports --- app/cli.js | 4 ++-- app/docs.js | 9 ++++----- app/utils/index.js | 17 +++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/cli.js b/app/cli.js index 15d4998..4397587 100644 --- a/app/cli.js +++ b/app/cli.js @@ -2,8 +2,8 @@ import pkg from '../package.json' import path from 'path' import {info, fs} from './utils' import program from 'commander' -// import docs from './docs.js' -import {base_config} from './config.js' +import docs from './docs' +import {base_config} from './config' export default function cli(argv) { // helper functions to parse passed options diff --git a/app/docs.js b/app/docs.js index 7aebc22..a69dbd1 100755 --- a/app/docs.js +++ b/app/docs.js @@ -5,11 +5,10 @@ process.on("uncaughtException", function(err) { process.exit(1); }); -import {info, fs, is, to, log} from "./utils"; -import paths from "./paths.js"; -import AnnotationApi from "./annotation"; -import parser from "./parser.js"; -import sorter from "./sorter.js"; +import {info, fs, is, to, log, glob} from './utils' +import AnnotationApi from './annotation' +import parser from './parser' +import sorter from './sorter' //// /// @name docs.js diff --git a/app/utils/index.js b/app/utils/index.js index f6eaf93..dad6669 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,8 +1,9 @@ -export denodeify from './denodeify.js' -export emmitter from './emmiter.js' -export fs from './fs.js' -export glob from './glob.js' -export info from './info.js' -export is from './is.js' -export log from './log.js' -export to from './to.js' \ No newline at end of file +export denodeify from './denodeify' +export emmitter from './emmiter' +export fs from './fs' +export glob from './glob' +export info from './info' +export is from './is' +export log from './log' +export to from './to' +export array from './array' \ No newline at end of file From 08fa65c08728ea4d3befeb8cae346d68c216e579 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:43:32 -0400 Subject: [PATCH 054/273] Added 2 additional settings --- app/config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/config.js b/app/config.js index 97479d1..a86d0c1 100644 --- a/app/config.js +++ b/app/config.js @@ -7,6 +7,8 @@ const default_options = { ignore: ['.*', 'node_modules/', 'bower_components/', 'jspm_packages/'], // files to be ignored changed: true, // determins if only changed files should be parsed or not blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. + debug: true, + timestamps: true, annotations: {} } From c46d60ae015cec5136b958c21995e2c0be22de2a Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:44:57 -0400 Subject: [PATCH 055/273] Fixed JSCS errors --- app/docs.js | 129 ++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 64 deletions(-) diff --git a/app/docs.js b/app/docs.js index a69dbd1..748046a 100755 --- a/app/docs.js +++ b/app/docs.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; -process.on("uncaughtException", function(err) { - log.error("An uncaughtException was found:", err.stack); - process.exit(1); -}); +process.on('uncaughtException', function(err) { + log.error('An uncaughtException was found:', err.stack) + process.exit(1) +}) import {info, fs, is, to, log, glob} from './utils' import AnnotationApi from './annotation' @@ -30,48 +30,48 @@ var docs = (function() { _.file_specific_settings = { css: { header: { - start: "/***", - line: "*", - end: "***/" + start: '/***', + line: '*', + end: '***/' }, body: { - start: "/**", - line: "*", - end: "**/" + start: '/**', + line: '*', + end: '**/' } }, rb: { header: { - start: "###", - line: "##", - end: "###" + start: '###', + line: '##', + end: '###' }, body: { - line: "##" + line: '##' } }, html: { header: { - start: "" + start: '' }, body: { - start: "" + start: '' } }, cfm: { header: { - start: "" + start: '' }, body: { - start: "" + start: '' } } - }; - _.file_specific_settings.py = _.file_specific_settings.rb; + } + _.file_specific_settings.py = _.file_specific_settings.rb // _.file_specific_settings.coffee = _.file_specific_settings.rb; /// @name settings @@ -81,21 +81,21 @@ var docs = (function() { _.settings = (filetype) => { let defaults = { header: { // file level comment block identifier - start: "////", - line: "///", - end: "////" + start: '////', + line: '///', + end: '////' }, body: { // block level comment block identifier - start: "", - line: "///", - end: "" + start: '', + line: '///', + end: '' }, blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. - annotation_prefix: "@", // annotation identifier(this should probably never be changed) - single_line_prefix: "#" // single line prefix for comments inside of the code below the comment block - }; - return !is.undefined(_.file_specific_settings[filetype]) ? to.extend(defaults, _.file_specific_settings[filetype]) : defaults; - }; + annotation_prefix: '@', // annotation identifier(this should probably never be changed) + single_line_prefix: '#' // single line prefix for comments inside of the code below the comment block + } + return !is.undefined(_.file_specific_settings[filetype]) ? to.extend(defaults, _.file_specific_settings[filetype]) : defaults + } /// @name setting /// @description Allows you to specify settings for specific file types @@ -104,8 +104,8 @@ var docs = (function() { _.setting = (extention, obj) => { return to.extend(_.file_specific_settings, { [extention]: obj - }); - }; + }) + } /// @name parse /// @description Takes the contents of a file and parses it @@ -114,22 +114,22 @@ var docs = (function() { /// @promise /// @returns {object} - the data that was parsed _.parse = (files, changed) => { - log.time("paths"); - log.time("total"); // starts the timer for the total runtime + log.time('paths') + log.time('total') // starts the timer for the total runtime return new Promise((resolve, reject) => { paths(files, changed) .then((file_paths) => { - let length = file_paths.length, - s = length > 1 ? "s" : ""; - log.timeEnd("paths", `%s completed after %dms with ${length} file${s} to parse`); - log.time("parser"); + let length = file_paths.length + let s = length > 1 ? 's' : '' + log.timeEnd('paths', `%s completed after %dms with ${length} file${s} to parse`) + log.time('parser') // Converts the `file_paths` into an array of parsing files. // Onces they're all parsed then return the array of parsed files. - return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))); + return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))) }) .then((parsed_files) => { - log.timeEnd("parser"); + log.timeEnd('parser') // get the stored data file if it exists, or return an empty object return new Promise((resolve, reject) => { fs.readJson(info.temp.file) @@ -139,10 +139,10 @@ var docs = (function() { // Loop through the parsed files and update the // json data that was stored. for (let data in parsed_files) { - to.merge(json, parsed_files[data], false); + to.merge(json, parsed_files[data], false) } - resolve(json); + resolve(json) // Update the temp json data. Even though this returns a promise // it's not returned below because there's no need to wait for it @@ -150,36 +150,37 @@ var docs = (function() { // `json` object has already been updated. fs.outputJson(info.temp.file, json, { spaces: 2 - }, 1); - }); - }); + }, 1) + }) + }) }) .then((json) => { - log.time("sorter"); - return [json, _.sorter(json)]; + log.time('sorter') + return [json, _.sorter(json)] }) .then((data) => { - let [raw, sorted] = data; - log.timeEnd("sorter"); - log.timeEnd("total"); + let [raw, sorted] = data + log.timeEnd('sorter') + log.timeEnd('total') resolve({ raw, sorted - }); + }) }) .catch((err) => { - reject({}); - log.error(err.stack); - }); + reject({}) + log.error(err.stack) + }) }) .catch((err) => { - reject({}); - log.error(err.stack); + reject({}) + log.error(err.stack) }); }; - return _; -})(); + return _ +})() + export default docs; From b6f7b9ab0dfb0ad71bf1945f32bdbd5ec830b41b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 16:55:12 -0400 Subject: [PATCH 056/273] Removed the need for paths since a filter was added to globs --- app/paths.js | 103 --------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 app/paths.js diff --git a/app/paths.js b/app/paths.js deleted file mode 100644 index 73a52d0..0000000 --- a/app/paths.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; -import {fs, info, glob, is, to} from './utils' -import path from 'path' - -// @name paths -// @description -// Filters out changed files, `.md` files, and paths that aren't files -// @promise -// @args {array, string} -// @returns {promise, array} - Filtered file paths -export default function paths(globs, changed = true) { - globs = to.array(globs); // Converts globs into an array if it's not already. - - // @name get_paths - // @description - // This gets the file paths to check - // @arg {array} - of file path globs - // @promise - // @returns {array} - the filepaths to return - function get_paths(files) { - return new Promise((resolve, reject) => { - let globs = []; - // get the files paths using glob - for (let i = 0, l = files.length; i < l; i++) { - globs.push(glob(files[i])); - } - - Promise.all(globs) - .then((result) => resolve(to.array.flat(result))) - .catch((err) => { - throw err; - }); - }); - }; - - // @name check - // @description - // checks the status of the file to see if it has changed or not. - // @arg {string} - path to file - // @promise - // @returns {string} - this will be the filepath or an empty string - function check(file) { - var source = path.join(info.root, file), - target = path.join(info.temp.folder, file); - return new Promise((resolve, reject) => { - Promise.all([fs.stat(source), fs.stat(target)]) - .then(function(stats) { - // a) copies source file into the target directory because it's newer - if (stats[0].mtime > stats[1].mtime) { - resolve(source); - fs.fake_copy(source, target); // copies new files over. - } else { - resolve(Promise.resolve('')); - } - }) - .catch((err) => { - fs.fake_copy(source, target); // copies new files over. - resolve(source); - }); - }); - }; - - // @name filter - // @description - // Filters out - // - changed files if `changed` is true, - // - `.md`, and `.` files(always) - // - any paths that aren't files - // - // @arg {array} of globs - // @promise - // @returns {array} - Array of file paths - function filter(files) { - files = files.filter((obj) => { - let ext = path.extname(obj).toLowerCase(); - return ext !== '.md' && ext.charAt(0) === '.'; - }); - - // a) Return all the files that were passed except - // the `.md`, and `.` files. - if (!changed) { - return Promise.resolve(files); - } - - return new Promise((resolve, reject) => { - Promise.all(files.map((file) => check(file))) - .then((to_filter) => resolve(to.array.unique(to.array(to_filter)))) - .catch((err) => { - resolve([]); - throw err; - }); - }); - }; - - return new Promise((resolve, reject) => { - get_paths(globs) - .then((files) => filter(files)) - .then((filtered_files) => resolve(filtered_files)) - .catch((err) => { - throw err; - }); - }); -}; From 4b4d74b4b2ad42c13a16951fddafbc5dc720fa1e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 19:44:41 -0400 Subject: [PATCH 057/273] Ensured all comment types have all default settings --- app/config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index a86d0c1..c2808f3 100644 --- a/app/config.js +++ b/app/config.js @@ -83,8 +83,15 @@ export default function config(options = {}) { for (let lang in option) comments[option[lang]] = value } - options.comments = comments + // ensures each comment as all the required comment settings + // this makes it easier later on when parsing + for (let [lang, value] of to.entries(comments)) { + if (lang !== '_') { + comments[lang] = to.extend(JSON.parse(JSON.stringify(default_comment)), value) + } + } + options.comments = comments return options } From 3108b8532c50bb6c902f436fdc0bd336a7650f0f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 20:46:49 -0400 Subject: [PATCH 058/273] added a default to remove paths to directories --- app/utils/glob.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/utils/glob.js b/app/utils/glob.js index cf58c54..d41f80f 100644 --- a/app/utils/glob.js +++ b/app/utils/glob.js @@ -3,21 +3,23 @@ import is from './is' import array from './array' import denodeify from './denodeify' import co from 'co' +import path from 'path' // can't use `import` from es6 because it // returns an error saying "glob" is read only let _glob = denodeify(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 -const glob = co.wrap(function*(files, ignore = [], filter) { +/// @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 +const glob = co.wrap(function*(files, ignore = [], filter, files_only = true) { files = array(to.array(files)).map((file) => _glob(file)); ignore = array(to.array(ignore)).map((file) => _glob(file.replace(/!/, ''))) @@ -37,6 +39,10 @@ const glob = co.wrap(function*(files, ignore = [], filter) { }) } + if (files_only) { + files = files.filter((file) => path.extname(file).indexOf('.') > -1) + } + if (is.func(filter)) { if (is.promise(filter())) { return yield array(files).filter(filter) From 95e4937cb3c1c2ea89e2f495975e86c1a3b37d7a Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 13 Oct 2015 21:58:45 -0400 Subject: [PATCH 059/273] fixed jscs errors --- app/parser.js | 121 +++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/app/parser.js b/app/parser.js index 83cfb95..35c160f 100644 --- a/app/parser.js +++ b/app/parser.js @@ -1,4 +1,4 @@ -import {info, fs, is, to} from "./utils" +import {info, fs, is, to} from './utils' import path from 'path' /// @name parse_file @@ -6,16 +6,17 @@ import path from 'path' /// Parses a single file /// @arg {string} - The path to the file you're wanting to parse /// @returns {array} - Array of parsed blocks -export default function(file_path, settings, api) { - let filetype = path.extname(file_path).replace(".", ""), // the filetype of the current file - setting = settings(filetype), - annotations = api.list(filetype), // gets the annotations to use on this file - annotation_keys = to.keys(annotations), // stores the annotation names for this file in an array - file = {}, // placeholder to hold the file information that is defined in the return promise - debug = { - get_blocks: {}, - parse_blocks: {} - }; +export default function(args = {}) { + let { file_path, comments, api } = args + let filetype = path.extname(file_path).replace('.', '') // the filetype of the current file + let comment = comments[filetype] ? comments[filetype] : comments._ + let annotations = api.list(filetype) // gets the annotations to use on this file + let annotation_keys = to.keys(annotations) // stores the annotation names for this file in an array + let file = {} // placeholder to hold the file information that is defined in the return promise + let debug = { + get_blocks: {}, + parse_blocks: {} + } debug.get_blocks.self = false; debug.get_blocks.result = false; debug.parse_blocks.self = false; @@ -27,25 +28,25 @@ export default function(file_path, settings, api) { // @todo {5} - add a line offest argument to this so that you can call parse content on other language types. function get_blocks(content, config, restrict = true, start_at = 0) { start_at = is.number(start_at) ? start_at : 0; - let lines = to.array(content), - parsed_blocks = [], - block_info, - is_start_and_end = is.all.truthy(config.start, config.end), - in_comment = false, // used to determin that you are in a comment - in_code = false; // used to determin if you are in the code after the comment block + let lines = to.array(content) + let parsed_blocks = [] + let block_info + let is_start_and_end = is.all.truthy(config.start, config.end) + let in_comment = false // used to determin that you are in a comment + let in_code = false // used to determin if you are in the code after the comment block // a) The file doesn't contain any header level comments, or body level comments - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log(""); + debug.get_blocks.self && console.log(''); + debug.get_blocks.self && console.log(''); + debug.get_blocks.self && console.log(''); + debug.get_blocks.self && console.log(''); // debug.get_blocks.self && console.log("file =", to.json(file)); - debug.get_blocks.self && console.log("start_at =", start_at); - debug.get_blocks.self && console.log("starting line =", lines[start_at]); - debug.get_blocks.self && console.log("is_start_and_end =", is_start_and_end); - debug.get_blocks.self && console.log("config.start check =", is.in(file.contents, config.start)); - debug.get_blocks.self && console.log(""); - debug.get_blocks.self && console.log("test 1:", is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); - debug.get_blocks.self && console.log("test 2:", !is.between(start_at, 0, lines.length - 1)); + debug.get_blocks.self && console.log('start_at =', start_at); + debug.get_blocks.self && console.log('starting line =', lines[start_at]); + debug.get_blocks.self && console.log('is_start_and_end =', is_start_and_end); + debug.get_blocks.self && console.log('config.start check =', is.in(file.contents, config.start)); + debug.get_blocks.self && console.log(''); + debug.get_blocks.self && console.log('test 1:', is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); + debug.get_blocks.self && console.log('test 2:', !is.between(start_at, 0, lines.length - 1)); if ((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)) { debug.get_blocks.self && console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); @@ -53,35 +54,35 @@ export default function(file_path, settings, api) { } for (let i = start_at, l = lines.length; i < l; i++) { - let line = lines[i], - comment_index = { + let line = lines[i] + let comment_index = { start: is_start_and_end ? is.included(line, config.start) : false, line: is.included(line, config.line), end: is_start_and_end ? is.included(line, config.end) : false - }; - debug.get_blocks.self && console.log("line", i, "=", line); - debug.get_blocks.self && console.log("length"); + } + debug.get_blocks.self && console.log('line', i, '=', line); + debug.get_blocks.self && console.log('length'); // a) The line isn't empty so parse it. if (!is.empty(line)) { // a) is the start and end style or there was an instance of a comment line if (is_start_and_end && (!is.false(comment_index.start) || in_comment) || !is.false(comment_index.line)) { - debug.get_blocks.self && console.log("IN COMMENT", "{", "start:", comment_index.start, ", line:", comment_index.line, ", end:", comment_index.end, "}"); + debug.get_blocks.self && console.log('IN COMMENT', '{', 'start:', comment_index.start, ', line:', comment_index.line, ', end:', comment_index.end, '}'); // a) is the start of a new block if (!is.false(comment_index.start) || !is_start_and_end && !in_comment) { - debug.get_blocks.self && console.log("START OF A NEW BLOCK ---------------------------------------------------------------"); + debug.get_blocks.self && console.log('START OF A NEW BLOCK ---------------------------------------------------------------'); in_code = false; // a) There was block that has already been processed if (!is.undefined(block_info)) { // holds the current block information - debug.get_blocks.self && console.log("BLOCK WAS PUSHED TO PARSED_BLOCKS"); + debug.get_blocks.self && console.log('BLOCK WAS PUSHED TO PARSED_BLOCKS'); block_info.code.end = i - 1; // @todo check to make sure this is correct parsed_blocks.push(block_info); // Stops the loop after the first comment block // has been parsed. This is for file header comments if (restrict) { - debug.get_blocks.self && console.log("IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); + debug.get_blocks.self && console.log('IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); block_info.comment.end = i; return parsed_blocks; } @@ -107,7 +108,7 @@ export default function(file_path, settings, api) { // a) check for the end comment if (is_start_and_end && block_info.comment.start !== i && !is.false(comment_index.end)) { - debug.get_blocks.self && console.log("LAST LINE IN COMMENT"); + debug.get_blocks.self && console.log('LAST LINE IN COMMENT'); in_comment = false; block_info.comment.end = i; // sets the end line in the comment block @@ -119,7 +120,7 @@ export default function(file_path, settings, api) { // a) adds this line to block_info comment contents if (in_comment && is.false(comment_index.start) && is.false(comment_index.end)) { - debug.get_blocks.self && console.log("LINE ADDED TO BLOCK COMMENT CONTENTS"); + debug.get_blocks.self && console.log('LINE ADDED TO BLOCK COMMENT CONTENTS'); // a) removes the `config.line` from the line. if (!is.false(comment_index.line)) { line = line.slice(comment_index.line + config.line.length); @@ -139,7 +140,7 @@ export default function(file_path, settings, api) { // a) The last line in the file is a commment if (in_comment && (is_start_and_end && !is.false(comment_index.end) ? i === l : i === l - 1)) { - debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS A COMMENT"); + debug.get_blocks.self && console.log('LAST LINE IN THE FILE IS A COMMENT'); block_info.comment.end = is_start_and_end ? i - 1 : i; parsed_blocks.push(block_info); break; // ensures that the loop stops because it's the last line in the file @@ -151,14 +152,14 @@ export default function(file_path, settings, api) { // Stops the loop after the first comment block // has been parsed. This is for file header comments if (restrict) { - debug.get_blocks.self && console.log("IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!"); + debug.get_blocks.self && console.log('IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); parsed_blocks.push(block_info); break; } - debug.get_blocks.self && console.log("IN CODE"); + debug.get_blocks.self && console.log('IN CODE'); // a) The previous line was a comment if (!in_code) { - debug.get_blocks.self && console.log("THE PREVIOUS LINE WAS A COMMENT"); + debug.get_blocks.self && console.log('THE PREVIOUS LINE WAS A COMMENT'); in_code = true; block_info.code.start = i; } @@ -168,7 +169,7 @@ export default function(file_path, settings, api) { // a) pushes the last block onto the body if (i === l - 1) { - debug.get_blocks.self && console.log("LAST LINE IN THE FILE IS CODE"); + debug.get_blocks.self && console.log('LAST LINE IN THE FILE IS CODE'); block_info.code.end = i; parsed_blocks.push(block_info); } @@ -176,12 +177,12 @@ export default function(file_path, settings, api) { } // the last line in the file was an empty line. else if (i === l - 1 && is.truthy(block_info)) { - block_info[is.between(block_info.comment.end) ? "comment" : "code"].end = i; + block_info[is.between(block_info.comment.end) ? 'comment' : 'code'].end = i; parsed_blocks.push(block_info); - debug.get_blocks.self && console.log("LINE WAS EMPTY"); + debug.get_blocks.self && console.log('LINE WAS EMPTY'); } - debug.get_blocks.self && console.log(""); + debug.get_blocks.self && console.log(''); } // end loop return parsed_blocks; @@ -209,7 +210,7 @@ export default function(file_path, settings, api) { /// @arg {string} name - the name of the annotation you want to add /// @arg {string} str - information that is passed to the annotation add: (name, str) => { - str = str.split("\n"); + str = str.split('\n'); return run_annotation({ name: name, line: to.normalize(str[0]), @@ -252,7 +253,7 @@ export default function(file_path, settings, api) { // Then once it has all the information it calls the annotation function(the annotation one it found) // for this file type or the default function. // @arg {object} - The blocks to parse - const parse_block = (block, prefix = setting.annotation_prefix, restrict_lines = false) => { + const parse_block = (block, prefix = comment.prefix, restrict_lines = false) => { let contents = to.array(block.comment.contents), block_annotations = {}, current = {}; // holds the current annotation @@ -264,7 +265,7 @@ export default function(file_path, settings, api) { // a) there is an index of the annotation prefix if (prefix_index >= 0) { - let first_space = line.indexOf(" ", prefix_index), + let first_space = line.indexOf(' ', prefix_index), name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length); // a) the name is one of the annotation names @@ -323,7 +324,7 @@ export default function(file_path, settings, api) { } } // end blocks loop - debug.parse_blocks.self && console.log("parsed_blocks", parsed_blocks); + debug.parse_blocks.self && console.log('parsed_blocks', parsed_blocks); return parsed_blocks; }; @@ -335,27 +336,27 @@ export default function(file_path, settings, api) { file = { contents, // all of the contents of the file path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, "." + filetype), // name of the file + name: path.basename(file_path, '.' + filetype), // name of the file type: filetype, // filetype of the file start: 0, // starting point of the file end: to.array(contents).length - 1 // ending point of the file }; - debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); debug.get_blocks.result || debug.parse_blocks.result && console.log(""); + debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); - let header = get_blocks(contents, setting.header); - debug.get_blocks.result && console.log("get_blocks(header) =", !is.empty(header) ? header[0].comment.contents : "no header for this file"); debug.get_blocks.result && console.log(""); debug.get_blocks.result && console.log(""); + let header = get_blocks(contents, comment.header); + debug.get_blocks.result && console.log('get_blocks(header) =', !is.empty(header) ? header[0].comment.contents : 'no header for this file'); debug.get_blocks.result && console.log(''); debug.get_blocks.result && console.log(''); - let body = get_blocks(contents, setting.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0); - debug.get_blocks.result && console.log("get_blocks(body) =", body); + let body = get_blocks(contents, comment.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0); + debug.get_blocks.result && console.log('get_blocks(body) =', body); - debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && debug.parse_blocks.result && console.log(""); + debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); header = parse_blocks(header)[0]; - debug.parse_blocks.result && console.log("parse_blocks(header) =", header); debug.parse_blocks.result && console.log(""); debug.parse_blocks.result && console.log(""); + debug.parse_blocks.result && console.log('parse_blocks(header) =', header); debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && console.log(''); body = parse_blocks(body); - debug.parse_blocks.result && console.log("parse_blocks(body) =", body); + debug.parse_blocks.result && console.log('parse_blocks(body) =', body); // removes the contents from the file info because it's // not something that is needed in the returned data. From 633166d8dd32aaeac8715bb61d29b602583610c2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 14 Oct 2015 10:42:07 -0400 Subject: [PATCH 060/273] Removed weird setting that prepended the filetype to the page --- app/sorter.js | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/app/sorter.js b/app/sorter.js index 9d4328c..bee6980 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -6,19 +6,7 @@ import {info, fs, path, is, to, log} from "./utils"; /// @arg {object} /// @returns {object} export default function(json) { - let nav, pages, - _settings = { - header: { - // This can be file "type", "", false if you always - // want to go with what's declared in the page. - prepend_type: true - }, - body: { - // same as `header.page_prepend` but this is for body comment blocks - prepend_type: false - } - // todo: true, // create a todo page with ALL the todo comments listed - }; + let nav, pages; /// @name pages /// @description @@ -84,12 +72,7 @@ export default function(json) { for (let file of files) { // a) Ensures there's only one page defined in the header // b) There wasn't a page defined so set it to general - file.header.page = file.header.page ? file.header.page[0] : "general"; - - // a) Prepend the filetype to the page - if (is.truthy(_settings.header.prepend_type)) { - file.header.page = path.join(file.info.type, file.header.page); - } + file.header.page = file.header.page ? file.header.page[0] : 'general'; // a) Set the name in the header to be the name of the file if (is.falsy(file.header.name)) { From 96a273f86fe6ba1d99bcc2a11826e7b2ddb72859 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 14 Oct 2015 12:19:01 -0400 Subject: [PATCH 061/273] fixed jscs errors --- app/sorter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/sorter.js b/app/sorter.js index bee6980..a2c95b2 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -1,4 +1,4 @@ -import {info, fs, path, is, to, log} from "./utils"; +import {info, fs, path, is, to, log} from './utils'; /// @name sort /// @description @@ -29,7 +29,7 @@ export default function(json) { delete value.page; let _pages = result, - path_list = path.split("/").filter(Boolean), // convert to array, and filter out empty strings + path_list = path.split('/').filter(Boolean), // convert to array, and filter out empty strings // 1 less than the link so the last item in the `path_list` is what // the passed value will be set to length = path_list.length - 1; @@ -59,7 +59,7 @@ export default function(json) { }; } - if (type === "header") { + if (type === 'header') { _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); } else { _pages[path_list[length]].page.body.push(value); @@ -80,7 +80,7 @@ export default function(json) { } // set the header for the file - set(file.header.page, "header", file.header); + set(file.header.page, 'header', file.header); // loop over each block in the body of the file for (let block of file.body) { @@ -89,13 +89,13 @@ export default function(json) { if (block.page) { for (let page of block.page) { if (page !== file.header.page) { - set(page, "body", block); + set(page, 'body', block); } } } // add the block to the page - set(file.header.page, "body", block); + set(file.header.page, 'body', block); } } } @@ -141,7 +141,7 @@ export default function(json) { /// @returns {object} function set(a, b) { for (let [key, value] of to.entries(b)) { - if (key !== "page") { + if (key !== 'page') { let nav_item = { title: is.truthy(value.page.header.name) ? value.page.header.name : to.case.title(to.case.space(key)), href: `${a.href}/${key}`, From 635f71973d502e230ef67227d179c7d3b1e674b9 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 14 Oct 2015 12:19:29 -0400 Subject: [PATCH 062/273] Added todo comment --- app/utils/info.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/utils/info.js b/app/utils/info.js index eeb570c..db1cfe8 100644 --- a/app/utils/info.js +++ b/app/utils/info.js @@ -8,6 +8,7 @@ info.dir = info.root.split(path.sep) // splits the project dir by the system spe info.dir = info.dir[info.dir.length - 1] // gets the working directory info.temp = {} +// @todo {8} - come back and change the `.tmp` directory to be inside of `/node_modules/docs/.temp` info.temp.folder = path.join(info.root, '.tmp') info.temp.file = path.join(info.temp.folder, 'data.json') From 6ca672d627669087bb4aa98bf77b33837e928879 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 14 Oct 2015 18:21:17 -0400 Subject: [PATCH 063/273] `fs.ensureFile` changed to be a promise --- app/utils/fs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/utils/fs.js b/app/utils/fs.js index 6a10c58..fe72c15 100644 --- a/app/utils/fs.js +++ b/app/utils/fs.js @@ -23,5 +23,6 @@ fs.readJson = denodeify(fs.readJson) fs.outputJson = denodeify(fs.outputJson) fs.stat = denodeify(fs.stat) fs.readFile = denodeify(fs.readFile) +fs.ensureFile = denodeify(fs.ensureFile) export default fs \ No newline at end of file From c7de088bf3fdd66447634971fba2c3be4acade4e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 14 Oct 2015 18:23:00 -0400 Subject: [PATCH 064/273] Updated to actually call the docs function now --- app/cli.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/cli.js b/app/cli.js index 4397587..9e5c5c4 100644 --- a/app/cli.js +++ b/app/cli.js @@ -29,13 +29,22 @@ export default function cli(argv) { .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) .parse(process.argv) - // @todo update docs function to work like this - // docs({ - // config, - // files, - // ignore, - // changed, - // blankLines: blank_lines - // } = program) - // .then((parsed) => fs.outputJson(dest, parsed)) + let { + dest, + config, + files, + ignore, + changed, + blankLines: blank_lines + } = program; + + return docs({ + config, + files, + ignore, + changed, + blank_lines + }) + .then((parsed) => fs.outputJson(dest, parsed, { spaces: 2 })) + .catch((err) => console.error(err.stack)) } \ No newline at end of file From d93db581be7d186fbacaffe2c59ba2121aa15bda Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:18:47 -0500 Subject: [PATCH 065/273] Added more options --- app/config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index c2808f3..dca6ed3 100644 --- a/app/config.js +++ b/app/config.js @@ -4,7 +4,10 @@ import {info, fs, is, to, log} from './utils' const default_options = { config: `${info.root}/docsfile.js`, files: ['app/**/*'], // files to search - ignore: ['.*', 'node_modules/', 'bower_components/', 'jspm_packages/'], // files to be ignored + ignore: ['.*', 'node_modules/', 'bower_components/', 'jspm_packages/', 'dist/', 'build/', 'docs/'], // files to be ignored + // add gitignore files to the ignore list. Depending on ignored files it + // could cause things to ge parsed slower, that's why it's defaulted to `false` + gitignore: false, changed: true, // determins if only changed files should be parsed or not blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. debug: true, From 74572a3ad8725548ea2607c2410f638dafc9a8f3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:20:48 -0500 Subject: [PATCH 066/273] Changed config to be a async function This was needed because of the ability to add git ignore files --- app/config.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index dca6ed3..db557f1 100644 --- a/app/config.js +++ b/app/config.js @@ -1,4 +1,5 @@ import {info, fs, is, to, log} from './utils' +import path from 'path' // changed by `options` key const default_options = { @@ -51,7 +52,7 @@ export const base_config = { comments } -export default function config(options = {}) { +export default async function config(options = {}) { let config_file = (options.config ? options : base_config).config // try to get the `docsfile.js` so the user config can be merged @@ -68,6 +69,17 @@ export default function config(options = {}) { // merge options with base_config so there's a complete list of settings options = to.extend(to.clone(base_config), options) + if (options.gitignore) { + try { + options.ignore = to.flat_array([ + options.ignore, + to.array(to.string(await fs.readFile(path.join(info.root, '.gitignore')))) + ]) + + } catch(err){} + } + + // ensures `files`, `ignore` is always an array this way no // more checks have to happen for it options.files = to.array(options.files) From f91eaccd083c384a73abe1849c4dc1afe11f26e2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:22:56 -0500 Subject: [PATCH 067/273] Added a few more options, and updated description --- app/cli.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/cli.js b/app/cli.js index 9e5c5c4..6654101 100644 --- a/app/cli.js +++ b/app/cli.js @@ -1,11 +1,10 @@ import pkg from '../package.json' -import path from 'path' import {info, fs} from './utils' import program from 'commander' import docs from './docs' import {base_config} from './config' -export default function cli(argv) { +export default function cli() { // helper functions to parse passed options const to_list = (str) => str.replace(/\s/g, '').split(',').filter(Boolean) const to_boolean = (str) => str !== 'false' ? true : false @@ -15,18 +14,20 @@ export default function cli(argv) { .version(pkg.version) .usage('docs [options]') .description(` - Parse all your documentation, and output a json file. + Parse all your documentation, and output a json file. To see all the default options + see @todo add a link to the options - Note: - If you want to select \`.*\` file by it's self you have to add - quotes around it, or a trailing comma. This is a issue with 'commander'. + Note: Put globs quotes \`'.*, app/**/*'\` to avoid issues `) + .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) .option('-c, --config [path]', `Path to configuration file`, base_config.config) .option('-f, --files ', `Paths to parsed`, to_list, base_config.files) .option('-i, --ignore ', `Paths to ignore`, to_list, base_config.ignore) + .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', base_config.gitignore) + .option('-d, --debug', 'Output debugging information', base_config.debug) // @todo add debug information + .option('-t, --timestamps', 'Output timestamps of how long it takes to parse the files', base_config.timestamps) .option('-a, --changed [boolean]', `Parse changed files`, to_boolean, base_config.changed) .option('-b, --blank-lines ', `Stops parsing lines after consecutive blank lines`, to_number, base_config.blank_lines) - .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) .parse(process.argv) let { @@ -34,6 +35,9 @@ export default function cli(argv) { config, files, ignore, + gitignore, + debug, + timestamps, changed, blankLines: blank_lines } = program; @@ -42,6 +46,9 @@ export default function cli(argv) { config, files, ignore, + gitignore, + debug, + timestamps, changed, blank_lines }) From 12f1f55caa6c0e4042b16c4078b11dfba7f6d7c5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:23:37 -0500 Subject: [PATCH 068/273] Added jshint support I know I'm an idiot for not doing this earlier --- .jshintrc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..ca95742 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,36 @@ +{ + "esnext": true, + "varstmt": true, + "asi": true, + "boss": true, + "browser": true, + "camelcase": false, + "curly": false, + "devel": false, + "devel": true, + "eqeqeq": true, + "eqnull": true, + "es5": false, + "evil": false, + "immed": false, + "indent": 2, + "jquery": true, + "latedef": false, + "laxbreak": true, + "laxcomma": true, + "maxcomplexity": 6, + "maxdepth": 4, + "maxstatements": 25, + "noarg": true, + "maxparams": 3, + "newcap": true, + "node": true, + "noempty": false, + "nonew": true, + "quotmark": "single", + "smarttabs": true, + "strict": false, + "trailing": false, + "undef": true, + "unused": true +} \ No newline at end of file From 53ec2508a65b283ff98a83b6bf090621ffe072cd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:24:01 -0500 Subject: [PATCH 069/273] updated gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 51ad94c..2f55c63 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ node_modules/ -**/nmp-debug.log +nmp-debug.log dist/ .tmp .DS_Store From ba2c364bf2da802b7105cd1a22317b8a8c5947f4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:24:57 -0500 Subject: [PATCH 070/273] Removed `is` and added `array` `is` wasn't being used and `array` was needed --- app/docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 app/docs.js diff --git a/app/docs.js b/app/docs.js old mode 100755 new mode 100644 index 748046a..842017c --- a/app/docs.js +++ b/app/docs.js @@ -5,7 +5,7 @@ process.on('uncaughtException', function(err) { process.exit(1) }) -import {info, fs, is, to, log, glob} from './utils' +import {info, fs, to, log, glob, array} from './utils' import AnnotationApi from './annotation' import parser from './parser' import sorter from './sorter' From 51c054f098819eb65f679156764316e5cc37ea3c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:25:37 -0500 Subject: [PATCH 071/273] Overhauled the main docs function to be easier to use :thumbsup: --- app/docs.js | 253 ++++++++++++++++++---------------------------------- 1 file changed, 88 insertions(+), 165 deletions(-) diff --git a/app/docs.js b/app/docs.js index 842017c..a223c57 100644 --- a/app/docs.js +++ b/app/docs.js @@ -14,173 +14,96 @@ import sorter from './sorter' /// @name docs.js /// @author Tyler Benton /// @description -/// This is used to parse any filetype that you want to and gets the documentation for it and returns an {} of the document data +/// This is used to parse any filetype that you want to and gets the +/// documentation for it and returns an `{}` of the document data //// -var docs = (function() { - // the main object to return - let _ = { - is, - to, - annotation: new AnnotationApi(), - sorter, - fs - }; - - // the settings object that holds the file specific settings as well as the base settings - _.file_specific_settings = { - css: { - header: { - start: '/***', - line: '*', - end: '***/' - }, - body: { - start: '/**', - line: '*', - end: '**/' - } - }, - rb: { - header: { - start: '###', - line: '##', - end: '###' - }, - body: { - line: '##' - } - }, - html: { - header: { - start: '' - }, - body: { - start: '' - } - }, - cfm: { - header: { - start: '' - }, - body: { - start: '' - } - } - } - _.file_specific_settings.py = _.file_specific_settings.rb - // _.file_specific_settings.coffee = _.file_specific_settings.rb; - - /// @name settings - /// @description Merges the default settings with the file specific settings - /// @arg {string} filetype - the current filetype that is being parsed - /// @returns {object} the settings to use - _.settings = (filetype) => { - let defaults = { - header: { // file level comment block identifier - start: '////', - line: '///', - end: '////' - }, - body: { // block level comment block identifier - start: '', - line: '///', - end: '' - }, - blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. - annotation_prefix: '@', // annotation identifier(this should probably never be changed) - single_line_prefix: '#' // single line prefix for comments inside of the code below the comment block + +import get_config from './config' +import co from 'co' +import path from 'path' + +const docs = co.wrap(function*(user_config = {}) { + log.time('total') + let { + files, + ignore, + changed, + blank_lines, + debug, + timestamps, + annotations, + comments, + } = yield get_config(user_config); + + let api = new AnnotationApi() + + try { + yield fs.ensureFile(info.temp.file) + let json = fs.readFile(info.temp.file) + + log.time('paths') + files = yield glob(files, ignore, changed ? has_file_changed : false) + log.timeEnd('paths', `%s completed after %dms with ${files.length} file${files.length > 1 ? 's': ''} to parse`) + + log.time('parser') + files = yield array(files).map((file_path) => parser({ file_path, comments, api })) + log.timeEnd('parser') + + // converts json to a readable JS object + json = to.string(yield json) + json = !!json ? JSON.parse(json) : {} + + // Loop through the parsed files and update the + // json data that was stored. + for (let i in files) { + to.merge(json, files[i], false) } - return !is.undefined(_.file_specific_settings[filetype]) ? to.extend(defaults, _.file_specific_settings[filetype]) : defaults - } - /// @name setting - /// @description Allows you to specify settings for specific file types - /// @arg {string} extention - the file extention you want to target - /// @arg {object} obj - the settings you want to adjust for this file type - _.setting = (extention, obj) => { - return to.extend(_.file_specific_settings, { - [extention]: obj - }) + // Update the temp json data. Even though this returns a promise + // it's not returned below because there's no need to wait for it + // to finish writing out the json file before moving on. Because the + // `json` object has already been updated. + fs.outputJson(info.temp.file, json, { spaces: 2 }) + .catch((err) => log.error(err.stack)) + + log.time('sorter') + json = sorter(json) + log.timeEnd('sorter') + log.timeEnd('total') + return json + } catch(err) { + log.error(err.stack) } +}); - /// @name parse - /// @description Takes the contents of a file and parses it - /// @arg {string, array} files - file paths to parse - /// @arg {boolean} changed [true] - If true it will only parse changed files - /// @promise - /// @returns {object} - the data that was parsed - _.parse = (files, changed) => { - log.time('paths') - log.time('total') // starts the timer for the total runtime - return new Promise((resolve, reject) => { - paths(files, changed) - .then((file_paths) => { - let length = file_paths.length - let s = length > 1 ? 's' : '' - log.timeEnd('paths', `%s completed after %dms with ${length} file${s} to parse`) - log.time('parser') - - // Converts the `file_paths` into an array of parsing files. - // Onces they're all parsed then return the array of parsed files. - return Promise.all(file_paths.map((file_path) => parser(file_path, _.settings, _.annotation))) - }) - .then((parsed_files) => { - log.timeEnd('parser') - // get the stored data file if it exists, or return an empty object - return new Promise((resolve, reject) => { - fs.readJson(info.temp.file) - .then((json) => json) - .catch((err) => Promise.resolve({})) - .then((json) => { - // Loop through the parsed files and update the - // json data that was stored. - for (let data in parsed_files) { - to.merge(json, parsed_files[data], false) - } - - resolve(json) - - // Update the temp json data. Even though this returns a promise - // it's not returned below because there's no need to wait for it - // to finish writing out the json file before moving on. Because the - // `json` object has already been updated. - fs.outputJson(info.temp.file, json, { - spaces: 2 - }, 1) - }) - }) - }) - .then((json) => { - log.time('sorter') - return [json, _.sorter(json)] - }) - .then((data) => { - let [raw, sorted] = data - log.timeEnd('sorter') - log.timeEnd('total') - resolve({ - raw, - sorted - }) - }) - .catch((err) => { - reject({}) - log.error(err.stack) - }) - }) - .catch((err) => { - reject({}) - log.error(err.stack) - }); - }; - - return _ -})() - - - -export default docs; + + +export default docs + +// @name has_file_changed +// @access private +// @description +// checks the status of the file to see if it has changed or not. +// @arg {string} - path to file +// @async +// @returns {boolean} +async function has_file_changed(file) { + let source = path.join(info.root, file) + let target = path.join(info.temp.folder, file) + + try { + let stats = await array([source, target]).map((_path) => fs.stat(_path)) + + // copies new files over because it's changed + if (stats[0].mtime > stats[1].mtime) { + fs.fake_copy(source, target) + return true + } else { + return false + } + } catch(err) { + // copies new files over because it doesn't exist in the temp target directory + fs.fake_copy(source, target); + return true + } +}; \ No newline at end of file From ef1cce89adbb756a26b5b53d826af8972fcca8e1 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 12:26:55 -0500 Subject: [PATCH 072/273] Fixed jscs errors and jshint errors --- app/sorter.js | 82 ++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/app/sorter.js b/app/sorter.js index a2c95b2..d5411fd 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -1,4 +1,4 @@ -import {info, fs, path, is, to, log} from './utils'; +import {is, to} from './utils' /// @name sort /// @description @@ -6,14 +6,14 @@ import {info, fs, path, is, to, log} from './utils'; /// @arg {object} /// @returns {object} export default function(json) { - let nav, pages; + let nav, pages /// @name pages /// @description /// This function loops over the json that was passed and creates a organized structure /// based on the `@pages` annotations that were passed. pages = (() => { - let result = {}; + let result = {} // @name set // @description // creates a structure from an array, and adds the passed object to @@ -22,31 +22,33 @@ export default function(json) { // @returns {object} - The nested object with the set value function set(path, type, value) { // ensures values won't change in the passed value - value = to.clone(value); + value = to.clone(value) // deletes the page from the value so it // won't get added to the data - delete value.page; + delete value.page - let _pages = result, - path_list = path.split('/').filter(Boolean), // convert to array, and filter out empty strings - // 1 less than the link so the last item in the `path_list` is what - // the passed value will be set to - length = path_list.length - 1; + let _pages = 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 = 0; i < length; i++) { - let page = path_list[i]; + let page = path_list[i] if (!_pages[page]) { _pages[page] = { page: { header: {}, body: [] } - }; + } } - _pages = _pages[page]; + _pages = _pages[page] } // a) Define the default data set(can't use `page` because it will be overwritten) @@ -56,15 +58,15 @@ export default function(json) { header: {}, body: [] } - }; + } } if (type === 'header') { - _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value); + _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value) } else { - _pages[path_list[length]].page.body.push(value); + _pages[path_list[length]].page.body.push(value) } - }; + } // loop over each filetype in the json object to create the pages structure for (let [filetype, files] of to.entries(json)) { @@ -72,15 +74,15 @@ export default function(json) { for (let file of files) { // a) Ensures there's only one page defined in the header // b) There wasn't a page defined so set it to general - file.header.page = file.header.page ? file.header.page[0] : 'general'; + file.header.page = file.header.page ? file.header.page[0] : 'general' // a) Set the name in the header to be the name of the file if (is.falsy(file.header.name)) { - file.header.name = to.case.title(file.info.name); + file.header.name = to.case.title(file.info.name) } // set the header for the file - set(file.header.page, 'header', file.header); + set(file.header.page, 'header', file.header) // loop over each block in the body of the file for (let block of file.body) { @@ -89,25 +91,25 @@ export default function(json) { if (block.page) { for (let page of block.page) { if (page !== file.header.page) { - set(page, 'body', block); + set(page, 'body', block) } } } // add the block to the page - set(file.header.page, 'body', block); + set(file.header.page, 'body', block) } } } - return result; - })(); + return result + })() /// @name nav /// @description /// This function builds the navigation based of how the pages were built. nav = ((pages) => { - let result = []; // placeholder to store the result + let result = [] // placeholder to store the result /// @name body_names /// @description Helper function to get the name of each block in the body @@ -115,19 +117,19 @@ export default function(json) { /// @arg {array} - the body of the page /// @returns {array} function body_names(href, body) { - let body_names = []; + let _body_names = [] // loop over each block in the body for (let block of body) { // a) Add the name to the body_names if (is.existy(block.name)) { - body_names.push({ + _body_names.push({ title: block.name, href: `${href}#${to.case.dash(block.name)}` - }); + }) } } - return body_names; + return _body_names } @@ -147,22 +149,22 @@ export default function(json) { href: `${a.href}/${key}`, body: [], subpages: [] - }; + } // add the name of each block in the body - nav_item.body = body_names(nav_item.href, value.page.body); + nav_item.body = body_names(nav_item.href, value.page.body) // a) Call `set` again because it's not the last level if (to.keys(value).length > 1) { // the reason it's `> 1` is because `page` will always be defined. - nav_item = set(nav_item, value); + nav_item = set(nav_item, value) } - a.subpages.push(nav_item); + a.subpages.push(nav_item) } } - return a; - }; + return a + } // loop over the pages structure to create the navigation for (let [key, value] of to.entries(pages)) { @@ -171,14 +173,14 @@ export default function(json) { href: `/${key}`, body: body_names(`/${key}`, value.page.body), subpages: [] - }, value)); + }, value)) } - return result; - })(pages); + return result + })(pages) return { nav, pages - }; -}; \ No newline at end of file + } +} \ No newline at end of file From 2f0a0873d33bda5bb6da37d308a6c1708e0f7025 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 15 Oct 2015 16:49:34 -0500 Subject: [PATCH 073/273] Added packages specifically for testing --- package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a3203c5..ad3f006 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "author": "Tyler Benton", "version": "0.0.0beta1", "scripts": { + "test": "istanbul test | tape tests/**/* | tap-spec", "watch": "rm -rf ./dist; babel app/ -d ./dist --stage 0 --optional runtime --watch", "deploy": "npm run test && git push origin master && npm publish", "build": "rm -rf ./dist; babel app/ -d ./dist --optional runtime --stage 0", @@ -30,6 +31,7 @@ "docs": "bin/docs" }, "dependencies": { + "babel-runtime": "^5.8.25", "chalk": "^1.1.0", "co": "^4.6.0", "commander": "^2.8.1", @@ -82,6 +84,9 @@ }, "devDependencies": { "babel": "^5.8.23", - "babel-runtime": "^5.8.25" + "istanbul": "^0.3.22", + "proxyquire": "^1.7.3", + "sinon": "^1.17.1", + "tape": "^4.2.1" } } From 9861628250681eef6c2d9f3676fde5ce735c763f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 11:41:57 -0500 Subject: [PATCH 074/273] Fixed typo --- app/utils/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/index.js b/app/utils/index.js index dad6669..b22fe28 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,5 +1,5 @@ export denodeify from './denodeify' -export emmitter from './emmiter' +export emmiter from './emmiter' export fs from './fs' export glob from './glob' export info from './info' From 89bcf9071787dbe7cf3c53395cdb4072e16b1b9f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 16:58:33 -0500 Subject: [PATCH 075/273] Updated `is.js` to use `is_js` lib instead --- app/utils/is.js | 340 ++++++++++-------------------------------------- 1 file changed, 72 insertions(+), 268 deletions(-) diff --git a/app/utils/is.js b/app/utils/is.js index eae7902..49ba8f5 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -1,216 +1,78 @@ +//// +/// @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 to_string = (arg) => Object.prototype.toString.call(arg) -const array_slice = (arg) => Array.prototype.slice.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.plain_object(obj) ? to.keys(obj) : obj).indexOf(value) > -1 + + +/// @name is.plain_object +/// @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.plain_object = (arg) => to_string(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' -let is = { - // placeholder for the interfaces - not: {}, - all: {}, - any: {}, - - /// @name is.argument - /// @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)), - - /// @name is.regex - /// @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]', - - /// @name is.func - /// @description is a given arg function? - /// @arg {*} arg - The item to check - /// @returns {boolean} - The result of the test - func: (arg) => to_string(arg) === '[object Function]' || typeof arg === 'function', - - /// @name is.array - /// @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]', - - /// @name is.boolean - /// @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]', - - /// @name is.object - /// @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, - - /// @name is.symbol - /// @description is a given arg a symbol? - /// @arg {*} arg - The item to check - /// @returns {boolean} - The result of the test - symbol: (arg) => typeof arg === 'symbol', - - /// @name is.json - /// @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]', - - /// @name is.empty - /// @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 === '' - } - }, - - /// @name is.exsity - /// @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, - - /// @name is.string - /// @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]', - - /// @name is.undefined - /// @description is a given arg undefined? - /// @arg {*} arg - The item to check - /// @returns {boolean} - undefined: (arg) => arg === void 0, - - /// @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` - /// @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, - - /// @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} - in: (obj, value) => is.included(is.object(obj) ? to.keys(obj) : obj, value) !== false, - - /// @name is.false - /// @description is a given arg false - /// @arg {*} arg - arg to check if it is false - /// @returns {boolean} - false: (arg) => arg === false, - - /// @name is.truthy - /// @description is a given arg truthy? - /// @arg {*} arg - /// @returns {boolean} - truthy: (arg) => arg !== null && arg !== undefined && arg !== false && !(arg !== arg) && arg !== '' && arg !== 0, - - /// @name is.falsy - /// @description is given arg falsy? - /// @arg {*} arg - /// @returns {boolean} - falsy: (arg) => !is.truthy(arg), - - /// @name is.nan - /// @description NaN is number, also it is the only arg which does not equal itself - /// @arg {*} arg - /// @returns {boolean} - nan: (arg) => arg !== arg, - - /// @name is.number - /// @description is given arg a number? - /// @arg {*} arg - /// @returns {boolean} - number: (arg) => is.not.nan(arg) && to_string(arg) === '[object Number]', - - /// @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} - between: (arg, min = 0, max = Infinity) => is.all.number(arg, min, max) && (arg >= min && arg <= max), - - /// @name is.positive - /// @description is a given number positive? - /// @arg {*} arg - /// @returns {boolean} - positive: (arg) => is.number(arg) && arg > 0, - - /// @name is.negative - /// @description is a given number negative? - /// @arg {*} arg - /// @returns {boolean} - negative: (arg) => is.number(arg) && arg < 0, - - /// @name is.above - /// @description is a given number above minimum parameter? - /// @arg {*} arg - /// @arg {number} min [-1] - /// @returns {boolean} - above: (arg, min = -1) => is.all.number(arg, min) && arg > min, - - /// @name is.under - /// @description is a given number above maximum parameter? - /// @arg {*} arg - /// @arg {number} max [100] - /// @returns {boolean} - under: (arg, max = 100) => is.all.number(arg, max) && arg < max, - - /// @name is.null - /// @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, - - /// @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} - promise: (arg) => arg && is.func(arg.then), - - /// @name is.stream - /// @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.func(arg.pipe), - - /// @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} - 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) @@ -232,68 +94,10 @@ is.any.in = (obj, ...values) => { return false } -const not = (func) => () => !func.apply(null, array_slice(arguments)) - -const all = (func) => { - return function() { - let parameters = array_slice(arguments) - let length = parameters.length - // support array - if (length === 1 && is.array(parameters[0])) { - parameters = parameters[0] - length = parameters.length - } +export default is - for (let i = 0, l = length; i < length; i++) { - if (!func.call(null, parameters[i])) { - return false - } - } - return true - } -} -const any = (func) => { - return function() { - let parameters = array_slice(arguments) - let 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 - } -} - -;(function setInterfaces() { - let options = is - for (var option in options) { - if (hasOwnProperty.call(options, option) && is.func(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]) - } - } - } - } -})() -export default is \ No newline at end of file From f6962b25ea7bb5132533cb537efd825b9f2ce750 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 16:59:01 -0500 Subject: [PATCH 076/273] Updated to use `is.plain_object`, and `is.fn` --- app/utils/glob.js | 2 +- app/utils/to.js | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/utils/glob.js b/app/utils/glob.js index d41f80f..76fbc3a 100644 --- a/app/utils/glob.js +++ b/app/utils/glob.js @@ -43,7 +43,7 @@ const glob = co.wrap(function*(files, ignore = [], filter, files_only = true) { files = files.filter((file) => path.extname(file).indexOf('.') > -1) } - if (is.func(filter)) { + if (is.fn(filter)) { if (is.promise(filter())) { return yield array(files).filter(filter) } diff --git a/app/utils/to.js b/app/utils/to.js index 29719c5..cefb26e 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -17,7 +17,7 @@ let to = { /// 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 + '', + string: (arg, glue = '\n') => is.string(arg) ? arg : is.buffer(arg) ? arg + '' : is.plain_object(arg) ? to_string(arg) : is.array(arg) ? arg.join(glue) : is.number(arg) || is.boolean(arg) ? arg.toString() : arg + '', case: { /// @name to.case.clean @@ -126,7 +126,7 @@ let to = { /// It also get's symbols if they're set as a key name. /// @arg {object} /// @returns {array} - keys: (arg) => (is.object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), /// @name to.entries /// @description @@ -194,7 +194,7 @@ let to = { /// Converts an object to a json string /// @arg {object} /// @returns {json object} - json: (arg, spacing = 2) => is.object(arg) && JSON.stringify(arg, null, spacing), + json: (arg, spacing = 2) => is.plain_object(arg) && JSON.stringify(arg, null, spacing), /// @name to.normalize /// @description @@ -236,11 +236,11 @@ let to = { let k = to.keys(b) for (let i = 0, l = k.length; i < l; i++) { - a[k[i]] = is.object(b[k[i]]) ? is.object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] : b[k[i]] + a[k[i]] = is.plain_object(b[k[i]]) ? is.plain_object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] : b[k[i]] } // 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] + // a[k] = is.plain_object(b[k]) ? is.plain_object(a[k]) ? to.extend(a[k], b[k]) : b[k] : b[k] // } return a @@ -252,7 +252,7 @@ let to = { /// /// @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], + clone: (arg) => is.plain_object(arg) ? to.extend({}, arg) : is.array(arg) ? [].concat(arg) : [].concat(arg)[0], /// @name to.merge /// @description @@ -311,12 +311,12 @@ let to = { // 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.func(b[k]) || is.func(a[k]) || is.undefined(a[k])) { + 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.object(a[k])) { - a[k] = is.object(b[k]) ? to.merge(a[k], b[k]) : b[k] + } else if (is.plain_object(a[k])) { + a[k] = is.plain_object(b[k]) ? to.merge(a[k], b[k]) : b[k] } else { a[k] = [a[k], b[k]] } @@ -329,7 +329,7 @@ let to = { } // a) Filter out duplicates - if (unique && !is.object(a[k][0])) { + if (unique && !is.plain_object(a[k][0])) { a[k] = to.array.unique(a[k]) } } @@ -346,10 +346,10 @@ let to = { /// 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, glue = "\n") => is.array(arg) ? arg : is.string(arg) ? arg.split(glue) : is.plain_object(arg) || is.number(arg) ? [arg] : [], array: (arg, ...args) => { let glue = args.length > 0 && is.regexp(args[args.length - 1]) ? args.pop() : '\n' - let 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] : [] + let to_array = (arg) => is.array(arg) ? arg : is.arguments(arg) ? array_slice(arg) : is.string(arg) ? arg.split(glue) : is.plain_object(arg) || is.number(arg) ? [arg] : [] let result = to_array(arg) if (args.length > 0) { @@ -375,9 +375,9 @@ let to = { /// @arg {array, object} /// @returns {array, object} - The sorted version sort: (arg, callback) => { - let run_sort = (obj) => is.func(callback) ? obj.sort.apply(null, callback) : obj.sort() + let run_sort = (obj) => is.fn(callback) ? obj.sort.apply(null, callback) : obj.sort() let result - if (is.object(arg)) { + if (is.plain_object(arg)) { let sorted = {} let keys = run_sort(to.keys(arg)) @@ -406,14 +406,14 @@ let to = { /// 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, + boolean: (arg) => is.boolean(arg) ? arg : is.array(arg) ? !!arg.length : is.plain_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, + number: (arg) => is.number(arg) ? arg : is.array(arg) ? arg.length : is.plain_object(arg) ? to.keys(arg).length : ~~arg, /// @name to.abs /// @description From 1f1900a3dcc6affb4b637be39bd124052fdb6e78 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:02:58 -0500 Subject: [PATCH 077/273] Fixed a few JShint errors --- app/index.js | 2 +- app/parser.js | 160 +++++++++++++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 69 deletions(-) diff --git a/app/index.js b/app/index.js index 1ffb1cb..601a1fe 100644 --- a/app/index.js +++ b/app/index.js @@ -14,5 +14,5 @@ if (typeof exports !== 'undefined') { return docs; }); } else { - root['docs'] = docs; + root.docs = docs; } \ No newline at end of file diff --git a/app/parser.js b/app/parser.js index 35c160f..087e48f 100644 --- a/app/parser.js +++ b/app/parser.js @@ -35,54 +35,54 @@ export default function(args = {}) { let in_comment = false // used to determin that you are in a comment let in_code = false // used to determin if you are in the code after the comment block // a) The file doesn't contain any header level comments, or body level comments - debug.get_blocks.self && console.log(''); - debug.get_blocks.self && console.log(''); - debug.get_blocks.self && console.log(''); - debug.get_blocks.self && console.log(''); - // debug.get_blocks.self && console.log("file =", to.json(file)); - debug.get_blocks.self && console.log('start_at =', start_at); - debug.get_blocks.self && console.log('starting line =', lines[start_at]); - debug.get_blocks.self && console.log('is_start_and_end =', is_start_and_end); - debug.get_blocks.self && console.log('config.start check =', is.in(file.contents, config.start)); - debug.get_blocks.self && console.log(''); - debug.get_blocks.self && console.log('test 1:', is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); - debug.get_blocks.self && console.log('test 2:', !is.between(start_at, 0, lines.length - 1)); + if (debug.get_blocks.self) console.log(''); + if (debug.get_blocks.self) console.log(''); + if (debug.get_blocks.self) console.log(''); + if (debug.get_blocks.self) console.log(''); + if (// debug.get_blocks.self) console.log("file =", to.json(file)); + if (debug.get_blocks.self) console.log('start_at =', start_at); + if (debug.get_blocks.self) console.log('starting line =', lines[start_at]); + if (debug.get_blocks.self) console.log('is_start_and_end =', is_start_and_end); + if (debug.get_blocks.self) console.log('config.start check =', is.in(file.contents, config.start)); + if (debug.get_blocks.self) console.log(''); + if (debug.get_blocks.self) console.log('test 1:', is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); + if (debug.get_blocks.self) console.log('test 2:', !is.between(start_at, 0, lines.length - 1)); if ((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)) { - debug.get_blocks.self && console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); + if (debug.get_blocks.self) console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); return []; } for (let i = start_at, l = lines.length; i < l; i++) { let line = lines[i] let comment_index = { - start: is_start_and_end ? is.included(line, config.start) : false, - line: is.included(line, config.line), - end: is_start_and_end ? is.included(line, config.end) : false + start: is_start_and_end && is.in(line, config.start) ? line.indexOf(config.start) : false, + line: is.in(line, config.line) ? line.indexOf(config.line) : false, + end: is_start_and_end && is.in(line, config.end) ? line.indexOf(config.end) : false } - debug.get_blocks.self && console.log('line', i, '=', line); - debug.get_blocks.self && console.log('length'); + if (debug.get_blocks.self) console.log('line', i, '=', line); + if (debug.get_blocks.self) console.log('length'); // a) The line isn't empty so parse it. if (!is.empty(line)) { // a) is the start and end style or there was an instance of a comment line if (is_start_and_end && (!is.false(comment_index.start) || in_comment) || !is.false(comment_index.line)) { - debug.get_blocks.self && console.log('IN COMMENT', '{', 'start:', comment_index.start, ', line:', comment_index.line, ', end:', comment_index.end, '}'); + if (debug.get_blocks.self) console.log('IN COMMENT', '{', 'start:', comment_index.start, ', line:', comment_index.line, ', end:', comment_index.end, '}'); // a) is the start of a new block if (!is.false(comment_index.start) || !is_start_and_end && !in_comment) { - debug.get_blocks.self && console.log('START OF A NEW BLOCK ---------------------------------------------------------------'); + if (debug.get_blocks.self) console.log('START OF A NEW BLOCK ---------------------------------------------------------------'); in_code = false; // a) There was block that has already been processed if (!is.undefined(block_info)) { // holds the current block information - debug.get_blocks.self && console.log('BLOCK WAS PUSHED TO PARSED_BLOCKS'); + if (debug.get_blocks.self) console.log('BLOCK WAS PUSHED TO PARSED_BLOCKS'); block_info.code.end = i - 1; // @todo check to make sure this is correct parsed_blocks.push(block_info); // Stops the loop after the first comment block // has been parsed. This is for file header comments if (restrict) { - debug.get_blocks.self && console.log('IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); + if (debug.get_blocks.self) console.log('IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); block_info.comment.end = i; return parsed_blocks; } @@ -108,7 +108,7 @@ export default function(args = {}) { // a) check for the end comment if (is_start_and_end && block_info.comment.start !== i && !is.false(comment_index.end)) { - debug.get_blocks.self && console.log('LAST LINE IN COMMENT'); + if (debug.get_blocks.self) console.log('LAST LINE IN COMMENT'); in_comment = false; block_info.comment.end = i; // sets the end line in the comment block @@ -116,11 +116,13 @@ export default function(args = {}) { i++; // skips end comment line line = lines[i]; // updates to be the next line comment_index.end = is.included(config.end); // updates the index + + // comment_index.end = is.in(line, config.end) ? line.indexOf(config.end) : false; } // a) adds this line to block_info comment contents if (in_comment && is.false(comment_index.start) && is.false(comment_index.end)) { - debug.get_blocks.self && console.log('LINE ADDED TO BLOCK COMMENT CONTENTS'); + if (debug.get_blocks.self) console.log('LINE ADDED TO BLOCK COMMENT CONTENTS'); // a) removes the `config.line` from the line. if (!is.false(comment_index.line)) { line = line.slice(comment_index.line + config.line.length); @@ -130,8 +132,8 @@ export default function(args = {}) { } // a) check the next line for an instance of the a line comment - if (!is_start_and_end && is.false(is.included(lines[i + 1], config.line))) { - debug.get_blocks.self && console.log("NEXT 'LINE' IS A COMMENT && NOT START AND END STYLE"); + if (!is_start_and_end && !is.in(lines[i + 1], config.line)) { + if (debug.get_blocks.self) console.log("NEXT 'LINE' IS A COMMENT && NOT START AND END STYLE"); in_comment = false; block_info.comment.end = i; // sets the end line in the comment block i++; // skips end comment line // @todo why does this need to be skipped? @@ -140,7 +142,7 @@ export default function(args = {}) { // a) The last line in the file is a commment if (in_comment && (is_start_and_end && !is.false(comment_index.end) ? i === l : i === l - 1)) { - debug.get_blocks.self && console.log('LAST LINE IN THE FILE IS A COMMENT'); + if (debug.get_blocks.self) console.log('LAST LINE IN THE FILE IS A COMMENT'); block_info.comment.end = is_start_and_end ? i - 1 : i; parsed_blocks.push(block_info); break; // ensures that the loop stops because it's the last line in the file @@ -152,14 +154,14 @@ export default function(args = {}) { // Stops the loop after the first comment block // has been parsed. This is for file header comments if (restrict) { - debug.get_blocks.self && console.log('IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); + if (debug.get_blocks.self) console.log('IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); parsed_blocks.push(block_info); break; } - debug.get_blocks.self && console.log('IN CODE'); + if (debug.get_blocks.self) console.log('IN CODE'); // a) The previous line was a comment if (!in_code) { - debug.get_blocks.self && console.log('THE PREVIOUS LINE WAS A COMMENT'); + if (debug.get_blocks.self) console.log('THE PREVIOUS LINE WAS A COMMENT'); in_code = true; block_info.code.start = i; } @@ -169,7 +171,7 @@ export default function(args = {}) { // a) pushes the last block onto the body if (i === l - 1) { - debug.get_blocks.self && console.log('LAST LINE IN THE FILE IS CODE'); + if (debug.get_blocks.self) console.log('LAST LINE IN THE FILE IS CODE'); block_info.code.end = i; parsed_blocks.push(block_info); } @@ -179,14 +181,14 @@ export default function(args = {}) { else if (i === l - 1 && is.truthy(block_info)) { block_info[is.between(block_info.comment.end) ? 'comment' : 'code'].end = i; parsed_blocks.push(block_info); - debug.get_blocks.self && console.log('LINE WAS EMPTY'); + if (debug.get_blocks.self) console.log('LINE WAS EMPTY'); } - debug.get_blocks.self && console.log(''); + if (debug.get_blocks.self) console.log(''); } // end loop return parsed_blocks; - }; + } // @name this.run_annotation // @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) @@ -230,7 +232,7 @@ export default function(args = {}) { result = annotations[annotation.name].callback.call(result); return result; - }; + } // @name parsed_blocks // @description @@ -239,12 +241,12 @@ export default function(args = {}) { // @returns {array} of parsed blocks function parse_blocks(blocks) { if (is.empty(blocks)) { - return []; + return [] } // if it's an object then convert it to an array. // blocks = to.array(blocks); - let parsed_blocks = []; + let parsed_blocks = [] // @name parse_block // @description @@ -254,30 +256,30 @@ export default function(args = {}) { // for this file type or the default function. // @arg {object} - The blocks to parse const parse_block = (block, prefix = comment.prefix, restrict_lines = false) => { - let contents = to.array(block.comment.contents), - block_annotations = {}, - current = {}; // holds the current annotation + let contents = to.array(block.comment.contents) + let block_annotations = {} + let current = {} // holds the current annotation // loop over each line in the comment block for (let i = 0, l = contents.length; i < l; i++) { - let line = contents[i], - prefix_index = line.indexOf(prefix); + let line = contents[i] + let prefix_index = line.indexOf(prefix) // a) there is an index of the annotation prefix if (prefix_index >= 0) { - let first_space = line.indexOf(' ', prefix_index), - name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length); + let first_space = line.indexOf(' ', prefix_index) + let name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length) // a) the name is one of the annotation names if (annotation_keys.indexOf(name_of_annotation) >= 0) { // a) parse the current annotation if (!is.empty(current)) { - current.end = i - 1; + current.end = i - 1 // run the annotation function and merge it with the other annotations in the block to.merge(block_annotations, { [current.name]: run_annotation(current, block) - }); + }) } // redefines resets the current annotation to be blank @@ -287,44 +289,44 @@ export default function(args = {}) { contents: [], start: i, // sets the starting line of the annotation end: 0 - }; + } } } // a) adds the current line to the contents if (!is.empty(current) && restrict_lines === false) { - current.contents.push(line); + current.contents.push(line) } // a) is the last line in the comment block if (i === l - 1 && !is.empty(current)) { - current.end = i; + current.end = i // run the annotation function and merge it with the other annotations in the block to.merge(block_annotations, { [current.name]: run_annotation(current, block) - }); + }) } } // end block loop - return block_annotations; - }; + return block_annotations + } // loop over each block for (let i in blocks) { - let block = blocks[i]; + let block = blocks[i] - block.comment.contents = to.normalize(block.comment.contents); - block.code.contents = to.normalize(block.code.contents); + block.comment.contents = to.normalize(block.comment.contents) + block.code.contents = to.normalize(block.code.contents) - let parsed_block = parse_block(block); + let parsed_block = parse_block(block) if (!is.empty(parsed_block)) { - parsed_blocks.push(parsed_block); + parsed_blocks.push(parsed_block) } } // end blocks loop - debug.parse_blocks.self && console.log('parsed_blocks', parsed_blocks); + if (debug.parse_blocks.self) console.log('parsed_blocks', parsed_blocks) return parsed_blocks; }; @@ -342,21 +344,43 @@ export default function(args = {}) { end: to.array(contents).length - 1 // ending point of the file }; - debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); debug.get_blocks.result || debug.parse_blocks.result && console.log(''); + if (debug.get_blocks.result || debug.parse_blocks.result) { + console.log(''); + console.log(''); + console.log(''); + console.log(''); + } let header = get_blocks(contents, comment.header); - debug.get_blocks.result && console.log('get_blocks(header) =', !is.empty(header) ? header[0].comment.contents : 'no header for this file'); debug.get_blocks.result && console.log(''); debug.get_blocks.result && console.log(''); - let body = get_blocks(contents, comment.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0); - debug.get_blocks.result && console.log('get_blocks(body) =', body); + if (debug.get_blocks.result) { + console.log('get_blocks(header) =', !is.empty(header) ? header[0].comment.contents : 'no header for this file') + console.log('') + console.log('') + } + + let body = get_blocks(contents, comment.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0) - debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && debug.parse_blocks.result && console.log(''); + if(debug.get_blocks.result) console.log('get_blocks(body) =', body); + + if (debug.parse_blocks.result && debug.parse_blocks.result) { + console.log('') + console.log('') + console.log('') + console.log('') + } header = parse_blocks(header)[0]; - debug.parse_blocks.result && console.log('parse_blocks(header) =', header); debug.parse_blocks.result && console.log(''); debug.parse_blocks.result && console.log(''); + + if (debug.parse_blocks.result) { + console.log('parse_blocks(header) =', header) + console.log('') + console.log('') + } body = parse_blocks(body); - debug.parse_blocks.result && console.log('parse_blocks(body) =', body); + + if (debug.parse_blocks.result) console.log('parse_blocks(body) =', body) // removes the contents from the file info because it's // not something that is needed in the returned data. @@ -368,11 +392,11 @@ export default function(args = {}) { header: header || {}, body }] - }); + }) }) .catch((err) => { console.log(err); reject({}); }); - }); -}; \ No newline at end of file + }) +} \ No newline at end of file From 634448e28394943875511223f8cc997bf3882f37 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:03:30 -0500 Subject: [PATCH 078/273] changed to use `is.in` --- app/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config.js b/app/config.js index db557f1..a10b33a 100644 --- a/app/config.js +++ b/app/config.js @@ -121,7 +121,7 @@ let valid_comment_options = to.keys(default_comment) /// @access private function ensure_valid_config(user_config) { for (let key in user_config) { - if (!is.included(valid_options, key)) { + if (!is.in(valid_options, key)) { log.warn(`'${key}' is not a valid option, see docs options for more details`) //# @todo add link to the doc options } } @@ -130,7 +130,7 @@ function ensure_valid_config(user_config) { if (user_config.comments) { for (let lang in user_config.comments) { for (let type in lang) { - if (!is.included(valid_comment_options, type)) { + if (!is.in(valid_comment_options, type)) { log.warn(`'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`) } } From 1e085f73f5659bb38cbe19cbc5b1d2eb50ced7bb Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:04:07 -0500 Subject: [PATCH 079/273] Added a few more default files to ignore --- app/config.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index a10b33a..27b3ffd 100644 --- a/app/config.js +++ b/app/config.js @@ -5,7 +5,13 @@ import path from 'path' const default_options = { config: `${info.root}/docsfile.js`, files: ['app/**/*'], // files to search - ignore: ['.*', 'node_modules/', 'bower_components/', 'jspm_packages/', 'dist/', 'build/', 'docs/'], // files to be ignored + // files to be ignored + ignore: [ + '.*', // all dot files + 'node_modules/', 'bower_components/', 'jspm_packages/', // package managers + 'dist/', 'build/', 'docs/', // normal folders + 'tests/', 'coverage/' // unit tests and coverage results + ], // add gitignore files to the ignore list. Depending on ignored files it // could cause things to ge parsed slower, that's why it's defaulted to `false` gitignore: false, From 7864e404b21d01423a1204e58b0f5fad2cee14a0 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:09:41 -0500 Subject: [PATCH 080/273] fixed formatting, and updated a few `is` functions --- app/annotation/index.js | 382 ++++++++++++++++++++-------------------- 1 file changed, 191 insertions(+), 191 deletions(-) diff --git a/app/annotation/index.js b/app/annotation/index.js index 78f2bc8..f2e4a24 100644 --- a/app/annotation/index.js +++ b/app/annotation/index.js @@ -1,197 +1,197 @@ 'use strict'; -import annotations from './annotations'; -import {is, to} from '../utils'; +import annotations from './annotations' +import {is, to} from '../utils' export default class AnnotationApi{ - constructor() { - // object of the all the annotation - // This object holds all the annotations - this.annotations = { - default: { + 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() { - 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.func(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; - } - } - } -}; + } + // 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() { + 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.fn(config)) { + config = { + callback: config + } + } + else if (is.plain_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.plain_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 + } + } + } +} From dce5d19b6e49242d1defadf8a0db09a7c4198cd0 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:28:38 -0500 Subject: [PATCH 081/273] Fixed formatting --- .jscsrc | 138 ++++++++++++++++++++++++++------------------------------ 1 file changed, 63 insertions(+), 75 deletions(-) diff --git a/.jscsrc b/.jscsrc index cac4809..c7d50f2 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,18 +1,14 @@ { - "disallowIdentifierNames": ["foo", "bar", "baz", "qux"], - "disallowKeywords": ["with"], - "disallowMixedSpacesAndTabs": "smart", - "disallowMultipleLineStrings": true, - "disallowMultipleSpaces": true, - "disallowPaddingNewlinesInBlocks": true, - "disallowPaddingNewlinesBeforeKeywords": [ - "case", - "catch", - "void", - "with" - ], - "disallowQuotedKeysInObjects": "allButReserved", - "requireSpaceAfterKeywords": [ + "esnext": true, + "disallowIdentifierNames": ["foo", "bar", "baz", "qux"], + "disallowKeywords": ["with"], + "disallowMixedSpacesAndTabs": "smart", + "disallowMultipleLineStrings": true, + "disallowMultipleSpaces": true, + "disallowPaddingNewlinesInBlocks": true, + "disallowPaddingNewlinesBeforeKeywords": ["case", "catch", "void", "with"], + "disallowQuotedKeysInObjects": "allButReserved", + "requireSpaceAfterKeywords": [ "do", "for", "if", @@ -25,65 +21,57 @@ "with", "return", "typeof" - ], - "requireSpaceBeforeKeywords": [ - "catch", - "else" - ], - "requireParenthesesAroundArrowParam": true, - "disallowSpaceBeforeKeywords": [ - "for", - "while" - ], - "requireCurlyBraces": [ - "else", - "else if", - "do", - "try", - "catch", - "default" - ], - "requireLineBreakAfterVariableAssignment": true, - "disallowSpaceAfterObjectKeys": "ignoreSingleLine", - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!", "!!", "~~"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInFunction": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInCallExpression": true, - "requireSpacesInConditionalExpression": true, - "requireSpacesInForStatement": true, - "disallowTrailingWhitespace": "ignoreEmptyLines", - "requireBlocksOnNewline": true, - "requireCommaBeforeLineBreak": true, - "disallowYodaConditions": true, - "requireOperatorBeforeLineBreak": ["?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "requireSpaceBeforeBinaryOperators": true, - "requireSpaceBeforeObjectValues": true, - "requireSpaceBetweenArguments": true, - "requireSpaceAfterBinaryOperators": true, - "disallowSpacesInsideObjectBrackets": null, - "safeContextKeyword": ["$obj", "obj", "$that", "that", "$elem", "elem", "_this", "self", "_self", "_", "$parent", "parent", "instance", "result", "context"], - "fileExtensions": [".js", "jscs"], - "validateQuoteMarks": { - "mark": "'", - "escape": true - }, - "requireSpaceBeforeBlockStatements": true, - "requireParenthesesAroundIIFE": true, - "validateLineBreaks": "LF", - "validateIndentation": 2, - "validateParameterSeparator": ", ", - "excludeFiles": [ - "node_modules/**/*" - ] + ], + "requireSpaceBeforeKeywords": ["catch", "else"], + "requireParenthesesAroundArrowParam": true, + "disallowSpaceBeforeKeywords": ["for", "while"], + "requireCurlyBraces": [ + "else", + "else if", + "do", + "try", + "catch", + "default" + ], + "requireLineBreakAfterVariableAssignment": true, + "disallowSpaceAfterObjectKeys": "ignoreSingleLine", + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!", "!!", "~~"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "disallowSpacesInAnonymousFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInFunction": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInCallExpression": true, + "requireSpacesInConditionalExpression": true, + "requireSpacesInForStatement": true, + "disallowTrailingWhitespace": "ignoreEmptyLines", + "requireBlocksOnNewline": true, + "requireCommaBeforeLineBreak": true, + "disallowYodaConditions": true, + "requireOperatorBeforeLineBreak": ["?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceBeforeObjectValues": true, + "requireSpaceBetweenArguments": true, + "requireSpaceAfterBinaryOperators": true, + "disallowSpacesInsideObjectBrackets": null, + "safeContextKeyword": ["$obj", "obj", "$that", "that", "$elem", "elem", "_this", "self", "_self", "_", "$parent", "parent", "instance", "result", "context"], + "fileExtensions": [".js", "jscs"], + "validateQuoteMarks": { + "mark": "'", + "escape": true + }, + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "validateLineBreaks": "LF", + "validateIndentation": 2, + "validateParameterSeparator": ", ", + "excludeFiles": ["node_modules/**/*"] } From 17b3d003855a930f6604b11c546d2b4500a7ccd8 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:29:06 -0500 Subject: [PATCH 082/273] reorganized and added some folders --- .gitignore | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2f55c63..7439999 100755 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -node_modules/ -nmp-debug.log -dist/ +node_modules +bower_components +jspm_packages +dist .tmp .DS_Store .sass-cache -bower_components/ *.map -docs/docs.json \ No newline at end of file +docs/docs.json +coverage +.nyc_output \ No newline at end of file From ebe7693acce8cdfe7a6091629a3fd4e033a68d2f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:29:44 -0500 Subject: [PATCH 083/273] Added more files to ignore --- .npmignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 92f6bc6..587ef91 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,8 @@ tests/ -app/ \ No newline at end of file +app/ +coverage/ +.coveralls.yml +.travis.yml +.gitignore +.jscsrc +.jshintrc \ No newline at end of file From a242ea9777fc9cad3574666268786b634b481829 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:30:01 -0500 Subject: [PATCH 084/273] Updated to include email address --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad3f006..9e246fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "docs", "description": "Documentation chameleon, adapts to any language and will help you document all the things.", - "author": "Tyler Benton", + "author": "Tyler Benton ", "version": "0.0.0beta1", "scripts": { "test": "istanbul test | tape tests/**/* | tap-spec", From 47c2ccf3614978d0a68a3e89418746bb696f69d2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:30:39 -0500 Subject: [PATCH 085/273] Fixed package.json errors --- package.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9e246fe..38bf2d6 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "description": "Documentation chameleon, adapts to any language and will help you document all the things.", "author": "Tyler Benton ", "version": "0.0.0beta1", + "main": "dist/index.js", "scripts": { "test": "istanbul test | tape tests/**/* | tap-spec", "watch": "rm -rf ./dist; babel app/ -d ./dist --stage 0 --optional runtime --watch", @@ -10,16 +11,12 @@ "build": "rm -rf ./dist; babel app/ -d ./dist --optional runtime --stage 0", "prepublish": "npm run build" }, - "main": "dist/index.js", "files": [ "dist/", "bin/", "LICENSE" ], - "license": { - "type": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, + "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/tjbenton/docs.git" From f53a31299234ec9e3a6bac6f3f2e98c3e368391c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:32:46 -0500 Subject: [PATCH 086/273] Added `is_js` dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 38bf2d6..a26922d 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "commander": "^2.8.1", "fs-extra": "^0.24.0", "glob": "^5.0.6", + "is_js": "^0.7.4", "marked": "^0.3.3" }, "keywords": [ From a58895c694c45e32a48b752f56536d824fa0d757 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:33:15 -0500 Subject: [PATCH 087/273] Added a kick ass testing setup --- app/tests/utils/array.js | 0 app/tests/utils/denodeify.js | 0 app/tests/utils/glob.js | 0 app/tests/utils/info.js | 0 app/tests/utils/is.js | 137 +++++++++++++++++++++++++++++++++++ app/tests/utils/log.js | 0 app/tests/utils/to.js | 32 ++++++++ package.json | 21 ++++-- 8 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 app/tests/utils/array.js create mode 100644 app/tests/utils/denodeify.js create mode 100644 app/tests/utils/glob.js create mode 100644 app/tests/utils/info.js create mode 100644 app/tests/utils/is.js create mode 100644 app/tests/utils/log.js create mode 100644 app/tests/utils/to.js diff --git a/app/tests/utils/array.js b/app/tests/utils/array.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/utils/denodeify.js b/app/tests/utils/denodeify.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/utils/glob.js b/app/tests/utils/glob.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/utils/info.js b/app/tests/utils/info.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/utils/is.js b/app/tests/utils/is.js new file mode 100644 index 0000000..8caae0c --- /dev/null +++ b/app/tests/utils/is.js @@ -0,0 +1,137 @@ +import test from 'tape' +import is from '../../utils/is.js' + +test('is.false', (t) => { + t.notOk(is.false('foo'), + 'should return false if a string is passed') + t.notOk(is.false(0), + 'should return false if a number is passed') + t.ok(is.false(false), + 'should return true if false is pased to it') + t.end() +}) + +test('is.fn', (t) => { + t.ok(is.fn(test), + 'should return true if it is passed a function') + t.notOk(is.fn('foo'), + 'should return false if passed a string') + t.end() +}) + +test('is.in', (t) => { + const array = ['one', 'two', 'three'] + const object = {one: 1, two: 2, three: 3} + const string = 'onetwothree' + t.ok(is.in(array, 'two'), + 'should return true when the item is in the array') + t.notOk(is.in(array, 'four'), + 'should return false when the item is not in the array') + t.ok(is.in(object, 'two'), + 'should return true when the item is in the object') + t.notOk(is.in(object, 'four'), + 'should return false when the item is not in the object') + t.ok(is.in(string, 'two'), + 'should return true when the item is in the string') + t.notOk(is.in(string, 'four'), + 'should return false when the item is not in the string') + t.end() +}) + +test('is.all.in', (t) => { + const array = ['one', 'two', 'three'] + const object = {one: 1, two: 2, three: 3} + const string = 'onetwothree' + t.ok(is.all.in(array, 'one', 'two'), + 'should return true because all items are in the array') + t.notOk(is.all.in(array, 'one', 'four'), + 'should return false because one item isn\'t in the array') + t.ok(is.all.in(object, 'one', 'two'), + 'should return true because all items are in the object') + t.notOk(is.all.in(object, 'one', 'four'), + 'should return false because one item isn\'t in the object') + t.ok(is.all.in(string, 'one', 'two'), + 'should return true because all items are in the string') + t.notOk(is.all.in(string, 'one', 'four'), + 'should return false because one item isn\'t in the string') + t.end() +}) + +test('is.any.in', (t) => { + const array = ['one', 'two', 'three'] + const object = {one: 1, two: 2, three: 3} + const string = 'onetwothree' + t.ok(is.any.in(array, 'one', 'four'), + 'should return true because one is in the array') + t.notOk(is.any.in(array, 'four', 'five'), + 'should return false because none of the passed arguments are in the array') + t.ok(is.any.in(object, 'one', 'four'), + 'should return true because one is in the object') + t.notOk(is.any.in(object, 'four', 'five'), + 'should return false because none of the passed arguments are in the object') + t.ok(is.any.in(string, 'one', 'four'), + 'should return true because one is in the string') + t.notOk(is.any.in(string, 'four', 'five'), + 'should return false because none of the passed arguments are in the string') + t.end() +}) + +test('is.plain_object', (t) => { + t.ok(is.plain_object({}), + 'should return true if passed a {}') + t.notOk(is.plain_object([]), + 'should return false if passed a []') + t.notOk(is.plain_object(''), + 'should return false if passed a string') + t.notOk(is.plain_object(test), + 'should return false if passed a function') + t.end() +}) + +test('is.between', (t) => { + t.ok(is.between(200), + 'should return true because 200 is between 0 and Infinity') + t.ok(is.between(0), + 'should return true because 0 is between 0 and Infinity') + t.ok(is.between(-100, -1000), + 'should return true because -100 is between -1000 and infinity') + t.notOk(is.between(-1), + 'should return false because -1 is not between 0 and infinity') + t.end() +}) + +test('is.promise', (t) => { + async function something_async() { + return 'some cool stuff'; + } + t.notOk(is.promise('foo'), + 'should return false because a string is not a promise') + t.notOk(is.promise(test), + 'should return false because tape is not a promise') + t.ok(is.promise(something_async()), + 'should return true because something_async is an async function') + t.ok(is.promise(Promise.resolve('')), + 'should return true because it is a promise') + t.end() +}) + +test('is.buffer', (t) => { + const string = 'foo bar' + const some_buffer = new Buffer(string) + t.ok(is.buffer(some_buffer), + 'should return true because it is a buffer') + t.notOk(is.buffer(string), + 'should return false because a string is not a buffer') + t.end() +}) + +test('is.symbol', (t) => { + const string = 'foo bar' + t.ok(is.symbol(Symbol(string)), + 'should return true because it is a symbol') + t.notOk(is.symbol(string), + 'should return false because it is a string') + t.end() +}) + + diff --git a/app/tests/utils/log.js b/app/tests/utils/log.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/utils/to.js b/app/tests/utils/to.js new file mode 100644 index 0000000..b28b129 --- /dev/null +++ b/app/tests/utils/to.js @@ -0,0 +1,32 @@ +import test from 'tape'; +import to from '../../utils/to.js' +import is from '../../utils/is.js' + +test('to.string', (t) => { + const string = to.string('yo this is a string') + const array = to.string(['foo', 'bar', 'baz']) + const object = to.string({foo: 1, bar: 2, baz: 3}) + const buffer = new Buffer('yo this is a string') + const number = to.string(4) + const boolean = to.string(false) + // console.log(is.string(buffer)); + t.equal(typeof string, 'string', '`string` should be converted to a typeof string') + t.equal(string, 'yo this is a string', 'The passed string should not be changed') + t.equal(typeof array, 'string', '`array` should be converted to a typeof string') + // t.equal(typeof buffer, 'string', '`buffer` should be converted to a typeof string') + t.equal(typeof object, 'string', '`object` should be converted to a typeof string') + t.equal(typeof number, 'string', '`number` should be converted to a typeof string') + t.equal(typeof boolean, 'string', '`boolean` should be converted to a typeof string') + + t.end() +}) + +// test('Assertions with tape.', (assert) => { +// const expected = 'something to test'; +// const actual = 'sonething to test'; +// +// assert.equal(actual, expected, +// 'Given two mismatched values, .equal() should produce a nice bug report'); +// +// assert.end(); +// }) \ No newline at end of file diff --git a/package.json b/package.json index a26922d..9e48677 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,21 @@ "version": "0.0.0beta1", "main": "dist/index.js", "scripts": { - "test": "istanbul test | tape tests/**/* | tap-spec", - "watch": "rm -rf ./dist; babel app/ -d ./dist --stage 0 --optional runtime --watch", + "clean": "rm -rf ./dist", + "compile": "npm run clean; babel app/ -d ./dist --optional runtime --stage 0", + "watch": "npm run clean; babel app/ -d ./dist --stage 0 --optional runtime --watch", + "test": "tape dist/tests/**/*.js | faucet", + "coverage": "nyc npm test", + "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", + "plato": "plato -d coverage/plato dist/index.js", "deploy": "npm run test && git push origin master && npm publish", - "build": "rm -rf ./dist; babel app/ -d ./dist --optional runtime --stage 0", - "prepublish": "npm run build" + "prepublish": "npm run compile" + }, + "nyc": { + "exclude": [ + "node_modules/", + "*/utils/fs.js" + ] }, "files": [ "dist/", @@ -82,7 +92,8 @@ }, "devDependencies": { "babel": "^5.8.23", - "istanbul": "^0.3.22", + "faucet": "0.0.1", + "nyc": "^3.2.2", "proxyquire": "^1.7.3", "sinon": "^1.17.1", "tape": "^4.2.1" From 89e7b18ddc13f165ed8d5f41b9aa9bde3c108964 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 16 Oct 2015 17:34:59 -0500 Subject: [PATCH 088/273] General updates - Added `0.10`, `iojs`, `4` - Changed the script to run tests --- .travis.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9bc8db2..fc1bc52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ 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 + - "0.10" + - "0.12" + - "iojs-v2.1.0" + - "4" +sudo: false +install: npm i +script: npm test \ No newline at end of file From a41f5cf9488f24ee2ed732e534279bde84c5ec69 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:11:03 -0500 Subject: [PATCH 089/273] added crappy windows file for testing `\r` stuff --- app/tests/crappy_file_saved_on_windows.cs | 94 +++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 app/tests/crappy_file_saved_on_windows.cs diff --git a/app/tests/crappy_file_saved_on_windows.cs b/app/tests/crappy_file_saved_on_windows.cs new file mode 100644 index 0000000..442e0b2 --- /dev/null +++ b/app/tests/crappy_file_saved_on_windows.cs @@ -0,0 +1,94 @@ +//// +/// @author Tyler Benton +/// @page tests/c#-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 main +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Eaque temporibus praesentium iure, qui dolorem blanditiis +/// error a reprehenderit voluptates debitis iusto, quibusdam. +#include +int main(){ + char name[50]; + int marks,i,n; + printf("Enter number of students: "); + scanf("%d",&n); + FILE *fptr; + fptr=(fopen("C:\\student.txt","w")); + if(fptr==NULL){ + printf("Error!"); + exit(1); + } + for(i=0;i +struct s{ + char name[50]; + int height; +}; +int main(){ + struct s a[5],b[5]; + FILE *fptr; + int i; + fptr=fopen("file.txt","wb"); + for(i=0;i<5;++i){ + fflush(stdin); + printf("Enter name: "); + gets(a[i].name); + printf("Enter height: "); + scanf("%d",&a[i].height); + } + fwrite(a,sizeof(a),1,fptr); + fclose(fptr); + fptr=fopen("file.txt","rb"); + fread(b,sizeof(b),1,fptr); + for(i=0;i<5;++i){ + printf("Name: %s\nHeight: %d",b[i].name,b[i].height); + } + fclose(fptr); +} + +/// @name Something else +/// @description +/// This is another normal multi-line comment. +#include +int main(){ + char name[50]; + int marks,i,n; + printf("Enter number of students: "); + scanf("%d",&n); + FILE *fptr; + fptr=(fopen("C:\\student.txt","a")); + if(fptr==NULL){ + printf("Error!"); + exit(1); + } + for(i=0;i Date: Sat, 17 Oct 2015 23:19:02 -0500 Subject: [PATCH 090/273] wrote unit tests for the `to` helper functions --- app/tests/utils/to.js | 220 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 192 insertions(+), 28 deletions(-) diff --git a/app/tests/utils/to.js b/app/tests/utils/to.js index b28b129..17f53d9 100644 --- a/app/tests/utils/to.js +++ b/app/tests/utils/to.js @@ -1,32 +1,196 @@ import test from 'tape'; import to from '../../utils/to.js' -import is from '../../utils/is.js' +import fs from '../../utils/fs.js' +import info from '../../utils/info.js' +const string = 'yo this is a string' +const array = ['one', 'two', 'three'] +const object = {one: 1, two: 2, three: 3} +const buffer = new Buffer(string) +const number = 4 +const boolean = false test('to.string', (t) => { - const string = to.string('yo this is a string') - const array = to.string(['foo', 'bar', 'baz']) - const object = to.string({foo: 1, bar: 2, baz: 3}) - const buffer = new Buffer('yo this is a string') - const number = to.string(4) - const boolean = to.string(false) - // console.log(is.string(buffer)); - t.equal(typeof string, 'string', '`string` should be converted to a typeof string') - t.equal(string, 'yo this is a string', 'The passed string should not be changed') - t.equal(typeof array, 'string', '`array` should be converted to a typeof string') - // t.equal(typeof buffer, 'string', '`buffer` should be converted to a typeof string') - t.equal(typeof object, 'string', '`object` should be converted to a typeof string') - t.equal(typeof number, 'string', '`number` should be converted to a typeof string') - t.equal(typeof boolean, 'string', '`boolean` should be converted to a typeof string') - - t.end() -}) - -// test('Assertions with tape.', (assert) => { -// const expected = 'something to test'; -// const actual = 'sonething to test'; -// -// assert.equal(actual, expected, -// 'Given two mismatched values, .equal() should produce a nice bug report'); -// -// assert.end(); -// }) \ No newline at end of file + t.is(typeof to.string(string), 'string', + '`string` should be converted to a typeof string') + t.is(typeof to.string(array), 'string', + '`array` should be converted to a typeof string') + t.is(typeof to.string(buffer), 'string', + '`buffer` should be converted to a typeof string') + t.is(typeof to.string(object), 'string', + '`object` should be converted to a typeof string') + t.is(typeof to.string(number), 'string', + '`number` should be converted to a typeof string') + t.is(typeof to.string(boolean), 'string', + '`boolean` should be converted to a typeof string') + t.end() +}) + +test('to.normal_string', async (t) => { + try{ + // this file has some stupid ass characters in it + // that need to be removed in order to become like the + // rest of the fucking world. #microsoftBlowsAtStandards + let crappy_windows_file = await fs.readFile(`${info.root}/tests/lib/coffeescript/test.coffee`) + // crappy_windows_file = JSON.stringify({foo: crappy_windows_file + ''}) + t.is(to.normal_string(crappy_windows_file).match(/\r/g), null, + 'should be a normal string') + t.end() + } catch(err) { + t.fail('the file didn\'t load') + console.log(err.stack); + t.end() + } +}) + +test('to.keys', (t) => { + const keys = to.keys(object) + t.is(keys[0], 'one', 'should return one') + t.is(keys[1], 'two', 'should return two') + t.is(keys[2], 'three', 'should return three') + t.end() +}) + +test('to.entries', (t) => { + for (let [i, item] of to.entries(array)) { + t.ok(typeof i, 'number', '`i` should be a number') + t.ok(typeof item, 'string', '`i` should be a string') + } + t.end() +}) + +test('to.normalize', (t) => { + const actual = ` + .foo { + background: blue; + } + `; + const expected = [ '.foo {', ' background: blue;', '}' ].join('\n') + + t.is(to.normalize(actual), expected, 'all whitespace should be stripped') + t.ok(actual.split('\n')[2].length > 19, 'should be greater than 19' ) + t.is(to.normalize(actual).split('\n')[1].length, 19, 'should be 19') + t.end() +}) + +test('to.extend', (t) => { + let temp = to.extend({}, object); + t.deepEqual(object, object, + 'should equal each other, because they\'re the same') + t.deepEqual(temp, object, + 'should be the same as the first object') + t.is(to.extend(temp, {one: 3}).one, 3, + '`one` should be equal to 3') + t.end() +}) + + +test('to.clone', (t) => { + let actual = { one: { two: { three: { four: { five: 'whatup' } } } } } + let expected = { one: { two: { three: { four: { five: 'whatup' } } } } } + t.notDeepEqual(to.extend(to.clone(actual), {test: 'yo'}), actual, + 'the cloned object should not equal the original object') + t.deepEqual(actual, expected, + 'the actual object should remain the same as the expected object') + t.end() +}) + + +test('to.merge', (t) => { + 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' } } + let expected = { foo: { bar: [ '1', '2' ], baz: [ '3', '4', '5', '6' ], qux: [ 'one', 'two', 'three' ], quux: { garply: { waldo: [ 'one', 'two' ] } }, waldo: function() { return this; }, garply: 'item' } } + t.is(a.foo.bar, '1', 'a.foo.bar should be 1') + to.merge(a, b) + t.pass('a and be were merged') + t.ok(Array.isArray(a.foo.bar), 'a.foo.bar should be an array') + t.ok(Array.isArray(a.foo.baz), 'a.foo.baz should be an array') + t.ok(Array.isArray(a.foo.quux.garply.waldo), + 'a.foo.quux.garply.waldo should be an array') + t.end() +}) + +import is from 'is_js' + +test('to.object', async (t) => { + try{ + let json = await fs.readFile(`${info.root}/package.json`) + t.notOk(is.json(to.object(json)), + 'the passed json should now be an object') + t.end() + } catch(err) { + console.log(err.stack); + } +}) + +test('to.json', (t) => { + let obj = { foo: 'foo', bar: 'foo' } + t.is(typeof obj, 'object', + 'the test object should be an object') + t.is(typeof to.json(obj), 'string', + 'should be a json string') + t.end() +}) + +test('to.array', (t) => { + t.ok(Array.isArray(array), + 'array should should be an array') + t.ok(Array.isArray(to.array(array)), + 'array should be be returned with no changes') + t.notOk(Array.isArray(string), + 'string should not be an array') + t.ok(Array.isArray(to.array(string)), + 'string should be converted to a type of array') + t.notOk(Array.isArray(object), + 'object should not be an array') + t.ok(Array.isArray(to.array(object)), + 'object should be converted to a type of array') + t.notOk(Array.isArray(number), + 'number should not be an array') + t.ok(Array.isArray(to.array(number)), + 'number should be converted to a type of array') + t.end() +}) + +test('to.flat_array', (t) => { + t.is(to.flat_array([[[array]]])[0], 'one', + 'the array should be flattend and the first value should be one') + t.end() +}) + +test('to.unique_array', (t) => { + t.is(to.unique_array(['one', 'one', 'two', 'two']).length, 2, + 'should have a length of 2') + t.end() +}) + +test('to.sort', (t) => { + let actual = { + c: 1, + b: 2, + a: 3 + } + + t.is(Object.keys(actual)[0], 'c', + 'c should be the first key in the object') + t.is(Object.keys(to.sort(actual))[0], 'a', + 'a should be the first key in the object after it\'s sorted') + t.end() +}) + +test('to.number', (t) => { + t.is(to.number(4), 4, + 'should be 4') + t.is(to.number([ 'a', 'b', 'c' ]), 3, + 'should be 3') + t.is(to.number({ a: 1, b: 2, c: 3 }), 3, + 'should be 3') + t.is(to.number('foo'), 0, + 'should be 0') + t.is(to.number('10'), 10, + 'should be 10') + t.is(to.number(false), 0, + 'should be 0') + t.is(to.number(true), 1, + 'should be 1') + t.end() +}) \ No newline at end of file From c777d27bbd8452bc6f53a60db4de53f1c9b8a56e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:22:22 -0500 Subject: [PATCH 091/273] removed case functions and just imported `change-case` lib --- app/utils/to.js | 89 +++---------------------------------------------- 1 file changed, 4 insertions(+), 85 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index cefb26e..91803dd 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -2,6 +2,7 @@ const to_string = (arg) => Object.prototype.toString.call(arg) const array_slice = (arg) => Array.prototype.slice.call(arg) import markdown from 'marked' +import changeCase from 'change-case' import is from './is.js' let to = { @@ -12,98 +13,16 @@ let to = { /// @returns {string} of `html` markdown, + ...changeCase, + /// @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.plain_object(arg) ? to_string(arg) : is.array(arg) ? arg.join(glue) : is.number(arg) || is.boolean(arg) ? arg.toString() : arg + '', - - case: { - /// @name to.case.clean - /// @description - /// Remove any starting case from a `string`, like camel or snake, but keep - /// spaces and punctuation that may be important otherwise. - /// - /// @arg {string} - /// @return {string} - clean(str) { - let unseparate = (str) => str.replace(/[\W_]+(.|$)/g, (m, next) => next ? ' ' + next : '') - let uncamelize = (str) => str.replace(/(.)([A-Z]+)/g, (m, previous, uppers) => previous + ' ' + uppers.toLowerCase().split(' ').join(' ')) - - // a) has spaces - // b) has separator - return (/\s/.test(str) ? str : /[\W_]/.test(str) ? (unseparate(str) || str) : uncamelize(str)).toLowerCase() - }, - - /// @name to.case.title - /// @description Converts a string to title case - /// @arg {string} - /// @returns {string} - title(str) { - // https://github.com/gouch/to-title-case/blob/master/to-title-case.js - var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i - - return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) { - if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) { - return match.toLowerCase() - } - if (match.substr(1).search(/[A-Z]|\../) > -1) { - return match - } + if (is.plain_object(arg)) { - return match.charAt(0).toUpperCase() + match.substr(1) - }) - }, - - /// @name to.case.lower - /// @description Converts a string to lower case(aka `str.toLowerCase()`) - /// @arg {string} - /// @returns {string} - lower: (str) => str.toLowerCase(), - - /// @name to.case.upper - /// @description Converts a string to upper case(aka `str.toUpperCase()`) - /// @arg {string} - /// @returns {string} - upper: (str) => str.toUpperCase(), - - /// @name to.case.sentence - /// @description Converts a string to sentence case - /// @arg {string} - /// @returns {string} - sentence: (str) => to.case.clean(str).replace(/[a-z]/i, (letter) => letter.toUpperCase()), - - /// @name to.case.space - /// @description Replaces camel case, dot, and dash cases with a space - /// @arg {string} - /// @returns {string} - space: (str) => to.case.clean(str).replace(/[\W_]+(.|$)/g, (matches, match) => match ? ' ' + match : ''), - - /// @name to.case.snake - /// @description Converts a string to snake case - /// @arg {string} - /// @returns {string} - snake: (str) => to.case.space(str).replace(/\s/g, '_'), - - /// @name to.case.dash - /// @description Converts a string to dash case - /// @arg {string} - /// @returns {string} - dash: (str) => to.case.space(str).replace(/\s/g, '-'), - - /// @name to.case.dot - /// @description Converts a string to dot case - /// @arg {string} - /// @returns {string} - dot: (str) => to.case.space(str).replace(/\s/g, '.'), - - /// @name to.case.swap - /// @description Converts capital letters to lower case and vice versa - /// @arg {string} - /// @returns {string} - swap: (str) => str.split('').map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join('') }, From 2c35652403817f94fcaa8dfcbac2437761d9c57f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:22:53 -0500 Subject: [PATCH 092/273] Fixed the clone function so it works correctly now --- app/utils/to.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index 91803dd..776f561 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -171,7 +171,35 @@ let to = { /// /// @arg {*} - The item you want to clone /// @returns {*} - The copied result - clone: (arg) => is.plain_object(arg) ? to.extend({}, arg) : is.array(arg) ? [].concat(arg) : [].concat(arg)[0], + clone(arg) { + // Basis. + if (!(arg instanceof Object)) { + return arg; + } + + let clone; + + // Filter out special objects. + let Constructor = arg.constructor; + switch (Constructor) { + // Implement other special objects here. + case RegExp: + clone = new Constructor(arg); + break; + case Date: + clone = new Constructor(arg.getTime()); + break; + default: + clone = new Constructor(); + } + + // Clone each property. + for (var prop in arg) { + clone[prop] = to.clone(arg[prop]); + } + + return clone; + }, /// @name to.merge /// @description From d1d2fb591524a63975e193885cb67c37fbada893 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:24:18 -0500 Subject: [PATCH 093/273] moved location of `to.json` --- app/utils/to.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index 776f561..cfead99 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -108,13 +108,6 @@ let to = { } }, - /// @name to.json - /// @description - /// Converts an object to a json string - /// @arg {object} - /// @returns {json object} - json: (arg, spacing = 2) => is.plain_object(arg) && JSON.stringify(arg, null, spacing), - /// @name to.normalize /// @description /// Removes trailing/leading blank lines. Removes extra whitespace before all the lines that @@ -285,7 +278,18 @@ let to = { return a }, - object: (arg) => is.json(arg), + /// @name to.object + /// @description Converts a json object to a plain object + /// @arg {json} - The json to parse + /// @returns {object} + object: (arg) => is.json(arg) ? JSON.parse(arg) : 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) && JSON.stringify(arg, null, spacing), /// @name to.array /// @description From 8a5d703cf1b8dda48c18c80002ce8c39fc0c8fe4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:26:43 -0500 Subject: [PATCH 094/273] simplified some functions and removed unused functions --- app/utils/is.js | 4 +- app/utils/to.js | 106 +++++++++++++++--------------------------------- 2 files changed, 35 insertions(+), 75 deletions(-) diff --git a/app/utils/is.js b/app/utils/is.js index 49ba8f5..8e4e42f 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -75,7 +75,7 @@ is.symbol = (arg) => typeof arg === 'symbol' is.all.in = (obj, ...values) => { - values = to.array.flat(values) + values = to.flat_array(values) for (let i in values) { if (!is.in(obj, values[i])) { return false @@ -85,7 +85,7 @@ is.all.in = (obj, ...values) => { } is.any.in = (obj, ...values) => { - values = to.array.flat(values) + values = to.flat_array(values) for (let i in values) { if (is.in(obj, values[i])) { return true diff --git a/app/utils/to.js b/app/utils/to.js index cfead99..4e5912f 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -20,9 +20,20 @@ let to = { /// 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 (is.plain_object(arg)) { + return to_string(arg) + } + if (is.array(arg)) { + return arg.join(glue) + } + + return arg + '' }, @@ -45,7 +56,7 @@ let to = { /// It also get's symbols if they're set as a key name. /// @arg {object} /// @returns {array} - keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && to.array.flat([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && to.flat_array([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), /// @name to.entries /// @description @@ -236,7 +247,7 @@ let to = { /// garply: "item" // didn't exist before so it stays as a string /// } /// } - merge: (a, b, unique = true, flat = true) => { + merge(a, b, unique = true, flat = true) { // a) Don't touch `null` or `undefined` objects. if (!a || !b) { return a @@ -265,12 +276,12 @@ let to = { if (is.array(a[k])) { // a) Flatten the array if (flat) { - a[k] = to.array.flat(a[k]) + a[k] = to.flat_array(a[k]) } // a) Filter out duplicates if (unique && !is.plain_object(a[k][0])) { - a[k] = to.array.unique(a[k]) + a[k] = to.unique_array(a[k]) } } } @@ -297,21 +308,7 @@ let to = { /// 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.plain_object(arg) || is.number(arg) ? [arg] : [], - array: (arg, ...args) => { - let glue = args.length > 0 && is.regexp(args[args.length - 1]) ? args.pop() : '\n' - let to_array = (arg) => is.array(arg) ? arg : is.arguments(arg) ? array_slice(arg) : is.string(arg) ? arg.split(glue) : is.plain_object(arg) || is.number(arg) ? [arg] : [] - let 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 - }, + array: (arg, glue = '\n') => is.array(arg) ? arg : is.arguments(arg) ? array_slice(arg) : is.string(arg) ? arg.split(glue) : is.plain_object(arg) || is.number(arg) ? [arg] : [], /// @name to.flat_array /// @description @@ -320,6 +317,22 @@ let to = { /// @returnes {array} - single dimensional flat_array: (arg) => is.array(arg) ? [].concat(...arg.map(to.flat_array)) : arg, + /// @name to.unique_array + /// @description + /// Removes duplicate values from an array + /// @arg {array} + /// @returns {array} - without duplicates + unique_array(arg){ + let o = {} + let r = [] + + for (let i in arg) o[arg[i]] = arg[i] + + for (let i in o) r.push(o[i]) + + return r + }, + /// @name to.sort /// @description /// Sorts an array or object based off your callback function. If one is provided. @@ -343,65 +356,12 @@ let to = { 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.plain_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.plain_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} - single dimensional -to.array.flat = (arg) => [].concat.apply([], to.array(arg)) - -/// @name to.array.unique -/// @description -/// Removes duplicate values from an array -/// @arg {array} -/// @returns {array} - without duplicates -to.array.unique = (arg) => { - let o = {} - let r = [] - - for (let i in arg) o[arg[i]] = arg[i] - - for (let i in o) r.push(o[i]) - - return r + number: (arg) => is.number(arg) ? arg : is.array(arg) ? arg.length : is.plain_object(arg) ? to.keys(arg).length : ~~arg } export default to \ No newline at end of file From d29f6a1fb5527ba92490ee9d951dea2955f50de5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:27:12 -0500 Subject: [PATCH 095/273] added `change-case` --- app/annotation/index.js | 2 +- app/sorter.js | 8 ++++---- package.json | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/annotation/index.js b/app/annotation/index.js index f2e4a24..bcf201f 100644 --- a/app/annotation/index.js +++ b/app/annotation/index.js @@ -133,7 +133,7 @@ export default class AnnotationApi{ // 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) + obj.filetypes = is.in(obj, 'filetype') ? to.flat_array([filetype, config.filetype]) : to.array(filetype) this.add(name, obj); } return diff --git a/app/sorter.js b/app/sorter.js index d5411fd..922a9f0 100644 --- a/app/sorter.js +++ b/app/sorter.js @@ -78,7 +78,7 @@ export default function(json) { // a) Set the name in the header to be the name of the file if (is.falsy(file.header.name)) { - file.header.name = to.case.title(file.info.name) + file.header.name = to.titleCase(file.info.name) } // set the header for the file @@ -124,7 +124,7 @@ export default function(json) { if (is.existy(block.name)) { _body_names.push({ title: block.name, - href: `${href}#${to.case.dash(block.name)}` + href: `${href}#${to.paramCase(block.name)}` }) } } @@ -145,7 +145,7 @@ export default function(json) { for (let [key, value] of to.entries(b)) { if (key !== 'page') { let nav_item = { - title: is.truthy(value.page.header.name) ? value.page.header.name : to.case.title(to.case.space(key)), + title: is.truthy(value.page.header.name) ? value.page.header.name : to.titleCase(to.sentenceCase(key)), href: `${a.href}/${key}`, body: [], subpages: [] @@ -169,7 +169,7 @@ export default function(json) { // loop over the pages structure to create the navigation for (let [key, value] of to.entries(pages)) { result.push(set({ - title: to.case.title(to.case.space(key)), + title: to.titleCase(to.sentenceCase(key)), href: `/${key}`, body: body_names(`/${key}`, value.page.body), subpages: [] diff --git a/package.json b/package.json index 9e48677..d1d89c9 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,9 @@ "dependencies": { "babel-runtime": "^5.8.25", "chalk": "^1.1.0", + "change-case": "^2.3.0", "co": "^4.6.0", - "commander": "^2.8.1", + "commander": "^2.9.0", "fs-extra": "^0.24.0", "glob": "^5.0.6", "is_js": "^0.7.4", From 73016cec3c95d03b3689861ecf7c08d189937755 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:29:05 -0500 Subject: [PATCH 096/273] fixed jscs errors --- app/config.js | 7 +++---- app/parser.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/config.js b/app/config.js index 27b3ffd..3209acf 100644 --- a/app/config.js +++ b/app/config.js @@ -81,8 +81,7 @@ export default async function config(options = {}) { options.ignore, to.array(to.string(await fs.readFile(path.join(info.root, '.gitignore')))) ]) - - } catch(err){} + } catch(err) {} } @@ -97,7 +96,7 @@ export default async function config(options = {}) { let comments = {} // ensures comments are a normal structure (aka not `'rb, py': {...}`) - for (let [option, value] of to.entries(options.comments)){ + for (let [option, value] of to.entries(options.comments)) { // converts option into an array so multiple languages can be declared at the same time option = option.replace(/\s/g, '').split(',') @@ -108,7 +107,7 @@ export default async function config(options = {}) { // this makes it easier later on when parsing for (let [lang, value] of to.entries(comments)) { if (lang !== '_') { - comments[lang] = to.extend(JSON.parse(JSON.stringify(default_comment)), value) + comments[lang] = to.extend(to.clone(default_comment), value) } } diff --git a/app/parser.js b/app/parser.js index 087e48f..bbc2b1c 100644 --- a/app/parser.js +++ b/app/parser.js @@ -39,7 +39,7 @@ export default function(args = {}) { if (debug.get_blocks.self) console.log(''); if (debug.get_blocks.self) console.log(''); if (debug.get_blocks.self) console.log(''); - if (// debug.get_blocks.self) console.log("file =", to.json(file)); + if (debug.get_blocks.self) console.log('file =', to.json(file)); if (debug.get_blocks.self) console.log('start_at =', start_at); if (debug.get_blocks.self) console.log('starting line =', lines[start_at]); if (debug.get_blocks.self) console.log('is_start_and_end =', is_start_and_end); @@ -49,7 +49,7 @@ export default function(args = {}) { if (debug.get_blocks.self) console.log('test 2:', !is.between(start_at, 0, lines.length - 1)); if ((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)) { - if (debug.get_blocks.self) console.log("WELL SHIT FIRE, FILE DOESN'T CONTAIN ANY COMMENTS"); + if (debug.get_blocks.self) console.log('WELL SHIT FIRE, FILE DOESN\'T CONTAIN ANY COMMENTS'); return []; } From 459e68a99ff5e3614f12df645290c627117a2393 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 17 Oct 2015 23:29:05 -0500 Subject: [PATCH 097/273] fixed jscs errors --- app/utils/to.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index 4e5912f..9c30766 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -185,7 +185,7 @@ let to = { // Filter out special objects. let Constructor = arg.constructor; - switch (Constructor) { + switch(Constructor) { // Implement other special objects here. case RegExp: clone = new Constructor(arg); From fba6c47a82b120698daa90b78ce97368176c3f1d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 18 Oct 2015 10:59:06 -0500 Subject: [PATCH 098/273] Renamed tests to have `.tests.js` at the end --- app/tests/utils/{array.js => array.test.js} | 0 app/tests/utils/{denodeify.js => denodeify.test.js} | 0 app/tests/utils/{glob.js => glob.test.js} | 0 app/tests/utils/{info.js => info.test.js} | 0 app/tests/utils/{is.js => is.test.js} | 0 app/tests/utils/{log.js => log.test.js} | 0 app/tests/utils/{to.js => to.test.js} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename app/tests/utils/{array.js => array.test.js} (100%) rename app/tests/utils/{denodeify.js => denodeify.test.js} (100%) rename app/tests/utils/{glob.js => glob.test.js} (100%) rename app/tests/utils/{info.js => info.test.js} (100%) rename app/tests/utils/{is.js => is.test.js} (100%) rename app/tests/utils/{log.js => log.test.js} (100%) rename app/tests/utils/{to.js => to.test.js} (100%) diff --git a/app/tests/utils/array.js b/app/tests/utils/array.test.js similarity index 100% rename from app/tests/utils/array.js rename to app/tests/utils/array.test.js diff --git a/app/tests/utils/denodeify.js b/app/tests/utils/denodeify.test.js similarity index 100% rename from app/tests/utils/denodeify.js rename to app/tests/utils/denodeify.test.js diff --git a/app/tests/utils/glob.js b/app/tests/utils/glob.test.js similarity index 100% rename from app/tests/utils/glob.js rename to app/tests/utils/glob.test.js diff --git a/app/tests/utils/info.js b/app/tests/utils/info.test.js similarity index 100% rename from app/tests/utils/info.js rename to app/tests/utils/info.test.js diff --git a/app/tests/utils/is.js b/app/tests/utils/is.test.js similarity index 100% rename from app/tests/utils/is.js rename to app/tests/utils/is.test.js diff --git a/app/tests/utils/log.js b/app/tests/utils/log.test.js similarity index 100% rename from app/tests/utils/log.js rename to app/tests/utils/log.test.js diff --git a/app/tests/utils/to.js b/app/tests/utils/to.test.js similarity index 100% rename from app/tests/utils/to.js rename to app/tests/utils/to.test.js From 4e1d382dd20e1933308d2d960e203a50817d6836 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 18 Oct 2015 11:04:25 -0500 Subject: [PATCH 099/273] Moved location of `is` --- app/tests/utils/to.test.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index 17f53d9..a987aba 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -2,6 +2,8 @@ import test from 'tape'; import to from '../../utils/to.js' import fs from '../../utils/fs.js' import info from '../../utils/info.js' +import is from 'is_js' + const string = 'yo this is a string' const array = ['one', 'two', 'three'] const object = {one: 1, two: 2, three: 3} @@ -9,6 +11,7 @@ const buffer = new Buffer(string) const number = 4 const boolean = false + test('to.string', (t) => { t.is(typeof to.string(string), 'string', '`string` should be converted to a typeof string') @@ -25,6 +28,7 @@ test('to.string', (t) => { t.end() }) + test('to.normal_string', async (t) => { try{ // this file has some stupid ass characters in it @@ -42,6 +46,7 @@ test('to.normal_string', async (t) => { } }) + test('to.keys', (t) => { const keys = to.keys(object) t.is(keys[0], 'one', 'should return one') @@ -50,6 +55,7 @@ test('to.keys', (t) => { t.end() }) + test('to.entries', (t) => { for (let [i, item] of to.entries(array)) { t.ok(typeof i, 'number', '`i` should be a number') @@ -58,6 +64,7 @@ test('to.entries', (t) => { t.end() }) + test('to.normalize', (t) => { const actual = ` .foo { @@ -72,6 +79,7 @@ test('to.normalize', (t) => { t.end() }) + test('to.extend', (t) => { let temp = to.extend({}, object); t.deepEqual(object, object, @@ -109,7 +117,6 @@ test('to.merge', (t) => { t.end() }) -import is from 'is_js' test('to.object', async (t) => { try{ @@ -122,6 +129,7 @@ test('to.object', async (t) => { } }) + test('to.json', (t) => { let obj = { foo: 'foo', bar: 'foo' } t.is(typeof obj, 'object', @@ -131,6 +139,7 @@ test('to.json', (t) => { t.end() }) + test('to.array', (t) => { t.ok(Array.isArray(array), 'array should should be an array') @@ -151,18 +160,21 @@ test('to.array', (t) => { t.end() }) + test('to.flat_array', (t) => { t.is(to.flat_array([[[array]]])[0], 'one', 'the array should be flattend and the first value should be one') t.end() }) + test('to.unique_array', (t) => { t.is(to.unique_array(['one', 'one', 'two', 'two']).length, 2, 'should have a length of 2') t.end() }) + test('to.sort', (t) => { let actual = { c: 1, @@ -177,6 +189,7 @@ test('to.sort', (t) => { t.end() }) + test('to.number', (t) => { t.is(to.number(4), 4, 'should be 4') From 7ed4bcb087c0cafd0d5dc58a943ae06335c67f91 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:37:47 -0400 Subject: [PATCH 100/273] removed passed argument because it's not used --- bin/docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/docs b/bin/docs index 9abe760..b046205 100755 --- a/bin/docs +++ b/bin/docs @@ -2,5 +2,5 @@ 'use strict'; -require('../dist/cli.js')(process.argv.slice(2)); +require('../dist/cli.js')(); From bee8323015a39fe139ccee56830bb05595c1940c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:38:12 -0400 Subject: [PATCH 101/273] fixed bug with `to.object` --- app/tests/utils/to.test.js | 2 +- app/utils/to.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index a987aba..12b72ab 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -121,7 +121,7 @@ test('to.merge', (t) => { test('to.object', async (t) => { try{ let json = await fs.readFile(`${info.root}/package.json`) - t.notOk(is.json(to.object(json)), + t.ok(to.object(json).author, 'the passed json should now be an object') t.end() } catch(err) { diff --git a/app/utils/to.js b/app/utils/to.js index 9c30766..dbb1c66 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -293,7 +293,7 @@ let to = { /// @description Converts a json object to a plain object /// @arg {json} - The json to parse /// @returns {object} - object: (arg) => is.json(arg) ? JSON.parse(arg) : arg, + object: (arg) => JSON.parse(arg), /// @name to.json /// @description Converts an object to a json string From c7253b7ae02ee58f10575f71403007c44dc4fb29 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:41:03 -0400 Subject: [PATCH 102/273] reworked annotations to be in a single file This was to reduce the complexity of creating the annotations --- app/annotation/annotations/access.js | 11 - app/annotation/annotations/alias.js | 11 - app/annotation/annotations/arg.js | 15 -- app/annotation/annotations/author.js | 7 - app/annotation/annotations/chainable.js | 11 - app/annotation/annotations/construct.js | 12 - app/annotation/annotations/deprecated.js | 12 - app/annotation/annotations/description.js | 13 -- app/annotation/annotations/export.js | 0 app/annotation/annotations/index.js | 31 --- app/annotation/annotations/markup.js | 13 -- app/annotation/annotations/name.js | 9 - app/annotation/annotations/note.js | 12 - app/annotation/annotations/page.js | 12 - app/annotation/annotations/readonly.js | 11 - app/annotation/annotations/requires.js | 13 -- app/annotation/annotations/returns.js | 13 -- app/annotation/annotations/since.js | 12 - app/annotation/annotations/state.js | 14 -- app/annotation/annotations/todo.js | 13 -- app/annotation/annotations/type.js | 12 - app/annotation/annotations/version.js | 12 - .../index.js => annotation_api.js} | 10 +- app/annotations.js | 218 ++++++++++++++++++ 24 files changed, 223 insertions(+), 274 deletions(-) delete mode 100644 app/annotation/annotations/access.js delete mode 100644 app/annotation/annotations/alias.js delete mode 100644 app/annotation/annotations/arg.js delete mode 100644 app/annotation/annotations/author.js delete mode 100644 app/annotation/annotations/chainable.js delete mode 100644 app/annotation/annotations/construct.js delete mode 100644 app/annotation/annotations/deprecated.js delete mode 100644 app/annotation/annotations/description.js delete mode 100644 app/annotation/annotations/export.js delete mode 100644 app/annotation/annotations/index.js delete mode 100644 app/annotation/annotations/markup.js delete mode 100644 app/annotation/annotations/name.js delete mode 100644 app/annotation/annotations/note.js delete mode 100644 app/annotation/annotations/page.js delete mode 100644 app/annotation/annotations/readonly.js delete mode 100644 app/annotation/annotations/requires.js delete mode 100644 app/annotation/annotations/returns.js delete mode 100644 app/annotation/annotations/since.js delete mode 100644 app/annotation/annotations/state.js delete mode 100644 app/annotation/annotations/todo.js delete mode 100644 app/annotation/annotations/type.js delete mode 100644 app/annotation/annotations/version.js rename app/{annotation/index.js => annotation_api.js} (97%) create mode 100644 app/annotations.js diff --git a/app/annotation/annotations/access.js b/app/annotation/annotations/access.js deleted file mode 100644 index bd68fda..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() { - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/alias.js b/app/annotation/annotations/alias.js deleted file mode 100644 index a663ca5..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() { - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/arg.js b/app/annotation/annotations/arg.js deleted file mode 100644 index a039ad4..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() { // - // 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 b0b1a93..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 6ec862e..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() { - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/construct.js b/app/annotation/annotations/construct.js deleted file mode 100644 index 35d7ba9..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() { - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/deprecated.js b/app/annotation/annotations/deprecated.js deleted file mode 100644 index 1d6be08..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() { - // 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 7e85e29..0000000 --- a/app/annotation/annotations/description.js +++ /dev/null @@ -1,13 +0,0 @@ -import markdown from 'marked' -/// @name description -/// @page annotations -/// @description Description of the documented item -/// @note Runs through markdown -/// @returns {string} -export default { - description: { - callback() { - return markdown(this.annotation.line ? this.annotation.line + '\n' + this.annotation.contents : this.annotation.contents) - } - } -}; diff --git a/app/annotation/annotations/export.js b/app/annotation/annotations/export.js deleted file mode 100644 index e69de29..0000000 diff --git a/app/annotation/annotations/index.js b/app/annotation/annotations/index.js deleted file mode 100644 index 94f5f3c..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 7841e3a..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() { - // 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 4790398..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 2f75525..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() { - // 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 1f9e231..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() { - return [this.annotation.line]; - } - } -}; diff --git a/app/annotation/annotations/readonly.js b/app/annotation/annotations/readonly.js deleted file mode 100644 index c77bab0..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() { - return this.annotation.line; - } - } -}; diff --git a/app/annotation/annotations/requires.js b/app/annotation/annotations/requires.js deleted file mode 100644 index eae3a4b..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() { - // 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 fe12bd9..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() { // 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 df03719..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() { - // 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 8d7034c..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() { - // 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 e74e1f0..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() { - // 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 a562504..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() { - // 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 49b3b02..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() { - // add regex for `{type} - description` - return this.annotation.line; - } - } -}; diff --git a/app/annotation/index.js b/app/annotation_api.js similarity index 97% rename from app/annotation/index.js rename to app/annotation_api.js index bcf201f..3cee338 100644 --- a/app/annotation/index.js +++ b/app/annotation_api.js @@ -1,10 +1,9 @@ 'use strict'; -import annotations from './annotations' -import {is, to} from '../utils' +import { is, to } from './utils' -export default class AnnotationApi{ - constructor() { +export default class AnnotationApi { + constructor(annotations) { // object of the all the annotation // This object holds all the annotations this.annotations = { @@ -17,9 +16,10 @@ export default class AnnotationApi{ // js: { // annotation // } + } - // adds the default annotations to the list + // add the inital annotations this.add_annotations(annotations) } diff --git a/app/annotations.js b/app/annotations.js new file mode 100644 index 0000000..c7de87f --- /dev/null +++ b/app/annotations.js @@ -0,0 +1,218 @@ +import { to } from './utils' + +//// +/// @name Annotations +/// @page annotations +/// @description +/// These are the default annotations for the docs +//// +const annotations = { + /// @name access + /// @description Access of the documented item + /// @returns {string} + access: { + callback() { + return this.annotation.line; + } + }, + + /// @name alias + /// @description Whether the documented item is an alias of another item + /// @returns {string} + alias: { + callback() { + return this.annotation.line; + } + }, + + /// @name arg + /// @page annotations + /// @description Parameters from the documented function/mixin + /// @note Description runs through markdown + /// @returns {object} + arg: { + alias: ['argument', 'param', 'parameter'], + callback() { + // add regex for `{type} name-of-variable [default value] - description` + // make sure it supports multiple lines + return this.annotation.line; + } + }, + + /// @name author + /// @page annotations + /// @description Author of the documented item + /// @returns {string} + author: { + callback() { + return this.annotation.line.split(',').map((author) => author.trim()).filter(Boolean) + } + }, + + /// @name chainable + /// @page annotations + /// @description Used to notate that a function is chainable + /// @returns {boolean} + chainable: { + callback() { + return this.annotation.line; + } + }, + + /// @name deprecated + /// @page annotations + /// @description Lets you know that a mixin/function has been depricated + /// @returns {string} + deprecated: { + callback() { + // add regex for `{version} - description` + return this.annotation.line; + } + }, + + /// @name description + /// @page annotations + /// @description Description of the documented item + /// @note Runs through markdown + /// @returns {string} + description: { + callback() { + return to.markdown(this.annotation.line ? this.annotation.line + '\n' + this.annotation.contents : this.annotation.contents) + } + }, + + /// @name markup + /// @page annotations + /// @description Code for the documented item + /// @note Description is parsed as markdown + /// @returns {object} + markup: { + callback() { + // add regex for `{language} [settings] - description` + return this.annotation.contents; + } + }, + + /// @name name + /// @page annotations/name + /// @description Name of the documented item + /// @returns {string} + name: { + alias: ['title', 'heading'] + }, + /// @name note + /// @page annotations + /// @description A note about the documented item + /// @returns {object} + note: { + callback() { + // add regex for `{7} - A note` + return this.annotation.line; + } + }, + + /// @name page + /// @page annotations + /// @description The page you want the documented item to be on + /// @returns {string} + page: { + alias: ['group'], + callback() { + return [this.annotation.line]; + } + }, + + /// @name readonly + /// @page annotations + /// @description To note that a property is readonly + /// @returns {boolean} + readonly: { + callback() { + return this.annotation.line; + } + }, + + /// @name requires + /// @page annotations + /// @description Requirements from the documented item + /// @returns {object} + requires: { + alias: ['require'], + callback() { + // add regex for {type} item - description + return this.annotation.line; + } + }, + + /// @name returns + /// @page annotations + /// @description Return from the documented function + /// @returns {string} + returns: { + alias: ['return'], + callback() { // return + // add regex for `{type} - description`. Also ensure it supports multiple lines + return this.annotation.line; + } + }, + + /// @name since + /// @page annotations + /// @description Let's you know what version of the project a something was added + /// @returns {string} + since: { + callback() { + // add regex for `{type} - description` + return this.annotation.line; + } + }, + + /// @name state + /// @page annotations + /// @description A state of a the documented item + /// @returns {object} + state: { + callback() { + // 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; + } + }, + + /// @name todo + /// @page annotations + /// @description Things to do related to the documented item + /// @returns {object} + todo: { + callback() { + // add regex for {5} [assignee-one, assignee-two] - Task to be done + // make sure it supports multiple lines + return this.annotation.line; + } + }, + + /// @name type + /// @page annotations + /// @description Describes the type of a variable + /// @returns {string} + type: { + callback() { + // add regex for `{type} - description` + return this.annotation.line; + } + }, + + /// @name version + /// @page annotations + /// @description Describes the type of a variable + /// @returns {string} + version: { + callback() { + // add regex for `{type} - description` + return this.annotation.line; + } + } +} + +export default annotations \ No newline at end of file From a3de83d2fabb03e31b4019ec76240aae5ecd97cd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:42:08 -0400 Subject: [PATCH 103/273] :bug: annotation callbacks were breaking when cloned --- app/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index 3209acf..015edf7 100644 --- a/app/config.js +++ b/app/config.js @@ -73,7 +73,7 @@ export default async function config(options = {}) { options = to.extend(options, ensure_valid_config(config_file)) // merge options with base_config so there's a complete list of settings - options = to.extend(to.clone(base_config), options) + options = to.extend(base_config, options) if (options.gitignore) { try { From 37d3ea1369bd39ef2b46b65501a4817bdeb92fe7 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:42:32 -0400 Subject: [PATCH 104/273] Added the default annotations and api --- app/config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index 015edf7..9cd070a 100644 --- a/app/config.js +++ b/app/config.js @@ -1,5 +1,7 @@ import {info, fs, is, to, log} from './utils' import path from 'path' +import annotations from './annotations' +import AnnotationApi from './annotation_api' // changed by `options` key const default_options = { @@ -19,7 +21,7 @@ const default_options = { blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. debug: true, timestamps: true, - annotations: {} + annotations } const default_comment = { @@ -113,6 +115,8 @@ export default async function config(options = {}) { options.comments = comments + options.annotations = new AnnotationApi(options.annotations) + return options } From d6a338df7443476bffbde6195a2a74afa416b6be Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:43:43 -0400 Subject: [PATCH 105/273] renamed emmitter to be logger --- app/reporter.js | 43 +++++++++++++++++++++++++++ app/utils/emmiter.js | 22 -------------- app/utils/index.js | 2 +- app/utils/logger.js | 71 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 23 deletions(-) create mode 100644 app/reporter.js delete mode 100644 app/utils/emmiter.js create mode 100644 app/utils/logger.js diff --git a/app/reporter.js b/app/reporter.js new file mode 100644 index 0000000..e27e45e --- /dev/null +++ b/app/reporter.js @@ -0,0 +1,43 @@ +import { log } from './utils' + +export default function() { + this + .on('annotation_error', ({ annotation, error }) => + this.error(`with ${annoation}`, error)) + + .on('start', (name) => this.time(name)) + + .on('complete', (name, format = '%s finished after %dms') => + this.time_end(name, format)) + + + + // .on('fly_run', ({ path }) => + // log(`Flying with ${fmt.path}...`, path)) + // + // .on('flyfile_not_found', ({ error }) => + // log(`No Flyfile Error: ${fmt.error}`, error)) + // + // .on('fly_watch', () => + // log(`${fmt.warn}`, 'Watching files...')) + // + // .on('plugin_load', ({ plugin }) => + // log(`Loading plugin ${fmt.title}`, plugin)) + // + // .on('plugin_error', ({ plugin, error }) => + // log(`${fmt.error} failed due to ${fmt.error}`, plugin, error)) + // + // .on('task_error', ({ task, error }) => { + // trace(error) + // log(`${fmt.error} failed due to ${fmt.error}`, task, error) + // }) + // + // .on('task_start', ({ task }) => + // log(`Starting ${fmt.start}`, task)) + // + // .on('task_complete', ({ task, duration }) => { + // const time = timeInfo(duration) + // log(`Finished ${fmt.complete} in ${fmt.secs}`, + // task, time.duration, time.scale) + // }) +} \ No newline at end of file diff --git a/app/utils/emmiter.js b/app/utils/emmiter.js deleted file mode 100644 index 165664b..0000000 --- a/app/utils/emmiter.js +++ /dev/null @@ -1,22 +0,0 @@ -export default class Emitter { - constructor() { - this.events = [] - } - - /// @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, obj) { - (this.events[name] || []).forEach((event) => event.call(this, obj)) - return this - } -} \ No newline at end of file diff --git a/app/utils/index.js b/app/utils/index.js index b22fe28..f1093a4 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,5 +1,5 @@ export denodeify from './denodeify' -export emmiter from './emmiter' +export Logger from './logger' export fs from './fs' export glob from './glob' export info from './info' diff --git a/app/utils/logger.js b/app/utils/logger.js new file mode 100644 index 0000000..c7ddd9b --- /dev/null +++ b/app/utils/logger.js @@ -0,0 +1,71 @@ +import {format as _format} from 'util' +import chalk from 'chalk' + +let chevron = '\xBB' +let check = '\u2713' +let warning = '\u26A0' +let error = '\u2326' + +export default class Logger { + constructor() { + this.events = [] + this.times = {} + } + + /// @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 + } + + log(...args) { + console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)) + } + + warn(...args) { + console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]'))} ${args.shift()}`, ...args), '\n') + } + + error(...args) { + console.trace(...args) + console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]'))} ${args.shift()}`, ...args), '\n') + } + + time(label) { + this.times[label] = Date.now() + } + + time_end(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(_format(`${chalk.green(check)} ${format}`, label, duration)) + } + + debug(...args) { + args = args.map((f) => { + if (f instanceof Function) { + return f() + } + + return f + }) + + console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n') + } +} \ No newline at end of file From 456c8dff5816c936310435c61b0d5b51b78590dc Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:44:08 -0400 Subject: [PATCH 106/273] Added an event logger --- app/docs.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/docs.js b/app/docs.js index a223c57..c85e926 100644 --- a/app/docs.js +++ b/app/docs.js @@ -5,10 +5,13 @@ process.on('uncaughtException', function(err) { process.exit(1) }) -import {info, fs, to, log, glob, array} from './utils' import AnnotationApi from './annotation' +import { info, fs, is, to, glob, array, Logger } from './utils' import parser from './parser' import sorter from './sorter' +import reporter from './reporter' +let log = new Logger(); +reporter.call(log) //// /// @name docs.js @@ -40,14 +43,13 @@ const docs = co.wrap(function*(user_config = {}) { try { yield fs.ensureFile(info.temp.file) let json = fs.readFile(info.temp.file) - - log.time('paths') + log.emit('start', 'paths') files = yield glob(files, ignore, changed ? has_file_changed : false) - log.timeEnd('paths', `%s completed after %dms with ${files.length} file${files.length > 1 ? 's': ''} to parse`) + log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${files.length > 1 ? 's' : ''} to parse`) - log.time('parser') - files = yield array(files).map((file_path) => parser({ file_path, comments, api })) - log.timeEnd('parser') + log.emit('start', 'parser') + files = yield array(files).map((file_path) => parser({ file_path, ...options, log })) + log.emit('complete', 'parser') // converts json to a readable JS object json = to.string(yield json) @@ -66,10 +68,7 @@ const docs = co.wrap(function*(user_config = {}) { fs.outputJson(info.temp.file, json, { spaces: 2 }) .catch((err) => log.error(err.stack)) - log.time('sorter') - json = sorter(json) - log.timeEnd('sorter') - log.timeEnd('total') + log.emit('complete', 'total') return json } catch(err) { log.error(err.stack) From df436108fbee812c2642263a81dac673e01dd683 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:46:37 -0400 Subject: [PATCH 107/273] fixed formatting --- app/docs.js | 9 +++------ app/utils/is.js | 8 +------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/app/docs.js b/app/docs.js index c85e926..2d20d87 100644 --- a/app/docs.js +++ b/app/docs.js @@ -5,7 +5,6 @@ process.on('uncaughtException', function(err) { process.exit(1) }) -import AnnotationApi from './annotation' import { info, fs, is, to, glob, array, Logger } from './utils' import parser from './parser' import sorter from './sorter' @@ -73,9 +72,7 @@ const docs = co.wrap(function*(user_config = {}) { } catch(err) { log.error(err.stack) } -}); - - +}) export default docs @@ -102,7 +99,7 @@ async function has_file_changed(file) { } } catch(err) { // copies new files over because it doesn't exist in the temp target directory - fs.fake_copy(source, target); + fs.fake_copy(source, target) return true } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/app/utils/is.js b/app/utils/is.js index 8e4e42f..63652ba 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -73,7 +73,6 @@ is.included = (a, b) => !is.empty(a) && !is.empty(b) && a.indexOf(b) > -1 ? a.in /// @returns {boolean} - The result of the test is.symbol = (arg) => typeof arg === 'symbol' - is.all.in = (obj, ...values) => { values = to.flat_array(values) for (let i in values) { @@ -95,9 +94,4 @@ is.any.in = (obj, ...values) => { } -export default is - - - - - +export default is \ No newline at end of file From dc4ec765833e2fa28f134134d19c406c05865823 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:47:36 -0400 Subject: [PATCH 108/273] reordered some imports --- app/docs.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/docs.js b/app/docs.js index 2d20d87..cc3402f 100644 --- a/app/docs.js +++ b/app/docs.js @@ -5,10 +5,14 @@ process.on('uncaughtException', function(err) { process.exit(1) }) +import co from 'co' +import path from 'path' import { info, fs, is, to, glob, array, Logger } from './utils' import parser from './parser' import sorter from './sorter' import reporter from './reporter' +import get_config from './config' + let log = new Logger(); reporter.call(log) @@ -19,13 +23,9 @@ reporter.call(log) /// This is used to parse any filetype that you want to and gets the /// documentation for it and returns an `{}` of the document data //// - -import get_config from './config' -import co from 'co' -import path from 'path' - -const docs = co.wrap(function*(user_config = {}) { - log.time('total') +const docs = co.wrap(function*(options = {}) { + log.emit('start', 'total') + options = yield get_config(options) let { files, ignore, @@ -35,9 +35,8 @@ const docs = co.wrap(function*(user_config = {}) { timestamps, annotations, comments, - } = yield get_config(user_config); + } = options - let api = new AnnotationApi() try { yield fs.ensureFile(info.temp.file) @@ -52,7 +51,7 @@ const docs = co.wrap(function*(user_config = {}) { // converts json to a readable JS object json = to.string(yield json) - json = !!json ? JSON.parse(json) : {} + json = !!json ? to.object(json) : {} // Loop through the parsed files and update the // json data that was stored. From 6c40b839dcb9aed474a8f397e6821398cfe663e2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:48:45 -0400 Subject: [PATCH 109/273] :bug: Changed to be `to.extend` This fixes a bug where the temp `data.json` would continue to grow larger and larger instead of just being updated. Now it's based on the filepath of each file. --- app/docs.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/docs.js b/app/docs.js index cc3402f..bf8aa00 100644 --- a/app/docs.js +++ b/app/docs.js @@ -55,9 +55,7 @@ const docs = co.wrap(function*(options = {}) { // Loop through the parsed files and update the // json data that was stored. - for (let i in files) { - to.merge(json, files[i], false) - } + for (let i in files) to.extend(json, files[i]) // Update the temp json data. Even though this returns a promise // it's not returned below because there's no need to wait for it From a2a0b0d8a2da083330e04674e1ee9c3259d58e15 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:52:12 -0400 Subject: [PATCH 110/273] Simplified the parser - Reworked the way the parser was receiving options. - Moved the larger helper functions into seperate files - Removed the variable pollution where the parser had nested functions that were using variables outside of the helper functions which leads to confusion. --- app/parser.js | 402 ------------------------------------- app/parser/get_blocks.js | 145 +++++++++++++ app/parser/index.js | 76 +++++++ app/parser/parse_blocks.js | 168 ++++++++++++++++ 4 files changed, 389 insertions(+), 402 deletions(-) delete mode 100644 app/parser.js create mode 100644 app/parser/get_blocks.js create mode 100644 app/parser/index.js create mode 100644 app/parser/parse_blocks.js diff --git a/app/parser.js b/app/parser.js deleted file mode 100644 index bbc2b1c..0000000 --- a/app/parser.js +++ /dev/null @@ -1,402 +0,0 @@ -import {info, fs, is, to} from './utils' -import path from 'path' - -/// @name parse_file -/// @description -/// Parses a single file -/// @arg {string} - The path to the file you're wanting to parse -/// @returns {array} - Array of parsed blocks -export default function(args = {}) { - let { file_path, comments, api } = args - let filetype = path.extname(file_path).replace('.', '') // the filetype of the current file - let comment = comments[filetype] ? comments[filetype] : comments._ - let annotations = api.list(filetype) // gets the annotations to use on this file - let annotation_keys = to.keys(annotations) // stores the annotation names for this file in an array - let file = {} // placeholder to hold the file information that is defined in the return promise - let debug = { - get_blocks: {}, - parse_blocks: {} - } - debug.get_blocks.self = false; - debug.get_blocks.result = false; - debug.parse_blocks.self = false; - debug.parse_blocks.result = false; - - // @name get_blocks - // @description Parses the file and returns the comment blocks in an array - // @returns {array} of the comment blocks - // @todo {5} - add a line offest argument to this so that you can call parse content on other language types. - function get_blocks(content, config, restrict = true, start_at = 0) { - start_at = is.number(start_at) ? start_at : 0; - let lines = to.array(content) - let parsed_blocks = [] - let block_info - let is_start_and_end = is.all.truthy(config.start, config.end) - let in_comment = false // used to determin that you are in a comment - let in_code = false // used to determin if you are in the code after the comment block - // a) The file doesn't contain any header level comments, or body level comments - if (debug.get_blocks.self) console.log(''); - if (debug.get_blocks.self) console.log(''); - if (debug.get_blocks.self) console.log(''); - if (debug.get_blocks.self) console.log(''); - if (debug.get_blocks.self) console.log('file =', to.json(file)); - if (debug.get_blocks.self) console.log('start_at =', start_at); - if (debug.get_blocks.self) console.log('starting line =', lines[start_at]); - if (debug.get_blocks.self) console.log('is_start_and_end =', is_start_and_end); - if (debug.get_blocks.self) console.log('config.start check =', is.in(file.contents, config.start)); - if (debug.get_blocks.self) console.log(''); - if (debug.get_blocks.self) console.log('test 1:', is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)); - if (debug.get_blocks.self) console.log('test 2:', !is.between(start_at, 0, lines.length - 1)); - - if ((is.truthy(is_start_and_end) ? !is.in(file.contents, config.start) : !is.in(file.contents, config.line)) || !is.between(start_at, 0, lines.length - 1)) { - if (debug.get_blocks.self) console.log('WELL SHIT FIRE, FILE DOESN\'T CONTAIN ANY COMMENTS'); - return []; - } - - for (let i = start_at, l = lines.length; i < l; i++) { - let line = lines[i] - let comment_index = { - start: is_start_and_end && is.in(line, config.start) ? line.indexOf(config.start) : false, - line: is.in(line, config.line) ? line.indexOf(config.line) : false, - end: is_start_and_end && is.in(line, config.end) ? line.indexOf(config.end) : false - } - if (debug.get_blocks.self) console.log('line', i, '=', line); - if (debug.get_blocks.self) console.log('length'); - // a) The line isn't empty so parse it. - if (!is.empty(line)) { - // a) is the start and end style or there was an instance of a comment line - if (is_start_and_end && (!is.false(comment_index.start) || in_comment) || !is.false(comment_index.line)) { - if (debug.get_blocks.self) console.log('IN COMMENT', '{', 'start:', comment_index.start, ', line:', comment_index.line, ', end:', comment_index.end, '}'); - - // a) is the start of a new block - if (!is.false(comment_index.start) || !is_start_and_end && !in_comment) { - if (debug.get_blocks.self) console.log('START OF A NEW BLOCK ---------------------------------------------------------------'); - in_code = false; - - // a) There was block that has already been processed - if (!is.undefined(block_info)) { // holds the current block information - if (debug.get_blocks.self) console.log('BLOCK WAS PUSHED TO PARSED_BLOCKS'); - block_info.code.end = i - 1; // @todo check to make sure this is correct - parsed_blocks.push(block_info); - - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if (restrict) { - if (debug.get_blocks.self) console.log('IS RESTRICTED FIRST INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); - block_info.comment.end = i; - return parsed_blocks; - } - } - - // reset the `block_info` to use on the new block - block_info = { - comment: { - contents: [], - start: i, - end: -1 - }, - code: { - contents: [], - start: -1, - end: -1 - }, - file - }; - - in_comment = true; - } - - // a) check for the end comment - if (is_start_and_end && block_info.comment.start !== i && !is.false(comment_index.end)) { - if (debug.get_blocks.self) console.log('LAST LINE IN COMMENT'); - in_comment = false; - block_info.comment.end = i; // sets the end line in the comment block - - // @todo might need to remove this - i++; // skips end comment line - line = lines[i]; // updates to be the next line - comment_index.end = is.included(config.end); // updates the index - - // comment_index.end = is.in(line, config.end) ? line.indexOf(config.end) : false; - } - - // a) adds this line to block_info comment contents - if (in_comment && is.false(comment_index.start) && is.false(comment_index.end)) { - if (debug.get_blocks.self) console.log('LINE ADDED TO BLOCK COMMENT CONTENTS'); - // a) removes the `config.line` from the line. - if (!is.false(comment_index.line)) { - line = line.slice(comment_index.line + config.line.length); - } - - block_info.comment.contents.push(line); - } - - // a) check the next line for an instance of the a line comment - if (!is_start_and_end && !is.in(lines[i + 1], config.line)) { - if (debug.get_blocks.self) console.log("NEXT 'LINE' IS A COMMENT && NOT START AND END STYLE"); - in_comment = false; - block_info.comment.end = i; // sets the end line in the comment block - i++; // skips end comment line // @todo why does this need to be skipped? - line = lines[i]; // updates to be the next line - } - - // a) The last line in the file is a commment - if (in_comment && (is_start_and_end && !is.false(comment_index.end) ? i === l : i === l - 1)) { - if (debug.get_blocks.self) console.log('LAST LINE IN THE FILE IS A COMMENT'); - block_info.comment.end = is_start_and_end ? i - 1 : i; - parsed_blocks.push(block_info); - break; // ensures that the loop stops because it's the last line in the file - } - } - - // a) add code to current block_info - if (!in_comment && is.false(comment_index.end) && !is.undefined(block_info)) { - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if (restrict) { - if (debug.get_blocks.self) console.log('IS RESTRICTED SECOND INSTANCE !/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!/!'); - parsed_blocks.push(block_info); - break; - } - if (debug.get_blocks.self) console.log('IN CODE'); - // a) The previous line was a comment - if (!in_code) { - if (debug.get_blocks.self) console.log('THE PREVIOUS LINE WAS A COMMENT'); - in_code = true; - block_info.code.start = i; - } - - // adds this line to block code contents - block_info.code.contents.push(line); - - // a) pushes the last block onto the body - if (i === l - 1) { - if (debug.get_blocks.self) console.log('LAST LINE IN THE FILE IS CODE'); - block_info.code.end = i; - parsed_blocks.push(block_info); - } - } - } - // the last line in the file was an empty line. - else if (i === l - 1 && is.truthy(block_info)) { - block_info[is.between(block_info.comment.end) ? 'comment' : 'code'].end = i; - parsed_blocks.push(block_info); - if (debug.get_blocks.self) console.log('LINE WAS EMPTY'); - } - - if (debug.get_blocks.self) console.log(''); - } // end loop - - return parsed_blocks; - } - - // @name this.run_annotation - // @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) - function run_annotation(annotation, block = {}) { - // removes the first line because it's the "line" of the annotation - annotation.contents.shift(); - - // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents); - - // normalizes the current annotation line - annotation.line = to.normalize(annotation.line); - - // Merges the data together so it can be used to run all the annotations - let result = to.extend({ - annotation: annotation, // sets the annotation block information to be in it's own namespace of `annotation` - - /// @name this.add - /// @page annotation - /// @description Allows you to add a different annotation from within a annotation - /// @arg {string} name - the name of the annotation you want to add - /// @arg {string} str - information that is passed to the annotation - add: (name, str) => { - str = str.split('\n'); - return run_annotation({ - name: name, - line: to.normalize(str[0]), - contents: str, - start: null, - end: null - }); - } - }, block); - - // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if (is.truthy(api.file_list[filetype] && api.file_list[filetype][annotation.name]) && is.truthy(api.file_list.default[annotation.name])) { - result.default = api.file_list.default[annotation.name].call(result); - } - - - result = annotations[annotation.name].callback.call(result); - - return result; - } - - // @name parsed_blocks - // @description - // Used to parse an array of blocks and runs the annotations function and returns the result - // @arg {array} - The block/blocks you want to have parsed - // @returns {array} of parsed blocks - function parse_blocks(blocks) { - if (is.empty(blocks)) { - return [] - } - // if it's an object then convert it to an array. - // blocks = to.array(blocks); - - let parsed_blocks = [] - - // @name parse_block - // @description - // This parses the content passed to it seperates out each annotation - // parses and figures out the annotation line, and the content after it. - // Then once it has all the information it calls the annotation function(the annotation one it found) - // for this file type or the default function. - // @arg {object} - The blocks to parse - const parse_block = (block, prefix = comment.prefix, restrict_lines = false) => { - let contents = to.array(block.comment.contents) - let block_annotations = {} - let current = {} // holds the current annotation - - // loop over each line in the comment block - for (let i = 0, l = contents.length; i < l; i++) { - let line = contents[i] - let prefix_index = line.indexOf(prefix) - - // a) there is an index of the annotation prefix - if (prefix_index >= 0) { - let first_space = line.indexOf(' ', prefix_index) - let name_of_annotation = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length) - - // a) the name is one of the annotation names - if (annotation_keys.indexOf(name_of_annotation) >= 0) { - // a) parse the current annotation - if (!is.empty(current)) { - current.end = i - 1 - - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [current.name]: run_annotation(current, block) - }) - } - - // redefines resets the current annotation to be blank - current = { - name: name_of_annotation, // sets the current annotation name - line: line.slice(prefix_index + 1 + name_of_annotation.length), // removes the current annotation name and it's prefix from the first line - contents: [], - start: i, // sets the starting line of the annotation - end: 0 - } - } - } - - // a) adds the current line to the contents - if (!is.empty(current) && restrict_lines === false) { - current.contents.push(line) - } - - // a) is the last line in the comment block - if (i === l - 1 && !is.empty(current)) { - current.end = i - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [current.name]: run_annotation(current, block) - }) - } - } // end block loop - - return block_annotations - } - - - // loop over each block - for (let i in blocks) { - let block = blocks[i] - - block.comment.contents = to.normalize(block.comment.contents) - block.code.contents = to.normalize(block.code.contents) - - let parsed_block = parse_block(block) - - if (!is.empty(parsed_block)) { - parsed_blocks.push(parsed_block) - } - } // end blocks loop - - if (debug.parse_blocks.self) console.log('parsed_blocks', parsed_blocks) - - return parsed_blocks; - }; - - return new Promise((resolve, reject) => { - fs.readFile(file_path) - .then((contents) => { - contents = to.normal_string(to.string(contents)); // normalize the file - file = { - contents, // all of the contents of the file - path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, '.' + filetype), // name of the file - type: filetype, // filetype of the file - start: 0, // starting point of the file - end: to.array(contents).length - 1 // ending point of the file - }; - - if (debug.get_blocks.result || debug.parse_blocks.result) { - console.log(''); - console.log(''); - console.log(''); - console.log(''); - } - - let header = get_blocks(contents, comment.header); - - if (debug.get_blocks.result) { - console.log('get_blocks(header) =', !is.empty(header) ? header[0].comment.contents : 'no header for this file') - console.log('') - console.log('') - } - - let body = get_blocks(contents, comment.body, false, !is.empty(header) ? header[0].comment.end + 1 : 0) - - if(debug.get_blocks.result) console.log('get_blocks(body) =', body); - - if (debug.parse_blocks.result && debug.parse_blocks.result) { - console.log('') - console.log('') - console.log('') - console.log('') - } - - header = parse_blocks(header)[0]; - - if (debug.parse_blocks.result) { - console.log('parse_blocks(header) =', header) - console.log('') - console.log('') - } - - body = parse_blocks(body); - - if (debug.parse_blocks.result) console.log('parse_blocks(body) =', body) - - // removes the contents from the file info because it's - // not something that is needed in the returned data. - delete file.contents; - - resolve({ - [file.type]: [{ - info: file, - header: header || {}, - body - }] - }) - }) - .catch((err) => { - console.log(err); - reject({}); - }); - }) -} \ No newline at end of file diff --git a/app/parser/get_blocks.js b/app/parser/get_blocks.js new file mode 100644 index 0000000..20e8369 --- /dev/null +++ b/app/parser/get_blocks.js @@ -0,0 +1,145 @@ +import { is, to } from '../utils' + +/// @name blocks +/// @access private +/// @description Parses the file and returns the comment blocks in an array +/// @returns {array} of the comment blocks +/// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. +export default function get_blocks(options) { + let { + file, + contents, + comment, + restrict = true, + start_at = 0 + } = options + + start_at = to.number(start_at) + + let style = is.all.truthy(comment.start, comment.end) ? 'multi' : 'single' + + let block_base = { + comment: { contents: [], start: -1, end: -1 }, + code: { contents: [], start: -1, end: -1 }, + file + } + + let lines = to.array(contents) + let parsed = [] + let block + let in_comment = false // used to determin that you are in a comment + let in_code = false // used to determin if you are in the code after the comment block + + if (style === 'multi' ? !is.all.in(file.contents, comment.start, comment.end) : !is.in(file.contents, comment.line)) { + return [] + } + + for (let i = start_at, l = lines.length; i < l; i++) { + let line = lines[i] + let index = { + start: style === 'multi' && is.in(line, comment.start) ? line.indexOf(comment.start) : false, + line: is.in(line, comment.line) ? line.indexOf(comment.line) : false, + end: style === 'multi' && is.in(line, comment.end) ? line.indexOf(comment.end) : false + } + + // a) The line isn't empty so parse it. + if (!is.empty(line)) { + // a) is the start and end style or there was an instance of a comment line + if (style === 'multi' && (index.start !== false || in_comment) || index.line !== false) { + // a) is the start of a new block + if (index.start !== false || style !== 'multi' && !in_comment) { + // reset code to false + in_code = false + + // a) There was block that has already been processed + if (!is.undefined(block)) { // holds the current block information + block.code.end = i - 1 // @todo check to make sure this is correct + parsed.push(block) + + // Stops the loop after the first comment block + // has been parsed. This is for file header comments + if (restrict) { + block.comment.end = i + return parsed + } + } + + // reset the `block` to use on the new block + block = to.clone(block_base) + block.comment.start = i + + in_comment = true + } + + // a) check for the end comment + if (style === 'multi' && block.comment.start !== i && index.end !== false) { + in_comment = false + block.comment.end = i // sets the end line in the comment block + + // @todo might need to remove this + i++ // skips end comment line + line = lines[i] // updates to be the next line + index.end = is.in(line, comment.end) ? line.indexOf(comment.end) : false + } + + // a) adds this line to block comment contents + if (in_comment && (index.start === false || index.end === false)) { + // a) removes the `comment.line` from the line. + if (index.line !== false) { + line = line.slice(index.line + comment.line.length) + } + + block.comment.contents.push(line) + } + + // console.log(`${i}: ${line}`); + + // a) The last line in the file is a commment + if (in_comment && (style === 'multi' && index.end !== false ? i === l : i === l - 1)) { + block.comment.end = style === 'multi' ? i - 1 : i + parsed.push(block) + break // ensures that the loop stops because it's the last line in the file + } + + // a) check the next line for an instance of the a line comment + if (style !== 'multi' && !is.in(lines[i + 1], comment.line)) { + in_comment = false + block.comment.end = i // sets the end line in the comment block + i++ // skips end comment line // @todo why does this need to be skipped? + line = lines[i] // updates to be the next line + } + } + + // a) add code to current block + if (!in_comment && index.end === false && !is.undefined(block)) { + // Stops the loop after the first comment block + // has been parsed. This is for file header comments + if (restrict) { + parsed.push(block) + break + } + // a) The previous line was a comment + if (!in_code) { + in_code = true + block.code.start = i + } + + // adds this line to block code contents + block.code.contents.push(line) + + // a) pushes the last block onto the body + if (i === l - 1) { + block.code.end = i + parsed.push(block) + } + } + } + // the last line in the file was an empty line. + else if (i === l - 1 && is.truthy(block)) { + block[is.between(block.comment.end) ? 'comment' : 'code'].end = i + parsed.push(block) + } + } // end loop + + return parsed +} \ No newline at end of file diff --git a/app/parser/index.js b/app/parser/index.js new file mode 100644 index 0000000..e80a73a --- /dev/null +++ b/app/parser/index.js @@ -0,0 +1,76 @@ +import { info, fs, is, to } from '../utils' +import path from 'path' +import get_blocks from './get_blocks' +import parse_blocks from './parse_blocks' + +export default async function parser(options = {}) { + let { + file_path, + comments, + annotations, + debug, + log + } = options + + // the filetype of the current file + let filetype = path.extname(file_path).replace('.', '') + + // gets the comments to use on this file + let comment = comments[filetype] ? comments[filetype] : comments._ + + let contents = to.normal_string(await fs.readFile(file_path)) + + let file = { + contents, // all of the contents of the file + path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file + name: path.basename(file_path, '.' + filetype), // name of the file + type: filetype, // filetype of the file + comment, + start: 0, // starting point of the file + end: to.array(contents).length - 1 // ending point of the file + } + + // a) The file doesn't contain any header level comments, or body level comments + if (!is.any.in(contents, + comment.header.start, comment.header.line, comment.header.end, + comment.body.start, comment.body.line, comment.body.end)) { + console.log(`Well shitfire, '${file.path}' doesn't contain any sweet documentation`) + return [] + } + + + let header = get_blocks({ + file, + contents, + comment: comment.header + }) + + let body = get_blocks({ + file, + contents, + comment: comment.body, + restrict: false, + start_at: !is.empty(header) ? header[0].comment.end + 1 : 0 + }) + + header = parse_blocks({ + file, + blocks: header, + annotations, + comment + }) + + body = parse_blocks({ + file, + blocks: body, + annotations, + comment + }) + + return { + [file.path]: { + header, + body + } + } +} \ No newline at end of file diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js new file mode 100644 index 0000000..6e2bc9e --- /dev/null +++ b/app/parser/parse_blocks.js @@ -0,0 +1,168 @@ +import { is, to } from '../utils' + +// @name parsed_blocks +// @access private +// @description +// Used to parse an array of blocks and runs the annotations function and returns the result +// @arg {array} - The block/blocks you want to have parsed +// @returns {array} of parsed blocks +export default function parse_blocks(options = {}) { + let { + file, + blocks, + annotations, + comment + } = options + + if (is.empty(blocks)) { + return [] + } + + let parsed_blocks = [] + + + // loop over each block + for (let i in blocks) { + let block = blocks[i] + + block.comment.contents = to.normalize(block.comment.contents) + block.code.contents = to.normalize(block.code.contents) + + let parsed_block = parse_block({ file, block, annotations, comment }) + + if (!is.empty(parsed_block)) { + parsed_blocks.push(parsed_block) + } + } // end blocks loop + + return parsed_blocks; +} + + +// @name parse_block +// @description +// This parses the content passed to it seperates out each annotation +// parses and figures out the annotation line, and the content after it. +// Then once it has all the information it calls the annotation function(the annotation one it found) +// for this file type or the default function. +// @arg {object} - The blocks to parse +function parse_block(options = {}) { + let { + file, + block, + comment, + annotations + } = options + + // gets the annotations to use on this file + let keys = to.keys(annotations.list(file.type)) + + let contents = to.array(block.comment.contents) + let block_annotations = {} + let annotation = {} // holds the current annotation + + // loop over each line in the comment block + for (let i = 0, l = contents.length; i < l; i++) { + let line = contents[i] + let prefix_index = line.indexOf(comment.prefix) + + // a) there is an index of the annotation prefix + if (prefix_index >= 0) { + let first_space = line.indexOf(' ', prefix_index) + let name = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length) + + // a) the name is one of the annotation names + if (keys.indexOf(name) >= 0) { + // a) parse the current annotation + if (!is.empty(annotation)) { + annotation.end = i - 1 + + // run the annotation function and merge it with the other annotations in the block + to.merge(block_annotations, { + [annotation.name]: run_annotation({ annotation, block, annotations, file }) + }) + } + + // redefines resets the current annotation to be blank + annotation = { + name, // sets the current annotation name + line: line.slice(prefix_index + 1 + name.length), // removes the current annotation name and it's prefix from the first line + contents: [], + start: i, // sets the starting line of the annotation + end: 0 + } + } + } + + // a) adds the current line to the contents + if (!is.empty(annotation)) { + annotation.contents.push(line) + } + + // a) is the last line in the comment block + if (i === l - 1 && !is.empty(annotation)) { + annotation.end = i + // run the annotation function and merge it with the other annotations in the block + to.merge(block_annotations, { + [annotation.name]: run_annotation({ annotation, block, annotations, file }) + }) + } + } // end block loop + + + + return block_annotations +} + + +/// @name run_annotation +/// @access private +/// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) +function run_annotation(options) { + let { + annotation, + annotations, + file, + block = {} + } = options + + // removes the first line because it's the "line" of the annotation + annotation.contents.shift(); + + // normalizes the current annotation contents + annotation.contents = to.normalize(annotation.contents); + + // normalizes the current annotation line + annotation.line = to.normalize(annotation.line); + + // Merges the data together so it can be used to run all the annotations + let result = to.extend({ + annotation, // sets the annotation block information to be in it's own namespace of `annotation` + + /// @name this.add + /// @page annotation + /// @description Allows you to add a different annotation from within a annotation + /// @arg {string} name - the name of the annotation you want to add + /// @arg {string} str - information that is passed to the annotation + add: (name, str) => { + str = str.split('\n'); + return run_annotation({ + annotations, + annotation: { + name: name, + line: to.normalize(str[0]), + contents: str, + start: null, + end: null + } + }); + } + }, block); + + // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed + if (is.truthy(annotations.file_list[file.filetype] && annotations.file_list[file.filetype][annotation.name]) && is.truthy(annotations.file_list.default[annotation.name])) { + result.default = annotations.file_list.default[annotation.name].call(result); + } + + return annotations.list(file.type)[annotation.name].callback.call(result) +} \ No newline at end of file From 5b53970708ca235efaca89b1bdefb8edc6ac85a4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 20 Oct 2015 13:54:20 -0400 Subject: [PATCH 111/273] Switched to use `tap-spec` for the testing reporter This is a little more verbose but its more helpful when debugging. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1d89c9..7612c0a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "clean": "rm -rf ./dist", "compile": "npm run clean; babel app/ -d ./dist --optional runtime --stage 0", "watch": "npm run clean; babel app/ -d ./dist --stage 0 --optional runtime --watch", - "test": "tape dist/tests/**/*.js | faucet", + "test": "tape dist/tests/**/*.js | tap-spec", "coverage": "nyc npm test", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", "plato": "plato -d coverage/plato dist/index.js", @@ -93,10 +93,10 @@ }, "devDependencies": { "babel": "^5.8.23", - "faucet": "0.0.1", "nyc": "^3.2.2", "proxyquire": "^1.7.3", "sinon": "^1.17.1", + "tap-spec": "^4.1.0", "tape": "^4.2.1" } } From 2550d505aeebea5d8f67470cb3b9407e8a790623 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 21 Oct 2015 11:07:01 -0400 Subject: [PATCH 112/273] Combined the logger and reporter into a single file --- app/docs.js | 8 ++---- app/reporter.js | 43 ------------------------------- app/utils/index.js | 2 +- app/utils/logger.js | 63 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 64 insertions(+), 52 deletions(-) delete mode 100644 app/reporter.js diff --git a/app/docs.js b/app/docs.js index bf8aa00..548f090 100644 --- a/app/docs.js +++ b/app/docs.js @@ -7,15 +7,11 @@ process.on('uncaughtException', function(err) { import co from 'co' import path from 'path' -import { info, fs, is, to, glob, array, Logger } from './utils' +import { info, fs, is, to, glob, array, Reporter } from './utils' import parser from './parser' import sorter from './sorter' -import reporter from './reporter' import get_config from './config' -let log = new Logger(); -reporter.call(log) - //// /// @name docs.js /// @author Tyler Benton @@ -24,7 +20,6 @@ reporter.call(log) /// documentation for it and returns an `{}` of the document data //// const docs = co.wrap(function*(options = {}) { - log.emit('start', 'total') options = yield get_config(options) let { files, @@ -37,6 +32,7 @@ const docs = co.wrap(function*(options = {}) { comments, } = options + let log = new Reporter({ debug, warnings, timestamps }); try { yield fs.ensureFile(info.temp.file) diff --git a/app/reporter.js b/app/reporter.js deleted file mode 100644 index e27e45e..0000000 --- a/app/reporter.js +++ /dev/null @@ -1,43 +0,0 @@ -import { log } from './utils' - -export default function() { - this - .on('annotation_error', ({ annotation, error }) => - this.error(`with ${annoation}`, error)) - - .on('start', (name) => this.time(name)) - - .on('complete', (name, format = '%s finished after %dms') => - this.time_end(name, format)) - - - - // .on('fly_run', ({ path }) => - // log(`Flying with ${fmt.path}...`, path)) - // - // .on('flyfile_not_found', ({ error }) => - // log(`No Flyfile Error: ${fmt.error}`, error)) - // - // .on('fly_watch', () => - // log(`${fmt.warn}`, 'Watching files...')) - // - // .on('plugin_load', ({ plugin }) => - // log(`Loading plugin ${fmt.title}`, plugin)) - // - // .on('plugin_error', ({ plugin, error }) => - // log(`${fmt.error} failed due to ${fmt.error}`, plugin, error)) - // - // .on('task_error', ({ task, error }) => { - // trace(error) - // log(`${fmt.error} failed due to ${fmt.error}`, task, error) - // }) - // - // .on('task_start', ({ task }) => - // log(`Starting ${fmt.start}`, task)) - // - // .on('task_complete', ({ task, duration }) => { - // const time = timeInfo(duration) - // log(`Finished ${fmt.complete} in ${fmt.secs}`, - // task, time.duration, time.scale) - // }) -} \ No newline at end of file diff --git a/app/utils/index.js b/app/utils/index.js index f1093a4..c962ce7 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,5 +1,5 @@ export denodeify from './denodeify' -export Logger from './logger' +export {Logger, Reporter} from './logger' export fs from './fs' export glob from './glob' export info from './info' diff --git a/app/utils/logger.js b/app/utils/logger.js index c7ddd9b..58745bb 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -6,7 +6,7 @@ let check = '\u2713' let warning = '\u26A0' let error = '\u2326' -export default class Logger { +export class Logger { constructor() { this.events = [] this.times = {} @@ -68,4 +68,63 @@ export default class Logger { console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n') } -} \ No newline at end of file +} + + +export class Reporter extends Logger { + constructor(options = {}) { + super() + this.report(options) + } + + report(options) { + let { + debug = true, + warning = true, + timestamps = true + } = options + + this.on('annotation_error', ({ annotation, error }) => + this.error(`with ${annotation}`, error)) + + if (timestamps) { + this + .on('start', (name) => this.time(name)) + .on('complete', (name, format = '%s finished after %dms') => + this.time_end(name, format)) + } + + if (debug) this.on('debug', (...args) => this.debug(...args)) + + if (warning) this.on('warning', (...args) => this.warn(...args)) + } +} + +// .on('fly_run', ({ path }) => +// log(`Flying with ${fmt.path}...`, path)) +// +// .on('flyfile_not_found', ({ error }) => +// log(`No Flyfile Error: ${fmt.error}`, error)) +// +// .on('fly_watch', () => +// log(`${fmt.warn}`, 'Watching files...')) +// +// .on('plugin_load', ({ plugin }) => +// log(`Loading plugin ${fmt.title}`, plugin)) +// +// .on('plugin_error', ({ plugin, error }) => +// log(`${fmt.error} failed due to ${fmt.error}`, plugin, error)) +// +// .on('task_error', ({ task, error }) => { +// trace(error) +// log(`${fmt.error} failed due to ${fmt.error}`, task, error) +// }) +// +// .on('task_start', ({ task }) => +// log(`Starting ${fmt.start}`, task)) +// +// .on('task_complete', ({ task, duration }) => { +// const time = timeInfo(duration) +// log(`Finished ${fmt.complete} in ${fmt.secs}`, +// task, time.duration, time.scale) +// }) \ No newline at end of file From 13c0b427e2d791286c1c60e4b5838b6ee7f80f93 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 21 Oct 2015 11:07:52 -0400 Subject: [PATCH 113/273] Changed the cli options to overright the config file --- app/config.js | 4 ++-- app/docs.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/config.js b/app/config.js index 9cd070a..31ec883 100644 --- a/app/config.js +++ b/app/config.js @@ -71,8 +71,8 @@ export default async function config(options = {}) { config_file = {} } - // merge config file with passed options - options = to.extend(options, ensure_valid_config(config_file)) + // merge the config file with passed options + options = to.extend(ensure_valid_config(config_file), options) // merge options with base_config so there's a complete list of settings options = to.extend(base_config, options) diff --git a/app/docs.js b/app/docs.js index 548f090..c74ba0c 100644 --- a/app/docs.js +++ b/app/docs.js @@ -34,6 +34,8 @@ const docs = co.wrap(function*(options = {}) { let log = new Reporter({ debug, warnings, timestamps }); + log.emit('start', 'total') + try { yield fs.ensureFile(info.temp.file) let json = fs.readFile(info.temp.file) From 5af33d09ab14bf1f0c228c02befec769ce50906f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 22 Oct 2015 08:55:08 -0400 Subject: [PATCH 114/273] Added warning to the logger --- app/config.js | 9 ++++++--- app/docs.js | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/config.js b/app/config.js index 31ec883..170ebad 100644 --- a/app/config.js +++ b/app/config.js @@ -1,8 +1,10 @@ -import {info, fs, is, to, log} from './utils' +import {info, fs, is, to, Reporter} from './utils' import path from 'path' import annotations from './annotations' import AnnotationApi from './annotation_api' +let log = new Reporter(); + // changed by `options` key const default_options = { config: `${info.root}/docsfile.js`, @@ -20,6 +22,7 @@ const default_options = { changed: true, // determins if only changed files should be parsed or not blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. debug: true, + warning: true, timestamps: true, annotations } @@ -131,7 +134,7 @@ let valid_comment_options = to.keys(default_comment) function ensure_valid_config(user_config) { for (let key in user_config) { if (!is.in(valid_options, key)) { - log.warn(`'${key}' is not a valid option, see docs options for more details`) //# @todo add link to the doc options + log.emit('warning', `'${key}' is not a valid option, see docs options for more details`) //# @todo add link to the doc options } } @@ -140,7 +143,7 @@ function ensure_valid_config(user_config) { for (let lang in user_config.comments) { for (let type in lang) { if (!is.in(valid_comment_options, type)) { - log.warn(`'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`) + log.emit('warning', `'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`) } } } diff --git a/app/docs.js b/app/docs.js index c74ba0c..efe929f 100644 --- a/app/docs.js +++ b/app/docs.js @@ -27,12 +27,13 @@ const docs = co.wrap(function*(options = {}) { changed, blank_lines, debug, + warning, timestamps, annotations, comments, } = options - let log = new Reporter({ debug, warnings, timestamps }); + let log = new Reporter({ debug, warning, timestamps }); log.emit('start', 'total') From 69c24a72d5111e3af8d0fcca98de2cc96b236a4b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 22 Oct 2015 08:56:07 -0400 Subject: [PATCH 115/273] :bug: fix for cli inputs Where `--debug`, `--warning`, `--timestamps` were returning as strings instead of booleans --- app/cli.js | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/app/cli.js b/app/cli.js index 6654101..a09d024 100644 --- a/app/cli.js +++ b/app/cli.js @@ -24,34 +24,17 @@ export default function cli() { .option('-f, --files ', `Paths to parsed`, to_list, base_config.files) .option('-i, --ignore ', `Paths to ignore`, to_list, base_config.ignore) .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', base_config.gitignore) - .option('-d, --debug', 'Output debugging information', base_config.debug) // @todo add debug information - .option('-t, --timestamps', 'Output timestamps of how long it takes to parse the files', base_config.timestamps) + .option('-x, --debug [boolean]', 'Output debugging information', to_boolean, base_config.debug) + .option('-w, --warning [boolean]', 'Output warning messages', to_boolean, base_config.warning) + .option('-t, --timestamps [boolean]', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) .option('-a, --changed [boolean]', `Parse changed files`, to_boolean, base_config.changed) .option('-b, --blank-lines ', `Stops parsing lines after consecutive blank lines`, to_number, base_config.blank_lines) .parse(process.argv) - let { - dest, - config, - files, - ignore, - gitignore, - debug, - timestamps, - changed, - blankLines: blank_lines - } = program; - return docs({ - config, - files, - ignore, - gitignore, - debug, - timestamps, - changed, - blank_lines + ...program, + blank_lines: program.blankLines, }) - .then((parsed) => fs.outputJson(dest, parsed, { spaces: 2 })) + .then((parsed) => fs.outputJson(program.dest, parsed, { spaces: 2 })) .catch((err) => console.error(err.stack)) } \ No newline at end of file From 67b871f877190e4f0a4cef9d31f5dcf86ec8c6e3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 22 Oct 2015 08:57:01 -0400 Subject: [PATCH 116/273] Fixed formatting of logging messages --- app/utils/logger.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/utils/logger.js b/app/utils/logger.js index 58745bb..3190c8e 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -1,3 +1,4 @@ +import { is, to } from './' import {format as _format} from 'util' import chalk from 'chalk' @@ -30,16 +31,16 @@ export class Logger { } log(...args) { - console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)) + console.log(_format(`${chalk.green(chevron)} ${args.shift()}${'\n'}`, ...args), '\n') } warn(...args) { - console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]'))} ${args.shift()}`, ...args), '\n') + console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]\n'))}${args.shift()}`, ...args), '\n') } error(...args) { console.trace(...args) - console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]'))} ${args.shift()}`, ...args), '\n') + console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]\n'))}${args.shift()}`, awesome_report(...args)), '\n') } time(label) { @@ -58,18 +59,18 @@ export class Logger { } debug(...args) { - args = args.map((f) => { - if (f instanceof Function) { - return f() - } - - return f - }) - - console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n') + console.log(_format(`${chalk.styles.grey.open}${chevron} [DEBUG] ${args.shift()}${'\n'}`, awesome_report(...args), chalk.styles.grey.close), '\n') } } +function awesome_report(...args) { + return '\n' + to.normalize(args.map((arg) => { + if (is.fn(arg)) { + arg = arg() + } + }).join('\n')) + '\n' +} + export class Reporter extends Logger { constructor(options = {}) { @@ -85,7 +86,7 @@ export class Reporter extends Logger { } = options this.on('annotation_error', ({ annotation, error }) => - this.error(`with ${annotation}`, error)) + this.error(`with ${annotation}`, error)) if (timestamps) { this From 2682e0f685856314cc8d45f8e6b0c901afea8630 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 22 Oct 2015 08:58:12 -0400 Subject: [PATCH 117/273] Ensures the `header` is always defined This is so that there doesn't have to be a check to see if it exists later on, and prevents people from having to check for it in the main loop of their theme --- app/parser/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/parser/index.js b/app/parser/index.js index e80a73a..438bc5a 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -58,7 +58,7 @@ export default async function parser(options = {}) { blocks: header, annotations, comment - }) + })[0] || {} body = parse_blocks({ file, From 1a408e5ce7dc51057058c1924cc30578eb244c18 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 22 Oct 2015 09:01:21 -0400 Subject: [PATCH 118/273] Added a `page_fallback` option This will be used if `@page` isn't defined in the header and there isn't one defined in a body comment. --- app/config.js | 1 + app/docs.js | 1 + 2 files changed, 2 insertions(+) diff --git a/app/config.js b/app/config.js index 170ebad..55e026f 100644 --- a/app/config.js +++ b/app/config.js @@ -16,6 +16,7 @@ const default_options = { 'dist/', 'build/', 'docs/', // normal folders 'tests/', 'coverage/' // unit tests and coverage results ], + page_fallback: 'general', // used if `@page` isn't defined // add gitignore files to the ignore list. Depending on ignored files it // could cause things to ge parsed slower, that's why it's defaulted to `false` gitignore: false, diff --git a/app/docs.js b/app/docs.js index efe929f..f8c9986 100644 --- a/app/docs.js +++ b/app/docs.js @@ -26,6 +26,7 @@ const docs = co.wrap(function*(options = {}) { ignore, changed, blank_lines, + page_fallback, debug, warning, timestamps, From 578523462062a65aa8d473b8ae2bc80a0f4b4789 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 23 Oct 2015 07:59:26 -0400 Subject: [PATCH 119/273] Added an options for returning raw data --- app/config.js | 1 + app/docs.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/config.js b/app/config.js index 55e026f..eddc2c1 100644 --- a/app/config.js +++ b/app/config.js @@ -25,6 +25,7 @@ const default_options = { debug: true, warning: true, timestamps: true, + raw: false, // this will return the raw data by file, aka data won't be sorted annotations } diff --git a/app/docs.js b/app/docs.js index f8c9986..fba4966 100644 --- a/app/docs.js +++ b/app/docs.js @@ -30,6 +30,7 @@ const docs = co.wrap(function*(options = {}) { debug, warning, timestamps, + raw, annotations, comments, } = options @@ -64,6 +65,12 @@ const docs = co.wrap(function*(options = {}) { fs.outputJson(info.temp.file, json, { spaces: 2 }) .catch((err) => log.error(err.stack)) + if (!raw) { + log.emit('start', 'sorter') + json = sorter({ json, page_fallback, log }) + log.emit('complete', 'sorter') + } + log.emit('complete', 'total') return json } catch(err) { From 96176ead50211fb922357e097e056a50fb2f4b24 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 23 Oct 2015 20:51:26 -0400 Subject: [PATCH 120/273] Added a fix for changed files This way when changed is false it always starts with a empty object --- app/docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/docs.js b/app/docs.js index fba4966..529cae6 100644 --- a/app/docs.js +++ b/app/docs.js @@ -51,7 +51,7 @@ const docs = co.wrap(function*(options = {}) { log.emit('complete', 'parser') // converts json to a readable JS object - json = to.string(yield json) + json = changed ? to.string(yield json) : false json = !!json ? to.object(json) : {} // Loop through the parsed files and update the From 0bbbd4c6a5772404319026bd1b896c890ebb402f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 24 Oct 2015 10:07:28 -0400 Subject: [PATCH 121/273] added coveralls to devDependencies --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7612c0a..151e133 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ }, "devDependencies": { "babel": "^5.8.23", + "coveralls": "^2.11.4", "nyc": "^3.2.2", "proxyquire": "^1.7.3", "sinon": "^1.17.1", From c06cb8f9ecff7171268a0150266b7893dc31be05 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:32:14 -0400 Subject: [PATCH 122/273] Fixed the logger Removed format because it wasn't working correctly, and added my normalize function. --- app/utils/log.js | 54 --------------------------------------------- app/utils/logger.js | 31 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 63 deletions(-) delete mode 100644 app/utils/log.js diff --git a/app/utils/log.js b/app/utils/log.js deleted file mode 100644 index ff39546..0000000 --- a/app/utils/log.js +++ /dev/null @@ -1,54 +0,0 @@ -import {format as _format} from 'util' -import chalk from 'chalk' - -let _times = {} -let chevron = '\xBB' -let check = '\u2713' -let warning = '\u26A0' -let error = '\u2326' - -// @name Log -// @description -// A better console.log -function log(...args) { - console.log(_format(`${chalk.green(chevron)} ${args.shift()}`, ...args)) -} - -log.warn = (...args) => { - console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]'))} ${args.shift()}`, ...args), '\n') -} - -log.error = (...args) => { - console.trace(...args) - console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]'))} ${args.shift()}`, ...args), '\n') -} - -log.time = (label) => { - _times[label] = Date.now() -} - -log.timeEnd = (label, format = '%s completed after %dms') => { - let time = _times[label] - - if (!time) { - throw new Error(`No such label: ${label}`) - } - - let duration = Date.now() - time - console.log(_format(`${chalk.green(check)} ${format}`, label, duration)) -} - -log.debug = (...args) => { - args = args.map((f) => { - if (f instanceof Function) { - return f() - } - - return f - }) - - console.log(_format(`${chalk.styles.grey.open}${arrow} [DEBUG] ${args.shift()}`, ...args, chalk.styles.grey.close), '\n') -} - - -export default log \ No newline at end of file diff --git a/app/utils/logger.js b/app/utils/logger.js index 3190c8e..5f80146 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -1,5 +1,4 @@ import { is, to } from './' -import {format as _format} from 'util' import chalk from 'chalk' let chevron = '\xBB' @@ -31,16 +30,16 @@ export class Logger { } log(...args) { - console.log(_format(`${chalk.green(chevron)} ${args.shift()}${'\n'}`, ...args), '\n') + console.log(`${chalk.green(chevron)} ${awesome_report(...args)}`) } warn(...args) { - console.log(_format(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]\n'))}${args.shift()}`, ...args), '\n') + console.log(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]\n'))}${awesome_report(...args)}`) } error(...args) { console.trace(...args) - console.log(_format(`${chalk.red(error, chalk.bold.red('[ERROR]\n'))}${args.shift()}`, awesome_report(...args)), '\n') + console.log(`${chalk.red(error, chalk.bold.red('[ERROR]\n'))}${awesome_report(...args)}`) } time(label) { @@ -55,20 +54,30 @@ export class Logger { } let duration = Date.now() - time - console.log(_format(`${chalk.green(check)} ${format}`, label, duration)) + console.log(`${chalk.green(check)} ${format}`, label, duration) } debug(...args) { - console.log(_format(`${chalk.styles.grey.open}${chevron} [DEBUG] ${args.shift()}${'\n'}`, awesome_report(...args), chalk.styles.grey.close), '\n') + console.log(`${chalk.magenta(chevron, '[DEBUG]\n')}${awesome_report(...args)}`) + } + + file(file) { + console.log('\n\n', chalk.bgBlue.gray('\n', chevron, '[FILE]'), file, '') } } function awesome_report(...args) { - return '\n' + to.normalize(args.map((arg) => { + return args.map((arg) => { if (is.fn(arg)) { arg = arg() } - }).join('\n')) + '\n' + + if (is.object(arg)) { + return to.normalize(to.json(arg)) + } + + return to.normalize(to.string(arg)) + }).join('\n') + '\n' } @@ -95,7 +104,11 @@ export class Reporter extends Logger { this.time_end(name, format)) } - if (debug) this.on('debug', (...args) => this.debug(...args)) + if (debug) { + this + .on('debug', (...args) => this.debug(...args)) + .on('file', (...args) => this.file(...args)) + } if (warning) this.on('warning', (...args) => this.warn(...args)) } From 55ecb4577c5c526b6f96db8366d46412c8b59614 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:34:05 -0400 Subject: [PATCH 123/273] Change name to contents since that's what it is --- app/parser/parse_blocks.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js index 6e2bc9e..20be1c9 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse_blocks.js @@ -144,14 +144,14 @@ function run_annotation(options) { /// @description Allows you to add a different annotation from within a annotation /// @arg {string} name - the name of the annotation you want to add /// @arg {string} str - information that is passed to the annotation - add: (name, str) => { - str = str.split('\n'); + add: (name, contents) => { + contents = contents.split('\n'); return run_annotation({ annotations, annotation: { name: name, - line: to.normalize(str[0]), - contents: str, + line: to.normalize(contents[0]), + contents, start: null, end: null } From 51611666537f0c00ea70a30b38b476281c212d10 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:34:54 -0400 Subject: [PATCH 124/273] Added start and end lines to the block This allows for better warning information in the sorter function --- app/parser/parse_blocks.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js index 20be1c9..db7ee8f 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse_blocks.js @@ -28,10 +28,14 @@ export default function parse_blocks(options = {}) { block.comment.contents = to.normalize(block.comment.contents) block.code.contents = to.normalize(block.code.contents) - let parsed_block = parse_block({ file, block, annotations, comment }) + let parsed = parse_block({ file, block, annotations, comment }) - if (!is.empty(parsed_block)) { - parsed_blocks.push(parsed_block) + if (!is.empty(parsed)) { + parsed_blocks.push({ + ...parsed, + __start: block.comment.start, + __end: block.comment.end + }) } } // end blocks loop @@ -102,6 +106,7 @@ function parse_block(options = {}) { // a) is the last line in the comment block if (i === l - 1 && !is.empty(annotation)) { annotation.end = i + // run the annotation function and merge it with the other annotations in the block to.merge(block_annotations, { [annotation.name]: run_annotation({ annotation, block, annotations, file }) @@ -109,8 +114,6 @@ function parse_block(options = {}) { } } // end block loop - - return block_annotations } From 74654178708552cc6170bb24a19480f6b2b5bd3a Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:46:34 -0400 Subject: [PATCH 125/273] Added a kickass object iterator :raised_hands: --- app/tests/utils/to.test.js | 11 ++++++++ app/utils/to.js | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index 12b72ab..2044067 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -65,6 +65,17 @@ test('to.entries', (t) => { }) +test('to.object_entries', (t) => { + for (let { key, one, two, three } of to.object_entries({ test: object })) { + t.is(key, 'test', 'The key should be `test`') + t.is(one, 1, '`one` should equal 1') + t.is(two, 2, '`two` should equal 2') + t.is(three, 3, '`three` should equal 3') + } + t.end() +}) + + test('to.normalize', (t) => { const actual = ` .foo { diff --git a/app/utils/to.js b/app/utils/to.js index dbb1c66..c3c0089 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -119,6 +119,58 @@ let to = { } }, + /// @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.object_entries(example)) { + /// // key -> 'foo' + /// // one -> 'Item one' + /// // two -> 'Item two' + /// // three -> 'Item three' + /// } + object_entries(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 From 47652a18ed83e8cf1d1ac4d0cde6362e87860cca Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:49:50 -0400 Subject: [PATCH 126/273] updated sorter This update simplifies the sorter, increases performance, readability, and organization by seperating it out into multiple files --- app/sorter.js | 186 -------------------------------------------- app/sorter/index.js | 20 +++++ app/sorter/nav.js | 92 ++++++++++++++++++++++ app/sorter/pages.js | 127 ++++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+), 186 deletions(-) delete mode 100644 app/sorter.js create mode 100644 app/sorter/index.js create mode 100644 app/sorter/nav.js create mode 100644 app/sorter/pages.js diff --git a/app/sorter.js b/app/sorter.js deleted file mode 100644 index 922a9f0..0000000 --- a/app/sorter.js +++ /dev/null @@ -1,186 +0,0 @@ -import {is, to} from './utils' - -/// @name sort -/// @description -/// Sorts the parsed data into pages and creates the navigation -/// @arg {object} -/// @returns {object} -export default function(json) { - let nav, pages - - /// @name pages - /// @description - /// This function loops over the json that was passed and creates a organized structure - /// based on the `@pages` annotations that were passed. - pages = (() => { - let result = {} - // @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 - function 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 _pages = 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 = 0; i < length; i++) { - let page = path_list[i] - if (!_pages[page]) { - _pages[page] = { - page: { - header: {}, - body: [] - } - } - } - _pages = _pages[page] - } - - // a) Define the default data set(can't use `page` because it will be overwritten) - if (!_pages[path_list[length]]) { - _pages[path_list[length]] = { - page: { - header: {}, - body: [] - } - } - } - - if (type === 'header') { - _pages[path_list[length]].page.header = to.merge(_pages[path_list[length]].page.header, value) - } else { - _pages[path_list[length]].page.body.push(value) - } - } - - // loop over each filetype in the json object to create the pages structure - for (let [filetype, files] of to.entries(json)) { - // loop over each file in the filetype object - for (let file of files) { - // a) Ensures there's only one page defined in the header - // b) There wasn't a page defined so set it to general - file.header.page = file.header.page ? file.header.page[0] : 'general' - - // a) Set the name in the header to be the name of the file - if (is.falsy(file.header.name)) { - file.header.name = to.titleCase(file.info.name) - } - - // set the header for the file - set(file.header.page, 'header', file.header) - - // loop over each block in the body of the file - for (let block of file.body) { - // a) loop over each page in the block, - // and add the block to that page. - if (block.page) { - for (let page of block.page) { - if (page !== file.header.page) { - set(page, 'body', block) - } - } - } - - // add the block to the page - set(file.header.page, 'body', block) - } - } - } - - return result - })() - - /// @name nav - /// @description - /// This function builds the navigation based of how the pages were built. - nav = ((pages) => { - let result = [] // placeholder to store the result - - /// @name body_names - /// @description Helper function to get the name of each block in the body - /// @arg {string} - the href to append the `name` of the block to - /// @arg {array} - the body of the page - /// @returns {array} - function body_names(href, body) { - let _body_names = [] - // loop over each block in the body - for (let block of body) { - // a) Add the name to the body_names - if (is.existy(block.name)) { - _body_names.push({ - title: block.name, - href: `${href}#${to.paramCase(block.name)}` - }) - } - } - - return _body_names - } - - - /// @name set - /// @description - /// This is a helper function that recursivly goes through the - /// structure(`a`) creating the navigation structure for - /// the passed item. - /// @arg {object} - This is the top level object to continue to drill down. - /// @arg {object} - The inner structure to continue to loop over. - /// @returns {object} - function set(a, b) { - for (let [key, value] of to.entries(b)) { - if (key !== 'page') { - let nav_item = { - title: is.truthy(value.page.header.name) ? value.page.header.name : to.titleCase(to.sentenceCase(key)), - href: `${a.href}/${key}`, - body: [], - subpages: [] - } - - // add the name of each block in the body - nav_item.body = body_names(nav_item.href, value.page.body) - - // a) Call `set` again because it's not the last level - if (to.keys(value).length > 1) { // the reason it's `> 1` is because `page` will always be defined. - nav_item = set(nav_item, value) - } - - a.subpages.push(nav_item) - } - } - - return a - } - - // loop over the pages structure to create the navigation - for (let [key, value] of to.entries(pages)) { - result.push(set({ - title: to.titleCase(to.sentenceCase(key)), - href: `/${key}`, - body: body_names(`/${key}`, value.page.body), - subpages: [] - }, value)) - } - - return result - })(pages) - - return { - nav, - pages - } -} \ No newline at end of file diff --git a/app/sorter/index.js b/app/sorter/index.js new file mode 100644 index 0000000..9c87e75 --- /dev/null +++ b/app/sorter/index.js @@ -0,0 +1,20 @@ +import { is, to } from '../utils' +import get_pages from './pages' +import get_nav from './nav' + +/// @name sort +/// @description +/// Sorts the parsed data into pages and creates the navigation +/// @arg {object} +/// @returns {object} +export default function sorter(options = {}) { + let pages = get_pages(options) + + + let nav = get_nav(pages) + + return { + nav, + pages + } +} \ No newline at end of file diff --git a/app/sorter/nav.js b/app/sorter/nav.js new file mode 100644 index 0000000..324dc9c --- /dev/null +++ b/app/sorter/nav.js @@ -0,0 +1,92 @@ +import { is, to } from '../utils' + +/// @name nav +/// @description +/// This function builds the navigation based of how the pages were built. +export default function nav(pages) { + let result = [] + + // loop over the pages structure to create the navigation + for (let [key, value] of to.entries(pages)) { + result.push(set({ + title: to.titleCase(to.sentenceCase(key)), + href: `/${key}`, + body: body_names(`/${key}`, value.page.body), + subpages: [] + }, value)) + } + + return result +} + + +// let nav = ((pages) => { +// let result = [] // placeholder to store the result +// +// // loop over the pages structure to create the navigation +// for (let [key, value] of to.entries(pages)) { +// result.push(set({ +// title: to.titleCase(to.sentenceCase(key)), +// href: `/${key}`, +// body: body_names(`/${key}`, value.page.body), +// subpages: [] +// }, value)) +// } +// +// return result +// } + +/// @name body_names +/// @description Helper function to get the name of each block in the body +/// @arg {string} - the href to append the `name` of the block to +/// @arg {array} - the body of the page +/// @returns {array} +function body_names(href, body) { + let names = [] + // loop over each block in the body + for (let block of body) { + // a) Add the name to the body_names + if (is.existy(block.name)) { + names.push({ + title: block.name, + href: `${href}#${to.paramCase(block.name)}` + }) + } + } + + return names +} + + +/// @name set +/// @description +/// This is a helper function that recursivly goes through the +/// structure(`a`) creating the navigation structure for +/// the passed item. +/// @arg {object} - This is the top level object to continue to drill down. +/// @arg {object} - The inner structure to continue to loop over. +/// @returns {object} +function set(a, b) { + for (let [key, value] of to.entries(b)) { + if (key !== 'page') { + let nav_item = { + title: is.truthy(value.page.header.name) ? value.page.header.name : to.titleCase(to.sentenceCase(key)), + href: `${a.href}/${key}`, + body: [], + subpages: [] + } + + // add the name of each block in the body + nav_item.body = body_names(nav_item.href, value.page.body) + + // a) Call `set` again because it's not the last level + if (to.keys(value).length > 1) { // the reason it's `> 1` is because `page` will always be defined. + nav_item = set(nav_item, value) + } + + a.subpages.push(nav_item) + } + } + + return a +} \ No newline at end of file diff --git a/app/sorter/pages.js b/app/sorter/pages.js new file mode 100644 index 0000000..c08fd40 --- /dev/null +++ b/app/sorter/pages.js @@ -0,0 +1,127 @@ +import { is, to } from '../utils' + +// placeholder for the result +let result = {} + +/// @name pages +/// @description +/// This function loops over the json that was passed and creates a organized structure +/// based on the `@pages` annotations that were passed. +export default function pages(options = {}) { + let { json, debug, warning, page_fallback, log } = options + + for (let { path, header, body } of to.object_entries(json, 'path')) { + log.emit('file', path) + + if (!is.empty(header)) { + if (is.falsy(header.page)) { + if (is.truthy(page_fallback)) { + header.page = [page_fallback] + } else { + log.emit('warning', ` + Header comment ${header.name && '(' + header.name + ')'} doesn't have a \`@page\` defined in + ${path} + `) + } + } + + // a) Set the name in the header to be the name of the file + if (is.falsy(header.name)) { + log.emit('warning', ` + The hardest thing in development is naming but you gotta try, add a '@name' to the header comment in + ${path} + `) + } + + // set the header for the file + for (let page of header.page) set(page, 'header', header) + } + + if (!is.empty(body)) { + for (let block_in_body of body) { + let { __start, __end, ...block } = block_in_body + // warn the user that there isn't a page defined. + if (is.all.empty(header.page, block.page)) { + log.emit('warning', ` + ${block.name || 'a block'} starting on line ${__start} doesn't have a \`@page\` defined in + ${path} + `) + } + + // add the block to each page in the header + if (header.page) { + for (let page of header.page) { + set(page, 'body', block) + + let index = (body.page || []).indexOf(page) + + // remove the page from the body comment + if (index > -1) block.page.splice(index, 1) + } + } + + // add the block to each page in the block + if (block.page && !is.empty(block.page)) { + for (let page of block.page) set(page, 'body', block) + } + } + } + } + + return result +} + + +// @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 +function 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 pages = 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 = 0; i < length; i++) { + let page = path_list[i] + if (!pages[page]) { + pages[page] = { + page: { + header: {}, + body: [] + } + } + } + pages = pages[page] + } + + // a) Define the default data set(can't use `page` because it will be overwritten) + if (!pages[path_list[length]]) { + pages[path_list[length]] = { + page: { + header: {}, + body: [] + } + } + } + + if (type === 'header') { + pages[path_list[length]].page.header = to.merge(pages[path_list[length]].page.header, value) + } else { + pages[path_list[length]].page.body.push(value) + } +} \ No newline at end of file From 60ac880610a9f47cc09968b8d536bc22820a47ca Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:51:29 -0400 Subject: [PATCH 127/273] made some general changes to the --- .jscsrc | 3 +-- .jshintrc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.jscsrc b/.jscsrc index c7d50f2..8474702 100644 --- a/.jscsrc +++ b/.jscsrc @@ -13,7 +13,6 @@ "for", "if", "else", - "switch", "case", "try", "void", @@ -73,5 +72,5 @@ "validateLineBreaks": "LF", "validateIndentation": 2, "validateParameterSeparator": ", ", - "excludeFiles": ["node_modules/**/*"] + "excludeFiles": ["node_modules/**/*", "app/tests/**/*.js"] } diff --git a/.jshintrc b/.jshintrc index ca95742..e560055 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,29 +1,28 @@ { - "esnext": true, - "varstmt": true, "asi": true, "boss": true, "browser": true, "camelcase": false, "curly": false, - "devel": false, "devel": true, "eqeqeq": true, "eqnull": true, + "es3": false, "es5": false, + "esnext": true, "evil": false, "immed": false, "indent": 2, "jquery": true, - "latedef": false, + "latedef": true, "laxbreak": true, "laxcomma": true, "maxcomplexity": 6, - "maxdepth": 4, + "maxdepth": 5, + "maxparams": 4, "maxstatements": 25, - "noarg": true, - "maxparams": 3, "newcap": true, + "noarg": true, "node": true, "noempty": false, "nonew": true, @@ -32,5 +31,6 @@ "strict": false, "trailing": false, "undef": true, - "unused": true + "unused": true, + "varstmt": true } \ No newline at end of file From eb49dbf35d1abf8125484e4a276eca999d2859ae Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 11:53:50 -0400 Subject: [PATCH 128/273] Fixed formatting --- app/tests/utils/to.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index 2044067..2c1b146 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -30,7 +30,7 @@ test('to.string', (t) => { test('to.normal_string', async (t) => { - try{ + try { // this file has some stupid ass characters in it // that need to be removed in order to become like the // rest of the fucking world. #microsoftBlowsAtStandards @@ -130,7 +130,7 @@ test('to.merge', (t) => { test('to.object', async (t) => { - try{ + try { let json = await fs.readFile(`${info.root}/package.json`) t.ok(to.object(json).author, 'the passed json should now be an object') From df683b0fcdbaf5257bfb5091c1852f83f416e05a Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 12:03:57 -0400 Subject: [PATCH 129/273] removed log because it was merged with logger --- app/utils/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/utils/index.js b/app/utils/index.js index c962ce7..43779f0 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -4,6 +4,5 @@ export fs from './fs' export glob from './glob' export info from './info' export is from './is' -export log from './log' export to from './to' export array from './array' \ No newline at end of file From be14aa9f4bbd0654f28c375fcc199039c1f46558 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 18:08:20 -0400 Subject: [PATCH 130/273] Fixes an issue with buffers not being converted properly --- app/utils/to.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/utils/to.js b/app/utils/to.js index c3c0089..0e5d7e6 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -25,6 +25,10 @@ let to = { return arg } + if (Buffer.isBuffer(arg)) { + return arg + '' + } + if (is.plain_object(arg)) { return to_string(arg) } From c2fb2d2bd33fbe9d8065e7e43ff27750518ffaf3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 18:28:39 -0400 Subject: [PATCH 131/273] general cleanup --- app/parser/index.js | 21 ++++++--------------- app/sorter/pages.js | 6 ++---- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/app/parser/index.js b/app/parser/index.js index 438bc5a..3a6b0ff 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -4,27 +4,21 @@ import get_blocks from './get_blocks' import parse_blocks from './parse_blocks' export default async function parser(options = {}) { - let { - file_path, - comments, - annotations, - debug, - log - } = options + let { file_path, comments, annotations, log } = options // the filetype of the current file - let filetype = path.extname(file_path).replace('.', '') + let type = path.extname(file_path).replace('.', '') // gets the comments to use on this file - let comment = comments[filetype] ? comments[filetype] : comments._ + let comment = comments[type] ? comments[type] : comments._ let contents = to.normal_string(await fs.readFile(file_path)) let file = { contents, // all of the contents of the file path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, '.' + filetype), // name of the file - type: filetype, // filetype of the file + name: path.basename(file_path, '.' + type), // name of the file + type, // filetype of the file comment, start: 0, // starting point of the file end: to.array(contents).length - 1 // ending point of the file @@ -68,9 +62,6 @@ export default async function parser(options = {}) { }) return { - [file.path]: { - header, - body - } + [file.path]: { header, body } } } \ No newline at end of file diff --git a/app/sorter/pages.js b/app/sorter/pages.js index c08fd40..7bf748e 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -8,11 +8,9 @@ let result = {} /// This function loops over the json that was passed and creates a organized structure /// based on the `@pages` annotations that were passed. export default function pages(options = {}) { - let { json, debug, warning, page_fallback, log } = options + let { json, page_fallback, log } = options for (let { path, header, body } of to.object_entries(json, 'path')) { - log.emit('file', path) - if (!is.empty(header)) { if (is.falsy(header.page)) { if (is.truthy(page_fallback)) { @@ -39,7 +37,7 @@ export default function pages(options = {}) { if (!is.empty(body)) { for (let block_in_body of body) { - let { __start, __end, ...block } = block_in_body + let { __start, ...block } = block_in_body // warn the user that there isn't a page defined. if (is.all.empty(header.page, block.page)) { log.emit('warning', ` From e4cc94a121c05a2b73380a51b8cb5c293660ef7e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 18:29:46 -0400 Subject: [PATCH 132/273] removed support for `v0.10.0` The reason for this is because `co` doesn't support `v0.10.0` --- .travis.yml | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc1bc52..a50716e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: node_js node_js: - - "0.10" + - "iojs" - "0.12" - - "iojs-v2.1.0" - "4" sudo: false install: npm i diff --git a/package.json b/package.json index 151e133..2959070 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "comments" ], "engines": { - "node": ">=0.10.0" + "node": ">=0.12.0" }, "devDependencies": { "babel": "^5.8.23", From 0849d84d6ccff9b07ba61a74e8036547cfbbea2f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 19:45:38 -0400 Subject: [PATCH 133/273] removed unneeded `;` --- app/parser/parse_blocks.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js index db7ee8f..ec5ea13 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse_blocks.js @@ -39,7 +39,7 @@ export default function parse_blocks(options = {}) { } } // end blocks loop - return parsed_blocks; + return parsed_blocks } @@ -130,13 +130,13 @@ function run_annotation(options) { } = options // removes the first line because it's the "line" of the annotation - annotation.contents.shift(); + annotation.contents.shift() // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents); + annotation.contents = to.normalize(annotation.contents) // normalizes the current annotation line - annotation.line = to.normalize(annotation.line); + annotation.line = to.normalize(annotation.line) // Merges the data together so it can be used to run all the annotations let result = to.extend({ @@ -148,7 +148,7 @@ function run_annotation(options) { /// @arg {string} name - the name of the annotation you want to add /// @arg {string} str - information that is passed to the annotation add: (name, contents) => { - contents = contents.split('\n'); + contents = contents.split('\n') return run_annotation({ annotations, annotation: { @@ -163,8 +163,10 @@ function run_annotation(options) { }, block); // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if (is.truthy(annotations.file_list[file.filetype] && annotations.file_list[file.filetype][annotation.name]) && is.truthy(annotations.file_list.default[annotation.name])) { - result.default = annotations.file_list.default[annotation.name].call(result); + if (is.all.truthy( + (annotations.file_list[file.filetype] || {})[annotation.name], + annotations.file_list.default[annotation.name])) { + result.default = annotations.file_list.default[annotation.name].call(result) } return annotations.list(file.type)[annotation.name].callback.call(result) From 8b8579328589cc51fc4b3fddcb4a51d6be9d0548 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 22:16:59 -0400 Subject: [PATCH 134/273] added a map and filter function with object support --- app/utils/to.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index 0e5d7e6..f8fdfbd 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -394,7 +394,7 @@ let to = { /// 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) => { + sort(arg, callback) { let run_sort = (obj) => is.fn(callback) ? obj.sort.apply(null, callback) : obj.sort() let result if (is.plain_object(arg)) { @@ -412,6 +412,39 @@ let to = { return result }, + map(arg, callback) { + if (is.array(arg)) { + return arg.map.apply(null, callback) + } + + let result = {} + + for (let [key, value] of to.entries(arg)) { + let cb_result = callback(value, key) + if (is.truthy(cb_result) && !is.empty(cb_result) && is.plain_object(cb_result)) { + to.extend(result, cb_result) + } + } + + return result + }, + + filter(arg, callback) { + if (is.array(arg)) { + return arg.filter.apply(null, callback) + } + + let result = {} + + for (let [key, value] of to.entries(arg)) { + if (is.truthy(callback(value, key, arg))) { + to.extend(result, { key: value }) + } + } + + return result + }, + /// @name to.number /// @description /// Converts `arg` to number From 139eb5baa7f5053c08375b82e02311acf4dc6217 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 25 Oct 2015 22:17:45 -0400 Subject: [PATCH 135/273] added support for aliases --- app/parser/index.js | 8 ++++++++ app/parser/replace_aliases.js | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 app/parser/replace_aliases.js diff --git a/app/parser/index.js b/app/parser/index.js index 3a6b0ff..e1cffa8 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -2,6 +2,7 @@ import { info, fs, is, to } from '../utils' import path from 'path' import get_blocks from './get_blocks' import parse_blocks from './parse_blocks' +import replace_aliases from './replace_aliases' export default async function parser(options = {}) { let { file_path, comments, annotations, log } = options @@ -14,6 +15,13 @@ export default async function parser(options = {}) { let contents = to.normal_string(await fs.readFile(file_path)) + contents = replace_aliases({ + contents, + annotations: annotations.list(type), + comment, + log + }) + let file = { contents, // all of the contents of the file path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file diff --git a/app/parser/replace_aliases.js b/app/parser/replace_aliases.js new file mode 100644 index 0000000..7a18877 --- /dev/null +++ b/app/parser/replace_aliases.js @@ -0,0 +1,27 @@ +import { is, to } from '../utils' + +// @name aliases +// @description +// This function is used to replace all instances of aliases in a file +// @returns {string} - The file with the instances of aliases removed +export default function aliases(options = {}) { + let { contents, annotations, comment, log } = options + + annotations = to.map(annotations, (annotation, name) => { + if (is.truthy(annotation.alias) && !is.empty(annotation.alias)) { + return { [name]: annotation.alias } + } + + return false + }) + + for (let [annotation, aliases] of to.entries(annotations)) { + // sorts the aliases based off their length. This is to ensure if to two + // or more aliases are similar they will always get replaced correctly + // aka `param` and `parameter` + aliases = aliases.sort((a, b) => b.length > a.length ? 1 : 0) + contents = contents.replace(new RegExp(`(?:${comment.prefix})(${aliases.join('|')})`), comment.prefix + annotation) + } + + return contents +} \ No newline at end of file From 0c0a59699c30121ec1f6d9b28cb703bb903d3369 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 26 Oct 2015 08:20:52 -0400 Subject: [PATCH 136/273] Fixed linter errors --- app/parser/replace_aliases.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/parser/replace_aliases.js b/app/parser/replace_aliases.js index 7a18877..f9054ff 100644 --- a/app/parser/replace_aliases.js +++ b/app/parser/replace_aliases.js @@ -15,12 +15,13 @@ export default function aliases(options = {}) { return false }) - for (let [annotation, aliases] of to.entries(annotations)) { + for (let [annotation, alias_list] of to.entries(annotations)) { // sorts the aliases based off their length. This is to ensure if to two // or more aliases are similar they will always get replaced correctly // aka `param` and `parameter` aliases = aliases.sort((a, b) => b.length > a.length ? 1 : 0) contents = contents.replace(new RegExp(`(?:${comment.prefix})(${aliases.join('|')})`), comment.prefix + annotation) + contents = contents.replace(new RegExp(`(?:${comment.prefix})(${alias_list.join('|')})`), comment.prefix + annotation) } return contents From 85268f431581778fee8c2c9f1622cc5d2da28b93 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 26 Oct 2015 08:23:13 -0400 Subject: [PATCH 137/273] Added a check in for aliases This check ensure aliases won't override main annotations that have been defined. This means that if someone defines a new annotation of `title` then `title` is no longer a alias for `name`. --- app/parser/replace_aliases.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/parser/replace_aliases.js b/app/parser/replace_aliases.js index f9054ff..4aea79a 100644 --- a/app/parser/replace_aliases.js +++ b/app/parser/replace_aliases.js @@ -7,6 +7,8 @@ import { is, to } from '../utils' export default function aliases(options = {}) { let { contents, annotations, comment, log } = options + let main_annotation_list = to.keys(annotations) + annotations = to.map(annotations, (annotation, name) => { if (is.truthy(annotation.alias) && !is.empty(annotation.alias)) { return { [name]: annotation.alias } @@ -19,8 +21,10 @@ export default function aliases(options = {}) { // sorts the aliases based off their length. This is to ensure if to two // or more aliases are similar they will always get replaced correctly // aka `param` and `parameter` - aliases = aliases.sort((a, b) => b.length > a.length ? 1 : 0) - contents = contents.replace(new RegExp(`(?:${comment.prefix})(${aliases.join('|')})`), comment.prefix + annotation) + alias_list = alias_list + .filter((alias) => !is.in(main_annotation_list, alias)) + .sort((a, b) => b.length > a.length ? 1 : 0) + contents = contents.replace(new RegExp(`(?:${comment.prefix})(${alias_list.join('|')})`), comment.prefix + annotation) } From 078fb0a8b2e6593f957b9ca52f9f51ae83e1e76e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 26 Oct 2015 08:49:51 -0400 Subject: [PATCH 138/273] Fixed formatting --- app/parser/replace_aliases.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/parser/replace_aliases.js b/app/parser/replace_aliases.js index 4aea79a..adc653e 100644 --- a/app/parser/replace_aliases.js +++ b/app/parser/replace_aliases.js @@ -1,9 +1,10 @@ import { is, to } from '../utils' -// @name aliases -// @description -// This function is used to replace all instances of aliases in a file -// @returns {string} - The file with the instances of aliases removed +/// @name aliases +/// @access private +/// @description +/// This function is used to replace all instances of aliases in a file +/// @returns {string} - The file with the instances of aliases removed export default function aliases(options = {}) { let { contents, annotations, comment, log } = options @@ -24,7 +25,7 @@ export default function aliases(options = {}) { alias_list = alias_list .filter((alias) => !is.in(main_annotation_list, alias)) .sort((a, b) => b.length > a.length ? 1 : 0) - + contents = contents.replace(new RegExp(`(?:${comment.prefix})(${alias_list.join('|')})`), comment.prefix + annotation) } From 0595c042ee147829fc2a04d13fb07227aabe8737 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 27 Oct 2015 09:14:57 -0400 Subject: [PATCH 139/273] Added log to the parsed blocks --- app/parser/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/parser/index.js b/app/parser/index.js index e1cffa8..b63fc59 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -59,14 +59,16 @@ export default async function parser(options = {}) { file, blocks: header, annotations, - comment + comment, + log })[0] || {} body = parse_blocks({ file, blocks: body, annotations, - comment + comment, + log }) return { From c874ab1e7e61761788c5779afecee02e43b92dc3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 27 Oct 2015 09:21:52 -0400 Subject: [PATCH 140/273] Updated parser(autofill, resolve, removed run_annotation) - Added support for `autofill` this allows users to define defaults for annotations when they aren't defined. This function **only** runs if that annotation wasn't already declared in the block. - Relocated `run_annotation` to be in the annotation api. It made more sense for it to be located in there than it did for it to be in the parser. --- app/annotation_api.js | 83 ++++++++++++++++++++++++++++++++- app/parser/autofill.js | 19 ++++++++ app/parser/parse_blocks.js | 94 +++++++++++++------------------------- 3 files changed, 133 insertions(+), 63 deletions(-) create mode 100644 app/parser/autofill.js diff --git a/app/annotation_api.js b/app/annotation_api.js index 3cee338..affd0f0 100644 --- a/app/annotation_api.js +++ b/app/annotation_api.js @@ -16,7 +16,6 @@ export default class AnnotationApi { // js: { // annotation // } - } // add the inital annotations @@ -178,6 +177,88 @@ export default class AnnotationApi { return !is.undefined(this.annotations[filetype]) ? to.extend(to.clone(this.annotations.default), this.annotations[filetype]) : this.annotations.default } + autofill_list(filetype) { + return to.map(this.list(filetype), (annotation, name) => { + if (is.truthy(annotation.autofill)) { + return { [name]: annotation.autofill } + } + + return false + }) + } + + resolve_list(filetype) {} + + /// @name run_annotation + /// @access private + /// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) + run(options) { + let { + annotation, + annotations_list, + block = {}, + file, + log + } = 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: name, + line: to.normalize(contents[0]), + contents, + start: null, + end: null + }, + annotations_list, + ...block, + log + }) + } + + // removes the first line because it's the "line" of the annotation + annotation.contents.shift() + + // normalizes the current annotation contents + annotation.contents = to.normalize(annotation.contents) + + // normalizes the current annotation line + annotation.line = to.normalize(annotation.line) + + // Merges the data together so it can be used to run all the annotations + let result = { + // sets the annotation block information to be in it's own namespace of `annotation` + annotation, + + // adds the comment, code, and file information + ...block, + + add, + + // adds the ability to add logging information + log + } + + // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed + if (is.all.truthy((this.file_list[file.type] || {})[annotation.name], this.file_list.default[annotation.name])) { + result.default = this.file_list.default[annotation.name].call(result) + } + + result = annotations_list[annotation.name].callback.call(result) + + if (!is.fn(annotations_list[annotation.name].resolve)) { + return result + } + + return annotations_list[annotation.name].resolve.call(result) + } + /// @name file_list /// @description Gets the full list of annotations by filetype /// @returns {object} diff --git a/app/parser/autofill.js b/app/parser/autofill.js new file mode 100644 index 0000000..f516980 --- /dev/null +++ b/app/parser/autofill.js @@ -0,0 +1,19 @@ +import { is, to } from '../utils' + +// @name autofill +// @access private +// @description +// This function is used to run the all the functions that autofill if not defined. +export default function autofill(options) { + let { autofill_list, parsed, block, log } = options + + let parsed_keys = to.keys(parsed) + + for (let [annotation, annotation_autofill] of to.entries(autofill_list)) { + if (!is.in(parsed_keys, annotation)) { + parsed[annotation] = is.fn(annotation_autofill) ? annotation_autofill.call(block) : annotation_autofill + } + } + + return parsed +} \ No newline at end of file diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js index ec5ea13..2a032b5 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse_blocks.js @@ -1,4 +1,5 @@ import { is, to } from '../utils' +import autofill from './autofill' // @name parsed_blocks // @access private @@ -11,7 +12,8 @@ export default function parse_blocks(options = {}) { file, blocks, annotations, - comment + comment, + log } = options if (is.empty(blocks)) { @@ -20,6 +22,7 @@ export default function parse_blocks(options = {}) { let parsed_blocks = [] + let autofill_list = annotations.autofill_list(file.type) // loop over each block for (let i in blocks) { @@ -28,7 +31,15 @@ export default function parse_blocks(options = {}) { block.comment.contents = to.normalize(block.comment.contents) block.code.contents = to.normalize(block.code.contents) - let parsed = parse_block({ file, block, annotations, comment }) + let parsed = parse_block({ + annotations, + block, + comment, + file, + log + }) + + parsed = autofill({ autofill_list, parsed, block, log }) if (!is.empty(parsed)) { parsed_blocks.push({ @@ -52,14 +63,16 @@ export default function parse_blocks(options = {}) { // @arg {object} - The blocks to parse function parse_block(options = {}) { let { - file, + annotations, block, comment, - annotations + file, + log } = options // gets the annotations to use on this file - let keys = to.keys(annotations.list(file.type)) + let annotations_list = annotations.list(file.type); + let keys = to.keys(annotations_list) let contents = to.array(block.comment.contents) let block_annotations = {} @@ -83,7 +96,13 @@ function parse_block(options = {}) { // run the annotation function and merge it with the other annotations in the block to.merge(block_annotations, { - [annotation.name]: run_annotation({ annotation, block, annotations, file }) + [annotation.name]: annotations.run({ + annotation, + annotations_list, + block, + file, + log + }) }) } @@ -109,65 +128,16 @@ function parse_block(options = {}) { // run the annotation function and merge it with the other annotations in the block to.merge(block_annotations, { - [annotation.name]: run_annotation({ annotation, block, annotations, file }) + [annotation.name]: annotations.run({ + annotation, + annotations_list, + block, + file, + log + }) }) } } // end block loop return block_annotations -} - - -/// @name run_annotation -/// @access private -/// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) -function run_annotation(options) { - let { - annotation, - annotations, - file, - block = {} - } = options - - // removes the first line because it's the "line" of the annotation - annotation.contents.shift() - - // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents) - - // normalizes the current annotation line - annotation.line = to.normalize(annotation.line) - - // Merges the data together so it can be used to run all the annotations - let result = to.extend({ - annotation, // sets the annotation block information to be in it's own namespace of `annotation` - - /// @name this.add - /// @page annotation - /// @description Allows you to add a different annotation from within a annotation - /// @arg {string} name - the name of the annotation you want to add - /// @arg {string} str - information that is passed to the annotation - add: (name, contents) => { - contents = contents.split('\n') - return run_annotation({ - annotations, - annotation: { - name: name, - line: to.normalize(contents[0]), - contents, - start: null, - end: null - } - }); - } - }, block); - - // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if (is.all.truthy( - (annotations.file_list[file.filetype] || {})[annotation.name], - annotations.file_list.default[annotation.name])) { - result.default = annotations.file_list.default[annotation.name].call(result) - } - - return annotations.list(file.type)[annotation.name].callback.call(result) } \ No newline at end of file From f5ae6a26a9708a3b0b2330f2c5f37bb1d30c025b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 27 Oct 2015 09:25:57 -0400 Subject: [PATCH 141/273] Moved `...parsed` down to reduce the jshint errors --- app/parser/parse_blocks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js index 2a032b5..b4502d7 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse_blocks.js @@ -43,9 +43,9 @@ export default function parse_blocks(options = {}) { if (!is.empty(parsed)) { parsed_blocks.push({ - ...parsed, __start: block.comment.start, - __end: block.comment.end + __end: block.comment.end, + ...parsed }) } } // end blocks loop From 68d22ceb336f2a1dd534b53a961be2b6fd45042b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 30 Oct 2015 20:31:52 -0400 Subject: [PATCH 142/273] added a markdown test --- tests/lib/md/markdown.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/lib/md/markdown.md diff --git a/tests/lib/md/markdown.md b/tests/lib/md/markdown.md new file mode 100644 index 0000000..e3e67b8 --- /dev/null +++ b/tests/lib/md/markdown.md @@ -0,0 +1,19 @@ + + +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example +```scss +/// @name Name +``` \ No newline at end of file From fd30aa5d333bc1fe60d7e6cfb5b45d2a335fd932 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 30 Oct 2015 22:07:43 -0400 Subject: [PATCH 143/273] added md comment style --- app/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config.js b/app/config.js index eddc2c1..5b6bddd 100644 --- a/app/config.js +++ b/app/config.js @@ -49,7 +49,7 @@ const comments = { header: { start: '###', line: '##', end: '###' }, body: { line: '#' } }, - html: { + 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { header: { start: '' }, body: { start: '' } }, From d759ed188de57e695fd2d1525f84492d046d4395 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 30 Oct 2015 22:09:17 -0400 Subject: [PATCH 144/273] added a few more default files to parse --- app/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config.js b/app/config.js index 5b6bddd..32d27cd 100644 --- a/app/config.js +++ b/app/config.js @@ -3,12 +3,12 @@ import path from 'path' import annotations from './annotations' import AnnotationApi from './annotation_api' -let log = new Reporter(); +let log = new Reporter() // changed by `options` key const default_options = { config: `${info.root}/docsfile.js`, - files: ['app/**/*'], // files to search + files: ['app/**/*', 'src/**/*', '*.md'], // files to search // files to be ignored ignore: [ '.*', // all dot files From 9238097a7f0161549374736e952ea854860bb4f0 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 30 Oct 2015 22:21:38 -0400 Subject: [PATCH 145/273] Changed `callback` to be `parse` --- app/annotation_api.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/annotation_api.js b/app/annotation_api.js index affd0f0..a31cbb1 100644 --- a/app/annotation_api.js +++ b/app/annotation_api.js @@ -27,7 +27,7 @@ export default class AnnotationApi { /// Adds a single annotation to the list /// /// @arg {string, array} annotation - Name of the annotation - /// @arg {function, object} callbacks [annotation_base.callbacks] - Functions + /// @arg {function, object} parses [annotation_base.callbacks] - Functions /// @arg {string} ...alias - the rest of the arguments are alias /// /// @returns {this} @@ -39,8 +39,8 @@ export default class AnnotationApi { /// /// @markup {js} **Example:** Declaring a annotation with more options /// docs.annotation.add("name", { - /// alias: ["title", "heading"], - /// callback: function(){ + /// alias: ['title', 'heading'], + /// parse: function(){ /// return this.annotation.line /// }, /// autofill: false, @@ -48,13 +48,13 @@ export default class AnnotationApi { /// }) /// /// @markup {js} **Example** Specifing a file specific annotation - /// docs.annotation.add("promise", { - /// // the filetypes passed will use the `callback` and the other + /// docs.annotation.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"], - /// callback: function(){ + /// // to be `'default'` which will apply to all files. + /// filetype: ['js', 'jsx', 'es', 'es6', 'es7'], + /// parse: function(){ /// return this.annotation.line /// }, /// ... @@ -62,9 +62,9 @@ export default class AnnotationApi { /// /// @markup {js} **Example** Specifing a file specific annotation(Option 2) /// This is very useful - /// docs.annotation.add("name", { + /// docs.annotation.add('name', { /// default: { // for all filetypes that aren't defined for this annotation - /// callback: function(){ + /// parse: function(){ /// return this.annotation.line /// }, /// ... @@ -85,7 +85,7 @@ export default class AnnotationApi { // This function runs when the parser gets // the annotations information - callback() { + parse() { return this.annotation.line }, @@ -97,9 +97,9 @@ export default class AnnotationApi { // 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. + // 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 @@ -114,7 +114,7 @@ export default class AnnotationApi { } // a) set the passed `array` as the `alias` - // b) set the passed `function` as the `callback` function + // b) set the passed `function` as the `parse` function // c) it's a filetype specific `object` // d) throw an error if (is.array(config)) { @@ -124,7 +124,7 @@ export default class AnnotationApi { } else if (is.fn(config)) { config = { - callback: config + parse: config } } else if (is.plain_object(config) && !is.empty(config) && !is.any.in(config, ...to.keys(base_config))) { @@ -222,7 +222,7 @@ export default class AnnotationApi { }) } - // removes the first line because it's the "line" of the annotation + // removes the first line because it's the `line` of the annotation annotation.contents.shift() // normalizes the current annotation contents @@ -246,11 +246,11 @@ export default class AnnotationApi { } // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if (is.all.truthy((this.file_list[file.type] || {})[annotation.name], this.file_list.default[annotation.name])) { - result.default = this.file_list.default[annotation.name].call(result) + if (is.all.truthy((this.file_list[file.type] || {})[annotation.name], ((this.file_list.default || {})[annotation.name]) || {}).parse) { + result.default = this.file_list.default[annotation.name].parse.call(result) } - result = annotations_list[annotation.name].callback.call(result) + result = annotations_list[annotation.name].parse.call(result) if (!is.fn(annotations_list[annotation.name].resolve)) { return result From 19c233d475565e1257a22fee7df2e120df84bafe Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 31 Oct 2015 12:43:03 -0400 Subject: [PATCH 146/273] Updated to be `--no-` for debug, warning, change, timestamp --- app/cli.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/cli.js b/app/cli.js index a09d024..484bafa 100644 --- a/app/cli.js +++ b/app/cli.js @@ -7,7 +7,7 @@ import {base_config} 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 = (str) => str !== 'false' ? true : false + const to_boolean = (str) => false const to_number = (str) => ~~str program @@ -24,16 +24,30 @@ export default function cli() { .option('-f, --files ', `Paths to parsed`, to_list, base_config.files) .option('-i, --ignore ', `Paths to ignore`, to_list, base_config.ignore) .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', base_config.gitignore) - .option('-x, --debug [boolean]', 'Output debugging information', to_boolean, base_config.debug) - .option('-w, --warning [boolean]', 'Output warning messages', to_boolean, base_config.warning) - .option('-t, --timestamps [boolean]', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) - .option('-a, --changed [boolean]', `Parse changed files`, to_boolean, base_config.changed) + .option('-x, --no-debug', 'Output debugging information', to_boolean, base_config.debug) + .option('-w, --no-warning', 'Output warning messages', to_boolean, base_config.warning) + .option('-t, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) + .option('-a, --no-changed', `Parse changed files`, to_boolean, base_config.changed) .option('-b, --blank-lines ', `Stops parsing lines after consecutive blank lines`, to_number, base_config.blank_lines) .parse(process.argv) + + let { + noDebug: debug, + noWarning: warning, + noTimestamps: timestamps, + noChanged: changed, + blankLines: blank_lines, + } = program + + return docs({ + debug, + warning, + timestamps, + changed, ...program, - blank_lines: program.blankLines, + blank_lines, }) .then((parsed) => fs.outputJson(program.dest, parsed, { spaces: 2 })) .catch((err) => console.error(err.stack)) From 4040db2dd559ddebc00205f833319e7d705e71d3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 31 Oct 2015 13:04:20 -0400 Subject: [PATCH 147/273] added a option to convert an array to an object aka `[ ['key', 'value'] ]` > `{ 'key': 'value' }` --- app/utils/to.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index f8fdfbd..4180997 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -349,7 +349,15 @@ let to = { /// @description Converts a json object to a plain object /// @arg {json} - The json to parse /// @returns {object} - object: (arg) => JSON.parse(arg), + 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 From 38302d4782cd4cbd33128db8af520a31015ce99c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sat, 31 Oct 2015 13:06:34 -0400 Subject: [PATCH 148/273] Added more parsing for the annotations --- app/annotations.js | 290 +++++++++++++++++++++++++++++++++------------ 1 file changed, 217 insertions(+), 73 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index c7de87f..5256835 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -1,4 +1,41 @@ -import { to } from './utils' +import { is, to } from './utils' + +// 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 +const types = '(?:{(.*)})?' +const name = '([^\\s]*)?' +const space = '(?:\\s*)?' +const value = '(?:\\[(.*)\\])?' +const id = '(?:\\((.*)\\))?' +const description = '(?:\\-?\\s*)?(.*)?' + +const regexes = { + arg: new RegExp(types + space + name + space + value + space + description, 'i'), + deprecated: new RegExp(types + space + description, 'i'), + markup: new RegExp(id + space + types + space + value + space + description, 'i'), + note: new RegExp(types + space + description, 'i'), + requires: new RegExp(types + space + name + description, 'i'), + returns: new RegExp(types + space + description, 'i'), + state: new RegExp(types + space + description, 'i'), + todo: new RegExp(types + space + value + space + description, 'i'), + type: new RegExp(types + space + description, 'i'), + version: new RegExp(types + space + description, 'i'), +} + + +function list(str) { + return to.array(str, ',').map((item) => item.trim()).filter(Boolean) +} + +function regex(name, str) { + return regexes[name].exec(str).slice(1) +} + +function _markdown(...args) { + return to.markdown([...args].filter(Boolean).join('\n')) +} + //// /// @name Annotations @@ -7,210 +44,317 @@ import { to } from './utils' /// These are the default annotations for the docs //// const annotations = { - /// @name access - /// @description Access of the documented item - /// @returns {string} + /// @name @access + /// @description + /// Access of the documented item. If access isn't declared then it defaults to public. + /// @markup Usage + /// /// @access public + /// /// @access private access: { - callback() { - return this.annotation.line; + autofill() { + return 'public' + }, + parse() { + if (this.annotation.line === 'private') { + return 'private' + } + + return 'public' } }, - /// @name alias + /// @name @alias /// @description Whether the documented item is an alias of another item /// @returns {string} + /// @markup Usage alias: { - callback() { - return this.annotation.line; + parse() { + return list(this.annotation.line) } }, - /// @name arg + /// @name @arg /// @page annotations /// @description Parameters from the documented function/mixin /// @note Description runs through markdown /// @returns {object} arg: { alias: ['argument', 'param', 'parameter'], - callback() { - // add regex for `{type} name-of-variable [default value] - description` - // make sure it supports multiple lines - return this.annotation.line; + parse() { + let [ + types, + name, + value, + description + ] = regex('arg', this.annotation.line) + + return [{ + types: list(types), + name, + value, + description: _markdown(description, this.annotation.contents) + }] } }, - /// @name author + /// @name @author /// @page annotations /// @description Author of the documented item /// @returns {string} author: { - callback() { - return this.annotation.line.split(',').map((author) => author.trim()).filter(Boolean) + alias: ['authors'], + parse() { + return list(this.annotation.line) } }, - /// @name chainable + /// @name @chainable /// @page annotations /// @description Used to notate that a function is chainable /// @returns {boolean} chainable: { - callback() { - return this.annotation.line; + parse() { + return this.annotation.line } }, - /// @name deprecated + /// @name @deprecated /// @page annotations /// @description Lets you know that a mixin/function has been depricated /// @returns {string} deprecated: { - callback() { - // add regex for `{version} - description` - return this.annotation.line; + parse() { + let [ version, description ] = regex('deprecated', this.annotation.line) + return { + version: version, + description: _markdown(description, this.annotation.contents) + } } }, - /// @name description + /// @name @description /// @page annotations /// @description Description of the documented item /// @note Runs through markdown /// @returns {string} description: { - callback() { - return to.markdown(this.annotation.line ? this.annotation.line + '\n' + this.annotation.contents : this.annotation.contents) + alias: ['desc', 'definition', 'explanation', 'writeup', 'summary', 'summarization'], + parse() { + return _markdown(this.annotation.line, this.annotation.contents) } }, - /// @name markup + markdown: { + filetypes: ['markdown', 'mark', 'mdown', 'mkdn', 'md', 'mdml', 'mkd', 'mdwn', 'mdtxt', 'mdtext', 'text'], + parse() { + return to.markdown(this.file.contents) + } + }, + /// @name @markup /// @page annotations /// @description Code for the documented item /// @note Description is parsed as markdown /// @returns {object} + /// // markdown - `(id) {language} [settings] - description` markup: { - callback() { - // add regex for `{language} [settings] - description` - return this.annotation.contents; + alias: ['code', 'example', 'output', 'outputs'], + parse() { + let escaped_characters = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' + } + + let [ + id = false, + language = this.file.type, + settings = {}, + description + ] = regex('markup', this.annotation.line) + + let raw = this.annotation.contents; + + let escaped = raw.split('\n').map((line) => line.replace(/[&<>'"]/g, (m) => escaped_characters[m])).join('\n'); + + if (is.string(settings)) { + settings = to.object(list(settings).map((setting) => setting.split('='))) + } + + return [{ + id, + language, + settings, + description: _markdown(description), + raw, + escaped + }] } }, - /// @name name + /// @name @name /// @page annotations/name /// @description Name of the documented item /// @returns {string} name: { alias: ['title', 'heading'] }, - /// @name note + + /// @name @note /// @page annotations /// @description A note about the documented item /// @returns {object} note: { - callback() { - // add regex for `{7} - A note` - return this.annotation.line; + parse() { + let [ importance, description ] = regex('note', this.annotation.line) + + return [{ + importance, + description: _markdown(description, this.annotation.contents) + }] } }, - /// @name page + /// @name @page /// @page annotations /// @description The page you want the documented item to be on /// @returns {string} page: { alias: ['group'], - callback() { - return [this.annotation.line]; + parse() { + return list(this.annotation.line) } }, - /// @name readonly + /// @name @readonly /// @page annotations /// @description To note that a property is readonly /// @returns {boolean} readonly: { - callback() { - return this.annotation.line; + parse() { + return true } }, - /// @name requires + /// @name @requires /// @page annotations /// @description Requirements from the documented item /// @returns {object} requires: { alias: ['require'], - callback() { - // add regex for {type} item - description - return this.annotation.line; + parse() { + let [ types, name, description ] = regex('requires', this.annotation.line) + + return [{ + types: list(types), + name, + description: _markdown(description, this.annotation.contents) + }] } }, - /// @name returns + /// @name @returns /// @page annotations /// @description Return from the documented function /// @returns {string} returns: { alias: ['return'], - callback() { // return - // add regex for `{type} - description`. Also ensure it supports multiple lines - return this.annotation.line; + parse() { + let [ types, description ] = regex('returns', this.annotation.line) + + return { + types: list(types), + description: _markdown(description, this.annotation.contents) + } } }, - /// @name since + /// @name @since /// @page annotations /// @description Let's you know what version of the project a something was added /// @returns {string} since: { - callback() { - // add regex for `{type} - description` - return this.annotation.line; + parse() { + let [ types, description ] = regex('since', this.annotation.line) + + return { + types: list(types), + description: _markdown(description, this.annotation.contents) + } } }, - /// @name state + /// @name @state /// @page annotations /// @description A state of a the documented item /// @returns {object} + /// // state - `{state} - description` state: { - callback() { - // 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; + parse() { + let [ id, description ] = regex('state', this.annotation.line) + + return [{ + id, + description: _markdown(description, this.annotation.contents) + }] } }, - /// @name todo + /// @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 todo: { - callback() { - // add regex for {5} [assignee-one, assignee-two] - Task to be done - // make sure it supports multiple lines - return this.annotation.line; + parse() { + let [ importance, assignees, description ] = regex('todo', this.annotation.line) + + return [{ + importance, + assignees: list(assignees), + description: _markdown(description, this.annotation.contents) + }] + } + }, + + /// @name @throws + /// @description + /// The error that happends if something goes wrong + throws: { + alias: ['throws', 'exception', 'error'], + parse() { + return [join(this.annoation.line, this.annoation.content)] } }, - /// @name type + /// @name @type /// @page annotations /// @description Describes the type of a variable /// @returns {string} + /// // type - `{type} - description` type: { - callback() { - // add regex for `{type} - description` - return this.annotation.line; + parse() { + let [ type, description ] = regex('type', this.annotation.line) + return { + type, + description: _markdown(description, this.annotation.line) + } } }, - /// @name version + /// @name @version /// @page annotations /// @description Describes the type of a variable /// @returns {string} + /// // version `{type} - description` version: { - callback() { - // add regex for `{type} - description` - return this.annotation.line; + parse() { + let [ version, description ] = regex('version', this.annotation.line) + return { + version, + description: _markdown(description, this.annotation.line) + } } } } From c7cdbdffa32d9266b4c17f0ed8529b7ace7025a4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 06:49:25 -0500 Subject: [PATCH 149/273] changed `to.flat_array` to be `to.flatten` Naming things is hard --- app/annotation_api.js | 2 +- app/config.js | 2 +- app/tests/utils/to.test.js | 4 ++-- app/utils/glob.js | 4 ++-- app/utils/is.js | 4 ++-- app/utils/to.js | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/annotation_api.js b/app/annotation_api.js index a31cbb1..cf13308 100644 --- a/app/annotation_api.js +++ b/app/annotation_api.js @@ -132,7 +132,7 @@ export default class AnnotationApi { // object and rerun the add function for (let filetype in config) { let obj = config[filetype]; - obj.filetypes = is.in(obj, 'filetype') ? to.flat_array([filetype, config.filetype]) : to.array(filetype) + obj.filetypes = is.in(obj, 'filetype') ? to.flatten([filetype, config.filetype]) : to.array(filetype) this.add(name, obj); } return diff --git a/app/config.js b/app/config.js index 32d27cd..1ad9ef9 100644 --- a/app/config.js +++ b/app/config.js @@ -84,7 +84,7 @@ export default async function config(options = {}) { if (options.gitignore) { try { - options.ignore = to.flat_array([ + options.ignore = to.flatten([ options.ignore, to.array(to.string(await fs.readFile(path.join(info.root, '.gitignore')))) ]) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index 2c1b146..cbead6a 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -172,8 +172,8 @@ test('to.array', (t) => { }) -test('to.flat_array', (t) => { - t.is(to.flat_array([[[array]]])[0], 'one', +test('to.flatten', (t) => { + t.is(to.flatten([[[array]]])[0], 'one', 'the array should be flattend and the first value should be one') t.end() }) diff --git a/app/utils/glob.js b/app/utils/glob.js index 76fbc3a..5666c34 100644 --- a/app/utils/glob.js +++ b/app/utils/glob.js @@ -23,8 +23,8 @@ const glob = co.wrap(function*(files, ignore = [], filter, files_only = true) { files = array(to.array(files)).map((file) => _glob(file)); ignore = array(to.array(ignore)).map((file) => _glob(file.replace(/!/, ''))) - files = to.flat_array(yield files) - ignore = to.flat_array(yield ignore) + files = to.flatten(yield files) + ignore = to.flatten(yield ignore) // removed any files that are supposed to be ignored if (ignore.length) { diff --git a/app/utils/is.js b/app/utils/is.js index 63652ba..2ed8b00 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -74,7 +74,7 @@ is.included = (a, b) => !is.empty(a) && !is.empty(b) && a.indexOf(b) > -1 ? a.in is.symbol = (arg) => typeof arg === 'symbol' is.all.in = (obj, ...values) => { - values = to.flat_array(values) + values = to.flatten(values) for (let i in values) { if (!is.in(obj, values[i])) { return false @@ -84,7 +84,7 @@ is.all.in = (obj, ...values) => { } is.any.in = (obj, ...values) => { - values = to.flat_array(values) + values = to.flatten(values) for (let i in values) { if (is.in(obj, values[i])) { return true diff --git a/app/utils/to.js b/app/utils/to.js index 4180997..bf325fb 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -60,7 +60,7 @@ let to = { /// It also get's symbols if they're set as a key name. /// @arg {object} /// @returns {array} - keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && to.flat_array([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && to.flatten([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), /// @name to.entries /// @description @@ -332,7 +332,7 @@ let to = { if (is.array(a[k])) { // a) Flatten the array if (flat) { - a[k] = to.flat_array(a[k]) + a[k] = to.flatten(a[k]) } // a) Filter out duplicates @@ -374,12 +374,12 @@ let to = { /// @returns {array} array: (arg, glue = '\n') => is.array(arg) ? arg : is.arguments(arg) ? array_slice(arg) : is.string(arg) ? arg.split(glue) : is.plain_object(arg) || is.number(arg) ? [arg] : [], - /// @name to.flat_array + /// @name to.flatten /// @description /// Flattens an array, and arrays inside of it into a single array /// @arg {array} /// @returnes {array} - single dimensional - flat_array: (arg) => is.array(arg) ? [].concat(...arg.map(to.flat_array)) : arg, + flatten: (arg) => is.array(arg) ? [].concat(...arg.map(to.flatten)) : arg, /// @name to.unique_array /// @description From bd69059f9f664c39d1c6227ae48f6858433736c7 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 11:08:28 -0500 Subject: [PATCH 150/273] updated to better clone function --- app/utils/to.js | 68 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index bf325fb..108a8eb 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -231,34 +231,58 @@ let to = { /// /// @arg {*} - The item you want to clone /// @returns {*} - The copied result - clone(arg) { - // Basis. - if (!(arg instanceof Object)) { - return arg; + clone(obj, seen) { + if (!(obj instanceof Object)) { + return obj } - let clone; - - // Filter out special objects. - let Constructor = arg.constructor; - switch(Constructor) { - // Implement other special objects here. - case RegExp: - clone = new Constructor(arg); - break; - case Date: - clone = new Constructor(arg.getTime()); - break; - default: - clone = new Constructor(); + seen = seen || { orig: [], copy: [] } + + const lookup = seen.orig.indexOf(obj) + + if (lookup !== -1) { + return seen.copy[lookup] } - // Clone each property. - for (var prop in arg) { - clone[prop] = to.clone(arg[prop]); + let newObj + let cloneDeep = false + + if (!Array.isArray(obj)) { + if (Buffer.isBuffer(obj)) { + newObj = new Buffer(obj) + } else if (obj instanceof Date) { + newObj = new Date(obj.getTime()) + } else if (obj instanceof RegExp) { + newObj = new RegExp(obj) + } else { + const proto = Object.getPrototypeOf(obj) + if (proto && proto.isImmutable) { + newObj = obj + } else { + newObj = Object.create(proto) + cloneDeep = true + } + } + } else { + newObj = [] + cloneDeep = true + } + + seen.orig.push(obj) + seen.copy.push(newObj) + + if (cloneDeep) { + for (let [key, value] of to.entries(obj)) { + const descriptor = Object.getOwnPropertyDescriptor(obj, key) + if (descriptor && (descriptor.get || descriptor.set)) { + Object.defineProperty(newObj, key, descriptor) + } else { + newObj[key] = to.clone(value, seen) + } + } } - return clone; + return newObj }, /// @name to.merge From 14908896d9802a1c029f8c63f90c14eb96d399d8 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 11:09:32 -0500 Subject: [PATCH 151/273] Fixed jscs errors --- app/utils/to.js | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index 108a8eb..ab63276 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -60,7 +60,8 @@ let to = { /// It also get's symbols if they're set as a key name. /// @arg {object} /// @returns {array} - keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && to.flatten([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && + to.flatten([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), /// @name to.entries /// @description @@ -97,11 +98,11 @@ let to = { return obj.entries() } - let index = 0, - // 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. - keys = to.keys(obj) + let index = 0 + // 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) return { [Symbol.iterator]() { @@ -215,13 +216,13 @@ let to = { let k = to.keys(b) for (let i = 0, l = k.length; i < l; i++) { - a[k[i]] = is.plain_object(b[k[i]]) ? is.plain_object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] : b[k[i]] + if (is.plain_object(b[k[i]])) { + a[k[i]] = is.plain_object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] + } else { + a[k[i]] = b[k[i]] + } } - // for (let k in b) { - // a[k] = is.plain_object(b[k]) ? is.plain_object(a[k]) ? to.extend(a[k], b[k]) : b[k] : b[k] - // } - return a }, @@ -396,7 +397,19 @@ let to = { /// 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.arguments(arg) ? array_slice(arg) : is.string(arg) ? arg.split(glue) : is.plain_object(arg) || is.number(arg) ? [arg] : [], + array: (arg, glue = '\n') => { + if (is.array(arg)) { + return arg + } else if (is.arguments(arg)) { + return array_slice(arg) + } else if (is.string(arg)) { + return arg.split(glue) + } else if (is.plain_object(arg) || is.number(arg)) { + return [arg] + } else { + return [] + } + }, /// @name to.flatten /// @description @@ -482,7 +495,8 @@ let to = { /// Converts `arg` to number /// @arg {number, array, object, string, boolean} /// @returns {number} - number: (arg) => is.number(arg) ? arg : is.array(arg) ? arg.length : is.plain_object(arg) ? to.keys(arg).length : ~~arg + number: (arg) => is.number(arg) ? arg : is.array(arg) ? + arg.length : is.plain_object(arg) ? to.keys(arg).length : ~~arg } -export default to \ No newline at end of file +export default to From 85d84a087e9adb4b2b556e20f395769685c67342 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 11:10:08 -0500 Subject: [PATCH 152/273] changed `to.unique_array` to be `to.unique` naming things is hard :facepalm: --- app/utils/to.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index ab63276..653fe36 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -362,7 +362,7 @@ let to = { // a) Filter out duplicates if (unique && !is.plain_object(a[k][0])) { - a[k] = to.unique_array(a[k]) + a[k] = to.unique(a[k]) } } } @@ -418,12 +418,16 @@ let to = { /// @returnes {array} - single dimensional flatten: (arg) => is.array(arg) ? [].concat(...arg.map(to.flatten)) : arg, - /// @name to.unique_array + /// @name to.unique /// @description /// Removes duplicate values from an array /// @arg {array} /// @returns {array} - without duplicates - unique_array(arg){ + unique(arg) { + if (!is.array(arg)) { + return arg + } + let o = {} let r = [] From cc6ccbeca67e1153cbd4c98187fbbb5c70594326 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 14:47:30 -0500 Subject: [PATCH 153/273] Updated jscsrc to use googles default This reduces the amount of things that need to be set dramatically. --- .jscsrc | 71 ++++++++++++--------------------------------------------- 1 file changed, 15 insertions(+), 56 deletions(-) diff --git a/.jscsrc b/.jscsrc index 8474702..ad073a7 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,76 +1,35 @@ { + "preset": "google", + "requireSemicolons": false, "esnext": true, - "disallowIdentifierNames": ["foo", "bar", "baz", "qux"], - "disallowKeywords": ["with"], - "disallowMixedSpacesAndTabs": "smart", - "disallowMultipleLineStrings": true, - "disallowMultipleSpaces": true, - "disallowPaddingNewlinesInBlocks": true, - "disallowPaddingNewlinesBeforeKeywords": ["case", "catch", "void", "with"], - "disallowQuotedKeysInObjects": "allButReserved", - "requireSpaceAfterKeywords": [ - "do", - "for", - "if", - "else", - "case", - "try", - "void", - "while", - "with", - "return", - "typeof" - ], - "requireSpaceBeforeKeywords": ["catch", "else"], - "requireParenthesesAroundArrowParam": true, - "disallowSpaceBeforeKeywords": ["for", "while"], + "requireCamelCaseOrUpperCaseIdentifiers": false, "requireCurlyBraces": [ "else", "else if", "do", "try", - "catch", - "default" + "catch" ], - "requireLineBreakAfterVariableAssignment": true, - "disallowSpaceAfterObjectKeys": "ignoreSingleLine", - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!", "!!", "~~"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true + "maximumLineLength": { + "value": 100, + "allExcept": ["comments", "regex"] }, - "disallowSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInFunction": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInCallExpression": true, - "requireSpacesInConditionalExpression": true, - "requireSpacesInForStatement": true, - "disallowTrailingWhitespace": "ignoreEmptyLines", + "disallowMultipleSpaces": true, + "disallowMultipleLineBreaks": false, + "disallowPaddingNewlinesInBlocks": true, + "disallowNewlineBeforeBlockStatements": false, + "disallowQuotedKeysInObjects": "allButReserved", + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "requireBlocksOnNewline": true, "requireCommaBeforeLineBreak": true, - "disallowYodaConditions": true, - "requireOperatorBeforeLineBreak": ["?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "requireSpaceBeforeBinaryOperators": true, - "requireSpaceBeforeObjectValues": true, "requireSpaceBetweenArguments": true, - "requireSpaceAfterBinaryOperators": true, - "disallowSpacesInsideObjectBrackets": null, - "safeContextKeyword": ["$obj", "obj", "$that", "that", "$elem", "elem", "_this", "self", "_self", "_", "$parent", "parent", "instance", "result", "context"], - "fileExtensions": [".js", "jscs"], + "disallowSpacesInsideObjectBrackets": false, + "disallowSpacesInsideArrayBrackets": false, "validateQuoteMarks": { "mark": "'", "escape": true }, - "requireSpaceBeforeBlockStatements": true, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", - "validateIndentation": 2, - "validateParameterSeparator": ", ", "excludeFiles": ["node_modules/**/*", "app/tests/**/*.js"] } From cf9a8917e48d907e24dce3298c21431befef52ba Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 14:49:40 -0500 Subject: [PATCH 154/273] removed gulp file because it's not longer needed. There might be an example of it later but it's not needed to run tests anymore since the cli has been built --- tests/gulpfile.js | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100755 tests/gulpfile.js diff --git a/tests/gulpfile.js b/tests/gulpfile.js deleted file mode 100755 index 7e8d204..0000000 --- a/tests/gulpfile.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -var gulp = require("gulp"), - docs = require("docs"), - path = require("path"); - -// This is for the documentation -gulp.task("docs", function() { - docs.parse("lib/**/*") - .then(function(result) { - console.log(docs.to.json(result.sorted)); - docs.fs.outputJson("./test.json", result.sorted, { - spaces: 2 - }, 1); - }); -}); - -gulp.task("default", ["docs"]); \ No newline at end of file From a78ff5f4d2ec16a86cadfbd593f5c212bf2abd76 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 15:27:31 -0500 Subject: [PATCH 155/273] had to change back to the old `to.clone` --- app/utils/to.js | 68 ++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index 653fe36..bcc2f91 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -232,58 +232,34 @@ let to = { /// /// @arg {*} - The item you want to clone /// @returns {*} - The copied result - clone(obj, seen) { - if (!(obj instanceof Object)) { - return obj + clone(arg) { + // Basis. + if (!(arg instanceof Object)) { + return arg; } - seen = seen || { orig: [], copy: [] } - - const lookup = seen.orig.indexOf(obj) - - if (lookup !== -1) { - return seen.copy[lookup] - } - - let newObj - let cloneDeep = false - - if (!Array.isArray(obj)) { - if (Buffer.isBuffer(obj)) { - newObj = new Buffer(obj) - } else if (obj instanceof Date) { - newObj = new Date(obj.getTime()) - } else if (obj instanceof RegExp) { - newObj = new RegExp(obj) - } else { - const proto = Object.getPrototypeOf(obj) - if (proto && proto.isImmutable) { - newObj = obj - } else { - newObj = Object.create(proto) - cloneDeep = true - } - } - } else { - newObj = [] - cloneDeep = true + let clone; + + // Filter out special objects. + let Constructor = arg.constructor; + switch (Constructor) { + // Implement other special objects here. + case RegExp: + clone = new Constructor(arg); + break; + case Date: + clone = new Constructor(arg.getTime()); + break; + default: + clone = new Constructor(); } - seen.orig.push(obj) - seen.copy.push(newObj) - - if (cloneDeep) { - for (let [key, value] of to.entries(obj)) { - const descriptor = Object.getOwnPropertyDescriptor(obj, key) - if (descriptor && (descriptor.get || descriptor.set)) { - Object.defineProperty(newObj, key, descriptor) - } else { - newObj[key] = to.clone(value, seen) - } - } + // Clone each property. + for (var prop in arg) { + clone[prop] = to.clone(arg[prop]); } - return newObj + return clone; }, /// @name to.merge From 2d853d81901f98102a79a8d47c3e94b93aa42e86 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 15:31:17 -0500 Subject: [PATCH 156/273] Adds the last line in the contents to the comment contents --- app/parser/get_blocks.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/parser/get_blocks.js b/app/parser/get_blocks.js index 20e8369..0eadba4 100644 --- a/app/parser/get_blocks.js +++ b/app/parser/get_blocks.js @@ -74,6 +74,7 @@ export default function get_blocks(options) { // a) check for the end comment if (style === 'multi' && block.comment.start !== i && index.end !== false) { in_comment = false + block.comment.contents.push(line) block.comment.end = i // sets the end line in the comment block // @todo might need to remove this From 5fc7c968eef6400f780d446a7918f76b8a565e51 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 15:31:38 -0500 Subject: [PATCH 157/273] fixes a bug with multi line comments --- app/parser/get_blocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/parser/get_blocks.js b/app/parser/get_blocks.js index 0eadba4..d30eb15 100644 --- a/app/parser/get_blocks.js +++ b/app/parser/get_blocks.js @@ -80,7 +80,7 @@ export default function get_blocks(options) { // @todo might need to remove this i++ // skips end comment line line = lines[i] // updates to be the next line - index.end = is.in(line, comment.end) ? line.indexOf(comment.end) : false + index.end = (line && is.in(line, comment.end)) ? line.indexOf(comment.end) : false } // a) adds this line to block comment contents From d96157143f1219d2c3ff8d3974f9960c1b8f94d5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 15:51:39 -0500 Subject: [PATCH 158/273] scoped the regexes --- app/annotations.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 5256835..62ee7f6 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -3,24 +3,29 @@ import { is, to } from './utils' // 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 -const types = '(?:{(.*)})?' -const name = '([^\\s]*)?' -const space = '(?:\\s*)?' -const value = '(?:\\[(.*)\\])?' -const id = '(?:\\((.*)\\))?' -const description = '(?:\\-?\\s*)?(.*)?' - -const regexes = { - arg: new RegExp(types + space + name + space + value + space + description, 'i'), - deprecated: new RegExp(types + space + description, 'i'), - markup: new RegExp(id + space + types + space + value + space + description, 'i'), - note: new RegExp(types + space + description, 'i'), - requires: new RegExp(types + space + name + description, 'i'), - returns: new RegExp(types + space + description, 'i'), - state: new RegExp(types + space + description, 'i'), - todo: new RegExp(types + space + value + space + description, 'i'), - type: new RegExp(types + space + description, 'i'), - version: new RegExp(types + space + description, 'i'), +let regexes + +{ + const types = '(?:{(.*)})?' + const name = '([^\\s]*)?' + const space = '(?:\\s*)?' + const value = '(?:\\[(.*)\\])?' + const id = '(?:\\((.*)\\))?' + const description = '(?:\\-?\\s*)?(.*)?' + + regexes = { + arg: new RegExp(types + space + name + space + value + space + description, 'i'), + deprecated: new RegExp(types + space + description, 'i'), + markup: new RegExp(id + space + types + space + value + space + description, 'i'), + note: new RegExp(types + space + description, 'i'), + requires: new RegExp(types + space + name + description, 'i'), + returns: new RegExp(types + space + description, 'i'), + state_id: new RegExp(`${id}${space}(.*)`, 'i'), + state: new RegExp(types + space + value + space + description, 'i'), + todo: new RegExp(types + space + value + space + description, 'i'), + type: new RegExp(types + space + description, 'i'), + version: new RegExp(types + space + description, 'i'), + } } From 5db8d957278b49ff25542afdc2251c9a245aa6a1 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 22:40:29 -0500 Subject: [PATCH 159/273] added super powers to `@state` --- app/annotations.js | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 62ee7f6..724b7a9 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -293,17 +293,35 @@ const annotations = { /// @name @state /// @page annotations /// @description A state of a the documented item - /// @returns {object} - /// // state - `{state} - description` + /// @returns {hashmap} + /// @markup + /// /// @states (id) {state} [state_id] - description + /// /// @states (id) + /// /// {state} [state_id] - description + /// /// {state} [state_id] - description + /// /// {state} [state_id] - description state: { parse() { - let [ id, description ] = regex('state', this.annotation.line) - - return [{ - id, - description: _markdown(description, this.annotation.contents) - }] - } + let states = this.annotation.contents.split('\n') + let [ markup_id, state_line ] = regex('state_id', this.annotation.line) + states.unshift(state_line) + + states = states.filter(Boolean).map((line, i) => { + let [ state, state_id = `${i}`, description ] = regex('state', line) + return { + state, + state_id, + description: _markdown(description) + } + }) + + return [ + { markup_id, states } + ] + }, + // resolve() { + // /// @todo {10} - add code to that adds the markup code for this stuff. + // } }, /// @name @todo From 3006f0adde19ebeb7ad46c79e9021849eececfca Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 22:41:55 -0500 Subject: [PATCH 160/273] fixed jscs errors --- app/annotations.js | 7 +++++-- app/docs.js | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 724b7a9..eb770f4 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -150,7 +150,10 @@ const annotations = { }, markdown: { - filetypes: ['markdown', 'mark', 'mdown', 'mkdn', 'md', 'mdml', 'mkd', 'mdwn', 'mdtxt', 'mdtext', 'text'], + filetypes: [ + 'markdown', 'mark', 'mdown', 'mkdn', 'mdtxt', + 'mkd', 'mdml', 'mdwn', 'mdtext', 'text', 'md' + ], parse() { return to.markdown(this.file.contents) } @@ -382,4 +385,4 @@ const annotations = { } } -export default annotations \ No newline at end of file +export default annotations diff --git a/app/docs.js b/app/docs.js index 529cae6..a6296e4 100644 --- a/app/docs.js +++ b/app/docs.js @@ -44,7 +44,8 @@ const docs = co.wrap(function*(options = {}) { let json = fs.readFile(info.temp.file) log.emit('start', 'paths') files = yield glob(files, ignore, changed ? has_file_changed : false) - log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${files.length > 1 ? 's' : ''} to parse`) + let s = files.length > 1 ? 's' : '' + log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${s} to parse`) log.emit('start', 'parser') files = yield array(files).map((file_path) => parser({ file_path, ...options, log })) From 802a24c9fe02224b0f90668806bf75c13de08996 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 22:45:28 -0500 Subject: [PATCH 161/273] Updated logger This change was to remove reporter and just have a logger. It also added better printing abilities to the console. --- app/config.js | 4 +- app/docs.js | 4 +- app/utils/index.js | 5 +- app/utils/logger.js | 139 ++++++++++++++----------- app/utils/purdy.js | 248 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 334 insertions(+), 66 deletions(-) create mode 100644 app/utils/purdy.js diff --git a/app/config.js b/app/config.js index 1ad9ef9..9f86d88 100644 --- a/app/config.js +++ b/app/config.js @@ -1,9 +1,9 @@ -import {info, fs, is, to, Reporter} from './utils' +import { info, fs, is, to, Logger } from './utils' import path from 'path' import annotations from './annotations' import AnnotationApi from './annotation_api' -let log = new Reporter() +let log = new Logger() // changed by `options` key const default_options = { diff --git a/app/docs.js b/app/docs.js index a6296e4..5323bd4 100644 --- a/app/docs.js +++ b/app/docs.js @@ -7,7 +7,7 @@ process.on('uncaughtException', function(err) { import co from 'co' import path from 'path' -import { info, fs, is, to, glob, array, Reporter } from './utils' +import { info, fs, is, to, glob, array, Logger } from './utils' import parser from './parser' import sorter from './sorter' import get_config from './config' @@ -35,7 +35,7 @@ const docs = co.wrap(function*(options = {}) { comments, } = options - let log = new Reporter({ debug, warning, timestamps }); + let log = new Logger({ debug, warning, timestamps }); log.emit('start', 'total') diff --git a/app/utils/index.js b/app/utils/index.js index 43779f0..0212641 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,8 +1,9 @@ export denodeify from './denodeify' -export {Logger, Reporter} from './logger' +export Logger from './logger' +export {Purdy} from './purdy' export fs from './fs' export glob from './glob' export info from './info' export is from './is' export to from './to' -export array from './array' \ No newline at end of file +export array from './array' diff --git a/app/utils/logger.js b/app/utils/logger.js index 5f80146..1969e09 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -1,4 +1,4 @@ -import { is, to } from './' +import Purdy from './purdy' import chalk from 'chalk' let chevron = '\xBB' @@ -6,10 +6,21 @@ let check = '\u2713' let warning = '\u26A0' let error = '\u2326' -export class Logger { - constructor() { +const messaging = { + warning: chalk.yellow(warning, chalk.bold.yellow('[WARNING]')), + debug: chalk.magenta(chevron, '[DEBUG]'), + error: chalk.red(error, chalk.bold.red('[ERROR]')), + file: chalk.bgBlue.gray(chevron, '[FILE]') +} + +const purdy = new Purdy() + +export default class Logger { + constructor(options = {}) { this.events = [] this.times = {} + + this.report(options) } /// @description @@ -29,62 +40,9 @@ export class Logger { return this } - log(...args) { - console.log(`${chalk.green(chevron)} ${awesome_report(...args)}`) - } - - warn(...args) { - console.log(`${chalk.yellow(warning, chalk.bold.yellow('[WARNING]\n'))}${awesome_report(...args)}`) - } - - error(...args) { - console.trace(...args) - console.log(`${chalk.red(error, chalk.bold.red('[ERROR]\n'))}${awesome_report(...args)}`) - } - - time(label) { - this.times[label] = Date.now() - } - - time_end(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(`${chalk.green(check)} ${format}`, label, duration) - } - - debug(...args) { - console.log(`${chalk.magenta(chevron, '[DEBUG]\n')}${awesome_report(...args)}`) - } - - file(file) { - console.log('\n\n', chalk.bgBlue.gray('\n', chevron, '[FILE]'), file, '') - } -} - -function awesome_report(...args) { - return args.map((arg) => { - if (is.fn(arg)) { - arg = arg() - } - - if (is.object(arg)) { - return to.normalize(to.json(arg)) - } - - return to.normalize(to.string(arg)) - }).join('\n') + '\n' -} - - -export class Reporter extends Logger { - constructor(options = {}) { - super() - this.report(options) + print(...args) { + purdy.print(...args) + return this } report(options) { @@ -112,6 +70,67 @@ export class Reporter extends Logger { if (warning) this.on('warning', (...args) => this.warn(...args)) } + + warn(...args) { + console.log( + '\n\n', + messaging.warning, + '\n', + ...purdy.format(...args) + ) + return this + } + + error(arg) { + console.log( + '\n\n', + messaging.error, + '\n', + ...purdy.format(arg) + ) + return this + } + + time(label) { + this.times[label] = Date.now() + return this + } + + time_end(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( + `${chalk.green(check)} ${format}`, + label, + duration + ) + return this + } + + debug(...args) { + console.log( + '\n\n', + messaging.debug, + '\n', + ...purdy.format(...args) + ) + return this + } + + file(file) { + console.log( + '\n\n', + messaging.file, + file, + '' + ) + return this + } } // .on('fly_run', ({ path }) => @@ -141,4 +160,4 @@ export class Reporter extends Logger { // const time = timeInfo(duration) // log(`Finished ${fmt.complete} in ${fmt.secs}`, // task, time.duration, time.scale) -// }) \ No newline at end of file +// }) diff --git a/app/utils/purdy.js b/app/utils/purdy.js new file mode 100644 index 0000000..5322280 --- /dev/null +++ b/app/utils/purdy.js @@ -0,0 +1,248 @@ +// Load modules +import to from './to' +import chalk from 'chalk' + +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', + 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 = chalk[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).split('\n') + let quote = str.length > 1 ? '`' : `'` + let out = [] + + for (let line of str) + out.push(this.indent() + this.colorize(line, 'string')) + + return quote + out.join('\n') + quote + } + + _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') + } +} From e5f99d6bf3b1abd1b4c8abe9112af8a3305b6eef Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Sun, 1 Nov 2015 22:46:33 -0500 Subject: [PATCH 162/273] Updated some tests --- app/tests/utils/to.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index cbead6a..c768ffd 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -106,8 +106,12 @@ test('to.extend', (t) => { test('to.clone', (t) => { let actual = { one: { two: { three: { four: { five: 'whatup' } } } } } let expected = { one: { two: { three: { four: { five: 'whatup' } } } } } - t.notDeepEqual(to.extend(to.clone(actual), {test: 'yo'}), actual, - 'the cloned object should not equal the original object') + let test_one = to.clone(actual) + test_one.test = 'yo' + t.ok(actual.test === undefined, + '`acutal.test` should not be defined') + t.ok(test_one.test === 'yo', + '`test_one.test` should equal yo') t.deepEqual(actual, expected, 'the actual object should remain the same as the expected object') t.end() @@ -179,8 +183,8 @@ test('to.flatten', (t) => { }) -test('to.unique_array', (t) => { - t.is(to.unique_array(['one', 'one', 'two', 'two']).length, 2, +test('to.unique', (t) => { + t.is(to.unique(['one', 'one', 'two', 'two']).length, 2, 'should have a length of 2') t.end() }) From 62013581963e388db019cb581ce75eeb1b4c8fd4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 2 Nov 2015 08:10:52 -0500 Subject: [PATCH 163/273] Added test files for annotations These don't currently have test cases, this commit is just to get them out of my current working area :thumbsup: --- app/tests/annotations/access.test.js | 0 app/tests/annotations/alias.test.js | 0 app/tests/annotations/arg.test.js | 0 app/tests/annotations/author.test.js | 9 +++++++++ app/tests/annotations/chainable.test.js | 0 app/tests/annotations/depricated.test.js | 0 app/tests/annotations/description.test.js | 0 app/tests/annotations/markup.test.js | 0 app/tests/annotations/name.test.js | 0 app/tests/annotations/note.test.js | 0 app/tests/annotations/page.test.js | 0 app/tests/annotations/readonly.test.js | 0 app/tests/annotations/requires.test.js | 0 app/tests/annotations/returns.test.js | 0 app/tests/annotations/since.test.js | 0 app/tests/annotations/state.test.js | 0 app/tests/annotations/todo.test.js | 0 app/tests/annotations/type.test.js | 0 app/tests/annotations/version.test.js | 0 19 files changed, 9 insertions(+) create mode 100644 app/tests/annotations/access.test.js create mode 100644 app/tests/annotations/alias.test.js create mode 100644 app/tests/annotations/arg.test.js create mode 100644 app/tests/annotations/author.test.js create mode 100644 app/tests/annotations/chainable.test.js create mode 100644 app/tests/annotations/depricated.test.js create mode 100644 app/tests/annotations/description.test.js create mode 100644 app/tests/annotations/markup.test.js create mode 100644 app/tests/annotations/name.test.js create mode 100644 app/tests/annotations/note.test.js create mode 100644 app/tests/annotations/page.test.js create mode 100644 app/tests/annotations/readonly.test.js create mode 100644 app/tests/annotations/requires.test.js create mode 100644 app/tests/annotations/returns.test.js create mode 100644 app/tests/annotations/since.test.js create mode 100644 app/tests/annotations/state.test.js create mode 100644 app/tests/annotations/todo.test.js create mode 100644 app/tests/annotations/type.test.js create mode 100644 app/tests/annotations/version.test.js diff --git a/app/tests/annotations/access.test.js b/app/tests/annotations/access.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/alias.test.js b/app/tests/annotations/alias.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/arg.test.js b/app/tests/annotations/arg.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/author.test.js b/app/tests/annotations/author.test.js new file mode 100644 index 0000000..e2141f9 --- /dev/null +++ b/app/tests/annotations/author.test.js @@ -0,0 +1,9 @@ +import test from 'tape' +import { author } from '../../annotations' + + +test('author test yo', (t) => { + console.log(author); + t.pass('yo bitch') + t.end() +}) \ No newline at end of file diff --git a/app/tests/annotations/chainable.test.js b/app/tests/annotations/chainable.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/depricated.test.js b/app/tests/annotations/depricated.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/description.test.js b/app/tests/annotations/description.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/markup.test.js b/app/tests/annotations/markup.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/name.test.js b/app/tests/annotations/name.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/note.test.js b/app/tests/annotations/note.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/page.test.js b/app/tests/annotations/page.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/readonly.test.js b/app/tests/annotations/readonly.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/requires.test.js b/app/tests/annotations/requires.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/returns.test.js b/app/tests/annotations/returns.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/since.test.js b/app/tests/annotations/since.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/state.test.js b/app/tests/annotations/state.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/todo.test.js b/app/tests/annotations/todo.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/type.test.js b/app/tests/annotations/type.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/annotations/version.test.js b/app/tests/annotations/version.test.js new file mode 100644 index 0000000..e69de29 From 32c3452cdb59b6b23e69a45c494bdd7b5e279c48 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 2 Nov 2015 08:13:47 -0500 Subject: [PATCH 164/273] added some test cases for the new `@state`, and `@markup` --- tests/lib/scss/test.scss | 149 ++++++++++++++++++++++++++++++--------- 1 file changed, 117 insertions(+), 32 deletions(-) diff --git a/tests/lib/scss/test.scss b/tests/lib/scss/test.scss index c50e811..c14c501 100755 --- a/tests/lib/scss/test.scss +++ b/tests/lib/scss/test.scss @@ -3,42 +3,127 @@ /// @page tests/scss-file //// +/// @name state test +/// @state (ermahgerd) +/// {:hover, :focus} - pseudo class stuff +/// {.something-else} [unique_identifier] - some really cool shit +/// +/// @state (ermahgerd) +/// {:active} - pseudo class stuff +/// {.something-else} [unique_identifier] - some other really cool shit +/// +/// @markup (ermahgerd) {html} **Example** Some example +///
+///
+/// {@state.unique_identifier.description} +///
+///
+/// +/// @state (ermahgerd-two) +/// {:hover, :focus} - pseudo class stuff +/// {.something-else} - some really cool shit +/// +/// @state (ermahgerd-two) +/// {:active} - pseudo class stuff +/// {.something-else} - some other really cool shit +/// +/// @markup (ermahgerd-two) {html} **Example** Some other example +///
+///
+/// {@state[1].description} +///
+///
+ + + + /// @name moz-only +/// @access someshit /// @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: ""; +/// @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; - } +@mixin moz-only() { + $selector: &; + @at-root { + @-moz-document url-prefix() { + #{$selector}{ + @content; + } + } } - } -} - -/// @name Test one -/// @page tests/all -/// @state .state-1 -/// @state .state-2 -/// @state .state-3 -/// @description -/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. -/// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore -/// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis -/// iste nostrum vel, culpa iure. Adipisci. -.foo{ - } +// @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--small} - A tiny button +// @state {.c-btn--medium} - A medium button +// @state {.c-btn--large} - A large button +// @state {.c-btn--huge} - A huge button +// @state {.c-btn--massive} - A massive button +// @state {.c-btn--primary} - Primary action +// @state {.c-btn--primary:hover} +// @state {.c-btn--primary:active} +// @state {.c-btn--secondary} - Secondary action +// @state {.c-btn--secondary:hover} +// @state {.c-btn--secondary:active} +// @state {.c-btn--tertiary} - Tertiary action +// @state {.c-btn--tertiary}:hover +// @state {.c-btn--tertiary}:active +// @state {.c-btn--text} - It's a text link as a button +// @state {.c-btn--text:hover} +// @state {.c-btn--text:active} +// +// @markup +//
+// Button (anchor) +// +// +//
+.c-btn { + background: color(a); + border: none; + border-radius: get($config, border-radius); + display: inline-block; + font-size: 1em; + font-weight: bold; + line-height: 1em; + padding: em(13px) 1.5em; + text-align: center; + transition: background 0.25s ease-out, color 0.25s ease-out; + vertical-align: middle; + width: auto; // this resets the input style of 100% + &, &:hover, &:active, &:focus { + color: #fff; + text-decoration: none; + } + &:hover { + background: color(a, -2); + } + &:active, &:focus { + background: color(a, 2); + } + &:disabled { + opacity: 0.5; + } +} \ No newline at end of file From 2d7181b24f71ae44b2327a77e08e54bdabd81cfb Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 2 Nov 2015 09:03:18 -0500 Subject: [PATCH 165/273] Changed `./tests` to `./examples` --- app/docs.js | 16 +- {tests => examples}/lib/c#/README.md | 0 {tests => examples}/lib/c#/test.cs | 0 {tests => examples}/lib/c++/README.md | 0 {tests => examples}/lib/c++/test.c | 0 {tests => examples}/lib/c/README.md | 0 {tests => examples}/lib/c/test.c | 0 .../lib/coffeescript/README.md | 0 .../lib/coffeescript/test.coffee | 0 {tests => examples}/lib/coldfusion/README.md | 0 {tests => examples}/lib/coldfusion/test.cfm | 0 {tests => examples}/lib/css/test.css | 0 .../4-blank-lines-between-code-blocks.scss | 0 .../lib/edge-cases/empty-file.scss | 0 .../lib/edge-cases/ends-with-empty-lines.scss | 0 .../lib/edge-cases/header-comment-only.scss | 0 ...pace-between-header-and-body-comments.scss | 0 .../lib/edge-cases/only-body-comments.scss | 0 .../lib/edge-cases/only-comments.scss | 0 .../lib/edge-cases/preserves-blank-lines.scss | 0 .../single-body-comment-no-code.scss | 0 .../lib/edge-cases/single-body-comment.scss | 0 .../space-between-comment-and-code.scss | 0 .../starts-and-ends-with-spaces.scss | 0 .../edge-cases/starts-with-empty-lines.scss | 0 {tests => examples}/lib/html/README.md | 0 {tests => examples}/lib/html/test.html | 0 {tests => examples}/lib/java/README.md | 0 {tests => examples}/lib/java/test.java | 0 {tests => examples}/lib/js/test.js | 0 {tests => examples}/lib/less/README.md | 0 {tests => examples}/lib/less/test.less | 0 {tests => examples}/lib/md/markdown.md | 0 {tests => examples}/lib/php/README.md | 0 {tests => examples}/lib/php/test.php | 0 {tests => examples}/lib/python/README.md | 0 {tests => examples}/lib/python/test.py | 0 {tests => examples}/lib/ruby/README.md | 0 {tests => examples}/lib/ruby/test.rb | 0 {tests => examples}/lib/scss/test.scss | 0 {tests => examples}/lib/stylus/README.md | 0 {tests => examples}/lib/stylus/test.styl | 0 {tests => examples}/lib/swift/README.md | 0 {tests => examples}/lib/swift/test.swift | 0 {tests => examples}/package.json | 5 +- tests/Makefile | 9 - tests/test.json | 1412 ----------------- 47 files changed, 10 insertions(+), 1432 deletions(-) rename {tests => examples}/lib/c#/README.md (100%) rename {tests => examples}/lib/c#/test.cs (100%) rename {tests => examples}/lib/c++/README.md (100%) rename {tests => examples}/lib/c++/test.c (100%) rename {tests => examples}/lib/c/README.md (100%) rename {tests => examples}/lib/c/test.c (100%) rename {tests => examples}/lib/coffeescript/README.md (100%) rename {tests => examples}/lib/coffeescript/test.coffee (100%) rename {tests => examples}/lib/coldfusion/README.md (100%) rename {tests => examples}/lib/coldfusion/test.cfm (100%) rename {tests => examples}/lib/css/test.css (100%) rename {tests => examples}/lib/edge-cases/4-blank-lines-between-code-blocks.scss (100%) rename {tests => examples}/lib/edge-cases/empty-file.scss (100%) rename {tests => examples}/lib/edge-cases/ends-with-empty-lines.scss (100%) rename {tests => examples}/lib/edge-cases/header-comment-only.scss (100%) rename {tests => examples}/lib/edge-cases/no-space-between-header-and-body-comments.scss (100%) rename {tests => examples}/lib/edge-cases/only-body-comments.scss (100%) rename {tests => examples}/lib/edge-cases/only-comments.scss (100%) rename {tests => examples}/lib/edge-cases/preserves-blank-lines.scss (100%) rename {tests => examples}/lib/edge-cases/single-body-comment-no-code.scss (100%) rename {tests => examples}/lib/edge-cases/single-body-comment.scss (100%) rename {tests => examples}/lib/edge-cases/space-between-comment-and-code.scss (100%) rename {tests => examples}/lib/edge-cases/starts-and-ends-with-spaces.scss (100%) rename {tests => examples}/lib/edge-cases/starts-with-empty-lines.scss (100%) rename {tests => examples}/lib/html/README.md (100%) rename {tests => examples}/lib/html/test.html (100%) rename {tests => examples}/lib/java/README.md (100%) rename {tests => examples}/lib/java/test.java (100%) rename {tests => examples}/lib/js/test.js (100%) rename {tests => examples}/lib/less/README.md (100%) rename {tests => examples}/lib/less/test.less (100%) rename {tests => examples}/lib/md/markdown.md (100%) rename {tests => examples}/lib/php/README.md (100%) rename {tests => examples}/lib/php/test.php (100%) rename {tests => examples}/lib/python/README.md (100%) rename {tests => examples}/lib/python/test.py (100%) rename {tests => examples}/lib/ruby/README.md (100%) rename {tests => examples}/lib/ruby/test.rb (100%) rename {tests => examples}/lib/scss/test.scss (100%) rename {tests => examples}/lib/stylus/README.md (100%) rename {tests => examples}/lib/stylus/test.styl (100%) rename {tests => examples}/lib/swift/README.md (100%) rename {tests => examples}/lib/swift/test.swift (100%) rename {tests => examples}/package.json (67%) delete mode 100644 tests/Makefile delete mode 100644 tests/test.json diff --git a/app/docs.js b/app/docs.js index 5323bd4..a684783 100644 --- a/app/docs.js +++ b/app/docs.js @@ -1,10 +1,5 @@ 'use strict'; -process.on('uncaughtException', function(err) { - log.error('An uncaughtException was found:', err.stack) - process.exit(1) -}) - import co from 'co' import path from 'path' import { info, fs, is, to, glob, array, Logger } from './utils' @@ -102,9 +97,16 @@ async function has_file_changed(file) { } else { return false } - } catch(err) { + } catch (err) { // copies new files over because it doesn't exist in the temp target directory fs.fake_copy(source, target) return true } -} \ No newline at end of file +} + + +let logger = new Logger() +process.on('uncaughtException', function(err) { + logger.error('An uncaughtException was found:', err.stack) + process.exit(1) +}) diff --git a/tests/lib/c#/README.md b/examples/lib/c#/README.md similarity index 100% rename from tests/lib/c#/README.md rename to examples/lib/c#/README.md diff --git a/tests/lib/c#/test.cs b/examples/lib/c#/test.cs similarity index 100% rename from tests/lib/c#/test.cs rename to examples/lib/c#/test.cs diff --git a/tests/lib/c++/README.md b/examples/lib/c++/README.md similarity index 100% rename from tests/lib/c++/README.md rename to examples/lib/c++/README.md diff --git a/tests/lib/c++/test.c b/examples/lib/c++/test.c similarity index 100% rename from tests/lib/c++/test.c rename to examples/lib/c++/test.c diff --git a/tests/lib/c/README.md b/examples/lib/c/README.md similarity index 100% rename from tests/lib/c/README.md rename to examples/lib/c/README.md diff --git a/tests/lib/c/test.c b/examples/lib/c/test.c similarity index 100% rename from tests/lib/c/test.c rename to examples/lib/c/test.c diff --git a/tests/lib/coffeescript/README.md b/examples/lib/coffeescript/README.md similarity index 100% rename from tests/lib/coffeescript/README.md rename to examples/lib/coffeescript/README.md diff --git a/tests/lib/coffeescript/test.coffee b/examples/lib/coffeescript/test.coffee similarity index 100% rename from tests/lib/coffeescript/test.coffee rename to examples/lib/coffeescript/test.coffee diff --git a/tests/lib/coldfusion/README.md b/examples/lib/coldfusion/README.md similarity index 100% rename from tests/lib/coldfusion/README.md rename to examples/lib/coldfusion/README.md diff --git a/tests/lib/coldfusion/test.cfm b/examples/lib/coldfusion/test.cfm similarity index 100% rename from tests/lib/coldfusion/test.cfm rename to examples/lib/coldfusion/test.cfm diff --git a/tests/lib/css/test.css b/examples/lib/css/test.css similarity index 100% rename from tests/lib/css/test.css rename to examples/lib/css/test.css diff --git a/tests/lib/edge-cases/4-blank-lines-between-code-blocks.scss b/examples/lib/edge-cases/4-blank-lines-between-code-blocks.scss similarity index 100% rename from tests/lib/edge-cases/4-blank-lines-between-code-blocks.scss rename to examples/lib/edge-cases/4-blank-lines-between-code-blocks.scss diff --git a/tests/lib/edge-cases/empty-file.scss b/examples/lib/edge-cases/empty-file.scss similarity index 100% rename from tests/lib/edge-cases/empty-file.scss rename to examples/lib/edge-cases/empty-file.scss diff --git a/tests/lib/edge-cases/ends-with-empty-lines.scss b/examples/lib/edge-cases/ends-with-empty-lines.scss similarity index 100% rename from tests/lib/edge-cases/ends-with-empty-lines.scss rename to examples/lib/edge-cases/ends-with-empty-lines.scss diff --git a/tests/lib/edge-cases/header-comment-only.scss b/examples/lib/edge-cases/header-comment-only.scss similarity index 100% rename from tests/lib/edge-cases/header-comment-only.scss rename to examples/lib/edge-cases/header-comment-only.scss diff --git a/tests/lib/edge-cases/no-space-between-header-and-body-comments.scss b/examples/lib/edge-cases/no-space-between-header-and-body-comments.scss similarity index 100% rename from tests/lib/edge-cases/no-space-between-header-and-body-comments.scss rename to examples/lib/edge-cases/no-space-between-header-and-body-comments.scss diff --git a/tests/lib/edge-cases/only-body-comments.scss b/examples/lib/edge-cases/only-body-comments.scss similarity index 100% rename from tests/lib/edge-cases/only-body-comments.scss rename to examples/lib/edge-cases/only-body-comments.scss diff --git a/tests/lib/edge-cases/only-comments.scss b/examples/lib/edge-cases/only-comments.scss similarity index 100% rename from tests/lib/edge-cases/only-comments.scss rename to examples/lib/edge-cases/only-comments.scss diff --git a/tests/lib/edge-cases/preserves-blank-lines.scss b/examples/lib/edge-cases/preserves-blank-lines.scss similarity index 100% rename from tests/lib/edge-cases/preserves-blank-lines.scss rename to examples/lib/edge-cases/preserves-blank-lines.scss diff --git a/tests/lib/edge-cases/single-body-comment-no-code.scss b/examples/lib/edge-cases/single-body-comment-no-code.scss similarity index 100% rename from tests/lib/edge-cases/single-body-comment-no-code.scss rename to examples/lib/edge-cases/single-body-comment-no-code.scss diff --git a/tests/lib/edge-cases/single-body-comment.scss b/examples/lib/edge-cases/single-body-comment.scss similarity index 100% rename from tests/lib/edge-cases/single-body-comment.scss rename to examples/lib/edge-cases/single-body-comment.scss diff --git a/tests/lib/edge-cases/space-between-comment-and-code.scss b/examples/lib/edge-cases/space-between-comment-and-code.scss similarity index 100% rename from tests/lib/edge-cases/space-between-comment-and-code.scss rename to examples/lib/edge-cases/space-between-comment-and-code.scss diff --git a/tests/lib/edge-cases/starts-and-ends-with-spaces.scss b/examples/lib/edge-cases/starts-and-ends-with-spaces.scss similarity index 100% rename from tests/lib/edge-cases/starts-and-ends-with-spaces.scss rename to examples/lib/edge-cases/starts-and-ends-with-spaces.scss diff --git a/tests/lib/edge-cases/starts-with-empty-lines.scss b/examples/lib/edge-cases/starts-with-empty-lines.scss similarity index 100% rename from tests/lib/edge-cases/starts-with-empty-lines.scss rename to examples/lib/edge-cases/starts-with-empty-lines.scss diff --git a/tests/lib/html/README.md b/examples/lib/html/README.md similarity index 100% rename from tests/lib/html/README.md rename to examples/lib/html/README.md diff --git a/tests/lib/html/test.html b/examples/lib/html/test.html similarity index 100% rename from tests/lib/html/test.html rename to examples/lib/html/test.html diff --git a/tests/lib/java/README.md b/examples/lib/java/README.md similarity index 100% rename from tests/lib/java/README.md rename to examples/lib/java/README.md diff --git a/tests/lib/java/test.java b/examples/lib/java/test.java similarity index 100% rename from tests/lib/java/test.java rename to examples/lib/java/test.java diff --git a/tests/lib/js/test.js b/examples/lib/js/test.js similarity index 100% rename from tests/lib/js/test.js rename to examples/lib/js/test.js diff --git a/tests/lib/less/README.md b/examples/lib/less/README.md similarity index 100% rename from tests/lib/less/README.md rename to examples/lib/less/README.md diff --git a/tests/lib/less/test.less b/examples/lib/less/test.less similarity index 100% rename from tests/lib/less/test.less rename to examples/lib/less/test.less diff --git a/tests/lib/md/markdown.md b/examples/lib/md/markdown.md similarity index 100% rename from tests/lib/md/markdown.md rename to examples/lib/md/markdown.md diff --git a/tests/lib/php/README.md b/examples/lib/php/README.md similarity index 100% rename from tests/lib/php/README.md rename to examples/lib/php/README.md diff --git a/tests/lib/php/test.php b/examples/lib/php/test.php similarity index 100% rename from tests/lib/php/test.php rename to examples/lib/php/test.php diff --git a/tests/lib/python/README.md b/examples/lib/python/README.md similarity index 100% rename from tests/lib/python/README.md rename to examples/lib/python/README.md diff --git a/tests/lib/python/test.py b/examples/lib/python/test.py similarity index 100% rename from tests/lib/python/test.py rename to examples/lib/python/test.py diff --git a/tests/lib/ruby/README.md b/examples/lib/ruby/README.md similarity index 100% rename from tests/lib/ruby/README.md rename to examples/lib/ruby/README.md diff --git a/tests/lib/ruby/test.rb b/examples/lib/ruby/test.rb similarity index 100% rename from tests/lib/ruby/test.rb rename to examples/lib/ruby/test.rb diff --git a/tests/lib/scss/test.scss b/examples/lib/scss/test.scss similarity index 100% rename from tests/lib/scss/test.scss rename to examples/lib/scss/test.scss diff --git a/tests/lib/stylus/README.md b/examples/lib/stylus/README.md similarity index 100% rename from tests/lib/stylus/README.md rename to examples/lib/stylus/README.md diff --git a/tests/lib/stylus/test.styl b/examples/lib/stylus/test.styl similarity index 100% rename from tests/lib/stylus/test.styl rename to examples/lib/stylus/test.styl diff --git a/tests/lib/swift/README.md b/examples/lib/swift/README.md similarity index 100% rename from tests/lib/swift/README.md rename to examples/lib/swift/README.md diff --git a/tests/lib/swift/test.swift b/examples/lib/swift/test.swift similarity index 100% rename from tests/lib/swift/test.swift rename to examples/lib/swift/test.swift diff --git a/tests/package.json b/examples/package.json similarity index 67% rename from tests/package.json rename to examples/package.json index e377110..a8b5459 100644 --- a/tests/package.json +++ b/examples/package.json @@ -5,8 +5,5 @@ }, "engines": { "node": ">=0.10.0" - }, - "devDependencies": { - "gulp": "^3.8.11" } -} +} \ No newline at end of file diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index ac42d19..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -rebuild: - rm -rf node_modules/ - npm i - -build: - rm -rf node_modules/docs - rm -rf .tmp/ - npm i - gulp \ No newline at end of file diff --git a/tests/test.json b/tests/test.json deleted file mode 100644 index 6deb177..0000000 --- a/tests/test.json +++ /dev/null @@ -1,1412 +0,0 @@ -{ - "nav": [ - { - "title": "C", - "href": "/c", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/c/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/c/tests/c-file", - "body": [ - { - "title": "main", - "href": "/c/tests/c-file#main" - }, - { - "title": "Something", - "href": "/c/tests/c-file#something" - }, - { - "title": "Something else", - "href": "/c/tests/c-file#something-else" - } - ], - "subpages": [] - }, - { - "title": "Test", - "href": "/c/tests/c++-file", - "body": [ - { - "title": "main", - "href": "/c/tests/c++-file#main" - }, - { - "title": "Something", - "href": "/c/tests/c++-file#something" - }, - { - "title": "Something else", - "href": "/c/tests/c++-file#something-else" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Cs", - "href": "/cs", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/cs/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/cs/tests/c#-file", - "body": [ - { - "title": "main", - "href": "/cs/tests/c#-file#main" - }, - { - "title": "Something", - "href": "/cs/tests/c#-file#something" - }, - { - "title": "Something else", - "href": "/cs/tests/c#-file#something-else" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Coffee", - "href": "/coffee", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/coffee/general", - "body": [], - "subpages": [] - } - ] - }, - { - "title": "Cfm", - "href": "/cfm", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/cfm/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/cfm/tests/cfm-file", - "body": [ - { - "title": "main", - "href": "/cfm/tests/cfm-file#main" - }, - { - "title": "John Doe", - "href": "/cfm/tests/cfm-file#john-doe" - }, - { - "title": "Something else", - "href": "/cfm/tests/cfm-file#something-else" - }, - { - "title": "Bob", - "href": "/cfm/tests/cfm-file#bob" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Css", - "href": "/css", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/css/test", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/css/test/css-file", - "body": [ - { - "title": "Base Styles", - "href": "/css/test/css-file#base-styles" - }, - { - "title": "Input", - "href": "/css/test/css-file#input" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Scss", - "href": "/scss", - "body": [], - "subpages": [ - { - "title": "Edge Cases", - "href": "/scss/edge-cases", - "body": [], - "subpages": [ - { - "title": "4-Blank-Lines-Between-Code-Blocks", - "href": "/scss/edge-cases/4-blank-lines-between-code-blocks", - "body": [ - { - "title": "moz-only", - "href": "/scss/edge-cases/4-blank-lines-between-code-blocks#moz-only" - } - ], - "subpages": [] - }, - { - "title": [ - "Ends-With-Empty-Lines", - "Space-Between-Comment-and-Code" - ], - "href": "/scss/edge-cases/ends-with-empty-lines", - "body": [ - { - "title": "Only block in body", - "href": "/scss/edge-cases/ends-with-empty-lines#only-block-in-body" - }, - { - "title": "Space between comment bock and code block", - "href": "/scss/edge-cases/ends-with-empty-lines#space-between-comment-bock-and-code-block" - }, - { - "title": "No space between", - "href": "/scss/edge-cases/ends-with-empty-lines#no-space-between" - } - ], - "subpages": [] - }, - { - "title": "Header", - "href": "/scss/edge-cases/header-comment-only", - "body": [], - "subpages": [] - }, - { - "title": "No-Space-Between-Header-and-Body-Comments", - "href": "/scss/edge-cases/no-space-between-header-and-body-comment", - "body": [ - { - "title": "moz-only", - "href": "/scss/edge-cases/no-space-between-header-and-body-comment#moz-only" - } - ], - "subpages": [] - }, - { - "title": "Only-Comments", - "href": "/scss/edge-cases/only-comments", - "body": [ - { - "title": "moz-only", - "href": "/scss/edge-cases/only-comments#moz-only" - } - ], - "subpages": [] - }, - { - "title": "Starts-and-Ends-With-Spaces", - "href": "/scss/edge-cases/starts-and-ends-with-empty-lines", - "body": [ - { - "title": "Only block in body", - "href": "/scss/edge-cases/starts-and-ends-with-empty-lines#only-block-in-body" - } - ], - "subpages": [] - }, - { - "title": "Starts-With-Empty-Lines", - "href": "/scss/edge-cases/starts-with-empty-lines", - "body": [ - { - "title": "Only block in body", - "href": "/scss/edge-cases/starts-with-empty-lines#only-block-in-body" - } - ], - "subpages": [] - } - ] - }, - { - "title": [ - "Empty-File", - "Only-Body-Comments", - "Preserves-Blank-Lines", - "Single-Body-Comment-No-Code", - "Single-Body-Comment" - ], - "href": "/scss/general", - "body": [ - { - "title": "Button group", - "href": "/scss/general#button-group" - }, - { - "title": "moz-only", - "href": "/scss/general#moz-only" - } - ], - "subpages": [] - }, - { - "title": "Tests", - "href": "/scss/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/scss/tests/scss-file", - "body": [ - { - "title": "moz-only", - "href": "/scss/tests/scss-file#moz-only" - }, - { - "title": "Test one", - "href": "/scss/tests/scss-file#test-one" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Components", - "href": "/components", - "body": [], - "subpages": [ - { - "title": "Buttons", - "href": "/components/buttons", - "body": [], - "subpages": [] - } - ] - }, - { - "title": "Tests", - "href": "/tests", - "body": [], - "subpages": [ - { - "title": "All", - "href": "/tests/all", - "body": [ - { - "title": "Test one", - "href": "/tests/all#test-one" - } - ], - "subpages": [] - } - ] - }, - { - "title": "Html", - "href": "/html", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/html/tests", - "body": [], - "subpages": [ - { - "title": "Header", - "href": "/html/tests/html-file", - "body": [ - { - "title": "Body Block 1", - "href": "/html/tests/html-file#body-block-1" - }, - { - "title": "Body Block 2", - "href": "/html/tests/html-file#body-block-2" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Java", - "href": "/java", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/java/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/java/tests/java-file", - "body": [ - { - "title": "Body Block 1", - "href": "/java/tests/java-file#body-block-1" - }, - { - "title": "Body Block 2", - "href": "/java/tests/java-file#body-block-2" - }, - { - "title": "Body Block 3", - "href": "/java/tests/java-file#body-block-3" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Js", - "href": "/js", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/js/general", - "body": [], - "subpages": [] - } - ] - }, - { - "title": "Less", - "href": "/less", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/less/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/less/tests/less-test", - "body": [ - { - "title": "base color", - "href": "/less/tests/less-test#base-color" - }, - { - "title": "Nav", - "href": "/less/tests/less-test#nav" - }, - { - "title": "Button group", - "href": "/less/tests/less-test#button-group" - }, - { - "title": "Opacity", - "href": "/less/tests/less-test#opacity" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Php", - "href": "/php", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/php/tests", - "body": [], - "subpages": [ - { - "title": "Header", - "href": "/php/tests/php-file", - "body": [ - { - "title": "Body block 1", - "href": "/php/tests/php-file#body-block-1" - }, - { - "title": "Body block 2", - "href": "/php/tests/php-file#body-block-2" - }, - { - "title": "Body block 3", - "href": "/php/tests/php-file#body-block-3" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Py", - "href": "/py", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/py/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/py/tests/py-file", - "body": [ - { - "title": "main", - "href": "/py/tests/py-file#main" - }, - { - "title": "something", - "href": "/py/tests/py-file#something" - }, - { - "title": "something else", - "href": "/py/tests/py-file#something-else" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Rb", - "href": "/rb", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/rb/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/rb/tests/rb-file", - "body": [ - { - "title": "main", - "href": "/rb/tests/rb-file#main" - }, - { - "title": "Something", - "href": "/rb/tests/rb-file#something" - }, - { - "title": "Something else", - "href": "/rb/tests/rb-file#something-else" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Styl", - "href": "/styl", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/styl/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/styl/tests/styl-file", - "body": [ - { - "title": "main", - "href": "/styl/tests/styl-file#main" - }, - { - "title": "Somethin", - "href": "/styl/tests/styl-file#somethin" - }, - { - "title": "Something else", - "href": "/styl/tests/styl-file#something-else" - } - ], - "subpages": [] - } - ] - } - ] - }, - { - "title": "Swift", - "href": "/swift", - "body": [], - "subpages": [ - { - "title": "Tests", - "href": "/swift/tests", - "body": [], - "subpages": [ - { - "title": "Test", - "href": "/swift/tests/swift-file", - "body": [ - { - "title": "main", - "href": "/swift/tests/swift-file#main" - }, - { - "title": "Something", - "href": "/swift/tests/swift-file#something" - }, - { - "title": "Something else", - "href": "/swift/tests/swift-file#something-else" - } - ], - "subpages": [] - } - ] - } - ] - } - ], - "pages": { - "c": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "c-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

main method

\n" - }, - { - "name": "Something", - "description": "

This is a normal multi-line comment.

\n" - }, - { - "name": "Something else", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - }, - "c++-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

main method

\n" - }, - { - "name": "Something", - "description": "

This is a normal multi-line comment.

\n" - }, - { - "name": "Something else", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - } - } - }, - "cs": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "c#-file": { - "page": { - "header": { - "author": "Tyler Benton", - "description": "

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

\n", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

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

\n" - }, - { - "name": "Something", - "description": "

This is a normal multi-line comment.

\n" - }, - { - "name": "Something else", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - } - } - }, - "coffee": { - "page": { - "header": {}, - "body": [] - }, - "general": { - "page": { - "header": { - "name": "Test" - }, - "body": [] - } - } - }, - "cfm": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "cfm-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

main method

\n" - }, - { - "name": "John Doe", - "description": "

This is a normal multi-line coldfusion comment.

\n" - }, - { - "name": "Something else", - "description": "

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

\n" - }, - { - "name": "Bob", - "description": "

This is another normal multi-line coldfusion comment.

\n" - } - ] - } - } - } - }, - "css": { - "page": { - "header": {}, - "body": [] - }, - "test": { - "page": { - "header": {}, - "body": [] - }, - "css-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "Base Styles", - "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n" - }, - { - "name": "Input", - "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n" - } - ] - } - } - } - }, - "scss": { - "page": { - "header": {}, - "body": [] - }, - "edge-cases": { - "page": { - "header": {}, - "body": [] - }, - "4-blank-lines-between-code-blocks": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "4-Blank-Lines-Between-Code-Blocks" - }, - "body": [ - { - "name": "moz-only", - "author": "Tyler Benton", - "description": "

This allows you to write specific styles for mozilla firefox only

\n", - "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" - } - ] - } - }, - "ends-with-empty-lines": { - "page": { - "header": { - "author": [ - "Tyler Benton" - ], - "name": [ - "Ends-With-Empty-Lines", - "Space-Between-Comment-and-Code" - ] - }, - "body": [ - { - "name": "Only block in body", - "author": "Tyler Benton", - "description": "

This allows you to write specific styles for mozilla firefox only

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

This allows you to write specific styles for mozilla firefox only

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

A simple nav component, used to help with navigation

\n", - "markup": "" - } - ] - } - }, - "header-comment-only": { - "page": { - "header": { - "name": "Header", - "author": "Tyler Benton", - "description": "

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

\n" - }, - "body": [] - } - }, - "no-space-between-header-and-body-comment": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "No-Space-Between-Header-and-Body-Comments" - }, - "body": [ - { - "name": "moz-only", - "author": "Tyler Benton", - "description": "

This allows you to write specific styles for mozilla firefox only

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

This allows you to write specific styles for mozilla firefox only

\n", - "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" - } - ] - } - }, - "starts-and-ends-with-empty-lines": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Starts-and-Ends-With-Spaces" - }, - "body": [ - { - "name": "Only block in body", - "author": "Tyler Benton", - "description": "

This allows you to write specific styles for mozilla firefox only

\n", - "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" - } - ] - } - }, - "starts-with-empty-lines": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Starts-With-Empty-Lines" - }, - "body": [ - { - "name": "Only block in body", - "author": "Tyler Benton", - "description": "

This allows you to write specific styles for mozilla firefox only

\n", - "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" - } - ] - } - } - }, - "general": { - "page": { - "header": { - "name": [ - "Empty-File", - "Only-Body-Comments", - "Preserves-Blank-Lines", - "Single-Body-Comment-No-Code", - "Single-Body-Comment" - ] - }, - "body": [ - { - "author": "Tyler Benton", - "description": "

Your standard form button.

\n", - "state": [ - ":hover", - ":active", - ":disabled - Dims the button when disabled.", - ".c-btn--mini - A mini button", - ".c-btn--tiny - A tiny button", - ".c-btn--medium - A medium button", - ".c-btn--large - A large button", - ".c-btn--primary - Primary action", - ".c-btn--primary:hover", - ".c-btn--primary:active", - ".c-btn--secondary - Secondary action", - ".c-btn--secondary:hover", - ".c-btn--secondary:active", - ".c-btn--tertiary - Tertiary action", - ".c-btn--tertiary:hover", - ".c-btn--tertiary:active", - ".c-btn--text - It's a text link as a button", - ".c-btn--text:hover", - ".c-btn--text:active" - ], - "markup": "
\n Button (a.button)\n \n \n
" - }, - { - "name": "Button group", - "description": "

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

\n", - "markup": "
\n Button (a.button)\n \n \n
" - }, - { - "name": "moz-only", - "author": "Tyler Benton", - "description": "

This allows you to write specific styles for mozilla firefox only

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

This allows you to write specific styles for mozilla firefox only

\n", - "markup": "@include moz-only(){\n // removes the weird styling in firefox\n -moz-appearance: none;\n padding: {\n top: nth-val(get($form-config, padding), 1) - .2em;\n bottom: nth-val(get($form-config, padding), 3) - .2em;\n };\n text-indent: 0.01px;\n text-overflow: \"\";\n}" - }, - { - "name": "Test one", - "state": [ - ".state-1", - ".state-2", - ".state-3" - ], - "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" - } - ] - } - } - } - }, - "components": { - "page": { - "header": {}, - "body": [] - }, - "buttons": { - "page": { - "header": {}, - "body": [ - { - "author": "Tyler Benton", - "description": "

Your standard form button.

\n", - "state": [ - ":hover", - ":active", - ":disabled - Dims the button when disabled.", - ".c-btn--mini - A mini button", - ".c-btn--tiny - A tiny button", - ".c-btn--medium - A medium button", - ".c-btn--large - A large button", - ".c-btn--primary - Primary action", - ".c-btn--primary:hover", - ".c-btn--primary:active", - ".c-btn--secondary - Secondary action", - ".c-btn--secondary:hover", - ".c-btn--secondary:active", - ".c-btn--tertiary - Tertiary action", - ".c-btn--tertiary:hover", - ".c-btn--tertiary:active", - ".c-btn--text - It's a text link as a button", - ".c-btn--text:hover", - ".c-btn--text:active" - ], - "markup": "
\n Button (a.button)\n \n \n
" - }, - { - "author": "Tyler Benton", - "description": "

Your standard form button.

\n", - "state": [ - ":hover", - ":active", - ":disabled - Dims the button when disabled.", - ".c-btn--mini - A mini button", - ".c-btn--tiny - A tiny button", - ".c-btn--medium - A medium button", - ".c-btn--large - A large button", - ".c-btn--primary - Primary action", - ".c-btn--primary:hover", - ".c-btn--primary:active", - ".c-btn--secondary - Secondary action", - ".c-btn--secondary:hover", - ".c-btn--secondary:active", - ".c-btn--tertiary - Tertiary action", - ".c-btn--tertiary:hover", - ".c-btn--tertiary:active", - ".c-btn--text - It's a text link as a button", - ".c-btn--text:hover", - ".c-btn--text:active" - ], - "markup": "
\n Button (a.button)\n \n \n
" - } - ] - } - } - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "all": { - "page": { - "header": {}, - "body": [ - { - "name": "Test one", - "state": [ - ".state-1", - ".state-2", - ".state-3" - ], - "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" - } - ] - } - } - }, - "html": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "html-file": { - "page": { - "header": { - "name": "Header", - "author": "Tyler Benton" - }, - "body": [ - { - "name": "Body Block 1", - "description": "

This is the main header of the site

\n" - }, - { - "name": "Body Block 2", - "description": "

This is the main footer of the site

\n" - } - ] - } - } - } - }, - "java": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "java-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "Body Block 1", - "description": "

A very simple class to print out Hello World

\n" - }, - { - "name": "Body Block 2", - "description": "

This is a normal multi-line comment.

\n" - }, - { - "name": "Body Block 3", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - } - } - }, - "js": { - "page": { - "header": {}, - "body": [] - }, - "general": { - "page": { - "header": { - "name": "Test" - }, - "body": [] - } - } - }, - "less": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "less-test": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "base color", - "type": "{color}" - }, - { - "name": "Nav", - "description": "

A simple nav component, used to help with navigation

\n", - "markup": "" - }, - { - "author": "Tyler Benton", - "description": "

Your standard form button.

\n", - "state": [ - ":hover", - ":active", - ":disabled - Dims the button when disabled.", - ".c-btn--mini - A mini button", - ".c-btn--tiny - A tiny button", - ".c-btn--medium - A medium button", - ".c-btn--large - A large button", - ".c-btn--primary - Primary action", - ".c-btn--primary:hover", - ".c-btn--primary:active", - ".c-btn--secondary - Secondary action", - ".c-btn--secondary:hover", - ".c-btn--secondary:active", - ".c-btn--tertiary - Tertiary action", - ".c-btn--tertiary:hover", - ".c-btn--tertiary:active", - ".c-btn--text - It's a text link as a button", - ".c-btn--text:hover", - ".c-btn--text:active" - ], - "markup": "
\n Button (a.button)\n \n \n
" - }, - { - "name": "Button group", - "description": "

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

\n", - "markup": "
\n Button (a.button)\n \n \n
" - }, - { - "name": "Opacity", - "description": "

A mixin to help with opacity fallbacks

\n", - "arg": "{number} - The opacity you to use, between 0.0 - 1.0", - "markup": ".foo{\n .opacity(.3);\n}" - } - ] - } - } - } - }, - "php": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "php-file": { - "page": { - "header": { - "name": "Header", - "author": "Tyler Benton" - }, - "body": [ - { - "name": "Body block 1", - "description": "

main method

\n" - }, - { - "name": "Body block 2", - "description": "

This is a normal multi-line comment.

\n" - }, - { - "name": "Body block 3", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - } - } - }, - "py": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "py-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

main method

\n" - }, - { - "name": "something", - "description": "

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

\n" - }, - { - "name": "something else", - "description": "

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

\n" - } - ] - } - } - } - }, - "rb": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "rb-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

main method

\n" - }, - { - "name": "Something", - "description": "

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

\n" - }, - { - "name": "Something else", - "description": "

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

\n" - } - ] - } - } - } - }, - "styl": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "styl-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

-\nLorem 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", - "markup": "asdfasdfasdfasdf" - }, - { - "name": "Somethin", - "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" - }, - { - "name": "Something else", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - } - } - }, - "swift": { - "page": { - "header": {}, - "body": [] - }, - "tests": { - "page": { - "header": {}, - "body": [] - }, - "swift-file": { - "page": { - "header": { - "author": "Tyler Benton", - "name": "Test" - }, - "body": [ - { - "name": "main", - "description": "

main method

\n" - }, - { - "name": "Something", - "description": "

This is a normal multi-line comment.

\n" - }, - { - "name": "Something else", - "description": "

This is another normal multi-line comment.

\n" - } - ] - } - } - } - } - } -} From b94fb1ff9c5efa736d0a133007165cb962ac80bf Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 3 Nov 2015 10:20:07 -0500 Subject: [PATCH 166/273] Updated string function to format multi line strings better --- app/utils/purdy.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/utils/purdy.js b/app/utils/purdy.js index 5322280..8d1d219 100644 --- a/app/utils/purdy.js +++ b/app/utils/purdy.js @@ -220,14 +220,27 @@ export default class Purdy { } _string(str) { - str = to.normalize(str).split('\n') + str = to.normalize(str, false).split('\n') let quote = str.length > 1 ? '`' : `'` - let out = [] + let l = str.length + + // returns because it's a single line string + if (l === 1) { + return quote + str[0] + 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 quote + out.join('\n') + quote + return out.join('\n') } _boolean(bool) { From fd9c732a8785a521bc560c18306bb6a5a4f554fb Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 3 Nov 2015 10:22:41 -0500 Subject: [PATCH 167/273] Updated to use `clor` instead of `chalk` The primary reason behind this is that `chalk` requires to many dependencies. `clor` only requires a single dependency. Both do exactly the same thing so there's no reason to have more dependencies than needed. --- app/utils/logger.js | 12 ++++++------ app/utils/purdy.js | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/utils/logger.js b/app/utils/logger.js index 1969e09..bfca257 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -1,5 +1,5 @@ import Purdy from './purdy' -import chalk from 'chalk' +import $ from 'clor' let chevron = '\xBB' let check = '\u2713' @@ -7,10 +7,10 @@ let warning = '\u26A0' let error = '\u2326' const messaging = { - warning: chalk.yellow(warning, chalk.bold.yellow('[WARNING]')), - debug: chalk.magenta(chevron, '[DEBUG]'), - error: chalk.red(error, chalk.bold.red('[ERROR]')), - file: chalk.bgBlue.gray(chevron, '[FILE]') + warning: $.yellow.bold(`${warning} [WARNING]`), + debug: $.magenta.bold(`${chevron}[DEBUG]`), + error: $.red.bold(`${error}[ERROR]`), + file: $.bgBlue.white(`${chevron}[FILE]`) } const purdy = new Purdy() @@ -105,7 +105,7 @@ export default class Logger { let duration = Date.now() - time console.log( - `${chalk.green(check)} ${format}`, + `${$.green(check)} ${format}`, label, duration ) diff --git a/app/utils/purdy.js b/app/utils/purdy.js index 8d1d219..4b81720 100644 --- a/app/utils/purdy.js +++ b/app/utils/purdy.js @@ -1,6 +1,6 @@ // Load modules import to from './to' -import chalk from 'chalk' +import $ from 'clor' export default class Purdy { constructor(options = {}) { @@ -73,7 +73,7 @@ export default class Purdy { colors = colors.split('.') for (let color of colors) { - string = chalk[color](string) + string = $[color](string) } return string diff --git a/package.json b/package.json index 2959070..8ebf02b 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ }, "dependencies": { "babel-runtime": "^5.8.25", - "chalk": "^1.1.0", "change-case": "^2.3.0", + "clor": "^1.0.2", "co": "^4.6.0", "commander": "^2.9.0", "fs-extra": "^0.24.0", From 48adf9d14423e560bcb0e2049ae74a945823f776 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 3 Nov 2015 10:23:29 -0500 Subject: [PATCH 168/273] Changed max length to be 125 --- .jscsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jscsrc b/.jscsrc index ad073a7..c9be920 100644 --- a/.jscsrc +++ b/.jscsrc @@ -11,7 +11,7 @@ "catch" ], "maximumLineLength": { - "value": 100, + "value": 125, "allExcept": ["comments", "regex"] }, "disallowMultipleSpaces": true, From caa2ed02562de76248595e39dd2eb9e7f03fbd0c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 3 Nov 2015 10:31:11 -0500 Subject: [PATCH 169/273] Fixed some tests This was mainly to change `test/lib` to be `examples/lib`, but I also fixed a few jscs errors --- app/tests/utils/to.test.js | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/app/tests/utils/to.test.js b/app/tests/utils/to.test.js index c768ffd..6660d6d 100644 --- a/app/tests/utils/to.test.js +++ b/app/tests/utils/to.test.js @@ -34,12 +34,12 @@ test('to.normal_string', async (t) => { // this file has some stupid ass characters in it // that need to be removed in order to become like the // rest of the fucking world. #microsoftBlowsAtStandards - let crappy_windows_file = await fs.readFile(`${info.root}/tests/lib/coffeescript/test.coffee`) + let crappy_windows_file = await fs.readFile(`${info.root}/examples/lib/coffeescript/test.coffee`) // crappy_windows_file = JSON.stringify({foo: crappy_windows_file + ''}) t.is(to.normal_string(crappy_windows_file).match(/\r/g), null, 'should be a normal string') t.end() - } catch(err) { + } catch (err) { t.fail('the file didn\'t load') console.log(err.stack); t.end() @@ -85,7 +85,7 @@ test('to.normalize', (t) => { const expected = [ '.foo {', ' background: blue;', '}' ].join('\n') t.is(to.normalize(actual), expected, 'all whitespace should be stripped') - t.ok(actual.split('\n')[2].length > 19, 'should be greater than 19' ) + t.ok(actual.split('\n')[2].length > 19, 'should be greater than 19') t.is(to.normalize(actual).split('\n')[1].length, 19, 'should be 19') t.end() }) @@ -119,9 +119,38 @@ test('to.clone', (t) => { test('to.merge', (t) => { - 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' } } - let expected = { foo: { bar: [ '1', '2' ], baz: [ '3', '4', '5', '6' ], qux: [ 'one', 'two', 'three' ], quux: { garply: { waldo: [ 'one', 'two' ] } }, waldo: function() { return this; }, garply: 'item' } } + 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' + } + } + let expected = { + foo: { + bar: [ '1', '2' ], + baz: [ '3', '4', '5', '6' ], + qux: [ 'one', 'two', 'three' ], + quux: { garply: { waldo: [ 'one', 'two' ] } + }, + waldo: function() { + return this + }, + garply: 'item' } + } t.is(a.foo.bar, '1', 'a.foo.bar should be 1') to.merge(a, b) t.pass('a and be were merged') @@ -139,7 +168,7 @@ test('to.object', async (t) => { t.ok(to.object(json).author, 'the passed json should now be an object') t.end() - } catch(err) { + } catch (err) { console.log(err.stack); } }) From 93dd7b03e9ad3f22aca52aee947a83563b64e841 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 3 Nov 2015 21:01:38 -0500 Subject: [PATCH 170/273] updated normalize to be able to opt out of removing lines --- app/utils/to.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index bcc2f91..a240365 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -182,15 +182,21 @@ let to = { /// 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`. /// @returns {string} - The normalized string - normalize: (content) => { + normalize: (content, leading = true, trailing = leading) => { content = to.array(content) // this allows arrays and strings to be passed // remove leading blank lines - while (content.length && !!!content[0].trim().length) content.shift() + if (leading) + while (content.length && !!!content[0].trim().length) + content.shift() // remove trailing blank lines - while (content.length && !!!(content[content.length - 1].trim()).length) content.pop() + if (trailing) + while (content.length && !!!(content[content.length - 1].trim()).length) + content.pop() return content.map((line) => line.slice( content.join('\n') // converts content to string to string From 156feaf953d3dcc52fc631f12b82a550b9b6e4da Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 17 Dec 2015 18:56:34 -0500 Subject: [PATCH 171/273] added a test case to check for --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index c36a34b..9a104a1 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,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. + - 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') + } + }) + } + ``` - ~~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. - 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. From 216c801ba44ab144482a406b2d15c70ab1896c14 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 21 Dec 2015 14:58:54 -0500 Subject: [PATCH 172/273] updated dependencies --- bin/docs | 4 +--- package.json | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/bin/docs b/bin/docs index b046205..c8a6279 100755 --- a/bin/docs +++ b/bin/docs @@ -1,6 +1,4 @@ #!/usr/bin/env node 'use strict'; - -require('../dist/cli.js')(); - +require('../dist/cli.js').default() diff --git a/package.json b/package.json index 8ebf02b..f3ae35b 100644 --- a/package.json +++ b/package.json @@ -37,17 +37,42 @@ "bin": { "docs": "bin/docs" }, + "engines": { + "node": ">=0.12.0" + }, "dependencies": { - "babel-runtime": "^5.8.25", - "change-case": "^2.3.0", - "clor": "^1.0.2", + "babel-runtime": "^6.3.19", + "change-case": "^2.3.1", + "clor": "^1.6.0", "co": "^4.6.0", "commander": "^2.9.0", "fs-extra": "^0.24.0", - "glob": "^5.0.6", + "glob": "^5.0.15", "is_js": "^0.7.4", "marked": "^0.3.3" }, + "devDependencies": { + "babel-cli": "^6.3.17", + "babel-plugin-transform-runtime": "^6.3.13", + "babel-polyfill": "^6.3.14", + "babel-preset-es2015": "^6.3.13", + "babel-preset-stage-0": "^6.3.13", + "coveralls": "^2.11.6", + "nyc": "^3.2.2", + "proxyquire": "^1.7.3", + "sinon": "^1.17.1", + "tap-spec": "^4.1.1", + "tape": "^4.2.1" + }, + "babel": { + "presets": [ + "stage-0", + "es2015" + ], + "plugins": [ + "transform-runtime" + ] + }, "keywords": [ "css", "sass", @@ -87,17 +112,5 @@ "parser", "annotation", "comments" - ], - "engines": { - "node": ">=0.12.0" - }, - "devDependencies": { - "babel": "^5.8.23", - "coveralls": "^2.11.4", - "nyc": "^3.2.2", - "proxyquire": "^1.7.3", - "sinon": "^1.17.1", - "tap-spec": "^4.1.0", - "tape": "^4.2.1" - } + ] } From cb4c2406321b01cc00be141b8cdfe6c4699fe608 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 17 Feb 2016 13:27:55 -0500 Subject: [PATCH 173/273] updated assets --- .babelrc | 12 ++++++++++++ package.json | 28 +++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..978074c --- /dev/null +++ b/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + "es2015", + "stage-0" + ], + "plugins": [ + "syntax-async-functions", + "transform-async-to-generator", + "transform-regenerator", + "transform-runtime" + ] +} diff --git a/package.json b/package.json index f3ae35b..fdad203 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "main": "dist/index.js", "scripts": { "clean": "rm -rf ./dist", - "compile": "npm run clean; babel app/ -d ./dist --optional runtime --stage 0", - "watch": "npm run clean; babel app/ -d ./dist --stage 0 --optional runtime --watch", + "compile": "npm run clean; babel app/ -d dist/", + "watch": "npm run clean; babel app/ -d dist/ --watch", "test": "tape dist/tests/**/*.js | tap-spec", "coverage": "nyc npm test", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", @@ -41,28 +41,30 @@ "node": ">=0.12.0" }, "dependencies": { - "babel-runtime": "^6.3.19", + "babel-runtime": "^6.5.0", "change-case": "^2.3.1", "clor": "^1.6.0", "co": "^4.6.0", "commander": "^2.9.0", "fs-extra": "^0.24.0", "glob": "^5.0.15", - "is_js": "^0.7.4", - "marked": "^0.3.3" + "is_js": "^0.7.6", + "marked": "^0.3.5" }, "devDependencies": { - "babel-cli": "^6.3.17", - "babel-plugin-transform-runtime": "^6.3.13", - "babel-polyfill": "^6.3.14", - "babel-preset-es2015": "^6.3.13", - "babel-preset-stage-0": "^6.3.13", + "babel-cli": "^6.5.1", + "babel-plugin-syntax-async-functions": "^6.5.0", + "babel-plugin-transform-async-to-generator": "^6.5.0", + "babel-plugin-transform-regenerator": "^6.5.2", + "babel-plugin-transform-runtime": "^6.5.2", + "babel-preset-es2015": "^6.5.0", + "babel-preset-stage-0": "^6.5.0", "coveralls": "^2.11.6", "nyc": "^3.2.2", - "proxyquire": "^1.7.3", - "sinon": "^1.17.1", + "proxyquire": "^1.7.4", + "sinon": "^1.17.3", "tap-spec": "^4.1.1", - "tape": "^4.2.1" + "tape": "^4.4.0" }, "babel": { "presets": [ From 135b3f569f6746e7acd899ad16d4bd4b8c6a3b5d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 13:36:58 -0500 Subject: [PATCH 174/273] moved tests --- .jscsrc | 35 --------- .jshintrc | 36 ---------- .../lib/edge-cases/ends-with-empty-lines.scss | 34 --------- examples/package.json | 9 --- .../annotations/access.test.js | 0 .../tests => tests}/annotations/alias.test.js | 0 {app/tests => tests}/annotations/arg.test.js | 0 .../annotations/author.test.js | 0 .../annotations/chainable.test.js | 0 .../annotations/depricated.test.js | 0 .../annotations/description.test.js | 0 .../annotations/markup.test.js | 0 {app/tests => tests}/annotations/name.test.js | 0 {app/tests => tests}/annotations/note.test.js | 0 {app/tests => tests}/annotations/page.test.js | 0 .../annotations/readonly.test.js | 0 .../annotations/requires.test.js | 0 .../annotations/returns.test.js | 0 .../tests => tests}/annotations/since.test.js | 0 .../tests => tests}/annotations/state.test.js | 0 {app/tests => tests}/annotations/todo.test.js | 0 {app/tests => tests}/annotations/type.test.js | 0 .../annotations/version.test.js | 0 .../cases/blank-file.js | 0 .../cases/empty-file.js | 0 tests/cases/empty-file.json | 4 ++ .../lib => tests/file-types}/c#/README.md | 0 {examples/lib => tests/file-types}/c#/test.cs | 0 .../lib => tests/file-types}/c++/README.md | 0 {examples/lib => tests/file-types}/c++/test.c | 0 .../lib => tests/file-types}/c/README.md | 0 {examples/lib => tests/file-types}/c/test.c | 0 .../file-types}/coffeescript/README.md | 0 .../file-types}/coffeescript/test.coffee | 0 .../file-types}/coldfusion/README.md | 0 .../file-types}/coldfusion/test.cfm | 0 .../lib => tests/file-types}/css/test.css | 0 .../4-blank-lines-between-code-blocks.scss | 0 .../edge-cases/header-comment-only.scss | 0 ...pace-between-header-and-body-comments.scss | 0 .../edge-cases/only-body-comments.scss | 0 .../file-types}/edge-cases/only-comments.scss | 0 .../edge-cases/preserves-blank-lines.scss | 0 .../single-body-comment-no-code.scss | 0 .../edge-cases/single-body-comment.scss | 0 .../space-between-comment-and-code.scss | 0 .../starts-and-ends-with-spaces.scss | 0 .../edge-cases/starts-with-empty-lines.scss | 0 .../lib => tests/file-types}/html/README.md | 0 .../lib => tests/file-types}/html/test.html | 0 .../lib => tests/file-types}/java/README.md | 0 .../lib => tests/file-types}/java/test.java | 0 {examples/lib => tests/file-types}/js/test.js | 0 .../lib => tests/file-types}/less/README.md | 0 .../lib => tests/file-types}/less/test.less | 0 .../lib => tests/file-types}/md/markdown.md | 0 .../lib => tests/file-types}/php/README.md | 0 .../lib => tests/file-types}/php/test.php | 0 .../lib => tests/file-types}/python/README.md | 0 .../lib => tests/file-types}/python/test.py | 0 .../lib => tests/file-types}/ruby/README.md | 0 .../lib => tests/file-types}/ruby/test.rb | 0 .../lib => tests/file-types}/scss/test.scss | 0 .../lib => tests/file-types}/stylus/README.md | 0 .../lib => tests/file-types}/stylus/test.styl | 0 .../lib => tests/file-types}/swift/README.md | 0 .../lib => tests/file-types}/swift/test.swift | 0 .../src/unit}/crappy_file_saved_on_windows.cs | 0 .../src/unit/utils/array.test.js | 0 .../src/unit/utils/denodeify.test.js | 0 .../src/unit/utils/glob.test.js | 0 .../src/unit/utils/info.test.js | 0 .../tests => tests/src/unit}/utils/is.test.js | 18 +++-- tests/src/unit/utils/log.test.js | 0 .../tests => tests/src/unit}/utils/to.test.js | 71 ++++++++----------- 75 files changed, 41 insertions(+), 166 deletions(-) delete mode 100644 .jscsrc delete mode 100644 .jshintrc delete mode 100644 examples/lib/edge-cases/ends-with-empty-lines.scss delete mode 100644 examples/package.json rename {app/tests => tests}/annotations/access.test.js (100%) rename {app/tests => tests}/annotations/alias.test.js (100%) rename {app/tests => tests}/annotations/arg.test.js (100%) rename {app/tests => tests}/annotations/author.test.js (100%) rename {app/tests => tests}/annotations/chainable.test.js (100%) rename {app/tests => tests}/annotations/depricated.test.js (100%) rename {app/tests => tests}/annotations/description.test.js (100%) rename {app/tests => tests}/annotations/markup.test.js (100%) rename {app/tests => tests}/annotations/name.test.js (100%) rename {app/tests => tests}/annotations/note.test.js (100%) rename {app/tests => tests}/annotations/page.test.js (100%) rename {app/tests => tests}/annotations/readonly.test.js (100%) rename {app/tests => tests}/annotations/requires.test.js (100%) rename {app/tests => tests}/annotations/returns.test.js (100%) rename {app/tests => tests}/annotations/since.test.js (100%) rename {app/tests => tests}/annotations/state.test.js (100%) rename {app/tests => tests}/annotations/todo.test.js (100%) rename {app/tests => tests}/annotations/type.test.js (100%) rename {app/tests => tests}/annotations/version.test.js (100%) rename app/tests/utils/array.test.js => tests/cases/blank-file.js (100%) rename app/tests/utils/denodeify.test.js => tests/cases/empty-file.js (100%) create mode 100644 tests/cases/empty-file.json rename {examples/lib => tests/file-types}/c#/README.md (100%) rename {examples/lib => tests/file-types}/c#/test.cs (100%) rename {examples/lib => tests/file-types}/c++/README.md (100%) rename {examples/lib => tests/file-types}/c++/test.c (100%) rename {examples/lib => tests/file-types}/c/README.md (100%) rename {examples/lib => tests/file-types}/c/test.c (100%) rename {examples/lib => tests/file-types}/coffeescript/README.md (100%) rename {examples/lib => tests/file-types}/coffeescript/test.coffee (100%) rename {examples/lib => tests/file-types}/coldfusion/README.md (100%) rename {examples/lib => tests/file-types}/coldfusion/test.cfm (100%) rename {examples/lib => tests/file-types}/css/test.css (100%) rename {examples/lib => tests/file-types}/edge-cases/4-blank-lines-between-code-blocks.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/header-comment-only.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/no-space-between-header-and-body-comments.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/only-body-comments.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/only-comments.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/preserves-blank-lines.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/single-body-comment-no-code.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/single-body-comment.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/space-between-comment-and-code.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/starts-and-ends-with-spaces.scss (100%) rename {examples/lib => tests/file-types}/edge-cases/starts-with-empty-lines.scss (100%) rename {examples/lib => tests/file-types}/html/README.md (100%) rename {examples/lib => tests/file-types}/html/test.html (100%) rename {examples/lib => tests/file-types}/java/README.md (100%) rename {examples/lib => tests/file-types}/java/test.java (100%) rename {examples/lib => tests/file-types}/js/test.js (100%) rename {examples/lib => tests/file-types}/less/README.md (100%) rename {examples/lib => tests/file-types}/less/test.less (100%) rename {examples/lib => tests/file-types}/md/markdown.md (100%) rename {examples/lib => tests/file-types}/php/README.md (100%) rename {examples/lib => tests/file-types}/php/test.php (100%) rename {examples/lib => tests/file-types}/python/README.md (100%) rename {examples/lib => tests/file-types}/python/test.py (100%) rename {examples/lib => tests/file-types}/ruby/README.md (100%) rename {examples/lib => tests/file-types}/ruby/test.rb (100%) rename {examples/lib => tests/file-types}/scss/test.scss (100%) rename {examples/lib => tests/file-types}/stylus/README.md (100%) rename {examples/lib => tests/file-types}/stylus/test.styl (100%) rename {examples/lib => tests/file-types}/swift/README.md (100%) rename {examples/lib => tests/file-types}/swift/test.swift (100%) rename {app/tests => tests/src/unit}/crappy_file_saved_on_windows.cs (100%) rename app/tests/utils/glob.test.js => tests/src/unit/utils/array.test.js (100%) rename app/tests/utils/info.test.js => tests/src/unit/utils/denodeify.test.js (100%) rename app/tests/utils/log.test.js => tests/src/unit/utils/glob.test.js (100%) rename examples/lib/edge-cases/empty-file.scss => tests/src/unit/utils/info.test.js (100%) rename {app/tests => tests/src/unit}/utils/is.test.js (92%) create mode 100644 tests/src/unit/utils/log.test.js rename {app/tests => tests/src/unit}/utils/to.test.js (79%) diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index c9be920..0000000 --- a/.jscsrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "preset": "google", - "requireSemicolons": false, - "esnext": true, - "requireCamelCaseOrUpperCaseIdentifiers": false, - "requireCurlyBraces": [ - "else", - "else if", - "do", - "try", - "catch" - ], - "maximumLineLength": { - "value": 125, - "allExcept": ["comments", "regex"] - }, - "disallowMultipleSpaces": true, - "disallowMultipleLineBreaks": false, - "disallowPaddingNewlinesInBlocks": true, - "disallowNewlineBeforeBlockStatements": false, - "disallowQuotedKeysInObjects": "allButReserved", - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "requireBlocksOnNewline": true, - "requireCommaBeforeLineBreak": true, - "requireSpaceBetweenArguments": true, - "disallowSpacesInsideObjectBrackets": false, - "disallowSpacesInsideArrayBrackets": false, - "validateQuoteMarks": { - "mark": "'", - "escape": true - }, - "requireParenthesesAroundIIFE": true, - "validateLineBreaks": "LF", - "excludeFiles": ["node_modules/**/*", "app/tests/**/*.js"] -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index e560055..0000000 --- a/.jshintrc +++ /dev/null @@ -1,36 +0,0 @@ -{ - "asi": true, - "boss": true, - "browser": true, - "camelcase": false, - "curly": false, - "devel": true, - "eqeqeq": true, - "eqnull": true, - "es3": false, - "es5": false, - "esnext": true, - "evil": false, - "immed": false, - "indent": 2, - "jquery": true, - "latedef": true, - "laxbreak": true, - "laxcomma": true, - "maxcomplexity": 6, - "maxdepth": 5, - "maxparams": 4, - "maxstatements": 25, - "newcap": true, - "noarg": true, - "node": true, - "noempty": false, - "nonew": true, - "quotmark": "single", - "smarttabs": true, - "strict": false, - "trailing": false, - "undef": true, - "unused": true, - "varstmt": true -} \ No newline at end of file diff --git a/examples/lib/edge-cases/ends-with-empty-lines.scss b/examples/lib/edge-cases/ends-with-empty-lines.scss deleted file mode 100644 index 3f81cc3..0000000 --- a/examples/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/examples/package.json b/examples/package.json deleted file mode 100644 index a8b5459..0000000 --- a/examples/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "docs", - "dependencies": { - "docs": "file:../" - }, - "engines": { - "node": ">=0.10.0" - } -} \ No newline at end of file diff --git a/app/tests/annotations/access.test.js b/tests/annotations/access.test.js similarity index 100% rename from app/tests/annotations/access.test.js rename to tests/annotations/access.test.js diff --git a/app/tests/annotations/alias.test.js b/tests/annotations/alias.test.js similarity index 100% rename from app/tests/annotations/alias.test.js rename to tests/annotations/alias.test.js diff --git a/app/tests/annotations/arg.test.js b/tests/annotations/arg.test.js similarity index 100% rename from app/tests/annotations/arg.test.js rename to tests/annotations/arg.test.js diff --git a/app/tests/annotations/author.test.js b/tests/annotations/author.test.js similarity index 100% rename from app/tests/annotations/author.test.js rename to tests/annotations/author.test.js diff --git a/app/tests/annotations/chainable.test.js b/tests/annotations/chainable.test.js similarity index 100% rename from app/tests/annotations/chainable.test.js rename to tests/annotations/chainable.test.js diff --git a/app/tests/annotations/depricated.test.js b/tests/annotations/depricated.test.js similarity index 100% rename from app/tests/annotations/depricated.test.js rename to tests/annotations/depricated.test.js diff --git a/app/tests/annotations/description.test.js b/tests/annotations/description.test.js similarity index 100% rename from app/tests/annotations/description.test.js rename to tests/annotations/description.test.js diff --git a/app/tests/annotations/markup.test.js b/tests/annotations/markup.test.js similarity index 100% rename from app/tests/annotations/markup.test.js rename to tests/annotations/markup.test.js diff --git a/app/tests/annotations/name.test.js b/tests/annotations/name.test.js similarity index 100% rename from app/tests/annotations/name.test.js rename to tests/annotations/name.test.js diff --git a/app/tests/annotations/note.test.js b/tests/annotations/note.test.js similarity index 100% rename from app/tests/annotations/note.test.js rename to tests/annotations/note.test.js diff --git a/app/tests/annotations/page.test.js b/tests/annotations/page.test.js similarity index 100% rename from app/tests/annotations/page.test.js rename to tests/annotations/page.test.js diff --git a/app/tests/annotations/readonly.test.js b/tests/annotations/readonly.test.js similarity index 100% rename from app/tests/annotations/readonly.test.js rename to tests/annotations/readonly.test.js diff --git a/app/tests/annotations/requires.test.js b/tests/annotations/requires.test.js similarity index 100% rename from app/tests/annotations/requires.test.js rename to tests/annotations/requires.test.js diff --git a/app/tests/annotations/returns.test.js b/tests/annotations/returns.test.js similarity index 100% rename from app/tests/annotations/returns.test.js rename to tests/annotations/returns.test.js diff --git a/app/tests/annotations/since.test.js b/tests/annotations/since.test.js similarity index 100% rename from app/tests/annotations/since.test.js rename to tests/annotations/since.test.js diff --git a/app/tests/annotations/state.test.js b/tests/annotations/state.test.js similarity index 100% rename from app/tests/annotations/state.test.js rename to tests/annotations/state.test.js diff --git a/app/tests/annotations/todo.test.js b/tests/annotations/todo.test.js similarity index 100% rename from app/tests/annotations/todo.test.js rename to tests/annotations/todo.test.js diff --git a/app/tests/annotations/type.test.js b/tests/annotations/type.test.js similarity index 100% rename from app/tests/annotations/type.test.js rename to tests/annotations/type.test.js diff --git a/app/tests/annotations/version.test.js b/tests/annotations/version.test.js similarity index 100% rename from app/tests/annotations/version.test.js rename to tests/annotations/version.test.js diff --git a/app/tests/utils/array.test.js b/tests/cases/blank-file.js similarity index 100% rename from app/tests/utils/array.test.js rename to tests/cases/blank-file.js diff --git a/app/tests/utils/denodeify.test.js b/tests/cases/empty-file.js similarity index 100% rename from app/tests/utils/denodeify.test.js rename to tests/cases/empty-file.js diff --git a/tests/cases/empty-file.json b/tests/cases/empty-file.json new file mode 100644 index 0000000..fc22cd6 --- /dev/null +++ b/tests/cases/empty-file.json @@ -0,0 +1,4 @@ +{ + "nav": [], + "pages": {} +} diff --git a/examples/lib/c#/README.md b/tests/file-types/c#/README.md similarity index 100% rename from examples/lib/c#/README.md rename to tests/file-types/c#/README.md diff --git a/examples/lib/c#/test.cs b/tests/file-types/c#/test.cs similarity index 100% rename from examples/lib/c#/test.cs rename to tests/file-types/c#/test.cs diff --git a/examples/lib/c++/README.md b/tests/file-types/c++/README.md similarity index 100% rename from examples/lib/c++/README.md rename to tests/file-types/c++/README.md diff --git a/examples/lib/c++/test.c b/tests/file-types/c++/test.c similarity index 100% rename from examples/lib/c++/test.c rename to tests/file-types/c++/test.c diff --git a/examples/lib/c/README.md b/tests/file-types/c/README.md similarity index 100% rename from examples/lib/c/README.md rename to tests/file-types/c/README.md diff --git a/examples/lib/c/test.c b/tests/file-types/c/test.c similarity index 100% rename from examples/lib/c/test.c rename to tests/file-types/c/test.c diff --git a/examples/lib/coffeescript/README.md b/tests/file-types/coffeescript/README.md similarity index 100% rename from examples/lib/coffeescript/README.md rename to tests/file-types/coffeescript/README.md diff --git a/examples/lib/coffeescript/test.coffee b/tests/file-types/coffeescript/test.coffee similarity index 100% rename from examples/lib/coffeescript/test.coffee rename to tests/file-types/coffeescript/test.coffee diff --git a/examples/lib/coldfusion/README.md b/tests/file-types/coldfusion/README.md similarity index 100% rename from examples/lib/coldfusion/README.md rename to tests/file-types/coldfusion/README.md diff --git a/examples/lib/coldfusion/test.cfm b/tests/file-types/coldfusion/test.cfm similarity index 100% rename from examples/lib/coldfusion/test.cfm rename to tests/file-types/coldfusion/test.cfm diff --git a/examples/lib/css/test.css b/tests/file-types/css/test.css similarity index 100% rename from examples/lib/css/test.css rename to tests/file-types/css/test.css diff --git a/examples/lib/edge-cases/4-blank-lines-between-code-blocks.scss b/tests/file-types/edge-cases/4-blank-lines-between-code-blocks.scss similarity index 100% rename from examples/lib/edge-cases/4-blank-lines-between-code-blocks.scss rename to tests/file-types/edge-cases/4-blank-lines-between-code-blocks.scss diff --git a/examples/lib/edge-cases/header-comment-only.scss b/tests/file-types/edge-cases/header-comment-only.scss similarity index 100% rename from examples/lib/edge-cases/header-comment-only.scss rename to tests/file-types/edge-cases/header-comment-only.scss diff --git a/examples/lib/edge-cases/no-space-between-header-and-body-comments.scss b/tests/file-types/edge-cases/no-space-between-header-and-body-comments.scss similarity index 100% rename from examples/lib/edge-cases/no-space-between-header-and-body-comments.scss rename to tests/file-types/edge-cases/no-space-between-header-and-body-comments.scss diff --git a/examples/lib/edge-cases/only-body-comments.scss b/tests/file-types/edge-cases/only-body-comments.scss similarity index 100% rename from examples/lib/edge-cases/only-body-comments.scss rename to tests/file-types/edge-cases/only-body-comments.scss diff --git a/examples/lib/edge-cases/only-comments.scss b/tests/file-types/edge-cases/only-comments.scss similarity index 100% rename from examples/lib/edge-cases/only-comments.scss rename to tests/file-types/edge-cases/only-comments.scss diff --git a/examples/lib/edge-cases/preserves-blank-lines.scss b/tests/file-types/edge-cases/preserves-blank-lines.scss similarity index 100% rename from examples/lib/edge-cases/preserves-blank-lines.scss rename to tests/file-types/edge-cases/preserves-blank-lines.scss diff --git a/examples/lib/edge-cases/single-body-comment-no-code.scss b/tests/file-types/edge-cases/single-body-comment-no-code.scss similarity index 100% rename from examples/lib/edge-cases/single-body-comment-no-code.scss rename to tests/file-types/edge-cases/single-body-comment-no-code.scss diff --git a/examples/lib/edge-cases/single-body-comment.scss b/tests/file-types/edge-cases/single-body-comment.scss similarity index 100% rename from examples/lib/edge-cases/single-body-comment.scss rename to tests/file-types/edge-cases/single-body-comment.scss diff --git a/examples/lib/edge-cases/space-between-comment-and-code.scss b/tests/file-types/edge-cases/space-between-comment-and-code.scss similarity index 100% rename from examples/lib/edge-cases/space-between-comment-and-code.scss rename to tests/file-types/edge-cases/space-between-comment-and-code.scss diff --git a/examples/lib/edge-cases/starts-and-ends-with-spaces.scss b/tests/file-types/edge-cases/starts-and-ends-with-spaces.scss similarity index 100% rename from examples/lib/edge-cases/starts-and-ends-with-spaces.scss rename to tests/file-types/edge-cases/starts-and-ends-with-spaces.scss diff --git a/examples/lib/edge-cases/starts-with-empty-lines.scss b/tests/file-types/edge-cases/starts-with-empty-lines.scss similarity index 100% rename from examples/lib/edge-cases/starts-with-empty-lines.scss rename to tests/file-types/edge-cases/starts-with-empty-lines.scss diff --git a/examples/lib/html/README.md b/tests/file-types/html/README.md similarity index 100% rename from examples/lib/html/README.md rename to tests/file-types/html/README.md diff --git a/examples/lib/html/test.html b/tests/file-types/html/test.html similarity index 100% rename from examples/lib/html/test.html rename to tests/file-types/html/test.html diff --git a/examples/lib/java/README.md b/tests/file-types/java/README.md similarity index 100% rename from examples/lib/java/README.md rename to tests/file-types/java/README.md diff --git a/examples/lib/java/test.java b/tests/file-types/java/test.java similarity index 100% rename from examples/lib/java/test.java rename to tests/file-types/java/test.java diff --git a/examples/lib/js/test.js b/tests/file-types/js/test.js similarity index 100% rename from examples/lib/js/test.js rename to tests/file-types/js/test.js diff --git a/examples/lib/less/README.md b/tests/file-types/less/README.md similarity index 100% rename from examples/lib/less/README.md rename to tests/file-types/less/README.md diff --git a/examples/lib/less/test.less b/tests/file-types/less/test.less similarity index 100% rename from examples/lib/less/test.less rename to tests/file-types/less/test.less diff --git a/examples/lib/md/markdown.md b/tests/file-types/md/markdown.md similarity index 100% rename from examples/lib/md/markdown.md rename to tests/file-types/md/markdown.md diff --git a/examples/lib/php/README.md b/tests/file-types/php/README.md similarity index 100% rename from examples/lib/php/README.md rename to tests/file-types/php/README.md diff --git a/examples/lib/php/test.php b/tests/file-types/php/test.php similarity index 100% rename from examples/lib/php/test.php rename to tests/file-types/php/test.php diff --git a/examples/lib/python/README.md b/tests/file-types/python/README.md similarity index 100% rename from examples/lib/python/README.md rename to tests/file-types/python/README.md diff --git a/examples/lib/python/test.py b/tests/file-types/python/test.py similarity index 100% rename from examples/lib/python/test.py rename to tests/file-types/python/test.py diff --git a/examples/lib/ruby/README.md b/tests/file-types/ruby/README.md similarity index 100% rename from examples/lib/ruby/README.md rename to tests/file-types/ruby/README.md diff --git a/examples/lib/ruby/test.rb b/tests/file-types/ruby/test.rb similarity index 100% rename from examples/lib/ruby/test.rb rename to tests/file-types/ruby/test.rb diff --git a/examples/lib/scss/test.scss b/tests/file-types/scss/test.scss similarity index 100% rename from examples/lib/scss/test.scss rename to tests/file-types/scss/test.scss diff --git a/examples/lib/stylus/README.md b/tests/file-types/stylus/README.md similarity index 100% rename from examples/lib/stylus/README.md rename to tests/file-types/stylus/README.md diff --git a/examples/lib/stylus/test.styl b/tests/file-types/stylus/test.styl similarity index 100% rename from examples/lib/stylus/test.styl rename to tests/file-types/stylus/test.styl diff --git a/examples/lib/swift/README.md b/tests/file-types/swift/README.md similarity index 100% rename from examples/lib/swift/README.md rename to tests/file-types/swift/README.md diff --git a/examples/lib/swift/test.swift b/tests/file-types/swift/test.swift similarity index 100% rename from examples/lib/swift/test.swift rename to tests/file-types/swift/test.swift diff --git a/app/tests/crappy_file_saved_on_windows.cs b/tests/src/unit/crappy_file_saved_on_windows.cs similarity index 100% rename from app/tests/crappy_file_saved_on_windows.cs rename to tests/src/unit/crappy_file_saved_on_windows.cs diff --git a/app/tests/utils/glob.test.js b/tests/src/unit/utils/array.test.js similarity index 100% rename from app/tests/utils/glob.test.js rename to tests/src/unit/utils/array.test.js diff --git a/app/tests/utils/info.test.js b/tests/src/unit/utils/denodeify.test.js similarity index 100% rename from app/tests/utils/info.test.js rename to tests/src/unit/utils/denodeify.test.js diff --git a/app/tests/utils/log.test.js b/tests/src/unit/utils/glob.test.js similarity index 100% rename from app/tests/utils/log.test.js rename to tests/src/unit/utils/glob.test.js diff --git a/examples/lib/edge-cases/empty-file.scss b/tests/src/unit/utils/info.test.js similarity index 100% rename from examples/lib/edge-cases/empty-file.scss rename to tests/src/unit/utils/info.test.js diff --git a/app/tests/utils/is.test.js b/tests/src/unit/utils/is.test.js similarity index 92% rename from app/tests/utils/is.test.js rename to tests/src/unit/utils/is.test.js index 8caae0c..e190078 100644 --- a/app/tests/utils/is.test.js +++ b/tests/src/unit/utils/is.test.js @@ -1,5 +1,5 @@ import test from 'tape' -import is from '../../utils/is.js' +import is from '../../../../dist/utils/is.js' test('is.false', (t) => { t.notOk(is.false('foo'), @@ -20,8 +20,8 @@ test('is.fn', (t) => { }) test('is.in', (t) => { - const array = ['one', 'two', 'three'] - const object = {one: 1, two: 2, three: 3} + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } const string = 'onetwothree' t.ok(is.in(array, 'two'), 'should return true when the item is in the array') @@ -39,8 +39,8 @@ test('is.in', (t) => { }) test('is.all.in', (t) => { - const array = ['one', 'two', 'three'] - const object = {one: 1, two: 2, three: 3} + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } const string = 'onetwothree' t.ok(is.all.in(array, 'one', 'two'), 'should return true because all items are in the array') @@ -58,8 +58,8 @@ test('is.all.in', (t) => { }) test('is.any.in', (t) => { - const array = ['one', 'two', 'three'] - const object = {one: 1, two: 2, three: 3} + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } const string = 'onetwothree' t.ok(is.any.in(array, 'one', 'four'), 'should return true because one is in the array') @@ -102,7 +102,7 @@ test('is.between', (t) => { test('is.promise', (t) => { async function something_async() { - return 'some cool stuff'; + return Promise.resolve('some cool stuff'); } t.notOk(is.promise('foo'), 'should return false because a string is not a promise') @@ -133,5 +133,3 @@ test('is.symbol', (t) => { 'should return false because it is a string') t.end() }) - - diff --git a/tests/src/unit/utils/log.test.js b/tests/src/unit/utils/log.test.js new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/utils/to.test.js b/tests/src/unit/utils/to.test.js similarity index 79% rename from app/tests/utils/to.test.js rename to tests/src/unit/utils/to.test.js index 6660d6d..d257e17 100644 --- a/app/tests/utils/to.test.js +++ b/tests/src/unit/utils/to.test.js @@ -1,12 +1,11 @@ -import test from 'tape'; -import to from '../../utils/to.js' -import fs from '../../utils/fs.js' -import info from '../../utils/info.js' -import is from 'is_js' +import test from 'tape' +import to from '../../../../dist/utils/to.js' +import fs from '../../../../dist/utils/fs.js' +import info from '../../../../dist/utils/info.js' const string = 'yo this is a string' -const array = ['one', 'two', 'three'] -const object = {one: 1, two: 2, three: 3} +const array = [ 'one', 'two', 'three' ] +const object = { one: 1, two: 2, three: 3 } const buffer = new Buffer(string) const number = 4 const boolean = false @@ -34,14 +33,14 @@ test('to.normal_string', async (t) => { // this file has some stupid ass characters in it // that need to be removed in order to become like the // rest of the fucking world. #microsoftBlowsAtStandards - let crappy_windows_file = await fs.readFile(`${info.root}/examples/lib/coffeescript/test.coffee`) + const crappy_windows_file = await fs.readFile(`${info.root}/tests/file-types/coffeescript/test.coffee`) // crappy_windows_file = JSON.stringify({foo: crappy_windows_file + ''}) t.is(to.normal_string(crappy_windows_file).match(/\r/g), null, 'should be a normal string') t.end() } catch (err) { t.fail('the file didn\'t load') - console.log(err.stack); + console.log(err.stack) t.end() } }) @@ -57,7 +56,7 @@ test('to.keys', (t) => { test('to.entries', (t) => { - for (let [i, item] of to.entries(array)) { + for (const [ i, item ] of to.entries(array)) { t.ok(typeof i, 'number', '`i` should be a number') t.ok(typeof item, 'string', '`i` should be a string') } @@ -66,7 +65,7 @@ test('to.entries', (t) => { test('to.object_entries', (t) => { - for (let { key, one, two, three } of to.object_entries({ test: object })) { + for (const { key, one, two, three } of to.object_entries({ test: object })) { t.is(key, 'test', 'The key should be `test`') t.is(one, 1, '`one` should equal 1') t.is(two, 2, '`two` should equal 2') @@ -81,7 +80,7 @@ test('to.normalize', (t) => { .foo { background: blue; } - `; + ` const expected = [ '.foo {', ' background: blue;', '}' ].join('\n') t.is(to.normalize(actual), expected, 'all whitespace should be stripped') @@ -92,21 +91,21 @@ test('to.normalize', (t) => { test('to.extend', (t) => { - let temp = to.extend({}, object); + const temp = to.extend({}, object) t.deepEqual(object, object, 'should equal each other, because they\'re the same') t.deepEqual(temp, object, 'should be the same as the first object') - t.is(to.extend(temp, {one: 3}).one, 3, + t.is(to.extend(temp, { one: 3 }).one, 3, '`one` should be equal to 3') t.end() }) test('to.clone', (t) => { - let actual = { one: { two: { three: { four: { five: 'whatup' } } } } } - let expected = { one: { two: { three: { four: { five: 'whatup' } } } } } - let test_one = to.clone(actual) + const actual = { one: { two: { three: { four: { five: 'whatup' } } } } } + const expected = { one: { two: { three: { four: { five: 'whatup' } } } } } + const test_one = to.clone(actual) test_one.test = 'yo' t.ok(actual.test === undefined, '`acutal.test` should not be defined') @@ -119,38 +118,26 @@ test('to.clone', (t) => { test('to.merge', (t) => { - let a = { + const a = { foo: { bar: '1', - baz: ['3', '4'], + baz: [ '3', '4' ], qux: 'one', quux: { garply: { waldo: 'one' } }, waldo: '' } } - let b = { + const b = { foo: { bar: '2', - baz: ['5', '6'], - qux: ['two', 'three'], + baz: [ '5', '6' ], + qux: [ 'two', 'three' ], quux: { garply: { waldo: 'two' } }, - waldo: function() { + waldo() { return this }, garply: 'item' } } - let expected = { - foo: { - bar: [ '1', '2' ], - baz: [ '3', '4', '5', '6' ], - qux: [ 'one', 'two', 'three' ], - quux: { garply: { waldo: [ 'one', 'two' ] } - }, - waldo: function() { - return this - }, - garply: 'item' } - } t.is(a.foo.bar, '1', 'a.foo.bar should be 1') to.merge(a, b) t.pass('a and be were merged') @@ -164,18 +151,18 @@ test('to.merge', (t) => { test('to.object', async (t) => { try { - let json = await fs.readFile(`${info.root}/package.json`) + const json = await fs.readFile(`${info.root}/package.json`) t.ok(to.object(json).author, 'the passed json should now be an object') t.end() } catch (err) { - console.log(err.stack); + console.log(err.stack) } }) test('to.json', (t) => { - let obj = { foo: 'foo', bar: 'foo' } + const obj = { foo: 'foo', bar: 'foo' } t.is(typeof obj, 'object', 'the test object should be an object') t.is(typeof to.json(obj), 'string', @@ -206,21 +193,21 @@ test('to.array', (t) => { test('to.flatten', (t) => { - t.is(to.flatten([[[array]]])[0], 'one', + t.is(to.flatten([ [ [ array ] ] ])[0], 'one', 'the array should be flattend and the first value should be one') t.end() }) test('to.unique', (t) => { - t.is(to.unique(['one', 'one', 'two', 'two']).length, 2, + t.is(to.unique([ 'one', 'one', 'two', 'two' ]).length, 2, 'should have a length of 2') t.end() }) test('to.sort', (t) => { - let actual = { + const actual = { c: 1, b: 2, a: 3 @@ -250,4 +237,4 @@ test('to.number', (t) => { t.is(to.number(true), 1, 'should be 1') t.end() -}) \ No newline at end of file +}) From 4dd22637b906bd2aa7ab0b081ee19583dd03ff10 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 13:37:20 -0500 Subject: [PATCH 175/273] updated linter files --- .eslintrc | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 +- 2 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..5f9d166 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,206 @@ +{ + "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, + "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-body-style": [ 2, "as-needed" ], + "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", "a", "b", "c", "d", "e", "x", "y", "z", "_", "t" ] + } + ], + "id-match": [ 2, "^(?:[a-z]{2,}([A-Z]{1}[a-z]+)*$)|([a-z_]+$)" ], + "indent": [ 2, 2 ], + "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-confusing-arrow": 2, + "no-bitwise": 2, + "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-underscore-dangle": 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 7439999..d17bf21 100755 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,8 @@ dist .tmp .DS_Store .sass-cache +npm-debug.log *.map docs/docs.json coverage -.nyc_output \ No newline at end of file +.nyc_output From 1b502a72d8459f3bc01c34f1774e3f93a5cfb991 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 13:37:53 -0500 Subject: [PATCH 176/273] updated scripts and deps --- package.json | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fdad203..88a8b13 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,15 @@ "main": "dist/index.js", "scripts": { "clean": "rm -rf ./dist", - "compile": "npm run clean; babel app/ -d dist/", - "watch": "npm run clean; babel app/ -d dist/ --watch", - "test": "tape dist/tests/**/*.js | tap-spec", + "compile": "npm run clean; babel app/ -d dist/; babel tests/src -d tests/dist/", + "watch": "npm run clean; babel app/ -d dist/ --watch;", + "clean-tests": "rm -rf ./tests/dist", + "compile-tests": "npm run clean-tests; babel tests/src -d tests/dist/", + "watch-tests": "npm run clean-tests; babel tests/src -d tests/dist/ --watch", + "unit-tests": "tape tests/dist/unit/**/*.js | tap-diff", + "mock-tests": "tape tests/dist/run.test.js | tap-diff", + "test": "tape tests/dist/**/*.js | tap-diff", + "test-verbose": "tape tests/dist/**/*.js | tap-diff", "coverage": "nyc npm test", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", "plato": "plato -d coverage/plato dist/index.js", @@ -53,6 +59,7 @@ }, "devDependencies": { "babel-cli": "^6.5.1", + "babel-eslint": "^5.0.0", "babel-plugin-syntax-async-functions": "^6.5.0", "babel-plugin-transform-async-to-generator": "^6.5.0", "babel-plugin-transform-regenerator": "^6.5.2", @@ -60,10 +67,13 @@ "babel-preset-es2015": "^6.5.0", "babel-preset-stage-0": "^6.5.0", "coveralls": "^2.11.6", + "eslint": "^2.1.0", + "eslint-plugin-babel": "^3.1.0", "nyc": "^3.2.2", "proxyquire": "^1.7.4", "sinon": "^1.17.3", - "tap-spec": "^4.1.1", + "tap-diff": "^0.1.1", + "tap-prettify": "0.0.2", "tape": "^4.4.0" }, "babel": { From c09a92ae93c2e1bf79b5e0a761b213cc33f08675 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 13:39:40 -0500 Subject: [PATCH 177/273] added test runner for mock tests --- tests/src/run.test.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/src/run.test.js diff --git a/tests/src/run.test.js b/tests/src/run.test.js new file mode 100644 index 0000000..365707b --- /dev/null +++ b/tests/src/run.test.js @@ -0,0 +1,33 @@ +/* eslint-disable no-loop-func */ + +import test from 'tape' +import path from 'path' +import docs from '../../dist/index.js' +import { fs, glob, array } from '../../dist/utils' + +const test_defaults = { + debug: false, + timestamps: false, + warning: false, + changed: false +} + + +test('case tests', async (mt) => { + const base = path.join(__dirname, '..', 'cases') + const actual_paths = await glob(path.join(base, '*'), [ path.join(base, '*.json') ]) + const actual = await array(actual_paths).map((file) => docs({ file, ...test_defaults })) + const expected = await array(actual_paths).map((file) => fs.readJson(file.replace(/\..*$/, '.json'))) + + for (let i = 0; i < actual_paths.length; i++) { + mt.test(actual_paths[i], (t) => { + t.deepEqual( + actual[i], + expected[i] + ) + t.end() + }) + } + + mt.end() +}) From 930873c49ad6ab8b8e72c7d7f6ff3d4b90478ed6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 13:49:38 -0500 Subject: [PATCH 178/273] updated to standards --- app/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/index.js b/app/index.js index 601a1fe..a36184e 100644 --- a/app/index.js +++ b/app/index.js @@ -1,4 +1,9 @@ -var docs = require('./dist/docs') +/* + eslint + no-undef: 0, + prefer-arrow-callback: 0 + */ +var docs = require('./docs.js') // Module exports // a) export module @@ -6,13 +11,11 @@ var docs = require('./dist/docs') // c) add docs to the root if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = docs; + exports = module.exports = docs } - exports.docs = docs; + exports.docs = docs } else if (typeof define === 'function' && define.amd) { // AMD definition - define(function(require) { - return docs; - }); + define(() => docs) } else { - root.docs = docs; -} \ No newline at end of file + root.docs = docs +} From 100d2438aeae08d61ddc8b652cf27c4b8362cf19 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 14:10:45 -0500 Subject: [PATCH 179/273] updated standards --- app/config.js | 13 ++++++++----- app/docs.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/config.js b/app/config.js index 9f86d88..86979c7 100644 --- a/app/config.js +++ b/app/config.js @@ -1,3 +1,4 @@ +/* eslint-disable guard-for-in */ import { info, fs, is, to, Logger } from './utils' import path from 'path' import annotations from './annotations' @@ -7,8 +8,8 @@ let log = new Logger() // changed by `options` key const default_options = { - config: `${info.root}/docsfile.js`, - files: ['app/**/*', 'src/**/*', '*.md'], // files to search + config: `${info.root}/.docsfile.js`, + files: [ 'app/**/*', 'src/**/*', '*.md' ], // files to search // files to be ignored ignore: [ '.*', // all dot files @@ -72,7 +73,7 @@ export default async function config(options = {}) { try { // merge the default options with the user options config_file = require(config_file) - } catch(err) { + } catch (err) { config_file = {} } @@ -88,7 +89,9 @@ export default async function config(options = {}) { options.ignore, to.array(to.string(await fs.readFile(path.join(info.root, '.gitignore')))) ]) - } catch(err) {} + } catch (err) { + // do nothing because there's no `.gitignore` + } } @@ -152,4 +155,4 @@ function ensure_valid_config(user_config) { } return user_config -} \ No newline at end of file +} diff --git a/app/docs.js b/app/docs.js index a684783..ed28353 100644 --- a/app/docs.js +++ b/app/docs.js @@ -1,8 +1,15 @@ -'use strict'; +'use strict' import co from 'co' import path from 'path' -import { info, fs, is, to, glob, array, Logger } from './utils' +import { + info, + to, + fs, + glob, + array, + Logger +} from './utils' import parser from './parser' import sorter from './sorter' import get_config from './config' From 6362c350d72cb76b119d83a37ccb9c749455fc3c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 15:24:54 -0500 Subject: [PATCH 180/273] updated to use async --- app/docs.js | 38 ++++++++-------- app/utils/array.js | 110 +++++++++++++++++++++------------------------ app/utils/glob.js | 19 ++++---- 3 files changed, 80 insertions(+), 87 deletions(-) diff --git a/app/docs.js b/app/docs.js index ed28353..49822ed 100644 --- a/app/docs.js +++ b/app/docs.js @@ -1,6 +1,5 @@ 'use strict' -import co from 'co' import path from 'path' import { info, @@ -21,8 +20,10 @@ import get_config from './config' /// This is used to parse any filetype that you want to and gets the /// documentation for it and returns an `{}` of the document data //// -const docs = co.wrap(function*(options = {}) { - options = yield get_config(options) +export default async function docs(options = {}) { + options = await get_config(options) + /* eslint-disable no-unused-vars */ + // these are all the options that can be used let { files, ignore, @@ -36,30 +37,33 @@ const docs = co.wrap(function*(options = {}) { annotations, comments, } = options + /* eslint-enable no-unused-vars */ - let log = new Logger({ debug, warning, timestamps }); + let log = new Logger({ debug, warning, timestamps }) log.emit('start', 'total') try { - yield fs.ensureFile(info.temp.file) + await fs.ensureFile(info.temp.file) let json = fs.readFile(info.temp.file) log.emit('start', 'paths') - files = yield glob(files, ignore, changed ? has_file_changed : false) - let s = files.length > 1 ? 's' : '' + files = await glob(files, ignore, changed ? has_file_changed : false) + let s = files.length > 1 ? 's' : '' // eslint-disable-line log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${s} to parse`) log.emit('start', 'parser') - files = yield array(files).map((file_path) => parser({ file_path, ...options, log })) + files = await array(files).map((file_path) => parser({ file_path, ...options, log })) log.emit('complete', 'parser') // converts json to a readable JS object - json = changed ? to.string(yield json) : false + json = changed ? to.string(await json) : false json = !!json ? to.object(json) : {} // Loop through the parsed files and update the // json data that was stored. - for (let i in files) to.extend(json, files[i]) + for (let file of files) { + to.extend(json, file) + } // Update the temp json data. Even though this returns a promise // it's not returned below because there's no need to wait for it @@ -76,12 +80,10 @@ const docs = co.wrap(function*(options = {}) { log.emit('complete', 'total') return json - } catch(err) { + } catch (err) { log.error(err.stack) } -}) - -export default docs +} // @name has_file_changed // @access private @@ -95,15 +97,15 @@ async function has_file_changed(file) { let target = path.join(info.temp.folder, file) try { - let stats = await array([source, target]).map((_path) => fs.stat(_path)) + let stats = await array([ source, target ]).map((_path) => fs.stat(_path)) // copies new files over because it's changed if (stats[0].mtime > stats[1].mtime) { fs.fake_copy(source, target) return true - } else { - return false } + + return false } catch (err) { // copies new files over because it doesn't exist in the temp target directory fs.fake_copy(source, target) @@ -113,7 +115,7 @@ async function has_file_changed(file) { let logger = new Logger() -process.on('uncaughtException', function(err) { +process.on('uncaughtException', (err) => { logger.error('An uncaughtException was found:', err.stack) process.exit(1) }) diff --git a/app/utils/array.js b/app/utils/array.js index ce0fe55..941fc3f 100644 --- a/app/utils/array.js +++ b/app/utils/array.js @@ -1,12 +1,13 @@ -'use strict'; +/* eslint-disable no-bitwise */ +'use strict' -export default function async_array(array){ - return new AsyncArray(array); +export default function async_array(array) { + return new AsyncArray(array) } class AsyncArray { - constructor(array){ + constructor(array) { this.array = to_object(array) } @@ -15,8 +16,8 @@ class AsyncArray { /// /// @arg {function} callback - The function to be applied to each value. /// @arg {any} receiver - The `this` value in the callback. - *for_each(callback, receiver) { - yield promise_all_map(this.array, callback, receiver); + async for_each(callback, receiver) { + await promiseAll(this.array, callback, receiver) } /// @description @@ -24,10 +25,10 @@ class AsyncArray { /// /// @arg {function} callback - The function to be applied to each value. /// @arg {any} receiver - The `this` value in the callback. - *for_each_stepped(callback, receiver) { + async for_each_stepped(callback, receiver) { for (let i = 0; i < this.array.length; i++) { - if (i in obj) { - yield call(callback, receiver, this.array[i], i, this.array) + if (i in this.array) { + await call(callback, receiver, this.array[i], i, this.array) } } } @@ -39,8 +40,8 @@ class AsyncArray { /// @arg {function} callback - The function to be applied to each value. /// @arg {any} receiver - The `this` value in the callback. /// @return {array} - The mapped array. - *map(callback, receiver) { - return yield promise_all_map(this.array, callback, receiver) + async map(callback, receiver) { + return await promiseAll(this.array, callback, receiver) } /// @description @@ -50,16 +51,16 @@ class AsyncArray { /// @arg {function} callback - The function to be applied to each value. /// @arg {any} receiver - The `this` value in the callback. /// @return {array} - The mapped array. - *map_stepped(callback, receiver) { - let result = []; + async map_stepped(callback, receiver) { + let result = [] for (let i = 0; i < this.array.length; i++) { - if (i in obj) { - result.push(yield call(callback, receiver, this.array[i], i, this.array)); + if (i in this.array) { + result.push(await call(callback, receiver, this.array[i], i, this.array)) } } - return result; + return result } /// @description @@ -68,11 +69,9 @@ class AsyncArray { /// @arg {function} callback - The function to filter the values. /// @arg {any} receiver - The `this` value in the callback. /// @return {array} - The filtered array. - *filter(callback, receiver) { - const results = yield promise_all_map(this.array, callback, receiver) - return _filter(this.array, function(_, i) { - return results[i] - }) + async filter(callback, receiver) { + const results = await promiseAll(this.array, callback, receiver) + return _filter(this.array, (obj, i) => results[i]) } /// @description @@ -81,13 +80,13 @@ class AsyncArray { /// @arg {function} callback - The function to filter the values. /// @arg {any} receiver - The `this` value in the callback. /// @return {array} - The filtered array. - *filter_stepped(callback, receiver) { + async filter_stepped(callback, receiver) { const result = [] for (let i = 0; i < this.array.length; i++) { - if (i in obj) { + if (i in this.array) { const item = this.array[i] - if (yield call(callback, receiver, item, i, this.array)) { + if (await call(callback, receiver, item, i, this.array)) { // eslint-disable-line result[result.length] = item } } @@ -102,28 +101,28 @@ class AsyncArray { /// @arg {function} callback - The function to be applied to each value. /// @arg {any} receiver - The `this` value in the callback. /// @return {any} - The accumulated value. - *reduce(callback, initial) { - const obj = this.array; - const len = ~~this.array.length; - let accum = initial; - let start = 0; + async reduce(callback, initial) { + const obj = this.array + const len = ~~this.array.length + let accum = initial + let start = 0 if (arguments.length < 3) { for (; start < len; start++) { if (start in obj) { - accum = obj[start++]; - break; + accum = obj[start++] + break } } } for (let i = start; i < len; i++) { if (i in obj) { - accum = yield callback(accum, obj[i], i, array); + accum = await callback(accum, obj[i], i, this.array) } } - return accum; + return accum } /// @description @@ -133,14 +132,14 @@ class AsyncArray { /// @arg {function} callback - The function to test each value. /// @arg {any} receiver - The `this` value in the callback. /// @return Boolean - *some(callback, receiver) { + async some(callback, receiver) { for (let i = 0; i < this.array.length; i++) { - if (i in obj && (yield call(callback, receiver, this.array[i], i, this.array))) { - return true; + if (i in this.array && (await call(callback, receiver, this.array[i], i, this.array))) { + return true } } - return false; + return false } /// @description @@ -150,43 +149,38 @@ class AsyncArray { /// @arg {function} callback - The function to test each value. /// @arg {any} receiver - The `this` value in the callback. /// @return Boolean - *every(callback, receiver) { + async every(callback, receiver) { for (let i = 0; i < this.array.length; i++) { - if (i in this.array && !(yield call(callback, receiver, this.array[i], i, this.array))) { - return false; + if (i in this.array && !(await call(callback, receiver, this.array[i], i, this.array))) { + return false } } - return true; + return true } } -function promise_map(array, callback, receiver) { - const obj = to_object(array); - const len = ~~obj.length; - const promises = []; +function promiseAll(array, callback, receiver) { + const obj = to_object(array) + const len = ~~obj.length + const promises = [] for (let i = 0; i < len; i++) { if (i in obj) { - promises[promises.length] = call(callback, receiver, obj[i], i, array); + promises[promises.length] = call(callback, receiver, obj[i], i, array) } } - return promises; + return Promise.all(promises) } -function promise_all_map(array, callback, receiver) { - return Promise.all(promise_map(array, callback, receiver)); -} - -const callbind = Function.prototype.bind.bind(Function.prototype.call); -const call = callbind(Function.prototype.call); -const apply = callbind(Function.prototype.apply); -const _filter = callbind(Array.prototype.filter); +const callbind = Function.prototype.bind.bind(Function.prototype.call) +const call = callbind(Function.prototype.call) +const _filter = callbind(Array.prototype.filter) function to_object(value) { if (value == null) { - throw new TypeError(`Can't convert ${value} to obj`); + throw new TypeError(`Can't convert ${value} to obj`) } - return Object(value); -} \ No newline at end of file + return Object(value) +} diff --git a/app/utils/glob.js b/app/utils/glob.js index 5666c34..1952ae6 100644 --- a/app/utils/glob.js +++ b/app/utils/glob.js @@ -2,12 +2,11 @@ import to from './to' import is from './is' import array from './array' import denodeify from './denodeify' -import co from 'co' import path from 'path' // can't use `import` from es6 because it // returns an error saying "glob" is read only -let _glob = denodeify(require('glob')) +const original_glob = denodeify(require('glob')) /// @description @@ -19,12 +18,12 @@ let _glob = denodeify(require('glob')) /// @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 -const glob = co.wrap(function*(files, ignore = [], filter, files_only = true) { - files = array(to.array(files)).map((file) => _glob(file)); - ignore = array(to.array(ignore)).map((file) => _glob(file.replace(/!/, ''))) +export default async function glob(files, ignore = [], filter, files_only = true) { + files = array(to.array(files)).map((file) => original_glob(file)) + ignore = array(to.array(ignore)).map((file) => original_glob(file.replace(/!/, ''))) - files = to.flatten(yield files) - ignore = to.flatten(yield ignore) + files = to.flatten(await files) + ignore = to.flatten(await ignore) // removed any files that are supposed to be ignored if (ignore.length) { @@ -45,13 +44,11 @@ const glob = co.wrap(function*(files, ignore = [], filter, files_only = true) { if (is.fn(filter)) { if (is.promise(filter())) { - return yield array(files).filter(filter) + return await array(files).filter(filter) } return files.filter(filter) } return files -}) - -export default glob \ No newline at end of file +} From 92d1e48620c24a276d9b267c686cdff90661d0ce Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 15:30:18 -0500 Subject: [PATCH 181/273] fixed standard --- app/cli.js | 46 +++++++++++++++++++++++++++------------------- app/config.js | 12 ++++++------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/cli.js b/app/cli.js index 484bafa..30c53f4 100644 --- a/app/cli.js +++ b/app/cli.js @@ -1,18 +1,19 @@ +/* eslint-disable no-bitwise */ import pkg from '../package.json' -import {info, fs} from './utils' +import { info, fs, to } from './utils' import program from 'commander' import docs from './docs' -import {base_config} from './config' +import { base_config } 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 = (str) => false + const to_boolean = () => false const to_number = (str) => ~~str program .version(pkg.version) - .usage('docs [options]') + .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 @@ -20,35 +21,42 @@ export default function cli() { Note: Put globs quotes \`'.*, app/**/*'\` to avoid issues `) .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) - .option('-c, --config [path]', `Path to configuration file`, base_config.config) - .option('-f, --files ', `Paths to parsed`, to_list, base_config.files) - .option('-i, --ignore ', `Paths to ignore`, to_list, base_config.ignore) + .option('-c, --config [path]', 'Path to configuration file', base_config.config) + .option('-i, --ignore ', 'Paths to ignore', to_list, base_config.ignore) .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', base_config.gitignore) .option('-x, --no-debug', 'Output debugging information', to_boolean, base_config.debug) .option('-w, --no-warning', 'Output warning messages', to_boolean, base_config.warning) .option('-t, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) - .option('-a, --no-changed', `Parse changed files`, to_boolean, base_config.changed) - .option('-b, --blank-lines ', `Stops parsing lines after consecutive blank lines`, to_number, base_config.blank_lines) + .option('-a, --no-changed', 'Parse changed files', to_boolean, base_config.changed) + .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, base_config.blank_lines) + .option('-p, --print', 'This will only print the results instead of outputting them', false) .parse(process.argv) let { - noDebug: debug, - noWarning: warning, - noTimestamps: timestamps, - noChanged: changed, blankLines: blank_lines, + print, + dest, + args } = program + let files = to.flatten(args.map((arg) => to_list(arg))) + + if (!files.length) { + files = base_config.files + } return docs({ - debug, - warning, - timestamps, - changed, + files, ...program, blank_lines, }) - .then((parsed) => fs.outputJson(program.dest, parsed, { spaces: 2 })) + .then((parsed) => { + if (print) { + console.log(JSON.stringify(parsed, null, 2)) + } else { + fs.outputJson(dest, parsed, { spaces: 2 }) + } + }) .catch((err) => console.error(err.stack)) -} \ No newline at end of file +} diff --git a/app/config.js b/app/config.js index 86979c7..7d2071f 100644 --- a/app/config.js +++ b/app/config.js @@ -103,25 +103,25 @@ export default async function config(options = {}) { // ensures blank_lines is a number to avoid errors options.blank_lines = to.number(options.blank_lines) - let comments = {} + let parsed_comments = {} // ensures comments are a normal structure (aka not `'rb, py': {...}`) - for (let [option, value] of to.entries(options.comments)) { + for (let [ option, value ] of to.entries(options.comments)) { // converts option into an array so multiple languages can be declared at the same time option = option.replace(/\s/g, '').split(',') - for (let lang in option) comments[option[lang]] = value + for (let lang in option) parsed_comments[option[lang]] = value } // ensures each comment as all the required comment settings // this makes it easier later on when parsing - for (let [lang, value] of to.entries(comments)) { + for (let [ lang, value ] of to.entries(parsed_comments)) { if (lang !== '_') { - comments[lang] = to.extend(to.clone(default_comment), value) + parsed_comments[lang] = to.extend(to.clone(default_comment), value) } } - options.comments = comments + options.comments = parsed_comments options.annotations = new AnnotationApi(options.annotations) From a4b6efe573f07238e45d39b32c8f06a78afc1b8b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 17:17:35 -0500 Subject: [PATCH 182/273] fixes an issue where multiple instances of `docs` didn't work --- app/config.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/config.js b/app/config.js index 7d2071f..59a4a46 100644 --- a/app/config.js +++ b/app/config.js @@ -80,8 +80,13 @@ export default async function config(options = {}) { // merge the config file with passed options options = to.extend(ensure_valid_config(config_file), options) + // ensures `files`, `ignore` is always an array this way no + // more checks have to happen for it + options.files = to.array(options.files) + options.ignore = to.array(options.ignore) + // merge options with base_config so there's a complete list of settings - options = to.extend(base_config, options) + options = to.extend(to.extend({}, base_config), options) if (options.gitignore) { try { @@ -94,12 +99,6 @@ export default async function config(options = {}) { } } - - // ensures `files`, `ignore` is always an array this way no - // more checks have to happen for it - options.files = to.array(options.files) - options.ignore = to.array(options.ignore) - // ensures blank_lines is a number to avoid errors options.blank_lines = to.number(options.blank_lines) @@ -124,7 +123,6 @@ export default async function config(options = {}) { options.comments = parsed_comments options.annotations = new AnnotationApi(options.annotations) - return options } From d6bf1a4cb8ef1c9323daa89b18d7ca6d3abbdcb4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 17:25:43 -0500 Subject: [PATCH 183/273] always ignore json files --- app/config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/config.js b/app/config.js index 59a4a46..ca9f3e8 100644 --- a/app/config.js +++ b/app/config.js @@ -99,6 +99,9 @@ export default async function config(options = {}) { } } + // always ignore json files because they don't support comments + options.ignore.push('*.json') + // ensures blank_lines is a number to avoid errors options.blank_lines = to.number(options.blank_lines) From 11fefe28a1ff81c616889d585f22df4c857a082d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 18 Feb 2016 17:26:15 -0500 Subject: [PATCH 184/273] deleted a duplicate test case --- tests/cases/blank-file.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/cases/blank-file.js diff --git a/tests/cases/blank-file.js b/tests/cases/blank-file.js deleted file mode 100644 index e69de29..0000000 From d2d35d38f6f1b47aa840068aac2bd5aff88afcc4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 08:11:14 -0500 Subject: [PATCH 185/273] standards --- .eslintrc | 2 +- app/annotation_api.js | 59 +++++++++++++++++++++++++------------------ app/sorter/nav.js | 23 +++-------------- app/sorter/pages.js | 25 ++++++++++-------- 4 files changed, 52 insertions(+), 57 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5f9d166..670ea04 100644 --- a/.eslintrc +++ b/.eslintrc @@ -81,7 +81,7 @@ "min": 2, "max": 30, "properties": "always", - "exceptions": [ "i", "a", "b", "c", "d", "e", "x", "y", "z", "_", "t" ] + "exceptions": [ "i", "a", "b", "c", "d", "e", "l", "x", "y", "z", "_", "t" ] } ], "id-match": [ 2, "^(?:[a-z]{2,}([A-Z]{1}[a-z]+)*$)|([a-z_]+$)" ], diff --git a/app/annotation_api.js b/app/annotation_api.js index cf13308..9acb793 100644 --- a/app/annotation_api.js +++ b/app/annotation_api.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' import { is, to } from './utils' @@ -78,7 +78,7 @@ export default class AnnotationApi { // the name of the annotation is always the key const base_config = { // this declares where this annotation get's applied - filetypes: ['default'], + filetypes: [ 'default' ], // holds an array of aliases for the given annotation alias: [], @@ -97,7 +97,7 @@ export default class AnnotationApi { // annotation exists autofill: false, - // Runs after the parsed and/or autofill runs the contents + // 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) @@ -121,23 +121,22 @@ export default class AnnotationApi { config = { alias: config } - } - else if (is.fn(config)) { + } else if (is.fn(config)) { config = { parse: config } - } - else if (is.plain_object(config) && !is.empty(config) && !is.any.in(config, ...to.keys(base_config))) { + } else if (is.plain_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.flatten([filetype, config.filetype]) : to.array(filetype) - this.add(name, obj); + 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.plain_object(config)) { + } else if (!is.plain_object(config)) { throw new Error('config must be a function or object') return } @@ -149,11 +148,13 @@ export default class AnnotationApi { // 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 - } - }) + if (base_config.filetypes.hasOwnProperty(filetype)) { + to.merge(this.annotations, { + [is.falsy(base_config.filetypes[filetype]) ? 'default' : base_config.filetypes[filetype]]: { + [name]: base_config + } + }) + } } return this @@ -164,7 +165,9 @@ export default class AnnotationApi { /// @arg {array} annotations - Annotation objects add_annotations(annotations) { for (let name in annotations) { - this.add(name, annotations[name]) + if (annotations.hasOwnProperty(name)) { + this.add(name, annotations[name]) + } } } @@ -174,7 +177,11 @@ export default class AnnotationApi { /// 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 + if (!is.undefined(this.annotations[filetype])) { + return to.extend(to.clone(this.annotations.default), this.annotations[filetype]) + } + + return this.annotations.default } autofill_list(filetype) { @@ -187,7 +194,7 @@ export default class AnnotationApi { }) } - resolve_list(filetype) {} + resolve_list(filetype) {} // eslint-disable-line /// @name run_annotation /// @access private @@ -210,7 +217,7 @@ export default class AnnotationApi { contents = to.normalize(contents) return this.run({ annotation: { - name: name, + name, line: to.normalize(contents[0]), contents, start: null, @@ -268,10 +275,12 @@ export default class AnnotationApi { 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 + 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/sorter/nav.js b/app/sorter/nav.js index 324dc9c..8d0c4e1 100644 --- a/app/sorter/nav.js +++ b/app/sorter/nav.js @@ -7,7 +7,7 @@ export default function nav(pages) { let result = [] // loop over the pages structure to create the navigation - for (let [key, value] of to.entries(pages)) { + for (let [ key, value ] of to.entries(pages)) { result.push(set({ title: to.titleCase(to.sentenceCase(key)), href: `/${key}`, @@ -19,23 +19,6 @@ export default function nav(pages) { return result } - -// let nav = ((pages) => { -// let result = [] // placeholder to store the result -// -// // loop over the pages structure to create the navigation -// for (let [key, value] of to.entries(pages)) { -// result.push(set({ -// title: to.titleCase(to.sentenceCase(key)), -// href: `/${key}`, -// body: body_names(`/${key}`, value.page.body), -// subpages: [] -// }, value)) -// } -// -// return result -// } - /// @name body_names /// @description Helper function to get the name of each block in the body /// @arg {string} - the href to append the `name` of the block to @@ -67,7 +50,7 @@ function body_names(href, body) { /// @arg {object} - The inner structure to continue to loop over. /// @returns {object} function set(a, b) { - for (let [key, value] of to.entries(b)) { + for (let [ key, value ] of to.entries(b)) { if (key !== 'page') { let nav_item = { title: is.truthy(value.page.header.name) ? value.page.header.name : to.titleCase(to.sentenceCase(key)), @@ -89,4 +72,4 @@ function set(a, b) { } return a -} \ No newline at end of file +} diff --git a/app/sorter/pages.js b/app/sorter/pages.js index 7bf748e..b2782f6 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -1,3 +1,4 @@ +/* eslint-disable complexity, max-depth */ import { is, to } from '../utils' // placeholder for the result @@ -14,7 +15,7 @@ export default function pages(options = {}) { if (!is.empty(header)) { if (is.falsy(header.page)) { if (is.truthy(page_fallback)) { - header.page = [page_fallback] + header.page = [ page_fallback ] } else { log.emit('warning', ` Header comment ${header.name && '(' + header.name + ')'} doesn't have a \`@page\` defined in @@ -54,7 +55,9 @@ export default function pages(options = {}) { let index = (body.page || []).indexOf(page) // remove the page from the body comment - if (index > -1) block.page.splice(index, 1) + if (index > -1) { + block.page.splice(index, 1) + } } } @@ -84,7 +87,7 @@ function set(path, type, value) { // won't get added to the data delete value.page - let pages = result + let obj = result // convert to array, and filter out empty strings let path_list = path.split('/').filter(Boolean) @@ -96,20 +99,20 @@ function set(path, type, value) { // last one and create the `page`, and `nav` if they don't exist. for (let i = 0; i < length; i++) { let page = path_list[i] - if (!pages[page]) { - pages[page] = { + if (!obj[page]) { + obj[page] = { page: { header: {}, body: [] } } } - pages = pages[page] + obj = obj[page] } // a) Define the default data set(can't use `page` because it will be overwritten) - if (!pages[path_list[length]]) { - pages[path_list[length]] = { + if (!obj[path_list[length]]) { + obj[path_list[length]] = { page: { header: {}, body: [] @@ -118,8 +121,8 @@ function set(path, type, value) { } if (type === 'header') { - pages[path_list[length]].page.header = to.merge(pages[path_list[length]].page.header, value) + obj[path_list[length]].page.header = to.merge(obj[path_list[length]].page.header, value) } else { - pages[path_list[length]].page.body.push(value) + obj[path_list[length]].page.body.push(value) } -} \ No newline at end of file +} From 5b1c2ca097415100e5013d7cc370edb4ce677951 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 09:46:31 -0500 Subject: [PATCH 186/273] fixed a bug with `pages.js` This was caching result when docs was called more than once in the same file --- app/sorter/index.js | 12 +++--- app/sorter/pages.js | 94 ++++++++++++++++++++++----------------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/app/sorter/index.js b/app/sorter/index.js index 9c87e75..4b7a86a 100644 --- a/app/sorter/index.js +++ b/app/sorter/index.js @@ -1,6 +1,6 @@ import { is, to } from '../utils' -import get_pages from './pages' -import get_nav from './nav' +import getPages from './pages' +import getPav from './nav' /// @name sort /// @description @@ -8,13 +8,11 @@ import get_nav from './nav' /// @arg {object} /// @returns {object} export default function sorter(options = {}) { - let pages = get_pages(options) - - - let nav = get_nav(pages) + let pages = getPages(options) + let nav = getPav(pages) return { nav, pages } -} \ No newline at end of file +} diff --git a/app/sorter/pages.js b/app/sorter/pages.js index b2782f6..f93c4f1 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -1,14 +1,15 @@ /* eslint-disable complexity, max-depth */ import { is, to } from '../utils' -// placeholder for the result -let result = {} /// @name pages /// @description /// This function loops over the json that was passed and creates a organized structure /// based on the `@pages` annotations that were passed. export default function pages(options = {}) { + // placeholder for the result + let result = {} + let { json, page_fallback, log } = options for (let { path, header, body } of to.object_entries(json, 'path')) { @@ -69,60 +70,59 @@ export default function pages(options = {}) { } } - return result -} - + // @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 + function 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 = 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 = 0; i < length; i++) { + let page = path_list[i] + if (!obj[page]) { + obj[page] = { + page: { + header: {}, + body: [] + } + } + } + obj = obj[page] + } -// @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 -function 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 = 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 = 0; i < length; i++) { - let page = path_list[i] - if (!obj[page]) { - 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]] = { page: { header: {}, body: [] } } } - 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]] = { - page: { - header: {}, - body: [] - } + 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) } } - 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) - } + return result } From a9d98442a8b93c6fd0ab16c195129a6f9c273068 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 09:59:46 -0500 Subject: [PATCH 187/273] updated case tests --- tests/src/run.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/src/run.test.js b/tests/src/run.test.js index 365707b..c4b1455 100644 --- a/tests/src/run.test.js +++ b/tests/src/run.test.js @@ -9,14 +9,15 @@ const test_defaults = { debug: false, timestamps: false, warning: false, - changed: false + changed: false, + ignore: '.*' } test('case tests', async (mt) => { const base = path.join(__dirname, '..', 'cases') const actual_paths = await glob(path.join(base, '*'), [ path.join(base, '*.json') ]) - const actual = await array(actual_paths).map((file) => docs({ file, ...test_defaults })) + const actual = await array(actual_paths).map((files) => docs({ files, ...test_defaults })) const expected = await array(actual_paths).map((file) => fs.readJson(file.replace(/\..*$/, '.json'))) for (let i = 0; i < actual_paths.length; i++) { From d4ecd3fc1ad4b90434bbf3f4d1892c1260423e3d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 10:13:28 -0500 Subject: [PATCH 188/273] ensures the json file is updated correctly --- app/docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/docs.js b/app/docs.js index 49822ed..6ce075f 100644 --- a/app/docs.js +++ b/app/docs.js @@ -69,7 +69,7 @@ export default async function docs(options = {}) { // it's not returned below because there's no need to wait for it // to finish writing out the json file before moving on. Because the // `json` object has already been updated. - fs.outputJson(info.temp.file, json, { spaces: 2 }) + fs.outputJson(info.temp.file, (changed ? json : {}), { spaces: 2 }) .catch((err) => log.error(err.stack)) if (!raw) { From 5af8d426e4b76b62befe4419de0579c18329e8c9 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 10:27:45 -0500 Subject: [PATCH 189/273] fixed a bug where `__start` was being removed --- app/sorter/pages.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/sorter/pages.js b/app/sorter/pages.js index f93c4f1..42e32a8 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -38,12 +38,11 @@ export default function pages(options = {}) { } if (!is.empty(body)) { - for (let block_in_body of body) { - let { __start, ...block } = block_in_body + for (let block of body) { // warn the user that there isn't a page defined. if (is.all.empty(header.page, block.page)) { log.emit('warning', ` - ${block.name || 'a block'} starting on line ${__start} doesn't have a \`@page\` defined in + ${block.name || 'a block'} starting on line ${block.__start} doesn't have a \`@page\` defined in ${path} `) } From 193d8e8ba3c9c7dda6aeea85fd53ce630b1b6899 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 11:31:45 -0500 Subject: [PATCH 190/273] removed co as a dependency --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 88a8b13..83f39e6 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "babel-runtime": "^6.5.0", "change-case": "^2.3.1", "clor": "^1.6.0", - "co": "^4.6.0", "commander": "^2.9.0", "fs-extra": "^0.24.0", "glob": "^5.0.15", From 4bb8ba00635b0732ed195656e31b210de38df899 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 19 Feb 2016 11:31:58 -0500 Subject: [PATCH 191/273] Updated to standards --- .eslintrc | 4 +- app/annotations.js | 107 ++++++++++++--------- app/parser/autofill.js | 6 +- app/parser/get_blocks.js | 17 ++-- app/parser/index.js | 2 +- app/parser/parse_blocks.js | 8 +- app/parser/replace_aliases.js | 6 +- app/sorter/index.js | 1 - app/utils/array.js | 2 +- app/utils/denodeify.js | 6 +- app/utils/fs.js | 7 +- app/utils/index.js | 2 +- app/utils/info.js | 2 +- app/utils/is.js | 4 +- app/utils/logger.js | 56 +++-------- app/utils/purdy.js | 11 ++- app/utils/to.js | 171 ++++++++++++++++++++-------------- bin/docs | 2 +- 18 files changed, 216 insertions(+), 198 deletions(-) diff --git a/.eslintrc b/.eslintrc index 670ea04..60ebfed 100644 --- a/.eslintrc +++ b/.eslintrc @@ -81,7 +81,7 @@ "min": 2, "max": 30, "properties": "always", - "exceptions": [ "i", "a", "b", "c", "d", "e", "l", "x", "y", "z", "_", "t" ] + "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_]+$)" ], @@ -104,7 +104,6 @@ "new-parens": 2, "no-alert": 2, "no-array-constructor": 2, - "no-confusing-arrow": 2, "no-bitwise": 2, "no-caller": 2, "no-catch-shadow": 2, @@ -160,7 +159,6 @@ "no-trailing-spaces": 2, "no-undef-init": 2, "no-undef": 2, - "no-underscore-dangle": 2, "no-unneeded-ternary": 2, "no-unused-expressions": [ 2, { "allowShortCircuit": true, "allowTernary": true } ], "no-unused-vars": 2, diff --git a/app/annotations.js b/app/annotations.js index eb770f4..e7a1d17 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -38,7 +38,7 @@ function regex(name, str) { } function _markdown(...args) { - return to.markdown([...args].filter(Boolean).join('\n')) + return to.markdown([ ...args ].filter(Boolean).join('\n')) } @@ -84,7 +84,7 @@ const annotations = { /// @note Description runs through markdown /// @returns {object} arg: { - alias: ['argument', 'param', 'parameter'], + alias: [ 'argument', 'param', 'parameter' ], parse() { let [ types, @@ -93,12 +93,14 @@ const annotations = { description ] = regex('arg', this.annotation.line) - return [{ - types: list(types), - name, - value, - description: _markdown(description, this.annotation.contents) - }] + return [ + { + types: list(types), + name, + value, + description: _markdown(description, this.annotation.contents) + } + ] } }, @@ -107,7 +109,7 @@ const annotations = { /// @description Author of the documented item /// @returns {string} author: { - alias: ['authors'], + alias: [ 'authors' ], parse() { return list(this.annotation.line) } @@ -131,7 +133,7 @@ const annotations = { parse() { let [ version, description ] = regex('deprecated', this.annotation.line) return { - version: version, + version, description: _markdown(description, this.annotation.contents) } } @@ -143,7 +145,7 @@ const annotations = { /// @note Runs through markdown /// @returns {string} description: { - alias: ['desc', 'definition', 'explanation', 'writeup', 'summary', 'summarization'], + alias: [ 'desc', 'definition', 'explanation', 'writeup', 'summary', 'summarization' ], parse() { return _markdown(this.annotation.line, this.annotation.contents) } @@ -165,7 +167,7 @@ const annotations = { /// @returns {object} /// // markdown - `(id) {language} [settings] - description` markup: { - alias: ['code', 'example', 'output', 'outputs'], + alias: [ 'code', 'example', 'output', 'outputs' ], parse() { let escaped_characters = { '&': '&', @@ -182,22 +184,31 @@ const annotations = { description ] = regex('markup', this.annotation.line) - let raw = this.annotation.contents; + let raw = this.annotation.contents - let escaped = raw.split('\n').map((line) => line.replace(/[&<>'"]/g, (m) => escaped_characters[m])).join('\n'); + let escaped = raw + .split('\n') + .map((line) => line + .replace(/[&<>'"]/g, (match) => + escaped_characters[match] + ) + ) + .join('\n') if (is.string(settings)) { settings = to.object(list(settings).map((setting) => setting.split('='))) } - return [{ - id, - language, - settings, - description: _markdown(description), - raw, - escaped - }] + return [ + { + id, + language, + settings, + description: _markdown(description), + raw, + escaped + } + ] } }, @@ -206,7 +217,7 @@ const annotations = { /// @description Name of the documented item /// @returns {string} name: { - alias: ['title', 'heading'] + alias: [ 'title', 'heading' ] }, /// @name @note @@ -217,10 +228,12 @@ const annotations = { parse() { let [ importance, description ] = regex('note', this.annotation.line) - return [{ - importance, - description: _markdown(description, this.annotation.contents) - }] + return [ + { + importance, + description: _markdown(description, this.annotation.contents) + } + ] } }, @@ -229,7 +242,7 @@ const annotations = { /// @description The page you want the documented item to be on /// @returns {string} page: { - alias: ['group'], + alias: [ 'group' ], parse() { return list(this.annotation.line) } @@ -250,15 +263,17 @@ const annotations = { /// @description Requirements from the documented item /// @returns {object} requires: { - alias: ['require'], + alias: [ 'require' ], parse() { let [ types, name, description ] = regex('requires', this.annotation.line) - return [{ - types: list(types), - name, - description: _markdown(description, this.annotation.contents) - }] + return [ + { + types: list(types), + name, + description: _markdown(description, this.annotation.contents) + } + ] } }, @@ -267,7 +282,7 @@ const annotations = { /// @description Return from the documented function /// @returns {string} returns: { - alias: ['return'], + alias: [ 'return' ], parse() { let [ types, description ] = regex('returns', this.annotation.line) @@ -334,13 +349,19 @@ const annotations = { /// // todo - {5} [assignee-one, assignee-two] - Task to be done todo: { parse() { - let [ importance, assignees, description ] = regex('todo', this.annotation.line) - - return [{ + let [ importance, - assignees: list(assignees), - description: _markdown(description, this.annotation.contents) - }] + assignees, + description + ] = regex('todo', this.annotation.line) + + return [ + { + importance, + assignees: list(assignees), + description: _markdown(description, this.annotation.contents) + } + ] } }, @@ -348,9 +369,9 @@ const annotations = { /// @description /// The error that happends if something goes wrong throws: { - alias: ['throws', 'exception', 'error'], + alias: [ 'throws', 'exception', 'error' ], parse() { - return [join(this.annoation.line, this.annoation.content)] + return [ _markdown(this.annoation.line, this.annoation.content) ] } }, diff --git a/app/parser/autofill.js b/app/parser/autofill.js index f516980..3dc37ff 100644 --- a/app/parser/autofill.js +++ b/app/parser/autofill.js @@ -5,15 +5,15 @@ import { is, to } from '../utils' // @description // This function is used to run the all the functions that autofill if not defined. export default function autofill(options) { - let { autofill_list, parsed, block, log } = options + let { autofill_list, parsed, block/* , log */ } = options let parsed_keys = to.keys(parsed) - for (let [annotation, annotation_autofill] of to.entries(autofill_list)) { + for (let [ annotation, annotation_autofill ] of to.entries(autofill_list)) { if (!is.in(parsed_keys, annotation)) { parsed[annotation] = is.fn(annotation_autofill) ? annotation_autofill.call(block) : annotation_autofill } } return parsed -} \ No newline at end of file +} diff --git a/app/parser/get_blocks.js b/app/parser/get_blocks.js index d30eb15..6711b66 100644 --- a/app/parser/get_blocks.js +++ b/app/parser/get_blocks.js @@ -1,3 +1,4 @@ +/* eslint-disable complexity, max-statements, max-depth */ import { is, to } from '../utils' /// @name blocks @@ -5,7 +6,7 @@ import { is, to } from '../utils' /// @description Parses the file and returns the comment blocks in an array /// @returns {array} of the comment blocks /// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. -export default function get_blocks(options) { +export default function getBlocks(options) { let { file, contents, @@ -37,10 +38,10 @@ export default function get_blocks(options) { for (let i = start_at, l = lines.length; i < l; i++) { let line = lines[i] let index = { - start: style === 'multi' && is.in(line, comment.start) ? line.indexOf(comment.start) : false, - line: is.in(line, comment.line) ? line.indexOf(comment.line) : false, - end: style === 'multi' && is.in(line, comment.end) ? line.indexOf(comment.end) : false - } + start: style === 'multi' && is.in(line, comment.start) ? line.indexOf(comment.start) : false, + line: is.in(line, comment.line) ? line.indexOf(comment.line) : false, + end: style === 'multi' && is.in(line, comment.end) ? line.indexOf(comment.end) : false + } // a) The line isn't empty so parse it. if (!is.empty(line)) { @@ -134,13 +135,11 @@ export default function get_blocks(options) { parsed.push(block) } } - } - // the last line in the file was an empty line. - else if (i === l - 1 && is.truthy(block)) { + } else if (i === l - 1 && is.truthy(block)) { // the last line in the file was an empty line. block[is.between(block.comment.end) ? 'comment' : 'code'].end = i parsed.push(block) } } // end loop return parsed -} \ No newline at end of file +} diff --git a/app/parser/index.js b/app/parser/index.js index b63fc59..a41ba74 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -74,4 +74,4 @@ export default async function parser(options = {}) { return { [file.path]: { header, body } } -} \ No newline at end of file +} diff --git a/app/parser/parse_blocks.js b/app/parser/parse_blocks.js index b4502d7..67ca908 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse_blocks.js @@ -25,9 +25,7 @@ export default function parse_blocks(options = {}) { let autofill_list = annotations.autofill_list(file.type) // loop over each block - for (let i in blocks) { - let block = blocks[i] - + for (let block of blocks) { block.comment.contents = to.normalize(block.comment.contents) block.code.contents = to.normalize(block.code.contents) @@ -71,7 +69,7 @@ function parse_block(options = {}) { } = options // gets the annotations to use on this file - let annotations_list = annotations.list(file.type); + let annotations_list = annotations.list(file.type) let keys = to.keys(annotations_list) let contents = to.array(block.comment.contents) @@ -140,4 +138,4 @@ function parse_block(options = {}) { } // end block loop return block_annotations -} \ No newline at end of file +} diff --git a/app/parser/replace_aliases.js b/app/parser/replace_aliases.js index adc653e..516bcd3 100644 --- a/app/parser/replace_aliases.js +++ b/app/parser/replace_aliases.js @@ -6,7 +6,7 @@ import { is, to } from '../utils' /// This function is used to replace all instances of aliases in a file /// @returns {string} - The file with the instances of aliases removed export default function aliases(options = {}) { - let { contents, annotations, comment, log } = options + let { contents, annotations, comment } = options /* , log */ let main_annotation_list = to.keys(annotations) @@ -18,7 +18,7 @@ export default function aliases(options = {}) { return false }) - for (let [annotation, alias_list] of to.entries(annotations)) { + for (let [ annotation, alias_list ] of to.entries(annotations)) { // sorts the aliases based off their length. This is to ensure if to two // or more aliases are similar they will always get replaced correctly // aka `param` and `parameter` @@ -30,4 +30,4 @@ export default function aliases(options = {}) { } return contents -} \ No newline at end of file +} diff --git a/app/sorter/index.js b/app/sorter/index.js index 4b7a86a..d760a63 100644 --- a/app/sorter/index.js +++ b/app/sorter/index.js @@ -1,4 +1,3 @@ -import { is, to } from '../utils' import getPages from './pages' import getPav from './nav' diff --git a/app/utils/array.js b/app/utils/array.js index 941fc3f..60ee708 100644 --- a/app/utils/array.js +++ b/app/utils/array.js @@ -1,4 +1,4 @@ -/* eslint-disable no-bitwise */ +/* eslint-disable no-bitwise, babel/no-await-in-loop */ 'use strict' export default function async_array(array) { diff --git a/app/utils/denodeify.js b/app/utils/denodeify.js index 2c7405e..39484e0 100644 --- a/app/utils/denodeify.js +++ b/app/utils/denodeify.js @@ -7,9 +7,9 @@ // import fs from "fs" // fs.readFile = denodeify(fs.readFile) export default function denodeify(func) { - return function(...args) { + return function plugin(...args) { return new Promise((resolve, reject) => { - func(...args, (err, ...args) => err ? reject(err) : resolve(...args)) + func(...args, (err, ...func_args) => err ? reject(err) : resolve(...func_args)) }) } -} \ No newline at end of file +} diff --git a/app/utils/fs.js b/app/utils/fs.js index fe72c15..840de92 100644 --- a/app/utils/fs.js +++ b/app/utils/fs.js @@ -8,9 +8,8 @@ import fs from 'fs-extra' // 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); + 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)), () => { @@ -25,4 +24,4 @@ fs.stat = denodeify(fs.stat) fs.readFile = denodeify(fs.readFile) fs.ensureFile = denodeify(fs.ensureFile) -export default fs \ No newline at end of file +export default fs diff --git a/app/utils/index.js b/app/utils/index.js index 0212641..8b97345 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,6 +1,6 @@ export denodeify from './denodeify' export Logger from './logger' -export {Purdy} from './purdy' +export { Purdy } from './purdy' export fs from './fs' export glob from './glob' export info from './info' diff --git a/app/utils/info.js b/app/utils/info.js index db1cfe8..67060c4 100644 --- a/app/utils/info.js +++ b/app/utils/info.js @@ -12,4 +12,4 @@ info.temp = {} info.temp.folder = path.join(info.root, '.tmp') info.temp.file = path.join(info.temp.folder, 'data.json') -export default info \ No newline at end of file +export default info diff --git a/app/utils/is.js b/app/utils/is.js index 2ed8b00..c549c6b 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -45,7 +45,7 @@ is.plain_object = (arg) => to_string(arg) === '[object Object]' /// @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), +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? @@ -94,4 +94,4 @@ is.any.in = (obj, ...values) => { } -export default is \ No newline at end of file +export default is diff --git a/app/utils/logger.js b/app/utils/logger.js index bfca257..953edc6 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -1,16 +1,19 @@ import Purdy from './purdy' -import $ from 'clor' +import clor from 'clor' -let chevron = '\xBB' -let check = '\u2713' -let warning = '\u26A0' -let error = '\u2326' + +let icon = { + chevron: '\xBB', + check: '\u2713', + warning: '\u26A0', + error: '\u2326' +} const messaging = { - warning: $.yellow.bold(`${warning} [WARNING]`), - debug: $.magenta.bold(`${chevron}[DEBUG]`), - error: $.red.bold(`${error}[ERROR]`), - file: $.bgBlue.white(`${chevron}[FILE]`) + 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() @@ -52,8 +55,8 @@ export default class Logger { timestamps = true } = options - this.on('annotation_error', ({ annotation, error }) => - this.error(`with ${annotation}`, error)) + this.on('annotation_error', ({ annotation, error_message }) => + this.error(`with ${annotation}`, error_message)) if (timestamps) { this @@ -105,7 +108,7 @@ export default class Logger { let duration = Date.now() - time console.log( - `${$.green(check)} ${format}`, + `${clor.green(icon.check)} ${format}`, label, duration ) @@ -132,32 +135,3 @@ export default class Logger { return this } } - -// .on('fly_run', ({ path }) => -// log(`Flying with ${fmt.path}...`, path)) -// -// .on('flyfile_not_found', ({ error }) => -// log(`No Flyfile Error: ${fmt.error}`, error)) -// -// .on('fly_watch', () => -// log(`${fmt.warn}`, 'Watching files...')) -// -// .on('plugin_load', ({ plugin }) => -// log(`Loading plugin ${fmt.title}`, plugin)) -// -// .on('plugin_error', ({ plugin, error }) => -// log(`${fmt.error} failed due to ${fmt.error}`, plugin, error)) -// -// .on('task_error', ({ task, error }) => { -// trace(error) -// log(`${fmt.error} failed due to ${fmt.error}`, task, error) -// }) -// -// .on('task_start', ({ task }) => -// log(`Starting ${fmt.start}`, task)) -// -// .on('task_complete', ({ task, duration }) => { -// const time = timeInfo(duration) -// log(`Finished ${fmt.complete} in ${fmt.secs}`, -// task, time.duration, time.scale) -// }) diff --git a/app/utils/purdy.js b/app/utils/purdy.js index 4b81720..075a3c5 100644 --- a/app/utils/purdy.js +++ b/app/utils/purdy.js @@ -1,6 +1,6 @@ // Load modules import to from './to' -import $ from 'clor' +import clor from 'clor' export default class Purdy { constructor(options = {}) { @@ -73,7 +73,7 @@ export default class Purdy { colors = colors.split('.') for (let color of colors) { - string = $[color](string) + string = clor[color](string) } return string @@ -221,7 +221,7 @@ export default class Purdy { _string(str) { str = to.normalize(str, false).split('\n') - let quote = str.length > 1 ? '`' : `'` + let quote = str.length > 1 ? '`' : "'" let l = str.length // returns because it's a single line string @@ -229,7 +229,7 @@ export default class Purdy { return quote + str[0] + quote } - let has_newline_only = /(?:\s*?(\n)\s*?)(.*)/.exec(str[0]) + // 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) @@ -237,8 +237,9 @@ export default class Purdy { // removes the first line from the str so it doesn't get indented let out = str.splice(0, 1) - for (let line of str) + for (let line of str) { out.push(this.indent() + this.colorize(line, 'string')) + } return out.join('\n') } diff --git a/app/utils/to.js b/app/utils/to.js index a240365..b78d255 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -61,7 +61,7 @@ let to = { /// @arg {object} /// @returns {array} keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && - to.flatten([Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg)]), + to.flatten([ Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg) ]), /// @name to.entries /// @description @@ -113,13 +113,13 @@ let to = { let key = keys[index] index++ return { - value: [key, obj[key]] - } - } else { - return { - done: true + value: [ key, obj[key] ] } } + + return { + done: true + } } } }, @@ -189,21 +189,27 @@ let to = { content = to.array(content) // this allows arrays and strings to be passed // remove leading blank lines - if (leading) - while (content.length && !!!content[0].trim().length) - content.shift() + if (leading) { + while (content.length && !!!content[0].trim().length) content.shift() + } // remove trailing blank lines - if (trailing) - while (content.length && !!!(content[content.length - 1].trim()).length) - 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 from each line + if (trailing) { + while (content.length && !!!(content[content.length - 1].trim()).length) content.pop() + } + + let trim_by = content.join('\n') // converts content to string to 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 + + return content + .map((line) => line.slice(trim_by)) // 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 }, /// @name to.extend @@ -219,7 +225,7 @@ let to = { return a } - let k = to.keys(b) + let k = to.keys(b) // eslint-disable-line for (let i = 0, l = k.length; i < l; i++) { if (is.plain_object(b[k[i]])) { @@ -241,31 +247,33 @@ let to = { clone(arg) { // Basis. if (!(arg instanceof Object)) { - return arg; + return arg } - let clone; + let clone // Filter out special objects. - let Constructor = arg.constructor; + let Constructor = arg.constructor switch (Constructor) { // Implement other special objects here. + /* eslint-disable indent */ case RegExp: - clone = new Constructor(arg); - break; + clone = new Constructor(arg) + break case Date: - clone = new Constructor(arg.getTime()); - break; + clone = new Constructor(arg.getTime()) + break default: - clone = new Constructor(); + clone = new Constructor() + /* eslint-enable indent */ } // Clone each property. - for (var prop in arg) { - clone[prop] = to.clone(arg[prop]); + for (var prop in arg) { // eslint-disable-line + clone[prop] = to.clone(arg[prop]) } - return clone; + return clone }, /// @name to.merge @@ -295,7 +303,16 @@ let to = { /// /// @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" } } + /// 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) /// @@ -310,7 +327,7 @@ let to = { /// garply: "item" // didn't exist before so it stays as a string /// } /// } - merge(a, b, unique = true, flat = true) { + merge(a, b, unique = true, flat = true) { // eslint-disable-line // a) Don't touch `null` or `undefined` objects. if (!a || !b) { return a @@ -318,33 +335,35 @@ let to = { // 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.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.plain_object(a[k])) { - a[k] = is.plain_object(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]) + 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.plain_object(a[k])) { + a[k] = is.plain_object(b[k]) ? to.merge(a[k], b[k]) : b[k] + } else { + a[k] = [ a[k], b[k] ] } - // a) Filter out duplicates - if (unique && !is.plain_object(a[k][0])) { - a[k] = to.unique(a[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.plain_object(a[k][0])) { + a[k] = to.unique(a[k]) + } } } } @@ -387,10 +406,10 @@ let to = { } else if (is.string(arg)) { return arg.split(glue) } else if (is.plain_object(arg) || is.number(arg)) { - return [arg] - } else { - return [] + return [ arg ] } + + return [] }, /// @name to.flatten @@ -410,14 +429,15 @@ let to = { return arg } - let o = {} - let r = [] + let obj = {} + let result = [] + /* eslint-disable guard-for-in */ + for (let i in arg) obj[arg[i]] = arg[i] - for (let i in arg) o[arg[i]] = arg[i] + for (let i in obj) result.push(obj[i]) + /* eslint-enable guard-for-in */ - for (let i in o) r.push(o[i]) - - return r + return result }, /// @name to.sort @@ -450,7 +470,7 @@ let to = { let result = {} - for (let [key, value] of to.entries(arg)) { + for (let [ key, value ] of to.entries(arg)) { let cb_result = callback(value, key) if (is.truthy(cb_result) && !is.empty(cb_result) && is.plain_object(cb_result)) { to.extend(result, cb_result) @@ -467,7 +487,7 @@ let to = { let result = {} - for (let [key, value] of to.entries(arg)) { + for (let [ key, value ] of to.entries(arg)) { if (is.truthy(callback(value, key, arg))) { to.extend(result, { key: value }) } @@ -481,8 +501,17 @@ let to = { /// Converts `arg` to number /// @arg {number, array, object, string, boolean} /// @returns {number} - number: (arg) => is.number(arg) ? arg : is.array(arg) ? - arg.length : is.plain_object(arg) ? to.keys(arg).length : ~~arg + number: (arg) => { + if (is.number(arg)) { + return arg + } else if (is.array(arg)) { + return arg.length + } else if (is.plain_object(arg)) { + return to.keys(arg).length + } + + return ~~arg // eslint-disable-line + } } export default to diff --git a/bin/docs b/bin/docs index c8a6279..c0c8dc7 100755 --- a/bin/docs +++ b/bin/docs @@ -1,4 +1,4 @@ #!/usr/bin/env node -'use strict'; +'use strict' require('../dist/cli.js').default() From 6d6553574a34a4eccebda60d752d89e0522b0615 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 22 Feb 2016 12:25:04 -0500 Subject: [PATCH 192/273] Updated test cases This is a big change to use Mocha instead of Tape. While I like how easy tape is to use, it just doesn't provide the information that I need when I'm trying to debug complex test cases. --- .eslintrc | 1 + app/annotations.js | 7 +- app/docs.js | 11 +- package.json | 22 +- tests/cases/header-comment-only.json | 39 +++ .../header-comment-only.scss | 0 ...pace-between-header-and-body-comments.json | 60 +++++ ...pace-between-header-and-body-comments.scss | 3 +- tests/cases/only-body-comments-no-page.json | 4 + tests/cases/only-body-comments-no-page.scss | 20 ++ tests/cases/only-body-comments.json | 152 +++++++++++ .../only-body-comments.scss | 41 +-- tests/run.test.js | 43 ++++ tests/src/run.test.js | 34 --- tests/src/unit/utils/is.test.js | 135 ---------- tests/src/unit/utils/to.test.js | 240 ------------------ .../unit/crappy_file_saved_on_windows.cs | 0 tests/{src => }/unit/utils/array.test.js | 0 tests/{src => }/unit/utils/denodeify.test.js | 0 tests/{src => }/unit/utils/glob.test.js | 0 tests/{src => }/unit/utils/info.test.js | 0 tests/unit/utils/is.test.js | 130 ++++++++++ tests/{src => }/unit/utils/log.test.js | 0 tests/unit/utils/to.test.js | 226 +++++++++++++++++ 24 files changed, 716 insertions(+), 452 deletions(-) create mode 100644 tests/cases/header-comment-only.json rename tests/{file-types/edge-cases => cases}/header-comment-only.scss (100%) create mode 100644 tests/cases/no-space-between-header-and-body-comments.json rename tests/{file-types/edge-cases => cases}/no-space-between-header-and-body-comments.scss (96%) create mode 100644 tests/cases/only-body-comments-no-page.json create mode 100644 tests/cases/only-body-comments-no-page.scss create mode 100644 tests/cases/only-body-comments.json rename tests/{file-types/edge-cases => cases}/only-body-comments.scss (57%) create mode 100644 tests/run.test.js delete mode 100644 tests/src/run.test.js delete mode 100644 tests/src/unit/utils/is.test.js delete mode 100644 tests/src/unit/utils/to.test.js rename tests/{src => }/unit/crappy_file_saved_on_windows.cs (100%) rename tests/{src => }/unit/utils/array.test.js (100%) rename tests/{src => }/unit/utils/denodeify.test.js (100%) rename tests/{src => }/unit/utils/glob.test.js (100%) rename tests/{src => }/unit/utils/info.test.js (100%) create mode 100644 tests/unit/utils/is.test.js rename tests/{src => }/unit/utils/log.test.js (100%) create mode 100644 tests/unit/utils/to.test.js diff --git a/.eslintrc b/.eslintrc index 60ebfed..ec8652c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,6 +26,7 @@ }, "env": { "node": true, + "mocha": true, "es6": true }, "parser": "babel-eslint", diff --git a/app/annotations.js b/app/annotations.js index e7a1d17..ffdeb5f 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -178,7 +178,7 @@ const annotations = { } let [ - id = false, + id = '0', language = this.file.type, settings = {}, description @@ -321,11 +321,12 @@ const annotations = { state: { parse() { let states = this.annotation.contents.split('\n') - let [ markup_id, state_line ] = regex('state_id', this.annotation.line) + let [ markup_id = '0', state_line ] = regex('state_id', this.annotation.line) states.unshift(state_line) states = states.filter(Boolean).map((line, i) => { - let [ state, state_id = `${i}`, description ] = regex('state', line) + let [ state = '', state_id = `${i}`, description = '' ] = regex('state', line) + return { state, state_id, diff --git a/app/docs.js b/app/docs.js index 6ce075f..db7f713 100644 --- a/app/docs.js +++ b/app/docs.js @@ -114,8 +114,9 @@ async function has_file_changed(file) { } -let logger = new Logger() -process.on('uncaughtException', (err) => { - logger.error('An uncaughtException was found:', err.stack) - process.exit(1) -}) +// let logger = new Logger() +// process.on('uncaughtException', (err) => { +// logger.error('An uncaughtException was found:', err) +// console.trace(err) +// process.exit(1) +// }) diff --git a/package.json b/package.json index 83f39e6..d2695fa 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,13 @@ "main": "dist/index.js", "scripts": { "clean": "rm -rf ./dist", - "compile": "npm run clean; babel app/ -d dist/; babel tests/src -d tests/dist/", - "watch": "npm run clean; babel app/ -d dist/ --watch;", - "clean-tests": "rm -rf ./tests/dist", - "compile-tests": "npm run clean-tests; babel tests/src -d tests/dist/", - "watch-tests": "npm run clean-tests; babel tests/src -d tests/dist/ --watch", - "unit-tests": "tape tests/dist/unit/**/*.js | tap-diff", - "mock-tests": "tape tests/dist/run.test.js | tap-diff", - "test": "tape tests/dist/**/*.js | tap-diff", - "test-verbose": "tape tests/dist/**/*.js | tap-diff", + "refresh": "rm -rf -- node_modules/ .tmp/ dist/; npm i", + "compile": "npm run clean; babel app/ -d dist/", + "watch": "npm run clean; babel app/ -d dist/ --watch", + "mocha": "mocha --compilers js:babel-register --ui tdd --check-leaks", + "unit-tests": "npm run mocha -- tests/unit/**/*.js", + "mock-tests": "npm run mocha -- --delay tests/run.test.js", + "test": "npm run unit-tests; npm run mock-tests", "coverage": "nyc npm test", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", "plato": "plato -d coverage/plato dist/index.js", @@ -68,12 +66,10 @@ "coveralls": "^2.11.6", "eslint": "^2.1.0", "eslint-plugin-babel": "^3.1.0", + "mocha": "^2.4.5", "nyc": "^3.2.2", "proxyquire": "^1.7.4", - "sinon": "^1.17.3", - "tap-diff": "^0.1.1", - "tap-prettify": "0.0.2", - "tape": "^4.4.0" + "sinon": "^1.17.3" }, "babel": { "presets": [ diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json new file mode 100644 index 0000000..1e5f20b --- /dev/null +++ b/tests/cases/header-comment-only.json @@ -0,0 +1,39 @@ +{ + "nav": [ + { + "title": "Edge Cases", + "href": "/edge-cases", + "body": [], + "subpages": [ + { + "title": "Header", + "href": "/edge-cases/header-comment-only", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "edge-cases": { + "page": { + "header": {}, + "body": [] + }, + "header-comment-only": { + "page": { + "header": { + "__start": 0, + "__end": 6, + "name": "Header", + "author": [ + "Tyler Benton" + ], + "access": "public" + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/edge-cases/header-comment-only.scss b/tests/cases/header-comment-only.scss similarity index 100% rename from tests/file-types/edge-cases/header-comment-only.scss rename to tests/cases/header-comment-only.scss 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..0275913 --- /dev/null +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -0,0 +1,60 @@ +{ + "nav": [ + { + "title": "Edge Cases", + "href": "/edge-cases", + "body": [], + "subpages": [ + { + "title": "No Space Between Header And Body Comment", + "href": "/edge-cases/no-space-between-header-and-body-comment", + "body": [ + { + "title": "moz-only", + "href": "/edge-cases/no-space-between-header-and-body-comment#moz-only" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "edge-cases": { + "page": { + "header": {}, + "body": [] + }, + "no-space-between-header-and-body-comment": { + "page": { + "header": { + "__start": 0, + "__end": 3, + "author": [ + "Tyler Benton" + ], + "access": "public" + }, + "body": [ + { + "__start": 4, + "__end": 27, + "name": "moz-only", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": {}, + "description": "

(example="false") 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}" + } + ], + "access": "public" + } + ] + } + } + } + } +} diff --git a/tests/file-types/edge-cases/no-space-between-header-and-body-comments.scss b/tests/cases/no-space-between-header-and-body-comments.scss similarity index 96% rename from tests/file-types/edge-cases/no-space-between-header-and-body-comments.scss rename to tests/cases/no-space-between-header-and-body-comments.scss index 2349e33..3c48d0a 100644 --- a/tests/file-types/edge-cases/no-space-between-header-and-body-comments.scss +++ b/tests/cases/no-space-between-header-and-body-comments.scss @@ -3,7 +3,6 @@ /// @page edge-cases/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:** /// @include moz-only(){ @@ -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..fc22cd6 --- /dev/null +++ b/tests/cases/only-body-comments-no-page.json @@ -0,0 +1,4 @@ +{ + "nav": [], + "pages": {} +} diff --git a/tests/cases/only-body-comments-no-page.scss b/tests/cases/only-body-comments-no-page.scss new file mode 100644 index 0000000..7c98ae3 --- /dev/null +++ b/tests/cases/only-body-comments-no-page.scss @@ -0,0 +1,20 @@ +/// @name Button group +/// @description +/// Used when there's a group of buttons that need to be on the same line. +/// +/// @markup +///
+/// Button (a.button) +/// +/// +///
+ +/// @name Test +/// @state .state-1 +/// @state .state-2 +/// @state .state-3 +/// @description +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +/// Quasi omnis facilis vero architecto perferendis, debitis dignissimos tempore +/// dolorem amet. Delectus, voluptatum, distinctio. Voluptas officiis +/// iste nostrum vel, culpa iure. Adipisci. diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json new file mode 100644 index 0000000..d70f0aa --- /dev/null +++ b/tests/cases/only-body-comments.json @@ -0,0 +1,152 @@ +{ + "nav": [ + { + "title": "Components", + "href": "/components", + "body": [], + "subpages": [ + { + "title": "Buttons", + "href": "/components/buttons", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "components": { + "page": { + "header": {}, + "body": [] + }, + "buttons": { + "page": { + "header": {}, + "body": [ + { + "__start": 0, + "__end": 31, + "author": [ + "Tyler Benton" + ], + "state": [ + { + "markup_id": "0", + "states": [ + { + "state": ":hover", + "state_id": "0", + "description": "" + }, + { + "state": ":active", + "state_id": "1", + "description": "" + }, + { + "state": ":disabled", + "state_id": "2", + "description": "

Dims the button when disabled.

\n" + }, + { + "state": ".c-btn--mini", + "state_id": "3", + "description": "

A mini button

\n" + }, + { + "state": ".c-btn--tiny", + "state_id": "4", + "description": "

A tiny button

\n" + }, + { + "state": ".c-btn--medium", + "state_id": "5", + "description": "

A medium button

\n" + }, + { + "state": ".c-btn--large", + "state_id": "6", + "description": "

A large button

\n" + }, + { + "state": ".c-btn--primary", + "state_id": "7", + "description": "

Primary action

\n" + }, + { + "state": ".c-btn--primary:hover", + "state_id": "8", + "description": "" + }, + { + "state": ".c-btn--primary:active", + "state_id": "9", + "description": "" + }, + { + "state": ".c-btn--secondary", + "state_id": "10", + "description": "

Secondary action

\n" + }, + { + "state": ".c-btn--secondary:hover", + "state_id": "11", + "description": "" + }, + { + "state": ".c-btn--secondary:active", + "state_id": "12", + "description": "" + }, + { + "state": ".c-btn--tertiary", + "state_id": "13", + "description": "

Tertiary action

\n" + }, + { + "state": ".c-btn--tertiary:hover", + "state_id": "14", + "description": "" + }, + { + "state": ".c-btn--tertiary:active", + "state_id": "15", + "description": "" + }, + { + "state": ".c-btn--text", + "state_id": "16", + "description": "

It's a text link as a button

\n" + }, + { + "state": ".c-btn--text:hover", + "state_id": "17", + "description": "" + }, + { + "state": ".c-btn--text:active", + "state_id": "18", + "description": "" + } + ] + } + ], + "markup": [ + { + "id": "0", + "language": "scss", + "settings": {}, + "description": "", + "raw": "
\n Button (a.button)\n \n \n
", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn @state">Button (a.button)</a>\n <button class="c-btn @state">Button (button)</button>\n <input class="c-btn @state" type="button" value="Button (input.button)">\n</div>" + } + ], + "access": "public" + } + ] + } + } + } + } +} diff --git a/tests/file-types/edge-cases/only-body-comments.scss b/tests/cases/only-body-comments.scss similarity index 57% rename from tests/file-types/edge-cases/only-body-comments.scss rename to tests/cases/only-body-comments.scss index d345f51..813669b 100644 --- a/tests/file-types/edge-cases/only-body-comments.scss +++ b/tests/cases/only-body-comments.scss @@ -3,25 +3,26 @@ /// /// @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 +/// @state +/// {:hover} +/// {:active} +/// {:disabled} - Dims the button when disabled. +/// {.c-btn--mini} - A mini button +/// {.c-btn--tiny} - A tiny button +/// {.c-btn--medium} - A medium button +/// {.c-btn--large} - A large button +/// {.c-btn--primary} - Primary action +/// {.c-btn--primary:hover} +/// {.c-btn--primary:active} +/// {.c-btn--secondary} - Secondary action +/// {.c-btn--secondary:hover} +/// {.c-btn--secondary:active} +/// {.c-btn--tertiary} - Tertiary action +/// {.c-btn--tertiary:hover} +/// {.c-btn--tertiary:active} +/// {.c-btn--text} - It's a text link as a button +/// {.c-btn--text:hover} +/// {.c-btn--text:active} /// /// @markup ///
@@ -49,4 +50,4 @@ /// 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/run.test.js b/tests/run.test.js new file mode 100644 index 0000000..d03665c --- /dev/null +++ b/tests/run.test.js @@ -0,0 +1,43 @@ +/* eslint-disable no-loop-func */ +/* global run */ +import path from 'path' +import docs from '../dist/index.js' +import { fs, glob, array, } from '../dist/utils' +import assert from 'assert' + +const test_defaults = { + debug: false, + timestamps: false, + warning: false, + changed: false, + ignore: '.*' +} + + +async function asynctests(tests) { + const base = path.join(__dirname, 'cases') + const actual_paths = await glob(path.join(base, '*'), [ path.join(base, '*.json') ]) + const actual = await array(actual_paths).map((files) => docs({ files, ...test_defaults })) + const expected = await array(actual_paths).map((file) => fs.readJson(file.replace(/\..*$/, '.json'))) + tests({ + actual_paths, + actual, + expected + }) + run() +} + +asynctests(({ actual_paths, actual, expected }) => { + suite('case tests', function() { // eslint-disable-line + this.timeout(50000) // eslint-disable-line + + for (let i = 0; i < actual_paths.length; i++) { + test(`${i}: ${actual_paths[i]}`, () => { + assert.deepStrictEqual( + actual[i], + expected[i] + ) + }) + } + }) +}) diff --git a/tests/src/run.test.js b/tests/src/run.test.js deleted file mode 100644 index c4b1455..0000000 --- a/tests/src/run.test.js +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-disable no-loop-func */ - -import test from 'tape' -import path from 'path' -import docs from '../../dist/index.js' -import { fs, glob, array } from '../../dist/utils' - -const test_defaults = { - debug: false, - timestamps: false, - warning: false, - changed: false, - ignore: '.*' -} - - -test('case tests', async (mt) => { - const base = path.join(__dirname, '..', 'cases') - const actual_paths = await glob(path.join(base, '*'), [ path.join(base, '*.json') ]) - const actual = await array(actual_paths).map((files) => docs({ files, ...test_defaults })) - const expected = await array(actual_paths).map((file) => fs.readJson(file.replace(/\..*$/, '.json'))) - - for (let i = 0; i < actual_paths.length; i++) { - mt.test(actual_paths[i], (t) => { - t.deepEqual( - actual[i], - expected[i] - ) - t.end() - }) - } - - mt.end() -}) diff --git a/tests/src/unit/utils/is.test.js b/tests/src/unit/utils/is.test.js deleted file mode 100644 index e190078..0000000 --- a/tests/src/unit/utils/is.test.js +++ /dev/null @@ -1,135 +0,0 @@ -import test from 'tape' -import is from '../../../../dist/utils/is.js' - -test('is.false', (t) => { - t.notOk(is.false('foo'), - 'should return false if a string is passed') - t.notOk(is.false(0), - 'should return false if a number is passed') - t.ok(is.false(false), - 'should return true if false is pased to it') - t.end() -}) - -test('is.fn', (t) => { - t.ok(is.fn(test), - 'should return true if it is passed a function') - t.notOk(is.fn('foo'), - 'should return false if passed a string') - t.end() -}) - -test('is.in', (t) => { - const array = [ 'one', 'two', 'three' ] - const object = { one: 1, two: 2, three: 3 } - const string = 'onetwothree' - t.ok(is.in(array, 'two'), - 'should return true when the item is in the array') - t.notOk(is.in(array, 'four'), - 'should return false when the item is not in the array') - t.ok(is.in(object, 'two'), - 'should return true when the item is in the object') - t.notOk(is.in(object, 'four'), - 'should return false when the item is not in the object') - t.ok(is.in(string, 'two'), - 'should return true when the item is in the string') - t.notOk(is.in(string, 'four'), - 'should return false when the item is not in the string') - t.end() -}) - -test('is.all.in', (t) => { - const array = [ 'one', 'two', 'three' ] - const object = { one: 1, two: 2, three: 3 } - const string = 'onetwothree' - t.ok(is.all.in(array, 'one', 'two'), - 'should return true because all items are in the array') - t.notOk(is.all.in(array, 'one', 'four'), - 'should return false because one item isn\'t in the array') - t.ok(is.all.in(object, 'one', 'two'), - 'should return true because all items are in the object') - t.notOk(is.all.in(object, 'one', 'four'), - 'should return false because one item isn\'t in the object') - t.ok(is.all.in(string, 'one', 'two'), - 'should return true because all items are in the string') - t.notOk(is.all.in(string, 'one', 'four'), - 'should return false because one item isn\'t in the string') - t.end() -}) - -test('is.any.in', (t) => { - const array = [ 'one', 'two', 'three' ] - const object = { one: 1, two: 2, three: 3 } - const string = 'onetwothree' - t.ok(is.any.in(array, 'one', 'four'), - 'should return true because one is in the array') - t.notOk(is.any.in(array, 'four', 'five'), - 'should return false because none of the passed arguments are in the array') - t.ok(is.any.in(object, 'one', 'four'), - 'should return true because one is in the object') - t.notOk(is.any.in(object, 'four', 'five'), - 'should return false because none of the passed arguments are in the object') - t.ok(is.any.in(string, 'one', 'four'), - 'should return true because one is in the string') - t.notOk(is.any.in(string, 'four', 'five'), - 'should return false because none of the passed arguments are in the string') - t.end() -}) - -test('is.plain_object', (t) => { - t.ok(is.plain_object({}), - 'should return true if passed a {}') - t.notOk(is.plain_object([]), - 'should return false if passed a []') - t.notOk(is.plain_object(''), - 'should return false if passed a string') - t.notOk(is.plain_object(test), - 'should return false if passed a function') - t.end() -}) - -test('is.between', (t) => { - t.ok(is.between(200), - 'should return true because 200 is between 0 and Infinity') - t.ok(is.between(0), - 'should return true because 0 is between 0 and Infinity') - t.ok(is.between(-100, -1000), - 'should return true because -100 is between -1000 and infinity') - t.notOk(is.between(-1), - 'should return false because -1 is not between 0 and infinity') - t.end() -}) - -test('is.promise', (t) => { - async function something_async() { - return Promise.resolve('some cool stuff'); - } - t.notOk(is.promise('foo'), - 'should return false because a string is not a promise') - t.notOk(is.promise(test), - 'should return false because tape is not a promise') - t.ok(is.promise(something_async()), - 'should return true because something_async is an async function') - t.ok(is.promise(Promise.resolve('')), - 'should return true because it is a promise') - t.end() -}) - -test('is.buffer', (t) => { - const string = 'foo bar' - const some_buffer = new Buffer(string) - t.ok(is.buffer(some_buffer), - 'should return true because it is a buffer') - t.notOk(is.buffer(string), - 'should return false because a string is not a buffer') - t.end() -}) - -test('is.symbol', (t) => { - const string = 'foo bar' - t.ok(is.symbol(Symbol(string)), - 'should return true because it is a symbol') - t.notOk(is.symbol(string), - 'should return false because it is a string') - t.end() -}) diff --git a/tests/src/unit/utils/to.test.js b/tests/src/unit/utils/to.test.js deleted file mode 100644 index d257e17..0000000 --- a/tests/src/unit/utils/to.test.js +++ /dev/null @@ -1,240 +0,0 @@ -import test from 'tape' -import to from '../../../../dist/utils/to.js' -import fs from '../../../../dist/utils/fs.js' -import info from '../../../../dist/utils/info.js' - -const string = 'yo this is a string' -const array = [ 'one', 'two', 'three' ] -const object = { one: 1, two: 2, three: 3 } -const buffer = new Buffer(string) -const number = 4 -const boolean = false - - -test('to.string', (t) => { - t.is(typeof to.string(string), 'string', - '`string` should be converted to a typeof string') - t.is(typeof to.string(array), 'string', - '`array` should be converted to a typeof string') - t.is(typeof to.string(buffer), 'string', - '`buffer` should be converted to a typeof string') - t.is(typeof to.string(object), 'string', - '`object` should be converted to a typeof string') - t.is(typeof to.string(number), 'string', - '`number` should be converted to a typeof string') - t.is(typeof to.string(boolean), 'string', - '`boolean` should be converted to a typeof string') - t.end() -}) - - -test('to.normal_string', async (t) => { - try { - // this file has some stupid ass characters in it - // that need to be removed in order to become like the - // rest of the fucking world. #microsoftBlowsAtStandards - const crappy_windows_file = await fs.readFile(`${info.root}/tests/file-types/coffeescript/test.coffee`) - // crappy_windows_file = JSON.stringify({foo: crappy_windows_file + ''}) - t.is(to.normal_string(crappy_windows_file).match(/\r/g), null, - 'should be a normal string') - t.end() - } catch (err) { - t.fail('the file didn\'t load') - console.log(err.stack) - t.end() - } -}) - - -test('to.keys', (t) => { - const keys = to.keys(object) - t.is(keys[0], 'one', 'should return one') - t.is(keys[1], 'two', 'should return two') - t.is(keys[2], 'three', 'should return three') - t.end() -}) - - -test('to.entries', (t) => { - for (const [ i, item ] of to.entries(array)) { - t.ok(typeof i, 'number', '`i` should be a number') - t.ok(typeof item, 'string', '`i` should be a string') - } - t.end() -}) - - -test('to.object_entries', (t) => { - for (const { key, one, two, three } of to.object_entries({ test: object })) { - t.is(key, 'test', 'The key should be `test`') - t.is(one, 1, '`one` should equal 1') - t.is(two, 2, '`two` should equal 2') - t.is(three, 3, '`three` should equal 3') - } - t.end() -}) - - -test('to.normalize', (t) => { - const actual = ` - .foo { - background: blue; - } - ` - const expected = [ '.foo {', ' background: blue;', '}' ].join('\n') - - t.is(to.normalize(actual), expected, 'all whitespace should be stripped') - t.ok(actual.split('\n')[2].length > 19, 'should be greater than 19') - t.is(to.normalize(actual).split('\n')[1].length, 19, 'should be 19') - t.end() -}) - - -test('to.extend', (t) => { - const temp = to.extend({}, object) - t.deepEqual(object, object, - 'should equal each other, because they\'re the same') - t.deepEqual(temp, object, - 'should be the same as the first object') - t.is(to.extend(temp, { one: 3 }).one, 3, - '`one` should be equal to 3') - t.end() -}) - - -test('to.clone', (t) => { - const actual = { one: { two: { three: { four: { five: 'whatup' } } } } } - const expected = { one: { two: { three: { four: { five: 'whatup' } } } } } - const test_one = to.clone(actual) - test_one.test = 'yo' - t.ok(actual.test === undefined, - '`acutal.test` should not be defined') - t.ok(test_one.test === 'yo', - '`test_one.test` should equal yo') - t.deepEqual(actual, expected, - 'the actual object should remain the same as the expected object') - t.end() -}) - - -test('to.merge', (t) => { - const a = { - foo: { - bar: '1', - baz: [ '3', '4' ], - qux: 'one', - quux: { garply: { waldo: 'one' } }, waldo: '' - } - } - const b = { - foo: { - bar: '2', - baz: [ '5', '6' ], - qux: [ 'two', 'three' ], - quux: { garply: { waldo: 'two' } }, - waldo() { - return this - }, - garply: 'item' - } - } - t.is(a.foo.bar, '1', 'a.foo.bar should be 1') - to.merge(a, b) - t.pass('a and be were merged') - t.ok(Array.isArray(a.foo.bar), 'a.foo.bar should be an array') - t.ok(Array.isArray(a.foo.baz), 'a.foo.baz should be an array') - t.ok(Array.isArray(a.foo.quux.garply.waldo), - 'a.foo.quux.garply.waldo should be an array') - t.end() -}) - - -test('to.object', async (t) => { - try { - const json = await fs.readFile(`${info.root}/package.json`) - t.ok(to.object(json).author, - 'the passed json should now be an object') - t.end() - } catch (err) { - console.log(err.stack) - } -}) - - -test('to.json', (t) => { - const obj = { foo: 'foo', bar: 'foo' } - t.is(typeof obj, 'object', - 'the test object should be an object') - t.is(typeof to.json(obj), 'string', - 'should be a json string') - t.end() -}) - - -test('to.array', (t) => { - t.ok(Array.isArray(array), - 'array should should be an array') - t.ok(Array.isArray(to.array(array)), - 'array should be be returned with no changes') - t.notOk(Array.isArray(string), - 'string should not be an array') - t.ok(Array.isArray(to.array(string)), - 'string should be converted to a type of array') - t.notOk(Array.isArray(object), - 'object should not be an array') - t.ok(Array.isArray(to.array(object)), - 'object should be converted to a type of array') - t.notOk(Array.isArray(number), - 'number should not be an array') - t.ok(Array.isArray(to.array(number)), - 'number should be converted to a type of array') - t.end() -}) - - -test('to.flatten', (t) => { - t.is(to.flatten([ [ [ array ] ] ])[0], 'one', - 'the array should be flattend and the first value should be one') - t.end() -}) - - -test('to.unique', (t) => { - t.is(to.unique([ 'one', 'one', 'two', 'two' ]).length, 2, - 'should have a length of 2') - t.end() -}) - - -test('to.sort', (t) => { - const actual = { - c: 1, - b: 2, - a: 3 - } - - t.is(Object.keys(actual)[0], 'c', - 'c should be the first key in the object') - t.is(Object.keys(to.sort(actual))[0], 'a', - 'a should be the first key in the object after it\'s sorted') - t.end() -}) - - -test('to.number', (t) => { - t.is(to.number(4), 4, - 'should be 4') - t.is(to.number([ 'a', 'b', 'c' ]), 3, - 'should be 3') - t.is(to.number({ a: 1, b: 2, c: 3 }), 3, - 'should be 3') - t.is(to.number('foo'), 0, - 'should be 0') - t.is(to.number('10'), 10, - 'should be 10') - t.is(to.number(false), 0, - 'should be 0') - t.is(to.number(true), 1, - 'should be 1') - t.end() -}) diff --git a/tests/src/unit/crappy_file_saved_on_windows.cs b/tests/unit/crappy_file_saved_on_windows.cs similarity index 100% rename from tests/src/unit/crappy_file_saved_on_windows.cs rename to tests/unit/crappy_file_saved_on_windows.cs diff --git a/tests/src/unit/utils/array.test.js b/tests/unit/utils/array.test.js similarity index 100% rename from tests/src/unit/utils/array.test.js rename to tests/unit/utils/array.test.js diff --git a/tests/src/unit/utils/denodeify.test.js b/tests/unit/utils/denodeify.test.js similarity index 100% rename from tests/src/unit/utils/denodeify.test.js rename to tests/unit/utils/denodeify.test.js diff --git a/tests/src/unit/utils/glob.test.js b/tests/unit/utils/glob.test.js similarity index 100% rename from tests/src/unit/utils/glob.test.js rename to tests/unit/utils/glob.test.js diff --git a/tests/src/unit/utils/info.test.js b/tests/unit/utils/info.test.js similarity index 100% rename from tests/src/unit/utils/info.test.js rename to tests/unit/utils/info.test.js diff --git a/tests/unit/utils/is.test.js b/tests/unit/utils/is.test.js new file mode 100644 index 0000000..08ac0d2 --- /dev/null +++ b/tests/unit/utils/is.test.js @@ -0,0 +1,130 @@ +import is from '../../../dist/utils/is.js' +import assert from 'assert' + + +console.log('mother fucker ') +console.log() +suite('is', () => { + test('is.false', () => { + assert.ok(!is.false('foo'), + 'should return false if a string is passed') + assert.ok(!is.false(0), + 'should return false if a number is passed') + assert.ok(is.false(false), + 'should return true if false is pased to it') + }) + + test('is.fn', () => { + assert.ok(is.fn(test), + 'should return true if it is passed a function') + assert.ok(!is.fn('foo'), + 'should return false if passed a string') + }) + + test('is.in', () => { + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } + const string = 'onetwothree' + assert.ok(is.in(array, 'two'), + 'should return true when the item is in the array') + assert.ok(!is.in(array, 'four'), + 'should return false when the item is not in the array') + assert.ok(is.in(object, 'two'), + 'should return true when the item is in the object') + assert.ok(!is.in(object, 'four'), + 'should return false when the item is not in the object') + assert.ok(is.in(string, 'two'), + 'should return true when the item is in the string') + assert.ok(!is.in(string, 'four'), + 'should return false when the item is not in the string') + }) + + test('is.all.in', () => { + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } + const string = 'onetwothree' + assert.ok(is.all.in(array, 'one', 'two'), + 'should return true because all items are in the array') + assert.ok(!is.all.in(array, 'one', 'four'), + 'should return false because one item isn\'t in the array') + assert.ok(is.all.in(object, 'one', 'two'), + 'should return true because all items are in the object') + assert.ok(!is.all.in(object, 'one', 'four'), + 'should return false because one item isn\'t in the object') + assert.ok(is.all.in(string, 'one', 'two'), + 'should return true because all items are in the string') + assert.ok(!is.all.in(string, 'one', 'four'), + 'should return false because one item isn\'t in the string') + }) + + test('is.any.in', () => { + const array = [ 'one', 'two', 'three' ] + const object = { one: 1, two: 2, three: 3 } + const string = 'onetwothree' + assert.ok(is.any.in(array, 'one', 'four'), + 'should return true because one is in the array') + assert.ok(!is.any.in(array, 'four', 'five'), + 'should return false because none of the passed arguments are in the array') + assert.ok(is.any.in(object, 'one', 'four'), + 'should return true because one is in the object') + assert.ok(!is.any.in(object, 'four', 'five'), + 'should return false because none of the passed arguments are in the object') + assert.ok(is.any.in(string, 'one', 'four'), + 'should return true because one is in the string') + assert.ok(!is.any.in(string, 'four', 'five'), + 'should return false because none of the passed arguments are in the string') + }) + + test('is.plain_object', () => { + assert.ok(is.plain_object({}), + 'should return true if passed a {}') + assert.ok(!is.plain_object([]), + 'should return false if passed a []') + assert.ok(!is.plain_object(''), + 'should return false if passed a string') + assert.ok(!is.plain_object(test), + 'should return false if passed a function') + }) + + test('is.between', () => { + assert.ok(is.between(200), + 'should return true because 200 is between 0 and Infinity') + assert.ok(is.between(0), + 'should return true because 0 is between 0 and Infinity') + assert.ok(is.between(-100, -1000), + 'should return true because -100 is between -1000 and infinity') + assert.ok(!is.between(-1), + 'should return false because -1 is not between 0 and infinity') + }) + + test('is.promise', () => { + async function something_async() { + return await Promise.resolve('some cool stuff') + } + assert.ok(!is.promise('foo'), + 'should return false because a string is not a promise') + assert.ok(!is.promise(test), + 'should return false because tape is not a promise') + assert.ok(is.promise(something_async()), + 'should return true because something_async is an async function') + assert.ok(is.promise(Promise.resolve('')), + 'should return true because it is a promise') + }) + + test('is.buffer', () => { + const string = 'foo bar' + const some_buffer = new Buffer(string) + assert.ok(is.buffer(some_buffer), + 'should return true because it is a buffer') + assert.ok(!is.buffer(string), + 'should return false because a string is not a buffer') + }) + + test('is.symbol', () => { + const string = 'foo bar' + assert.ok(is.symbol(Symbol(string)), + 'should return true because it is a symbol') + assert.ok(!is.symbol(string), + 'should return false because it is a string') + }) +}) diff --git a/tests/src/unit/utils/log.test.js b/tests/unit/utils/log.test.js similarity index 100% rename from tests/src/unit/utils/log.test.js rename to tests/unit/utils/log.test.js diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js new file mode 100644 index 0000000..1138f77 --- /dev/null +++ b/tests/unit/utils/to.test.js @@ -0,0 +1,226 @@ +import to from '../../../dist/utils/to.js' +import fs from '../../../dist/utils/fs.js' +import info from '../../../dist/utils/info.js' +import assert from 'assert' +const string = 'yo this is a string' +const array = [ 'one', 'two', 'three' ] +const object = { one: 1, two: 2, three: 3 } +const buffer = new Buffer(string) +const number = 4 +const boolean = false +const file = `${info.root}/tests/file-types/coffeescript/test.coffee` + +suite('to', () => { + test('to.string', async () => { + assert.strictEqual(typeof to.string(string), 'string', + '`string` should be converted to a typeof string') + assert.strictEqual(typeof to.string(array), 'string', + '`array` should be converted to a typeof string') + assert.strictEqual(typeof to.string(buffer), 'string', + '`buffer` should be converted to a typeof string') + assert.strictEqual(typeof to.string(await fs.readFile(file)), 'string', + '`read file` should be converted to a typeof string') + assert.strictEqual(typeof to.string(object), 'string', + '`object` should be converted to a typeof string') + assert.strictEqual(typeof to.string(number), 'string', + '`number` should be converted to a typeof string') + assert.strictEqual(typeof to.string(boolean), 'string', + '`boolean` should be converted to a typeof string') + }) + + + test('to.normal_string', async () => { + let result + try { + // this file has some stupid ass characters in it + // that need to be removed in order to become like the + // rest of the fucking world. #microsoftBlowsAtStandards + const crappy_windows_file = await fs.readFile(file) + result = to.normal_string(crappy_windows_file).match(/\r/g) + assert.equal(result, null, + 'should be a normal string') + } catch (err) { + assert.fail(result, null, 'the file didn\'t load') + console.log(err.stack) + } + }) + + + test('to.keys', () => { + const keys = to.keys(object) + assert.strictEqual(keys[0], 'one', 'should return one') + assert.strictEqual(keys[1], 'two', 'should return two') + assert.strictEqual(keys[2], 'three', 'should return three') + }) + + + test('to.entries', () => { + for (const [ i, item ] of to.entries(array)) { + assert.ok(typeof i, 'number', '`i` should be a number') + assert.ok(typeof item, 'string', '`i` should be a string') + } + }) + + + test('to.object_entries', () => { + for (const { key, one, two, three } of to.object_entries({ test: object })) { + assert.strictEqual(key, 'test', 'The key should be `test`') + assert.strictEqual(one, 1, '`one` should equal 1') + assert.strictEqual(two, 2, '`two` should equal 2') + assert.strictEqual(three, 3, '`three` should equal 3') + } + }) + + + test('to.normalize', () => { + const actual = ` + .foo { + background: blue; + } + ` + const expected = [ '.foo {', ' background: blue;', '}' ].join('\n') + + assert.strictEqual(to.normalize(actual), expected, 'all whitespace should be stripped') + assert.ok(actual.split('\n')[2].length > 19, 'should be greater than 19') + assert.strictEqual(to.normalize(actual).split('\n')[1].length, 19, 'should be 19') + }) + + + test('to.extend', () => { + const temp = to.extend({}, object) + assert.deepEqual(object, object, + 'should equal each other, because they\'re the same') + assert.deepEqual(temp, object, + 'should be the same as the first object') + assert.strictEqual(to.extend(temp, { one: 3 }).one, 3, + '`one` should be equal to 3') + }) + + + test('to.clone', () => { + const actual = { one: { two: { three: { four: { five: 'whatup' } } } } } + const expected = { one: { two: { three: { four: { five: 'whatup' } } } } } + const test_one = to.clone(actual) + test_one.test = 'yo' + assert.ok(actual.test === undefined, + '`acutal.test` should not be defined') + assert.ok(test_one.test === 'yo', + '`test_one.test` should equal yo') + assert.deepEqual(actual, expected, + 'the actual object should remain the same as the expected object') + }) + + + test('to.merge', () => { + const a = { + foo: { + bar: '1', + baz: [ '3', '4' ], + qux: 'one', + quux: { garply: { waldo: 'one' } }, waldo: '' + } + } + const b = { + foo: { + bar: '2', + baz: [ '5', '6' ], + qux: [ 'two', 'three' ], + quux: { garply: { waldo: 'two' } }, + waldo() { + return this + }, + garply: 'item' + } + } + assert.strictEqual(a.foo.bar, '1', 'a.foo.bar should be 1') + to.merge(a, b) + assert.ok(Array.isArray(a.foo.bar), 'a.foo.bar should be an array') + assert.ok(Array.isArray(a.foo.baz), 'a.foo.baz should be an array') + assert.ok(Array.isArray(a.foo.quux.garply.waldo), + 'a.foo.quux.garply.waldo should be an array') + }) + + + test('to.object', async () => { + try { + const json = await fs.readFile(`${info.root}/package.json`) + assert.ok(to.object(json).author, + 'the passed json should now be an object') + } catch (err) { + console.log(err.stack) + } + }) + + + test('to.json', () => { + const obj = { foo: 'foo', bar: 'foo' } + assert.strictEqual(typeof obj, 'object', + 'the test object should be an object') + assert.strictEqual(typeof to.json(obj), 'string', + 'should be a json string') + }) + + + test('to.array', () => { + assert.ok(Array.isArray(array), + 'array should should be an array') + assert.ok(Array.isArray(to.array(array)), + 'array should be be returned with no changes') + assert.ok(!Array.isArray(string), + 'string should not be an array') + assert.ok(Array.isArray(to.array(string)), + 'string should be converted to a type of array') + assert.ok(!Array.isArray(object), + 'object should not be an array') + assert.ok(Array.isArray(to.array(object)), + 'object should be converted to a type of array') + assert.ok(!Array.isArray(number), + 'number should not be an array') + assert.ok(Array.isArray(to.array(number)), + 'number should be converted to a type of array') + }) + + + test('to.flatten', () => { + assert.strictEqual(to.flatten([ [ [ array ] ] ])[0], 'one', + 'the array should be flattend and the first value should be one') + }) + + + test('to.unique', () => { + assert.strictEqual(to.unique([ 'one', 'one', 'two', 'two' ]).length, 2, + 'should have a length of 2') + }) + + + test('to.sort', () => { + const actual = { + c: 1, + b: 2, + a: 3 + } + + assert.strictEqual(Object.keys(actual)[0], 'c', + 'c should be the first key in the object') + assert.strictEqual(Object.keys(to.sort(actual))[0], 'a', + 'a should be the first key in the object after it\'s sorted') + }) + + + test('to.number', () => { + assert.strictEqual(to.number(4), 4, + 'should be 4') + assert.strictEqual(to.number([ 'a', 'b', 'c' ]), 3, + 'should be 3') + assert.strictEqual(to.number({ a: 1, b: 2, c: 3 }), 3, + 'should be 3') + assert.strictEqual(to.number('foo'), 0, + 'should be 0') + assert.strictEqual(to.number('10'), 10, + 'should be 10') + assert.strictEqual(to.number(false), 0, + 'should be 0') + assert.strictEqual(to.number(true), 1, + 'should be 1') + }) +}) From 15be4f32fd7442a83f5114204245f944d8f3313d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 23 Feb 2016 09:28:14 -0500 Subject: [PATCH 193/273] created a better async mocha suite --- package.json | 5 ++- tests/run.test.js | 85 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index d2695fa..5ba969b 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,8 @@ "refresh": "rm -rf -- node_modules/ .tmp/ dist/; npm i", "compile": "npm run clean; babel app/ -d dist/", "watch": "npm run clean; babel app/ -d dist/ --watch", - "mocha": "mocha --compilers js:babel-register --ui tdd --check-leaks", - "unit-tests": "npm run mocha -- tests/unit/**/*.js", - "mock-tests": "npm run mocha -- --delay tests/run.test.js", + "unit-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks tests/unit/**/*.js", + "mock-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks --delay tests/run.test.js", "test": "npm run unit-tests; npm run mock-tests", "coverage": "nyc npm test", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", diff --git a/tests/run.test.js b/tests/run.test.js index d03665c..bfa7b1c 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -14,30 +14,77 @@ const test_defaults = { } -async function asynctests(tests) { - const base = path.join(__dirname, 'cases') - const actual_paths = await glob(path.join(base, '*'), [ path.join(base, '*.json') ]) - const actual = await array(actual_paths).map((files) => docs({ files, ...test_defaults })) - const expected = await array(actual_paths).map((file) => fs.readJson(file.replace(/\..*$/, '.json'))) - tests({ - actual_paths, - actual, - expected - }) - run() -} - -asynctests(({ actual_paths, actual, expected }) => { - suite('case tests', function() { // eslint-disable-line - this.timeout(50000) // eslint-disable-line +addSuite('cases', async ({ paths, expected }) => { + const actual = await array(paths).map((files) => docs({ files, ...test_defaults })) - for (let i = 0; i < actual_paths.length; i++) { - test(`${i}: ${actual_paths[i]}`, () => { + return () => { + for (let i = 0; i < paths.length; i++) { + test(`${i}: ${paths[i]}`, () => { assert.deepStrictEqual( actual[i], expected[i] ) }) } - }) + } +}) + + +addSuite('annotations', async ({ paths, expected }) => { + const actual = await array(paths).map((files) => docs({ files, raw: true, ...test_defaults })) + + return () => { + for (let i = 0; i < paths.length; i++) { + let _path = paths[i] + test(`${i}: ${_path}`, () => { + assert.deepStrictEqual( + actual[i]['docs' + _path.split('/docs')[1]], + expected[i] + ) + }) + } + } }) + + +const mochaAsync = (fn) => { // eslint-disable-line + return async (done) => { + try { + await fn() + done() + } catch (err) { + done(err) + } + } +} + + +async function addSuite(name, folder, callback) { + if (arguments.length === 2) { + callback = folder + folder = name + } + // get the test cases + const cases = await getTestCases(folder) + // run any async stuff if needed before the tests. + // this `callback` is a curry function so it has to return a function + const tests = await callback({ ...cases }) + + suite(name, function() { // eslint-disable-line + this.timeout(50000) // eslint-disable-line + tests() + }) + + run() // mocha-tests +} + +// console.log(addSuite()) + +async function getTestCases(folder) { + const base = path.join(__dirname, folder) + const paths = await glob(path.join(base, '**', '*'), [ path.join(base, '**', '*.json') ]) + return { + paths, + expected: await array(paths).map((file) => fs.readJson(file.replace(path.extname(file), '.json'))) + } +} From 70046f01aad1e9127033a2269024cadfb4fb421f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 23 Feb 2016 09:31:23 -0500 Subject: [PATCH 194/273] :bugfix: for aliases This now looks globally instead of just the first instance. It also looks for a word boundary instead of an exact match. This means that there's no longer a conflict with `param` and `params` --- app/parser/replace_aliases.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/parser/replace_aliases.js b/app/parser/replace_aliases.js index 516bcd3..5c84acd 100644 --- a/app/parser/replace_aliases.js +++ b/app/parser/replace_aliases.js @@ -19,14 +19,11 @@ export default function aliases(options = {}) { }) for (let [ annotation, alias_list ] of to.entries(annotations)) { - // sorts the aliases based off their length. This is to ensure if to two - // or more aliases are similar they will always get replaced correctly - // aka `param` and `parameter` - alias_list = alias_list - .filter((alias) => !is.in(main_annotation_list, alias)) - .sort((a, b) => b.length > a.length ? 1 : 0) + // filter out any aliases that are already in the main annotation list + alias_list = alias_list.filter((alias) => !is.in(main_annotation_list, alias)) - contents = contents.replace(new RegExp(`(?:${comment.prefix})(${alias_list.join('|')})`), comment.prefix + annotation) + const alias_list_regex = new RegExp(`(?:${comment.prefix})(${alias_list.join('|')})\\b`, 'g') + contents = contents.replace(alias_list_regex, comment.prefix + annotation + ' ') } return contents From 72ea7d344ed453bd552c6a265d0c76c3321e40e6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 23 Feb 2016 09:34:14 -0500 Subject: [PATCH 195/273] added the `comment.type` to the comment block This gives the user access to `this.comment.type` inside of a `parse` function on an annotation. Which allows the user to do different things based on what the comment type is. --- app/config.js | 4 ++-- app/parser/get_blocks.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/config.js b/app/config.js index ca9f3e8..8b8d098 100644 --- a/app/config.js +++ b/app/config.js @@ -34,9 +34,9 @@ const default_comment = { prefix: '@', // annotation identifier(this should probably never be changed) inline_prefix: '#', // @todo add support for this single line prefix for comments inside of the code below the comment block // file level comment block identifier - header: { start: '////', line: '///', end: '////' }, + header: { start: '////', line: '///', end: '////', type: 'header' }, // block level comment block identifier - body: { start: '', line: '///', end: '' } + body: { start: '', line: '///', end: '', type: 'body' } } // some defaults for common languages diff --git a/app/parser/get_blocks.js b/app/parser/get_blocks.js index 6711b66..096bc62 100644 --- a/app/parser/get_blocks.js +++ b/app/parser/get_blocks.js @@ -20,7 +20,7 @@ export default function getBlocks(options) { let style = is.all.truthy(comment.start, comment.end) ? 'multi' : 'single' let block_base = { - comment: { contents: [], start: -1, end: -1 }, + comment: { contents: [], start: -1, end: -1, type: comment.type }, code: { contents: [], start: -1, end: -1 }, file } From db518b2fc65bebeedc1b7bf9c96a7a8b8324d836 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 23 Feb 2016 09:37:45 -0500 Subject: [PATCH 196/273] filters out any `null`, `undefined` This filters out any `null`, `undefined` results that come from the autofill function of a annotation --- app/parser/autofill.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/parser/autofill.js b/app/parser/autofill.js index 3dc37ff..dc431d7 100644 --- a/app/parser/autofill.js +++ b/app/parser/autofill.js @@ -11,7 +11,10 @@ export default function autofill(options) { for (let [ annotation, annotation_autofill ] of to.entries(autofill_list)) { if (!is.in(parsed_keys, annotation)) { - parsed[annotation] = is.fn(annotation_autofill) ? annotation_autofill.call(block) : annotation_autofill + const result = is.fn(annotation_autofill) ? annotation_autofill.call(block) : annotation_autofill + if (result != null) { + parsed[annotation] = result + } } } From 312cadafca0a343fb5f2f5ad525c4f5218744f43 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 23 Feb 2016 09:38:15 -0500 Subject: [PATCH 197/273] added the raw option into the cli --- app/cli.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/cli.js b/app/cli.js index 30c53f4..4f7412b 100644 --- a/app/cli.js +++ b/app/cli.js @@ -30,6 +30,7 @@ export default function cli() { .option('-a, --no-changed', 'Parse changed files', to_boolean, base_config.changed) .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, base_config.blank_lines) .option('-p, --print', 'This will only print the results instead of outputting them', false) + .option('-r, --raw', 'This prevents the data from each file from being sorted', false) .parse(process.argv) From 9c55c0c31a943b65f01f2b2fcd3055e305f4872d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 24 Feb 2016 11:24:53 -0500 Subject: [PATCH 198/273] Updated annotations, and annotation tests --- .eslintrc | 2 +- .jshintrc | 26 + .travis.yml | 3 +- app/annotations.js | 1077 ++++++++++++----- app/utils/purdy.js | 2 +- app/utils/to.js | 15 + package.json | 7 +- .../access/access.autofill.body.js | 1 + .../access/access.autofill.body.json | 11 + .../access/access.autofill.header.js | 3 + .../access/access.autofill.header.json | 10 + tests/annotations/access/access.header.js | 3 + tests/annotations/access/access.header.json | 9 + tests/annotations/access/access.options.js | 5 + tests/annotations/access/access.options.json | 20 + tests/annotations/alias/alias.js | 5 + tests/annotations/alias/alias.json | 31 + tests/annotations/arg.test.js | 0 tests/annotations/arg/arg.aliases.js | 5 + tests/annotations/arg/arg.aliases.json | 50 + tests/annotations/arg/arg.js | 16 + tests/annotations/arg/arg.json | 94 ++ tests/annotations/author.test.js | 9 - tests/annotations/author/author.alias.js | 1 + tests/annotations/author/author.alias.json | 15 + tests/annotations/author/author.body.js | 1 + tests/annotations/author/author.body.json | 13 + tests/annotations/author/author.header.js | 3 + tests/annotations/author/author.header.json | 12 + tests/annotations/author/author.multiple.js | 13 + tests/annotations/author/author.multiple.json | 41 + tests/annotations/chainable.test.js | 0 tests/annotations/chainable/chainable.js | 17 + tests/annotations/chainable/chainable.json | 58 + tests/annotations/depricated.test.js | 0 .../annotations/depricated/depricated.body.js | 10 + .../depricated/depricated.body.json | 41 + .../depricated/depricated.header.js | 6 + .../depricated/depricated.header.json | 13 + tests/annotations/description.test.js | 0 .../description/description.alias.js | 57 + .../description/description.alias.json | 89 ++ .../description/description.body.js | 14 + .../description/description.body.json | 23 + .../description/description.header.js | 7 + .../description/description.header.json | 10 + tests/annotations/markdown/mark.json | 8 + tests/annotations/markdown/mark.mark | 12 + tests/annotations/markdown/markdown.json | 8 + tests/annotations/markdown/markdown.markdown | 12 + tests/annotations/markdown/md.json | 8 + tests/annotations/markdown/md.md | 12 + tests/annotations/markdown/mdml.json | 8 + tests/annotations/markdown/mdml.mdml | 12 + tests/annotations/markdown/mdown.json | 8 + tests/annotations/markdown/mdown.mdown | 12 + tests/annotations/markdown/mdtext.json | 8 + tests/annotations/markdown/mdtext.mdtext | 12 + tests/annotations/markdown/mdtxt.json | 8 + tests/annotations/markdown/mdtxt.mdtxt | 12 + tests/annotations/markdown/mdwn.json | 8 + tests/annotations/markdown/mdwn.mdwn | 12 + tests/annotations/markdown/mkd.json | 8 + tests/annotations/markdown/mkd.mkd | 12 + tests/annotations/markdown/mkdn.json | 8 + tests/annotations/markdown/mkdn.mkdn | 12 + tests/annotations/markdown/text.json | 8 + tests/annotations/markdown/text.text | 12 + tests/annotations/markup.test.js | 0 .../{access.test.js => markup/markup.js} | 0 tests/annotations/markup/markup.json | 4 + tests/annotations/name.test.js | 0 tests/annotations/name/name.aliases.js | 5 + tests/annotations/name/name.aliases.json | 23 + tests/annotations/name/name.js | 1 + tests/annotations/name/name.json | 11 + tests/annotations/note.test.js | 0 tests/annotations/note/note.alias.js | 9 + tests/annotations/note/note.alias.json | 27 + tests/annotations/note/note.js | 19 + tests/annotations/note/note.json | 71 ++ tests/annotations/page.test.js | 0 tests/annotations/page/page.alias.js | 6 + tests/annotations/page/page.alias.json | 30 + tests/annotations/page/page.body.autofill.js | 1 + .../annotations/page/page.body.autofill.json | 11 + tests/annotations/page/page.body.js | 6 + tests/annotations/page/page.body.json | 30 + .../annotations/page/page.header.autofill.js | 3 + .../page/page.header.autofill.json | 10 + tests/annotations/page/page.header.js | 3 + tests/annotations/page/page.header.json | 11 + tests/annotations/readonly.test.js | 0 tests/annotations/readonly/readonly.js | 5 + tests/annotations/readonly/readonly.json | 23 + tests/annotations/requires.test.js | 0 tests/annotations/requires/requires.alias.js | 1 + .../annotations/requires/requires.alias.json | 17 + tests/annotations/requires/requires.body.js | 14 + tests/annotations/requires/requires.body.json | 103 ++ tests/annotations/requires/requires.header.js | 3 + .../annotations/requires/requires.header.json | 18 + tests/annotations/returns.test.js | 0 tests/annotations/returns/returns.alias.js | 22 + tests/annotations/returns/returns.alias.json | 86 ++ tests/annotations/returns/returns.js | 22 + tests/annotations/returns/returns.json | 86 ++ tests/annotations/since.test.js | 0 tests/annotations/since/since.body.js | 10 + tests/annotations/since/since.body.json | 41 + tests/annotations/since/since.header.js | 6 + tests/annotations/since/since.header.json | 13 + tests/annotations/state.test.js | 0 .../{alias.test.js => state/state.js} | 0 tests/annotations/state/state.json | 4 + tests/annotations/throws/throws.alias.js | 7 + tests/annotations/throws/throws.alias.json | 57 + tests/annotations/throws/throws.js | 15 + tests/annotations/throws/throws.json | 87 ++ tests/annotations/todo.test.js | 0 tests/annotations/todo/todo.body.js | 14 + tests/annotations/todo/todo.body.json | 85 ++ tests/annotations/todo/todo.header.js | 6 + tests/annotations/todo/todo.header.json | 19 + tests/annotations/type.test.js | 0 tests/annotations/type/type.js | 17 + tests/annotations/type/type.json | 68 ++ tests/annotations/version.test.js | 0 tests/annotations/version/version.js | 12 + tests/annotations/version/version.json | 50 + tests/cases/header-comment-only.json | 1 + tests/cases/header-comment-only.scss | 2 +- ...pace-between-header-and-body-comments.json | 1 + tests/cases/only-body-comments.json | 1 + tests/run.test.js | 15 +- tests/unit/utils/is.test.js | 2 - 136 files changed, 2947 insertions(+), 335 deletions(-) create mode 100644 .jshintrc create mode 100644 tests/annotations/access/access.autofill.body.js create mode 100644 tests/annotations/access/access.autofill.body.json create mode 100644 tests/annotations/access/access.autofill.header.js create mode 100644 tests/annotations/access/access.autofill.header.json create mode 100644 tests/annotations/access/access.header.js create mode 100644 tests/annotations/access/access.header.json create mode 100644 tests/annotations/access/access.options.js create mode 100644 tests/annotations/access/access.options.json create mode 100644 tests/annotations/alias/alias.js create mode 100644 tests/annotations/alias/alias.json delete mode 100644 tests/annotations/arg.test.js create mode 100644 tests/annotations/arg/arg.aliases.js create mode 100644 tests/annotations/arg/arg.aliases.json create mode 100644 tests/annotations/arg/arg.js create mode 100644 tests/annotations/arg/arg.json delete mode 100644 tests/annotations/author.test.js create mode 100644 tests/annotations/author/author.alias.js create mode 100644 tests/annotations/author/author.alias.json create mode 100644 tests/annotations/author/author.body.js create mode 100644 tests/annotations/author/author.body.json create mode 100644 tests/annotations/author/author.header.js create mode 100644 tests/annotations/author/author.header.json create mode 100644 tests/annotations/author/author.multiple.js create mode 100644 tests/annotations/author/author.multiple.json delete mode 100644 tests/annotations/chainable.test.js create mode 100644 tests/annotations/chainable/chainable.js create mode 100644 tests/annotations/chainable/chainable.json delete mode 100644 tests/annotations/depricated.test.js create mode 100644 tests/annotations/depricated/depricated.body.js create mode 100644 tests/annotations/depricated/depricated.body.json create mode 100644 tests/annotations/depricated/depricated.header.js create mode 100644 tests/annotations/depricated/depricated.header.json delete mode 100644 tests/annotations/description.test.js create mode 100644 tests/annotations/description/description.alias.js create mode 100644 tests/annotations/description/description.alias.json create mode 100644 tests/annotations/description/description.body.js create mode 100644 tests/annotations/description/description.body.json create mode 100644 tests/annotations/description/description.header.js create mode 100644 tests/annotations/description/description.header.json create mode 100644 tests/annotations/markdown/mark.json create mode 100644 tests/annotations/markdown/mark.mark create mode 100644 tests/annotations/markdown/markdown.json create mode 100644 tests/annotations/markdown/markdown.markdown create mode 100644 tests/annotations/markdown/md.json create mode 100644 tests/annotations/markdown/md.md create mode 100644 tests/annotations/markdown/mdml.json create mode 100644 tests/annotations/markdown/mdml.mdml create mode 100644 tests/annotations/markdown/mdown.json create mode 100644 tests/annotations/markdown/mdown.mdown create mode 100644 tests/annotations/markdown/mdtext.json create mode 100644 tests/annotations/markdown/mdtext.mdtext create mode 100644 tests/annotations/markdown/mdtxt.json create mode 100644 tests/annotations/markdown/mdtxt.mdtxt create mode 100644 tests/annotations/markdown/mdwn.json create mode 100644 tests/annotations/markdown/mdwn.mdwn create mode 100644 tests/annotations/markdown/mkd.json create mode 100644 tests/annotations/markdown/mkd.mkd create mode 100644 tests/annotations/markdown/mkdn.json create mode 100644 tests/annotations/markdown/mkdn.mkdn create mode 100644 tests/annotations/markdown/text.json create mode 100644 tests/annotations/markdown/text.text delete mode 100644 tests/annotations/markup.test.js rename tests/annotations/{access.test.js => markup/markup.js} (100%) create mode 100644 tests/annotations/markup/markup.json delete mode 100644 tests/annotations/name.test.js create mode 100644 tests/annotations/name/name.aliases.js create mode 100644 tests/annotations/name/name.aliases.json create mode 100644 tests/annotations/name/name.js create mode 100644 tests/annotations/name/name.json delete mode 100644 tests/annotations/note.test.js create mode 100644 tests/annotations/note/note.alias.js create mode 100644 tests/annotations/note/note.alias.json create mode 100644 tests/annotations/note/note.js create mode 100644 tests/annotations/note/note.json delete mode 100644 tests/annotations/page.test.js create mode 100644 tests/annotations/page/page.alias.js create mode 100644 tests/annotations/page/page.alias.json create mode 100644 tests/annotations/page/page.body.autofill.js create mode 100644 tests/annotations/page/page.body.autofill.json create mode 100644 tests/annotations/page/page.body.js create mode 100644 tests/annotations/page/page.body.json create mode 100644 tests/annotations/page/page.header.autofill.js create mode 100644 tests/annotations/page/page.header.autofill.json create mode 100644 tests/annotations/page/page.header.js create mode 100644 tests/annotations/page/page.header.json delete mode 100644 tests/annotations/readonly.test.js create mode 100644 tests/annotations/readonly/readonly.js create mode 100644 tests/annotations/readonly/readonly.json delete mode 100644 tests/annotations/requires.test.js create mode 100644 tests/annotations/requires/requires.alias.js create mode 100644 tests/annotations/requires/requires.alias.json create mode 100644 tests/annotations/requires/requires.body.js create mode 100644 tests/annotations/requires/requires.body.json create mode 100644 tests/annotations/requires/requires.header.js create mode 100644 tests/annotations/requires/requires.header.json delete mode 100644 tests/annotations/returns.test.js create mode 100644 tests/annotations/returns/returns.alias.js create mode 100644 tests/annotations/returns/returns.alias.json create mode 100644 tests/annotations/returns/returns.js create mode 100644 tests/annotations/returns/returns.json delete mode 100644 tests/annotations/since.test.js create mode 100644 tests/annotations/since/since.body.js create mode 100644 tests/annotations/since/since.body.json create mode 100644 tests/annotations/since/since.header.js create mode 100644 tests/annotations/since/since.header.json delete mode 100644 tests/annotations/state.test.js rename tests/annotations/{alias.test.js => state/state.js} (100%) create mode 100644 tests/annotations/state/state.json create mode 100644 tests/annotations/throws/throws.alias.js create mode 100644 tests/annotations/throws/throws.alias.json create mode 100644 tests/annotations/throws/throws.js create mode 100644 tests/annotations/throws/throws.json delete mode 100644 tests/annotations/todo.test.js create mode 100644 tests/annotations/todo/todo.body.js create mode 100644 tests/annotations/todo/todo.body.json create mode 100644 tests/annotations/todo/todo.header.js create mode 100644 tests/annotations/todo/todo.header.json delete mode 100644 tests/annotations/type.test.js create mode 100644 tests/annotations/type/type.js create mode 100644 tests/annotations/type/type.json delete mode 100644 tests/annotations/version.test.js create mode 100644 tests/annotations/version/version.js create mode 100644 tests/annotations/version/version.json diff --git a/.eslintrc b/.eslintrc index ec8652c..61ab232 100644 --- a/.eslintrc +++ b/.eslintrc @@ -105,7 +105,7 @@ "new-parens": 2, "no-alert": 2, "no-array-constructor": 2, - "no-bitwise": 2, + "no-bitwise": 0, "no-caller": 2, "no-catch-shadow": 2, "no-class-assign": 2, 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/.travis.yml b/.travis.yml index a50716e..a02751d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - "iojs" - "0.12" - "4" + - "5" sudo: false install: npm i -script: npm test \ No newline at end of file +script: npm test diff --git a/app/annotations.js b/app/annotations.js index ffdeb5f..3bb524a 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -1,4 +1,5 @@ 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 @@ -11,15 +12,17 @@ let regexes const space = '(?:\\s*)?' const value = '(?:\\[(.*)\\])?' const id = '(?:\\((.*)\\))?' - const description = '(?:\\-?\\s*)?(.*)?' + const description = '(?:\\s*\\-?\\s+)?(.*)?' regexes = { arg: new RegExp(types + space + name + space + value + space + description, 'i'), deprecated: new RegExp(types + space + description, 'i'), markup: new RegExp(id + space + types + space + value + space + description, 'i'), note: new RegExp(types + space + description, 'i'), + throws: new RegExp(types + space + description, 'i'), requires: new RegExp(types + space + name + description, 'i'), returns: new RegExp(types + space + description, 'i'), + since: new RegExp(types + space + description, 'i'), state_id: new RegExp(`${id}${space}(.*)`, 'i'), state: new RegExp(types + space + value + space + description, 'i'), todo: new RegExp(types + space + value + space + description, 'i'), @@ -37,374 +40,824 @@ function regex(name, str) { return regexes[name].exec(str).slice(1) } -function _markdown(...args) { +function multiple(annotation) { + return to.flatten([ + ...(annotation.line.split(',')), + ...(annotation.contents.split('\n').map((item) => item.split(','))) + ]) + .map((author) => author.trim()) + .filter(Boolean) +} + +function toBoolean(annotation) { + let line = annotation.line + + if (annotation.contents.length > 0) { + return undefined + } + + if (line === 'false') { + return false + } else if (line.length === 0 || line === 'true') { + return true + } + + return undefined +} + +function markdown(...args) { return to.markdown([ ...args ].filter(Boolean).join('\n')) } +function logAnnotationError(obj, expected) { + expected = to.array(expected) + const { + annotation, + comment, + code, + file + } = 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 = comment.contents.split('\n') + code.contents = code.contents.split('\n') + + // 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 = file.comment[comment.type].line + // 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') +} + //// /// @name Annotations /// @page annotations /// @description /// These are the default annotations for the docs +/// @type {object} //// -const annotations = { - /// @name @access - /// @description - /// Access of the documented item. If access isn't declared then it defaults to public. - /// @markup Usage - /// /// @access public - /// /// @access private - access: { - autofill() { - return 'public' - }, - parse() { - if (this.annotation.line === 'private') { - return 'private' - } +let annotations = {} - return 'public' - } + +export default + +/// @name @access +/// @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 header or body comment +annotations.access = { + autofill() { + return 'public' }, + parse() { + const line = this.annotation.line + if ( + line === 'private' || + line === 'protected' + ) { + return line + } + + return 'public' + } +} - /// @name @alias - /// @description Whether the documented item is an alias of another item - /// @returns {string} - /// @markup Usage - alias: { - parse() { - return list(this.annotation.line) +/// @name @alias +/// @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 +annotations.alias = { + parse() { + let alias_list = list(this.annotation.line) + if (is.empty(alias_list)) { + this.log.emit('warning', "You didn't pass in an alias to @alias on", logAnnotationError(this, '@alias name[, name]')) } - }, - /// @name @arg - /// @page annotations - /// @description Parameters from the documented function/mixin - /// @note Description runs through markdown - /// @returns {object} - arg: { - alias: [ 'argument', 'param', 'parameter' ], - parse() { - let [ - types, + return alias_list + } +} + +/// @name @arg +/// @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 +annotations.arg = { + alias: [ 'argument', 'param', 'parameter' ], + parse() { + let [ + types = [], + name = '', + value = '', + description = '', + ] = regex('arg', this.annotation.line) + + return [ + { + types: list(types), name, value, - description - ] = regex('arg', this.annotation.line) - - return [ - { - types: list(types), - name, - value, - description: _markdown(description, this.annotation.contents) - } - ] - } - }, + description: markdown(description, this.annotation.contents) + } + ] + } +} - /// @name @author - /// @page annotations - /// @description Author of the documented item - /// @returns {string} - author: { - alias: [ 'authors' ], - parse() { - return list(this.annotation.line) - } - }, +/// @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) + } +} - /// @name @chainable - /// @page annotations - /// @description Used to notate that a function is chainable - /// @returns {boolean} - chainable: { - parse() { - return this.annotation.line +/// @name @chainable +/// @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 +annotations.chainable = { + alias: [ 'chain' ], + parse() { + let bool = toBoolean(this.annotation) + + if (bool !== undefined) { + return bool } - }, - /// @name @deprecated - /// @page annotations - /// @description Lets you know that a mixin/function has been depricated - /// @returns {string} - deprecated: { - parse() { - let [ version, description ] = regex('deprecated', this.annotation.line) - return { - version, - description: _markdown(description, this.annotation.contents) - } - } - }, + return multiple(this.annotation) + } +} - /// @name @description - /// @page annotations - /// @description Description of the documented item - /// @note Runs through markdown - /// @returns {string} - description: { - alias: [ 'desc', 'definition', 'explanation', 'writeup', 'summary', 'summarization' ], - parse() { - return _markdown(this.annotation.line, this.annotation.contents) +/// @name @deprecated +/// @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 +annotations.deprecated = { + parse() { + let [ version = '0', description ] = regex('deprecated', this.annotation.line) + return { + version, + description: markdown(description, this.annotation.contents) } - }, + } +} - markdown: { - filetypes: [ - 'markdown', 'mark', 'mdown', 'mkdn', 'mdtxt', - 'mkd', 'mdml', 'mdwn', 'mdtext', 'text', 'md' - ], - parse() { - return to.markdown(this.file.contents) +/// @name @description +/// @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. +annotations.description = { + alias: [ + 'desc', 'definition', 'explanation', + 'writeup', 'summary', 'summarization' + ], + parse() { + return markdown(this.annotation.line, this.annotation.contents) + } +} + + +/// @name @markdown +/// @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 +/// +annotations.markdown = { + filetypes: [ + 'markdown', 'mark', 'mdown', + 'mkdn', 'mdtxt', 'mkd', + 'mdml', 'mdwn', 'mdtext', + 'text', 'md' + ], + parse() { + const comment = this.file.comment + const start = `(?:${comment.header.start}|${comment.body.start})`.replace('\\', '\\\\') + const end = `(?:${comment.header.end}|${comment.body.end})`.replace('\\', '\\\\') + const md_regex = new RegExp(`${start}(?:.|\\n)*\\n${end}`, 'gmi') + + return to.markdown(this.file.contents.replace(md_regex, '')) + } +} + +/// @name @markup +/// @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 +/// escaped: 'string' // escaped code, aka `` turns to `<span>` +/// } +/// ``` +/// @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 +annotations.markup = { + alias: [ 'code', 'example', 'output', 'outputs' ], + parse() { + let escaped_characters = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' } - }, - /// @name @markup - /// @page annotations - /// @description Code for the documented item - /// @note Description is parsed as markdown - /// @returns {object} - /// // markdown - `(id) {language} [settings] - description` - markup: { - alias: [ 'code', 'example', 'output', 'outputs' ], - parse() { - let escaped_characters = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - '\'': ''' - } - let [ - id = '0', - language = this.file.type, - settings = {}, - description - ] = regex('markup', this.annotation.line) - - let raw = this.annotation.contents - - let escaped = raw - .split('\n') - .map((line) => line - .replace(/[&<>'"]/g, (match) => - escaped_characters[match] - ) + let [ + id = '0', + language = this.file.type, + settings = {}, + description + ] = regex('markup', this.annotation.line) + + let raw = this.annotation.contents + + let escaped = raw + .split('\n') + .map((line) => line + .replace(/[&<>'"]/g, (match) => + escaped_characters[match] ) - .join('\n') + ) + .join('\n') + + if (is.string(settings)) { + settings = to.object(list(settings).map((setting) => setting.split('='))) + } - if (is.string(settings)) { - settings = to.object(list(settings).map((setting) => setting.split('='))) + return [ + { + id, + language, + settings, + description: markdown(description), + raw, + escaped } + ] + } +} - return [ - { - id, - language, - settings, - description: _markdown(description), - raw, - escaped - } - ] - } - }, +/// @name @name +/// @alias @title, @heading, @header +/// @description Name of the documented item +/// @returns {string} +/// +/// @markup Usage +/// /// @name Name of the documented item +annotations.name = { + alias: [ 'title', 'heading', 'header' ] +} - /// @name @name - /// @page annotations/name - /// @description Name of the documented item - /// @returns {string} - name: { - alias: [ 'title', 'heading' ] +/// @name @note +/// @alias @notes +/// @description A note about the documented item +/// @returns {object} +/// +/// @markup Usage +/// /// @note description +/// +/// /// @note {importance} description +/// +/// /// @note {importance} +/// /// multi +/// /// line +/// /// description +annotations.note = { + alias: [ 'notes' ], + parse() { + let [ importance = '0', description ] = regex('note', this.annotation.line) + + return [ + { + importance, + description: markdown(description, this.annotation.contents) + } + ] + } +} + +/// @name @page +/// @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 +annotations.page = { + alias: [ 'group' ], + parse() { + return list(this.annotation.line) }, + autofill() { + // autofill header comments + if (this.comment.type === 'header') { + return 'other' + } + // don't autofill body comments + return + } +} - /// @name @note - /// @page annotations - /// @description A note about the documented item - /// @returns {object} - note: { - parse() { - let [ importance, description ] = regex('note', this.annotation.line) - - return [ - { - importance, - description: _markdown(description, this.annotation.contents) - } - ] +/// @name @readonly +/// @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 +annotations.readonly = { + parse() { + let bool = toBoolean(this.annotation) + + if (bool !== undefined) { + return bool } - }, - /// @name @page - /// @page annotations - /// @description The page you want the documented item to be on - /// @returns {string} - page: { - alias: [ 'group' ], - parse() { - return list(this.annotation.line) + return true + } +} + +/// @name @requires +/// @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 +annotations.requires = { + alias: [ 'require' ], + parse() { + let [ types, name = '', description ] = regex('requires', this.annotation.line) + + return [ + { + types: list(types), + name, + description: markdown(description, this.annotation.contents) + } + ] + } +} + +/// @name @returns +/// @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 +annotations.returns = { + alias: [ 'return' ], + parse() { + let [ types, description ] = regex('returns', this.annotation.line) + + if ( + types == null || + types === '' + ) { + types = 'undefined' } - }, - /// @name @readonly - /// @page annotations - /// @description To note that a property is readonly - /// @returns {boolean} - readonly: { - parse() { - return true + return { + types: list(types), + description: markdown(description, this.annotation.contents) } - }, + } +} - /// @name @requires - /// @page annotations - /// @description Requirements from the documented item - /// @returns {object} - requires: { - alias: [ 'require' ], - parse() { - let [ types, name, description ] = regex('requires', this.annotation.line) - - return [ - { - types: list(types), - name, - description: _markdown(description, this.annotation.contents) - } - ] +/// @name @since +/// @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 +annotations.since = { + parse() { + let [ version = 'undefined', description ] = regex('since', this.annotation.line) + + return { + version, + description: markdown(description, this.annotation.contents) } - }, + } +} - /// @name @returns - /// @page annotations - /// @description Return from the documented function - /// @returns {string} - returns: { - alias: [ 'return' ], - parse() { - let [ types, description ] = regex('returns', this.annotation.line) +/// @name @state +/// @page annotations +/// @description A state of a the documented item +/// @returns {hashmap} +/// @markup Usage +/// /// @states (id) {state} [state_id] - description +/// +/// /// @states (id) {state} [state_id] - description +/// /// @states (id) {state} [state_id] - description +/// /// @states (id) {state} [state_id] - description +/// +/// /// @states (id) +/// /// {state} [state_id] - description +/// /// {state} [state_id] - description +/// /// {state} [state_id] - description +annotations.state = { + parse() { + let states = this.annotation.contents.split('\n') + let [ markup_id = '0', state_line ] = regex('state_id', this.annotation.line) + states.unshift(state_line) + + states = states.filter(Boolean).map((line, i) => { + let [ state = '', state_id = `${i}`, description = '' ] = regex('state', line) return { - types: list(types), - description: _markdown(description, this.annotation.contents) + state, + state_id, + description: markdown(description) } - } - }, + }) - /// @name @since - /// @page annotations - /// @description Let's you know what version of the project a something was added - /// @returns {string} - since: { - parse() { - let [ types, description ] = regex('since', this.annotation.line) + return [ + { markup_id, states } + ] + }, + // resolve() { + // /// @todo {10} - add code to that adds the markup code for this stuff. + // } +} - return { +/// @name @throws +/// @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 +annotations.throws = { + alias: [ 'throw', 'exception', 'error', 'catch' ], + parse() { + let [ types, description ] = regex('throws', this.annotation.line) + + return [ + { types: list(types), - description: _markdown(description, this.annotation.contents) + description: markdown(description, this.annotation.contents) } - } - }, - - /// @name @state - /// @page annotations - /// @description A state of a the documented item - /// @returns {hashmap} - /// @markup - /// /// @states (id) {state} [state_id] - description - /// /// @states (id) - /// /// {state} [state_id] - description - /// /// {state} [state_id] - description - /// /// {state} [state_id] - description - state: { - parse() { - let states = this.annotation.contents.split('\n') - let [ markup_id = '0', state_line ] = regex('state_id', this.annotation.line) - states.unshift(state_line) - - states = states.filter(Boolean).map((line, i) => { - let [ state = '', state_id = `${i}`, description = '' ] = regex('state', line) - - return { - state, - state_id, - description: _markdown(description) - } - }) - - return [ - { markup_id, states } - ] - }, - // resolve() { - // /// @todo {10} - add code to that adds the markup code for this stuff. - // } - }, + ] + } +} - /// @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 - todo: { - parse() { - let [ +/// @name @todo +/// @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 +annotations.todo = { + parse() { + let [ + importance = '0', + assignees, + description + ] = regex('todo', this.annotation.line) + + return [ + { importance, - assignees, - description - ] = regex('todo', this.annotation.line) - - return [ - { - importance, - assignees: list(assignees), - description: _markdown(description, this.annotation.contents) - } - ] + assignees: list(assignees), + description: markdown(description, this.annotation.contents) + } + ] + } +} + +/// @name @type +/// @description Describes the type of a variable +/// @returns {object} +/// @markup Usage +/// /// @type {type} +/// +/// /// @type {type} description +/// +/// /// @type {type} - description +/// +/// /// @type {type} +/// /// multi +/// /// line +/// /// description +annotations.type = { + parse() { + let [ type, description ] = regex('type', this.annotation.line) + + 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' } - }, - /// @name @throws - /// @description - /// The error that happends if something goes wrong - throws: { - alias: [ 'throws', 'exception', 'error' ], - parse() { - return [ _markdown(this.annoation.line, this.annoation.content) ] + return { + type, + description: markdown(description, this.annotation.contents) } - }, + } +} - /// @name @type - /// @page annotations - /// @description Describes the type of a variable - /// @returns {string} - /// // type - `{type} - description` - type: { - parse() { - let [ type, description ] = regex('type', this.annotation.line) - return { - type, - description: _markdown(description, this.annotation.line) - } +/// @name @version +/// @description Describes the type of a variable +/// @returns {string} +/// @markup Usage +/// /// @version {version} +/// +/// /// @version {version} - description +/// +/// /// @version {version} description +/// +/// /// @version {version} +/// /// multi +/// /// line +/// /// description +annotations.version = { + parse() { + let [ version, description ] = regex('version', this.annotation.line) + + if (!version) { + this.log.emit( + 'warning', + `You didn't pass in a version to ${clor.bold('@version ')}`, + logAnnotationError(this, `@version {version}${description ? ' - ' + description : ''}`) + ) + version = 'undefined' } - }, - /// @name @version - /// @page annotations - /// @description Describes the type of a variable - /// @returns {string} - /// // version `{type} - description` - version: { - parse() { - let [ version, description ] = regex('version', this.annotation.line) - return { - version, - description: _markdown(description, this.annotation.line) - } + return { + version, + description: markdown(description, this.annotation.contents) } } } -export default annotations +export default { ...annotations } diff --git a/app/utils/purdy.js b/app/utils/purdy.js index 075a3c5..9bd57a6 100644 --- a/app/utils/purdy.js +++ b/app/utils/purdy.js @@ -22,7 +22,7 @@ export default class Purdy { Null: 'red.bold', Number: 'blue.bold', RegExp: 'magenta', - String: 'green', + String: undefined, // use the default color Undefined: 'red.inverse', path: 'grey' } diff --git a/app/utils/to.js b/app/utils/to.js index b78d255..bca509e 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -15,6 +15,21 @@ let to = { ...changeCase, + /// @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.string /// @description /// Converts an object, array, number, or boolean to a string diff --git a/package.json b/package.json index 5ba969b..f41d90e 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "unit-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks tests/unit/**/*.js", "mock-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks --delay tests/run.test.js", "test": "npm run unit-tests; npm run mock-tests", - "coverage": "nyc npm test", - "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", - "plato": "plato -d coverage/plato dist/index.js", + "coverage": "nyc npm run unit-tests", + "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls", + "plato": "rm -rf coverage/plato; plato --recurse --exclude .json --jshint .jshintrc -d coverage/plato app", "deploy": "npm run test && git push origin master && npm publish", "prepublish": "npm run compile" }, @@ -67,6 +67,7 @@ "eslint-plugin-babel": "^3.1.0", "mocha": "^2.4.5", "nyc": "^3.2.2", + "plato": "github:deedubs/es6-plato", "proxyquire": "^1.7.4", "sinon": "^1.17.3" }, diff --git a/tests/annotations/access/access.autofill.body.js b/tests/annotations/access/access.autofill.body.js new file mode 100644 index 0000000..e52df67 --- /dev/null +++ b/tests/annotations/access/access.autofill.body.js @@ -0,0 +1 @@ +/// @name autofill access diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json new file mode 100644 index 0000000..73c35a8 --- /dev/null +++ b/tests/annotations/access/access.autofill.body.json @@ -0,0 +1,11 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "name": "autofill access", + "access": "public" + } + ] +} diff --git a/tests/annotations/access/access.autofill.header.js b/tests/annotations/access/access.autofill.header.js new file mode 100644 index 0000000..b3f6e24 --- /dev/null +++ b/tests/annotations/access/access.autofill.header.js @@ -0,0 +1,3 @@ +//// +/// @name autofill access +//// diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json new file mode 100644 index 0000000..642baf5 --- /dev/null +++ b/tests/annotations/access/access.autofill.header.json @@ -0,0 +1,10 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "name": "autofill access", + "page": "other", + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/access/access.header.js b/tests/annotations/access/access.header.js new file mode 100644 index 0000000..6fb91e8 --- /dev/null +++ b/tests/annotations/access/access.header.js @@ -0,0 +1,3 @@ +//// +/// @access private +//// diff --git a/tests/annotations/access/access.header.json b/tests/annotations/access/access.header.json new file mode 100644 index 0000000..5092915 --- /dev/null +++ b/tests/annotations/access/access.header.json @@ -0,0 +1,9 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "access": "private", + "page": "other" + }, + "body": [] +} diff --git a/tests/annotations/access/access.options.js b/tests/annotations/access/access.options.js new file mode 100644 index 0000000..b1f9593 --- /dev/null +++ b/tests/annotations/access/access.options.js @@ -0,0 +1,5 @@ +/// @access public + +/// @access auto + +/// @access private diff --git a/tests/annotations/access/access.options.json b/tests/annotations/access/access.options.json new file mode 100644 index 0000000..d55bcb6 --- /dev/null +++ b/tests/annotations/access/access.options.json @@ -0,0 +1,20 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "access": "private" + } + ] +} diff --git a/tests/annotations/alias/alias.js b/tests/annotations/alias/alias.js new file mode 100644 index 0000000..4484ce1 --- /dev/null +++ b/tests/annotations/alias/alias.js @@ -0,0 +1,5 @@ +/// @alias foo + +/// @alias foo, bar + +/// @alias foo, bar, diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json new file mode 100644 index 0000000..0480474 --- /dev/null +++ b/tests/annotations/alias/alias.json @@ -0,0 +1,31 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "alias": [ + "foo" + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "alias": [ + "foo", + "bar" + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "alias": [ + "foo", + "bar" + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/arg.test.js b/tests/annotations/arg.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/tests/annotations/arg/arg.aliases.js b/tests/annotations/arg/arg.aliases.js new file mode 100644 index 0000000..42cd108 --- /dev/null +++ b/tests/annotations/arg/arg.aliases.js @@ -0,0 +1,5 @@ +/// @argument {type} name-of-variable - argument alias + +/// @param {type} name-of-variable - param alias + +/// @parameter {type} name-of-variable - parameter alias diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json new file mode 100644 index 0000000..f377942 --- /dev/null +++ b/tests/annotations/arg/arg.aliases.json @@ -0,0 +1,50 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

argument alias

\n" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

param alias

\n" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

parameter alias

\n" + } + ], + "access": "public" + } + ] +} 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..787b52b --- /dev/null +++ b/tests/annotations/arg/arg.json @@ -0,0 +1,94 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "arg": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "arg": [ + { + "types": [ + "type", + "othertype" + ], + "name": "name-of-variable", + "value": "", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "", + "description": "

description

\n" + } + ], + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "arg": [ + { + "types": [ + "type" + ], + "name": "name-of-variable", + "value": "default value", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" + } + ], + "access": "public" + }, + { + "__start": 10, + "__end": 15, + "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" + } + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/author.test.js b/tests/annotations/author.test.js deleted file mode 100644 index e2141f9..0000000 --- a/tests/annotations/author.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import test from 'tape' -import { author } from '../../annotations' - - -test('author test yo', (t) => { - console.log(author); - t.pass('yo bitch') - t.end() -}) \ No newline at end of file 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..0fd3014 --- /dev/null +++ b/tests/annotations/author/author.alias.json @@ -0,0 +1,15 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "author": [ + "Author One", + "Author Two", + "Author Three" + ], + "access": "public" + } + ] +} 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..bfba48d --- /dev/null +++ b/tests/annotations/author/author.body.json @@ -0,0 +1,13 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "author": [ + "Tyler Benton" + ], + "access": "public" + } + ] +} 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..79b3d01 --- /dev/null +++ b/tests/annotations/author/author.header.json @@ -0,0 +1,12 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "author": [ + "Tyler Benton" + ], + "page": "other", + "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..15cf31d --- /dev/null +++ b/tests/annotations/author/author.multiple.json @@ -0,0 +1,41 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "author": [ + "Author One", + "Author Two" + ], + "page": "other", + "access": "public" + }, + "body": [ + { + "__start": 4, + "__end": 5, + "author": [ + "Author One", + "Author Two" + ], + "access": "public" + }, + { + "__start": 7, + "__end": 7, + "author": [ + "Author One", + "Author Two" + ], + "access": "public" + }, + { + "__start": 10, + "__end": 12, + "author": [ + "Author One", + "Author Two" + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/chainable.test.js b/tests/annotations/chainable.test.js deleted file mode 100644 index e69de29..0000000 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..97443e6 --- /dev/null +++ b/tests/annotations/chainable/chainable.json @@ -0,0 +1,58 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "chainable": true, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "chainable": true, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "chainable": false, + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "chainable": [ + "Object.prototype" + ], + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "chainable": [ + "One", + "Two" + ], + "access": "public" + }, + { + "__start": 10, + "__end": 12, + "chainable": [ + "One", + "Two" + ], + "access": "public" + }, + { + "__start": 14, + "__end": 16, + "chainable": [ + "One", + "Two" + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/depricated.test.js b/tests/annotations/depricated.test.js deleted file mode 100644 index e69de29..0000000 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..8ede92a --- /dev/null +++ b/tests/annotations/depricated/depricated.body.json @@ -0,0 +1,41 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "deprecated": { + "version": "0", + "description": "" + }, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "deprecated": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "deprecated": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "access": "public" + }, + { + "__start": 6, + "__end": 9, + "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" + }, + "access": "public" + } + ] +} 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..f31496c --- /dev/null +++ b/tests/annotations/depricated/depricated.header.json @@ -0,0 +1,13 @@ +{ + "header": { + "__start": 0, + "__end": 5, + "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": "other", + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/description.test.js b/tests/annotations/description.test.js deleted file mode 100644 index e69de29..0000000 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..94434d5 --- /dev/null +++ b/tests/annotations/description/description.alias.json @@ -0,0 +1,89 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 1, + "name": "single-line `desc`", + "description": "

Lorem ipsum

\n", + "access": "public" + }, + { + "__start": 3, + "__end": 6, + "name": "multi-line `desc`", + "description": "

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

\n", + "access": "public" + }, + { + "__start": 10, + "__end": 11, + "name": "single-line `definition`", + "description": "

Lorem ipsum

\n", + "access": "public" + }, + { + "__start": 13, + "__end": 16, + "name": "multi-line `definition`", + "description": "

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

\n", + "access": "public" + }, + { + "__start": 20, + "__end": 21, + "name": "single-line `explanation`", + "description": "

Lorem ipsum

\n", + "access": "public" + }, + { + "__start": 23, + "__end": 26, + "name": "multi-line `explanation`", + "description": "

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

\n", + "access": "public" + }, + { + "__start": 30, + "__end": 31, + "name": "single-line `writeup`", + "description": "

Lorem ipsum

\n", + "access": "public" + }, + { + "__start": 33, + "__end": 36, + "name": "multi-line `writeup`", + "description": "

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

\n", + "access": "public" + }, + { + "__start": 40, + "__end": 41, + "name": "single-line `summary`", + "description": "

Lorem ipsum

\n", + "access": "public" + }, + { + "__start": 43, + "__end": 46, + "name": "multi-line `summary`", + "description": "

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

\n", + "access": "public" + }, + { + "__start": 50, + "__end": 51, + "name": "single-line `summarization`", + "description": "

Lorem ipsum

\n", + "access": "public" + }, + { + "__start": 53, + "__end": 56, + "name": "multi-line `summarization`", + "description": "

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

\n", + "access": "public" + } + ] +} 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..2c085bd --- /dev/null +++ b/tests/annotations/description/description.body.json @@ -0,0 +1,23 @@ +{ + "header": {}, + "body": [ + { + "__start": 1, + "__end": 1, + "description": "

Lorem ipsum dolor sit amet

\n", + "access": "public" + }, + { + "__start": 3, + "__end": 7, + "description": "

Line one\nOther\nlines\nbelow\nit

\n", + "access": "public" + }, + { + "__start": 9, + "__end": 13, + "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", + "access": "public" + } + ] +} 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..3b66075 --- /dev/null +++ b/tests/annotations/description/description.header.json @@ -0,0 +1,10 @@ +{ + "header": { + "__start": 0, + "__end": 6, + "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": "other", + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json new file mode 100644 index 0000000..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mark.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mark.mark b/tests/annotations/markdown/mark.mark new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/markdown.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/markdown.markdown b/tests/annotations/markdown/markdown.markdown new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/md.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/md.md b/tests/annotations/markdown/md.md new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mdml.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdml.mdml b/tests/annotations/markdown/mdml.mdml new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mdown.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdown.mdown b/tests/annotations/markdown/mdown.mdown new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mdtext.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdtext.mdtext b/tests/annotations/markdown/mdtext.mdtext new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mdtxt.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdtxt.mdtxt b/tests/annotations/markdown/mdtxt.mdtxt new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mdwn.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mdwn.mdwn b/tests/annotations/markdown/mdwn.mdwn new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mkd.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mkd.mkd b/tests/annotations/markdown/mkd.mkd new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/mkdn.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/mkdn.mkdn b/tests/annotations/markdown/mkdn.mkdn new file mode 100644 index 0000000..e099e21 --- /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..0feed55 --- /dev/null +++ b/tests/annotations/markdown/text.json @@ -0,0 +1,8 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + }, + "body": [] +} diff --git a/tests/annotations/markdown/text.text b/tests/annotations/markdown/text.text new file mode 100644 index 0000000..e099e21 --- /dev/null +++ b/tests/annotations/markdown/text.text @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/annotations/markup.test.js b/tests/annotations/markup.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/tests/annotations/access.test.js b/tests/annotations/markup/markup.js similarity index 100% rename from tests/annotations/access.test.js 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.test.js b/tests/annotations/name.test.js deleted file mode 100644 index e69de29..0000000 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..4af84f1 --- /dev/null +++ b/tests/annotations/name/name.aliases.json @@ -0,0 +1,23 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "name": "Title", + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "name": "Heading", + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "name": "Header", + "access": "public" + } + ] +} 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..0067923 --- /dev/null +++ b/tests/annotations/name/name.json @@ -0,0 +1,11 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "name": "Foo", + "access": "public" + } + ] +} diff --git a/tests/annotations/note.test.js b/tests/annotations/note.test.js deleted file mode 100644 index e69de29..0000000 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..d778afa --- /dev/null +++ b/tests/annotations/note/note.alias.json @@ -0,0 +1,27 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 3, + "note": [ + { + "importance": "0", + "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" + } + ], + "access": "public" + }, + { + "__start": 5, + "__end": 8, + "note": [ + { + "importance": "10", + "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" + } + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/note/note.js b/tests/annotations/note/note.js new file mode 100644 index 0000000..cb76a0b --- /dev/null +++ b/tests/annotations/note/note.js @@ -0,0 +1,19 @@ +/// @note + +/// @note {10} + +/// @note Lorem ipsum dolor sit amet + +/// @note +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, +/// sed do eiusmod tempor incididunt ut labore et dolore magna +/// aliqua. Ut enim ad minim veniam, quis nostrud exercitation +/// ullamco laboris nisi ut aliquip ex ea commodo consequat. + +/// @note {5} Lorem ipsum dolor sit amet + +/// @note {5} +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit, +/// sed do eiusmod tempor incididunt ut labore et dolore magna +/// aliqua. Ut enim ad minim veniam, quis nostrud exercitation +/// ullamco laboris nisi ut aliquip ex ea commodo consequat. diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json new file mode 100644 index 0000000..93d5cb3 --- /dev/null +++ b/tests/annotations/note/note.json @@ -0,0 +1,71 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "note": [ + { + "importance": "0", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "note": [ + { + "importance": "10", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "note": [ + { + "importance": "0", + "description": "

Lorem ipsum dolor sit amet

\n" + } + ], + "access": "public" + }, + { + "__start": 6, + "__end": 10, + "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" + } + ], + "access": "public" + }, + { + "__start": 12, + "__end": 12, + "note": [ + { + "importance": "5", + "description": "

Lorem ipsum dolor sit amet

\n" + } + ], + "access": "public" + }, + { + "__start": 14, + "__end": 18, + "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" + } + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/page.test.js b/tests/annotations/page.test.js deleted file mode 100644 index e69de29..0000000 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..55f32ae --- /dev/null +++ b/tests/annotations/page/page.alias.json @@ -0,0 +1,30 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "page": [ + "level 1" + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "page": [ + "level 1/level 2" + ], + "access": "public" + }, + { + "__start": 4, + "__end": 5, + "page": [ + "page 1/level 2", + "page 2/level 2" + ], + "access": "public" + } + ] +} 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..2ca1162 --- /dev/null +++ b/tests/annotations/page/page.body.autofill.json @@ -0,0 +1,11 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "description": "

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

\n", + "access": "public" + } + ] +} 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..55f32ae --- /dev/null +++ b/tests/annotations/page/page.body.json @@ -0,0 +1,30 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "page": [ + "level 1" + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "page": [ + "level 1/level 2" + ], + "access": "public" + }, + { + "__start": 4, + "__end": 5, + "page": [ + "page 1/level 2", + "page 2/level 2" + ], + "access": "public" + } + ] +} 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..2ac8287 --- /dev/null +++ b/tests/annotations/page/page.header.autofill.json @@ -0,0 +1,10 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "name": "page autofill test", + "page": "other", + "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..731d0a0 --- /dev/null +++ b/tests/annotations/page/page.header.json @@ -0,0 +1,11 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "page": [ + "level 1/level 2" + ], + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/readonly.test.js b/tests/annotations/readonly.test.js deleted file mode 100644 index e69de29..0000000 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..dc7fd93 --- /dev/null +++ b/tests/annotations/readonly/readonly.json @@ -0,0 +1,23 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "readonly": true, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "readonly": true, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "readonly": false, + "access": "public" + } + ] +} diff --git a/tests/annotations/requires.test.js b/tests/annotations/requires.test.js deleted file mode 100644 index e69de29..0000000 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..e3473c5 --- /dev/null +++ b/tests/annotations/requires/requires.alias.json @@ -0,0 +1,17 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "requires": [ + { + "types": [], + "name": "node", + "description": "" + } + ], + "access": "public" + } + ] +} 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..5330ea1 --- /dev/null +++ b/tests/annotations/requires/requires.body.json @@ -0,0 +1,103 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "requires": [ + { + "types": [], + "name": "", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "requires": [ + { + "types": [ + "*" + ], + "name": "", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "requires": [ + { + "types": [ + "object", + "array", + "function", + "string" + ], + "name": "", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "requires": [ + { + "types": [], + "name": "path", + "description": "" + } + ], + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "requires": [ + { + "types": [], + "name": "path", + "description": "

the path function from node

\n" + } + ], + "access": "public" + }, + { + "__start": 10, + "__end": 10, + "requires": [ + { + "types": [ + "function" + ], + "name": "path", + "description": "

the path function from node

\n" + } + ], + "access": "public" + }, + { + "__start": 12, + "__end": 13, + "requires": [ + { + "types": [], + "name": "node", + "description": "" + }, + { + "types": [], + "name": "npm", + "description": "" + } + ], + "access": "public" + } + ] +} 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..c8cb77a --- /dev/null +++ b/tests/annotations/requires/requires.header.json @@ -0,0 +1,18 @@ +{ + "header": { + "__start": 0, + "__end": 2, + "requires": [ + { + "types": [ + "function" + ], + "name": "path", + "description": "

the path function from node

\n" + } + ], + "page": "other", + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/returns.test.js b/tests/annotations/returns.test.js deleted file mode 100644 index e69de29..0000000 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..a8875d4 --- /dev/null +++ b/tests/annotations/returns/returns.alias.json @@ -0,0 +1,86 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "returns": { + "types": [ + "object" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "access": "public" + }, + { + "__start": 10, + "__end": 10, + "returns": { + "types": [ + "array" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "access": "public" + }, + { + "__start": 12, + "__end": 21, + "returns": { + "types": [ + "object" + ], + "description": "

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" + }, + "access": "public" + } + ] +} 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..a8875d4 --- /dev/null +++ b/tests/annotations/returns/returns.json @@ -0,0 +1,86 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "returns": { + "types": [ + "undefined" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "returns": { + "types": [ + "array", + "string", + "boolean" + ], + "description": "" + }, + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "returns": { + "types": [ + "object" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "access": "public" + }, + { + "__start": 10, + "__end": 10, + "returns": { + "types": [ + "array" + ], + "description": "

Lorem ipsum dolor sit amet

\n" + }, + "access": "public" + }, + { + "__start": 12, + "__end": 21, + "returns": { + "types": [ + "object" + ], + "description": "

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" + }, + "access": "public" + } + ] +} diff --git a/tests/annotations/since.test.js b/tests/annotations/since.test.js deleted file mode 100644 index e69de29..0000000 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..be91e57 --- /dev/null +++ b/tests/annotations/since/since.body.json @@ -0,0 +1,41 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "since": { + "version": "undefined", + "description": "" + }, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "since": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "since": { + "version": "0.0.1", + "description": "

Lorem

\n" + }, + "access": "public" + }, + { + "__start": 6, + "__end": 9, + "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" + }, + "access": "public" + } + ] +} 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..be00333 --- /dev/null +++ b/tests/annotations/since/since.header.json @@ -0,0 +1,13 @@ +{ + "header": { + "__start": 0, + "__end": 5, + "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": "other", + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/state.test.js b/tests/annotations/state.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/tests/annotations/alias.test.js b/tests/annotations/state/state.js similarity index 100% rename from tests/annotations/alias.test.js rename to tests/annotations/state/state.js diff --git a/tests/annotations/state/state.json b/tests/annotations/state/state.json new file mode 100644 index 0000000..e7c86d2 --- /dev/null +++ b/tests/annotations/state/state.json @@ -0,0 +1,4 @@ +{ + "header": {}, + "body": [] +} diff --git a/tests/annotations/throws/throws.alias.js b/tests/annotations/throws/throws.alias.js new file mode 100644 index 0000000..64c48fe --- /dev/null +++ b/tests/annotations/throws/throws.alias.js @@ -0,0 +1,7 @@ +/// @throw {throw} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @exception {exception} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @error {error} Lorem ipsum dolor sit amet, consectetur adipisicing elit. + +/// @catch {catch} Lorem ipsum dolor sit amet, consectetur adipisicing elit. diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json new file mode 100644 index 0000000..b85659e --- /dev/null +++ b/tests/annotations/throws/throws.alias.json @@ -0,0 +1,57 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "throws": [ + { + "types": [ + "throw" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "throws": [ + { + "types": [ + "exception" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "throws": [ + { + "types": [ + "error" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "throws": [ + { + "types": [ + "catch" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + } + ] +} 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..33d4482 --- /dev/null +++ b/tests/annotations/throws/throws.json @@ -0,0 +1,87 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "throws": [ + { + "types": [], + "description": "" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "throws": [ + { + "types": [ + "fileNotFound" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 8, + "__end": 11, + "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" + } + ], + "access": "public" + }, + { + "__start": 13, + "__end": 14, + "throws": [ + { + "types": [ + "warning" + ], + "description": "

some warning message

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

when something goes wrong

\n" + } + ], + "access": "public" + } + ] +} diff --git a/tests/annotations/todo.test.js b/tests/annotations/todo.test.js deleted file mode 100644 index e69de29..0000000 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..55660ed --- /dev/null +++ b/tests/annotations/todo/todo.body.json @@ -0,0 +1,85 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "todo": [ + { + "importance": "0", + "assignees": [], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "todo": [ + { + "importance": "5", + "assignees": [], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "todo": [ + { + "importance": "5", + "assignees": [], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "todo": [ + { + "importance": "10", + "assignees": [ + "Assignee One" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "todo": [ + { + "importance": "10", + "assignees": [ + "Assignee One", + "Assignee Two" + ], + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + } + ], + "access": "public" + }, + { + "__start": 10, + "__end": 13, + "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" + } + ], + "access": "public" + } + ] +} 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..54c578d --- /dev/null +++ b/tests/annotations/todo/todo.header.json @@ -0,0 +1,19 @@ +{ + "header": { + "__start": 0, + "__end": 5, + "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": "other", + "access": "public" + }, + "body": [] +} diff --git a/tests/annotations/type.test.js b/tests/annotations/type.test.js deleted file mode 100644 index e69de29..0000000 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..7e7f235 --- /dev/null +++ b/tests/annotations/type/type.json @@ -0,0 +1,68 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "type": { + "type": "undefined", + "description": "" + }, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "type": { + "type": "object", + "description": "" + }, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "type": { + "type": "undefined", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "type": { + "type": "undefined", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "access": "public" + }, + { + "__start": 8, + "__end": 8, + "type": { + "type": "array", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "access": "public" + }, + { + "__start": 10, + "__end": 10, + "type": { + "type": "array", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "access": "public" + }, + { + "__start": 12, + "__end": 16, + "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" + }, + "access": "public" + } + ] +} diff --git a/tests/annotations/version.test.js b/tests/annotations/version.test.js deleted file mode 100644 index e69de29..0000000 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..5d9f453 --- /dev/null +++ b/tests/annotations/version/version.json @@ -0,0 +1,50 @@ +{ + "header": {}, + "body": [ + { + "__start": 0, + "__end": 0, + "version": { + "version": "undefined", + "description": "" + }, + "access": "public" + }, + { + "__start": 2, + "__end": 2, + "version": { + "version": "0.0.1", + "description": "" + }, + "access": "public" + }, + { + "__start": 4, + "__end": 4, + "version": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "access": "public" + }, + { + "__start": 6, + "__end": 6, + "version": { + "version": "^0.0.1", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" + }, + "access": "public" + }, + { + "__start": 8, + "__end": 11, + "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" + }, + "access": "public" + } + ] +} diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json index 1e5f20b..4900a28 100644 --- a/tests/cases/header-comment-only.json +++ b/tests/cases/header-comment-only.json @@ -29,6 +29,7 @@ "author": [ "Tyler Benton" ], + "description": "

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

\n", "access": "public" }, "body": [] diff --git a/tests/cases/header-comment-only.scss b/tests/cases/header-comment-only.scss index 96ecb94..a6a389e 100644 --- a/tests/cases/header-comment-only.scss +++ b/tests/cases/header-comment-only.scss @@ -4,4 +4,4 @@ /// @page edge-cases/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 index 0275913..90074d7 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -40,6 +40,7 @@ "__start": 4, "__end": 27, "name": "moz-only", + "description": "

This allows you to write specific styles for mozilla firefox only

\n", "markup": [ { "id": "0", diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index d70f0aa..d445900 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -30,6 +30,7 @@ "author": [ "Tyler Benton" ], + "description": "

Your standard form button.

\n", "state": [ { "markup_id": "0", diff --git a/tests/run.test.js b/tests/run.test.js index bfa7b1c..edfa820 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -64,12 +64,17 @@ async function addSuite(name, folder, callback) { callback = folder folder = name } - // get the test cases - const cases = await getTestCases(folder) - // run any async stuff if needed before the tests. - // this `callback` is a curry function so it has to return a function - const tests = await callback({ ...cases }) + let cases, tests + try { + // get the test cases + cases = await getTestCases(folder) + // run any async stuff if needed before the tests. + // this `callback` is a curry function so it has to return a function + tests = await callback({ ...cases }) + } catch (err) { + console.log(err) + } suite(name, function() { // eslint-disable-line this.timeout(50000) // eslint-disable-line tests() diff --git a/tests/unit/utils/is.test.js b/tests/unit/utils/is.test.js index 08ac0d2..1bda695 100644 --- a/tests/unit/utils/is.test.js +++ b/tests/unit/utils/is.test.js @@ -2,8 +2,6 @@ import is from '../../../dist/utils/is.js' import assert from 'assert' -console.log('mother fucker ') -console.log() suite('is', () => { test('is.false', () => { assert.ok(!is.false('foo'), From dfa4b60427fbaee73381d91b0fdc2c10ee21bd06 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 24 Feb 2016 13:39:25 -0500 Subject: [PATCH 199/273] Updated to fix issues with older versions of node - `assert.deepStrictEqual` isn't a thing in v4 and below, so `core-assert` was added as a dev dependency which is just the v5 assert lib - `babel-register` isn't exposed in v4 and below so it was added as a dev dependency for the mocha tests - Older versions of node don't support `github:deedubs/es6-plato` but they do support `deedubs/es6-plato` and so do the new versions --- .travis.yml | 2 ++ package.json | 6 ++++-- tests/run.test.js | 2 +- tests/unit/utils/is.test.js | 2 +- tests/unit/utils/to.test.js | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a02751d..912a5e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ language: node_js node_js: - "iojs" - "0.12" + - "4.0" - "4" + - "5.0" - "5" sudo: false install: npm i diff --git a/package.json b/package.json index f41d90e..6f47f6b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "dist/index.js", "scripts": { "clean": "rm -rf ./dist", - "refresh": "rm -rf -- node_modules/ .tmp/ dist/; npm i", + "refresh": "rm -rf -- node_modules/ .tmp/ dist/ .nyc_output/ coverage/; npm i", "compile": "npm run clean; babel app/ -d dist/", "watch": "npm run clean; babel app/ -d dist/ --watch", "unit-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks tests/unit/**/*.js", @@ -62,12 +62,14 @@ "babel-plugin-transform-runtime": "^6.5.2", "babel-preset-es2015": "^6.5.0", "babel-preset-stage-0": "^6.5.0", + "babel-register": "^6.5.2", + "core-assert": "^0.1.3", "coveralls": "^2.11.6", "eslint": "^2.1.0", "eslint-plugin-babel": "^3.1.0", "mocha": "^2.4.5", "nyc": "^3.2.2", - "plato": "github:deedubs/es6-plato", + "plato": "deedubs/es6-plato", "proxyquire": "^1.7.4", "sinon": "^1.17.3" }, diff --git a/tests/run.test.js b/tests/run.test.js index edfa820..a61a34d 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -3,7 +3,7 @@ import path from 'path' import docs from '../dist/index.js' import { fs, glob, array, } from '../dist/utils' -import assert from 'assert' +import assert from 'core-assert' const test_defaults = { debug: false, diff --git a/tests/unit/utils/is.test.js b/tests/unit/utils/is.test.js index 1bda695..e059bbf 100644 --- a/tests/unit/utils/is.test.js +++ b/tests/unit/utils/is.test.js @@ -1,5 +1,5 @@ import is from '../../../dist/utils/is.js' -import assert from 'assert' +import assert from 'core-assert' suite('is', () => { diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js index 1138f77..ab76b80 100644 --- a/tests/unit/utils/to.test.js +++ b/tests/unit/utils/to.test.js @@ -1,7 +1,7 @@ import to from '../../../dist/utils/to.js' import fs from '../../../dist/utils/fs.js' import info from '../../../dist/utils/info.js' -import assert from 'assert' +import assert from 'core-assert' const string = 'yo this is a string' const array = [ 'one', 'two', 'three' ] const object = { one: 1, two: 2, three: 3 } From 1d83658614682ea3301502f80011f4ccaa31116d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 25 Feb 2016 15:55:32 -0500 Subject: [PATCH 200/273] Fixed bug with config --- app/config.js | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/app/config.js b/app/config.js index 8b8d098..33260a1 100644 --- a/app/config.js +++ b/app/config.js @@ -7,7 +7,7 @@ import AnnotationApi from './annotation_api' let log = new Logger() // changed by `options` key -const default_options = { +export const default_options = { config: `${info.root}/.docsfile.js`, files: [ 'app/**/*', 'src/**/*', '*.md' ], // files to search // files to be ignored @@ -30,7 +30,7 @@ const default_options = { annotations } -const default_comment = { +export const default_comment = { prefix: '@', // annotation identifier(this should probably never be changed) inline_prefix: '#', // @todo add support for this single line prefix for comments inside of the code below the comment block // file level comment block identifier @@ -40,7 +40,7 @@ const default_comment = { } // some defaults for common languages -const comments = { +export const comments = { _: default_comment, css: { header: { start: '/***', line: '*', end: '***/' }, @@ -82,8 +82,9 @@ export default async function config(options = {}) { // ensures `files`, `ignore` is always an array this way no // more checks have to happen for it - options.files = to.array(options.files) - options.ignore = to.array(options.ignore) + if (options.files) options.files = to.array(options.files) + if (options.ignore) options.ignore = to.array(options.ignore) + // merge options with base_config so there's a complete list of settings options = to.extend(to.extend({}, base_config), options) @@ -105,10 +106,22 @@ export default async function config(options = {}) { // ensures blank_lines is a number to avoid errors options.blank_lines = to.number(options.blank_lines) + options.comments = parseComments(options.comments) + + options.annotations = new AnnotationApi(options.annotations) + return options +} + + +let valid_options = to.keys(default_options) +let valid_comment_options = to.keys(default_comment) + + +export function parseComments(comments) { let parsed_comments = {} // ensures comments are a normal structure (aka not `'rb, py': {...}`) - for (let [ option, value ] of to.entries(options.comments)) { + for (let [ option, value ] of to.entries(comments)) { // converts option into an array so multiple languages can be declared at the same time option = option.replace(/\s/g, '').split(',') @@ -123,16 +136,25 @@ export default async function config(options = {}) { } } - options.comments = parsed_comments + for (let [ lang, value ] of to.entries(parsed_comments)) { + if ( + lang !== '_' && + value.extend + ) { + if (!parsed_comments[value.extend]) { + throw new Error(`${value.extend} comment style doesn't exist`) + } else if (!is.string(value.extend)) { + throw new Error(`the value of extend must be a string you passed ${value.extend}`) + } else { + parsed_comments[lang] = to.extend(value, to.clone(parsed_comments[value.extend])) + } + } + delete parsed_comments[lang].extend + } - options.annotations = new AnnotationApi(options.annotations) - return options + return parsed_comments } - -let valid_options = to.keys(default_options) -let valid_comment_options = to.keys(default_comment) - /// @name ensure_valid_config /// @description /// Ensures that the user set's a valid config From 4acbdc4d1df23306ab5a3e8902e53bf475c4e160 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 26 Feb 2016 10:19:28 -0500 Subject: [PATCH 201/273] Several changes - Removed custom denodeify as a dependency and added es6-promisify instead - Remove custom array function as a dependency and added async-array-methods instead - Updated naming conventions - Updated dependencies - Added a tools folder for different tools that can be used for testing --- .npmignore | 9 +- README.md | 4 +- app/{annotation_api.js => annotation-api.js} | 10 +- app/cli.js | 23 ++- app/config.js | 8 +- app/docs.js | 16 +- app/parser/{get_blocks.js => get-blocks.js} | 0 app/parser/index.js | 34 ++-- .../{parse_blocks.js => parse-blocks.js} | 4 +- ...{replace_aliases.js => replace-aliases.js} | 0 app/sorter/nav.js | 10 +- app/sorter/pages.js | 2 +- app/utils/array.js | 186 ------------------ app/utils/denodeify.js | 15 -- app/utils/fs.js | 18 +- app/utils/glob.js | 31 +-- app/utils/index.js | 2 - app/utils/is.js | 8 +- app/utils/logger.js | 20 +- app/utils/to.js | 67 ++++--- package.json | 20 +- tests/run.test.js | 52 ++--- tests/unit/utils/array.test.js | 0 tests/unit/utils/denodeify.test.js | 0 tests/unit/utils/is.test.js | 15 +- tests/unit/utils/to.test.js | 29 ++- tools/async-suite.js | 31 +++ 27 files changed, 251 insertions(+), 363 deletions(-) rename app/{annotation_api.js => annotation-api.js} (97%) rename app/parser/{get_blocks.js => get-blocks.js} (100%) rename app/parser/{parse_blocks.js => parse-blocks.js} (97%) rename app/parser/{replace_aliases.js => replace-aliases.js} (100%) delete mode 100644 app/utils/array.js delete mode 100644 app/utils/denodeify.js delete mode 100644 tests/unit/utils/array.test.js delete mode 100644 tests/unit/utils/denodeify.test.js create mode 100644 tools/async-suite.js diff --git a/.npmignore b/.npmignore index 587ef91..8670170 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,15 @@ tests/ +tools/ app/ coverage/ .coveralls.yml .travis.yml .gitignore .jscsrc -.jshintrc \ No newline at end of file +.jshintrc +.eslintrc +.babelrc +**/.DS_Store +.DS_Store +.tmp +.nyc_output diff --git a/README.md b/README.md index 9a104a1..22f8351 100644 --- a/README.md +++ b/README.md @@ -408,10 +408,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 diff --git a/app/annotation_api.js b/app/annotation-api.js similarity index 97% rename from app/annotation_api.js rename to app/annotation-api.js index 9acb793..1262a05 100644 --- a/app/annotation_api.js +++ b/app/annotation-api.js @@ -19,7 +19,7 @@ export default class AnnotationApi { } // add the inital annotations - this.add_annotations(annotations) + this.addAnnotations(annotations) } /// @name add @@ -125,7 +125,7 @@ export default class AnnotationApi { config = { parse: config } - } else if (is.plain_object(config) && !is.empty(config) && !is.any.in(config, ...to.keys(base_config))) { + } else if (is.plainObject(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) { @@ -136,7 +136,7 @@ export default class AnnotationApi { } } return - } else if (!is.plain_object(config)) { + } else if (!is.plainObject(config)) { throw new Error('config must be a function or object') return } @@ -163,7 +163,7 @@ export default class AnnotationApi { /// @description /// Add an array of annotations /// @arg {array} annotations - Annotation objects - add_annotations(annotations) { + addAnnotations(annotations) { for (let name in annotations) { if (annotations.hasOwnProperty(name)) { this.add(name, annotations[name]) @@ -184,7 +184,7 @@ export default class AnnotationApi { return this.annotations.default } - autofill_list(filetype) { + autofillList(filetype) { return to.map(this.list(filetype), (annotation, name) => { if (is.truthy(annotation.autofill)) { return { [name]: annotation.autofill } diff --git a/app/cli.js b/app/cli.js index 4f7412b..4ccb3a9 100644 --- a/app/cli.js +++ b/app/cli.js @@ -26,17 +26,26 @@ export default function cli() { .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', base_config.gitignore) .option('-x, --no-debug', 'Output debugging information', to_boolean, base_config.debug) .option('-w, --no-warning', 'Output warning messages', to_boolean, base_config.warning) - .option('-t, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) + .option('-m, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) .option('-a, --no-changed', 'Parse changed files', to_boolean, base_config.changed) .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, base_config.blank_lines) .option('-p, --print', 'This will only print the results instead of outputting them', false) .option('-r, --raw', 'This prevents the data from each file from being sorted', false) + .option('-t, --dry-run', 'This will run everything without outputting anything', false) .parse(process.argv) let { blankLines: blank_lines, + dryRun: dry_run, print, + ignore, + gitignore, + debug, + warning, + timestamps, + changed, + raw, dest, args } = program @@ -49,12 +58,20 @@ export default function cli() { return docs({ files, - ...program, + ignore, + gitignore, + debug, + warning, + timestamps, + changed, + raw, blank_lines, }) .then((parsed) => { if (print) { - console.log(JSON.stringify(parsed, null, 2)) + console.log(to.json(parsed)) + } else if (dry_run) { + // do nothing } else { fs.outputJson(dest, parsed, { spaces: 2 }) } diff --git a/app/config.js b/app/config.js index 33260a1..7de38a7 100644 --- a/app/config.js +++ b/app/config.js @@ -2,7 +2,7 @@ import { info, fs, is, to, Logger } from './utils' import path from 'path' import annotations from './annotations' -import AnnotationApi from './annotation_api' +import AnnotationApi from './annotation-api' let log = new Logger() @@ -78,7 +78,7 @@ export default async function config(options = {}) { } // merge the config file with passed options - options = to.extend(ensure_valid_config(config_file), options) + options = to.extend(ensureValidConfig(config_file), options) // ensures `files`, `ignore` is always an array this way no // more checks have to happen for it @@ -155,11 +155,11 @@ export function parseComments(comments) { return parsed_comments } -/// @name ensure_valid_config +/// @name ensureValidConfig /// @description /// Ensures that the user set's a valid config /// @access private -function ensure_valid_config(user_config) { +function ensureValidConfig(user_config) { for (let key in user_config) { if (!is.in(valid_options, key)) { log.emit('warning', `'${key}' is not a valid option, see docs options for more details`) //# @todo add link to the doc options diff --git a/app/docs.js b/app/docs.js index db7f713..9776d5f 100644 --- a/app/docs.js +++ b/app/docs.js @@ -6,12 +6,12 @@ import { to, fs, glob, - array, Logger } from './utils' import parser from './parser' import sorter from './sorter' import get_config from './config' +import { map } from 'async-array-methods' //// /// @name docs.js @@ -47,12 +47,12 @@ export default async function docs(options = {}) { await fs.ensureFile(info.temp.file) let json = fs.readFile(info.temp.file) log.emit('start', 'paths') - files = await glob(files, ignore, changed ? has_file_changed : false) + files = await glob(files, ignore, changed ? hasFileChanged : false) let s = files.length > 1 ? 's' : '' // eslint-disable-line log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${s} to parse`) log.emit('start', 'parser') - files = await array(files).map((file_path) => parser({ file_path, ...options, log })) + files = await map(files, (file_path) => parser({ file_path, ...options, log })) log.emit('complete', 'parser') // converts json to a readable JS object @@ -85,30 +85,30 @@ export default async function docs(options = {}) { } } -// @name has_file_changed +// @name hasFileChanged // @access private // @description // checks the status of the file to see if it has changed or not. // @arg {string} - path to file // @async // @returns {boolean} -async function has_file_changed(file) { +async function hasFileChanged(file) { let source = path.join(info.root, file) let target = path.join(info.temp.folder, file) try { - let stats = await array([ source, target ]).map((_path) => fs.stat(_path)) + let stats = await map([ source, target ], (_path) => fs.stat(_path)) // copies new files over because it's changed if (stats[0].mtime > stats[1].mtime) { - fs.fake_copy(source, target) + fs.fakeCopy(source, target) return true } return false } catch (err) { // copies new files over because it doesn't exist in the temp target directory - fs.fake_copy(source, target) + fs.fakeCopy(source, target) return true } } diff --git a/app/parser/get_blocks.js b/app/parser/get-blocks.js similarity index 100% rename from app/parser/get_blocks.js rename to app/parser/get-blocks.js diff --git a/app/parser/index.js b/app/parser/index.js index a41ba74..c3b8d3e 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -1,8 +1,8 @@ import { info, fs, is, to } from '../utils' import path from 'path' -import get_blocks from './get_blocks' -import parse_blocks from './parse_blocks' -import replace_aliases from './replace_aliases' +import getBlocks from './get-blocks' +import parseBlocks from './parse-blocks' +import replaceAliases from './replace-aliases' export default async function parser(options = {}) { let { file_path, comments, annotations, log } = options @@ -13,9 +13,9 @@ export default async function parser(options = {}) { // gets the comments to use on this file let comment = comments[type] ? comments[type] : comments._ - let contents = to.normal_string(await fs.readFile(file_path)) + let contents = to.normalString(await fs.readFile(file_path)) - contents = replace_aliases({ + contents = replaceAliases({ contents, annotations: annotations.list(type), comment, @@ -33,21 +33,25 @@ export default async function parser(options = {}) { } // a) The file doesn't contain any header level comments, or body level comments - if (!is.any.in(contents, - comment.header.start, comment.header.line, comment.header.end, - comment.body.start, comment.body.line, comment.body.end)) { + if ( + !is.any.in( + contents, + ...to.values(comment.header).slice(0, -1), + ...to.values(comment.body).slice(0, -1) + ) + ) { console.log(`Well shitfire, '${file.path}' doesn't contain any sweet documentation`) return [] } - let header = get_blocks({ + let header = getBlocks({ file, contents, comment: comment.header }) - let body = get_blocks({ + let body = getBlocks({ file, contents, comment: comment.body, @@ -55,7 +59,7 @@ export default async function parser(options = {}) { start_at: !is.empty(header) ? header[0].comment.end + 1 : 0 }) - header = parse_blocks({ + header = parseBlocks({ file, blocks: header, annotations, @@ -63,7 +67,7 @@ export default async function parser(options = {}) { log })[0] || {} - body = parse_blocks({ + body = parseBlocks({ file, blocks: body, annotations, @@ -75,3 +79,9 @@ export default async function parser(options = {}) { [file.path]: { header, body } } } + +export { + getBlocks, + parseBlocks, + replaceAliases +} diff --git a/app/parser/parse_blocks.js b/app/parser/parse-blocks.js similarity index 97% rename from app/parser/parse_blocks.js rename to app/parser/parse-blocks.js index 67ca908..c80efca 100644 --- a/app/parser/parse_blocks.js +++ b/app/parser/parse-blocks.js @@ -7,7 +7,7 @@ import autofill from './autofill' // Used to parse an array of blocks and runs the annotations function and returns the result // @arg {array} - The block/blocks you want to have parsed // @returns {array} of parsed blocks -export default function parse_blocks(options = {}) { +export default function parseBlocks(options = {}) { let { file, blocks, @@ -22,7 +22,7 @@ export default function parse_blocks(options = {}) { let parsed_blocks = [] - let autofill_list = annotations.autofill_list(file.type) + let autofill_list = annotations.autofillList(file.type) // loop over each block for (let block of blocks) { diff --git a/app/parser/replace_aliases.js b/app/parser/replace-aliases.js similarity index 100% rename from app/parser/replace_aliases.js rename to app/parser/replace-aliases.js diff --git a/app/sorter/nav.js b/app/sorter/nav.js index 8d0c4e1..14f0013 100644 --- a/app/sorter/nav.js +++ b/app/sorter/nav.js @@ -11,7 +11,7 @@ export default function nav(pages) { result.push(set({ title: to.titleCase(to.sentenceCase(key)), href: `/${key}`, - body: body_names(`/${key}`, value.page.body), + body: bodyNames(`/${key}`, value.page.body), subpages: [] }, value)) } @@ -19,16 +19,16 @@ export default function nav(pages) { return result } -/// @name body_names +/// @name bodyNames /// @description Helper function to get the name of each block in the body /// @arg {string} - the href to append the `name` of the block to /// @arg {array} - the body of the page /// @returns {array} -function body_names(href, body) { +function bodyNames(href, body) { let names = [] // loop over each block in the body for (let block of body) { - // a) Add the name to the body_names + // a) Add the name to the bodyNames if (is.existy(block.name)) { names.push({ title: block.name, @@ -60,7 +60,7 @@ function set(a, b) { } // add the name of each block in the body - nav_item.body = body_names(nav_item.href, value.page.body) + nav_item.body = bodyNames(nav_item.href, value.page.body) // a) Call `set` again because it's not the last level if (to.keys(value).length > 1) { // the reason it's `> 1` is because `page` will always be defined. diff --git a/app/sorter/pages.js b/app/sorter/pages.js index 42e32a8..c5d9f9c 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -12,7 +12,7 @@ export default function pages(options = {}) { let { json, page_fallback, log } = options - for (let { path, header, body } of to.object_entries(json, 'path')) { + for (let { path, header, body } of to.objectEntries(json, 'path')) { if (!is.empty(header)) { if (is.falsy(header.page)) { if (is.truthy(page_fallback)) { diff --git a/app/utils/array.js b/app/utils/array.js deleted file mode 100644 index 60ee708..0000000 --- a/app/utils/array.js +++ /dev/null @@ -1,186 +0,0 @@ -/* eslint-disable no-bitwise, babel/no-await-in-loop */ -'use strict' - -export default function async_array(array) { - return new AsyncArray(array) -} - - -class AsyncArray { - constructor(array) { - this.array = to_object(array) - } - - /// @description - /// Iterate through an array of values raising a callback for each in parallel. - /// - /// @arg {function} callback - The function to be applied to each value. - /// @arg {any} receiver - The `this` value in the callback. - async for_each(callback, receiver) { - await promiseAll(this.array, callback, receiver) - } - - /// @description - /// Iterate through an array of values raising a callback for each. - /// - /// @arg {function} callback - The function to be applied to each value. - /// @arg {any} receiver - The `this` value in the callback. - async for_each_stepped(callback, receiver) { - for (let i = 0; i < this.array.length; i++) { - if (i in this.array) { - await call(callback, receiver, this.array[i], i, this.array) - } - } - } - - /// @description - /// Uses a callback to sequentially map an array of values in parallel. - /// - /// @arg {array} array The set of values to map over. - /// @arg {function} callback - The function to be applied to each value. - /// @arg {any} receiver - The `this` value in the callback. - /// @return {array} - The mapped array. - async map(callback, receiver) { - return await promiseAll(this.array, callback, receiver) - } - - /// @description - /// Uses a callback to sequentially map an array of values. - /// - /// @arg {array} array - The set of values to map over. - /// @arg {function} callback - The function to be applied to each value. - /// @arg {any} receiver - The `this` value in the callback. - /// @return {array} - The mapped array. - async map_stepped(callback, receiver) { - let result = [] - - for (let i = 0; i < this.array.length; i++) { - if (i in this.array) { - result.push(await call(callback, receiver, this.array[i], i, this.array)) - } - } - - return result - } - - /// @description - /// Uses a callback to sequentially filter an array of values in parallel. - /// - /// @arg {function} callback - The function to filter the values. - /// @arg {any} receiver - The `this` value in the callback. - /// @return {array} - The filtered array. - async filter(callback, receiver) { - const results = await promiseAll(this.array, callback, receiver) - return _filter(this.array, (obj, i) => results[i]) - } - - /// @description - /// Uses a callback to sequentially filter an array of values. - /// - /// @arg {function} callback - The function to filter the values. - /// @arg {any} receiver - The `this` value in the callback. - /// @return {array} - The filtered array. - async filter_stepped(callback, receiver) { - const result = [] - - for (let i = 0; i < this.array.length; i++) { - if (i in this.array) { - const item = this.array[i] - if (await call(callback, receiver, item, i, this.array)) { // eslint-disable-line - result[result.length] = item - } - } - } - - return result - } - - /// @description - /// Uses a callback to reduce a set of values. - /// - /// @arg {function} callback - The function to be applied to each value. - /// @arg {any} receiver - The `this` value in the callback. - /// @return {any} - The accumulated value. - async reduce(callback, initial) { - const obj = this.array - const len = ~~this.array.length - let accum = initial - let start = 0 - - if (arguments.length < 3) { - for (; start < len; start++) { - if (start in obj) { - accum = obj[start++] - break - } - } - } - - for (let i = start; i < len; i++) { - if (i in obj) { - accum = await callback(accum, obj[i], i, this.array) - } - } - - return accum - } - - /// @description - /// Returns true the first time a callback returns a truthy value against a set - /// of values, otherwise returns false. - /// - /// @arg {function} callback - The function to test each value. - /// @arg {any} receiver - The `this` value in the callback. - /// @return Boolean - async some(callback, receiver) { - for (let i = 0; i < this.array.length; i++) { - if (i in this.array && (await call(callback, receiver, this.array[i], i, this.array))) { - return true - } - } - - return false - } - - /// @description - /// Returns false the first time a callback returns a falsey value against a set - /// of values, otherwise returns true. - /// - /// @arg {function} callback - The function to test each value. - /// @arg {any} receiver - The `this` value in the callback. - /// @return Boolean - async every(callback, receiver) { - for (let i = 0; i < this.array.length; i++) { - if (i in this.array && !(await call(callback, receiver, this.array[i], i, this.array))) { - return false - } - } - - return true - } -} - -function promiseAll(array, callback, receiver) { - const obj = to_object(array) - const len = ~~obj.length - const promises = [] - - for (let i = 0; i < len; i++) { - if (i in obj) { - promises[promises.length] = call(callback, receiver, obj[i], i, array) - } - } - - return Promise.all(promises) -} - -const callbind = Function.prototype.bind.bind(Function.prototype.call) -const call = callbind(Function.prototype.call) -const _filter = callbind(Array.prototype.filter) - -function to_object(value) { - if (value == null) { - throw new TypeError(`Can't convert ${value} to obj`) - } - return Object(value) -} diff --git a/app/utils/denodeify.js b/app/utils/denodeify.js deleted file mode 100644 index 39484e0..0000000 --- a/app/utils/denodeify.js +++ /dev/null @@ -1,15 +0,0 @@ -// @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 default function denodeify(func) { - return function plugin(...args) { - return new Promise((resolve, reject) => { - func(...args, (err, ...func_args) => err ? reject(err) : resolve(...func_args)) - }) - } -} diff --git a/app/utils/fs.js b/app/utils/fs.js index 840de92..4db60bd 100644 --- a/app/utils/fs.js +++ b/app/utils/fs.js @@ -1,13 +1,13 @@ // File System import path from 'path' -import denodeify from './denodeify.js' import fs from 'fs-extra' +import promisify from 'es6-promisify' -// @name fs.fake_copy +// @name fs.fakeCopy // @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) => { +fs.fakeCopy = (source, target, callback) => { source = path.parse(source) target = path.parse(target) @@ -17,11 +17,13 @@ fs.fake_copy = (source, target, 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) -fs.ensureFile = denodeify(fs.ensureFile) +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 +// export default promisify(fs) diff --git a/app/utils/glob.js b/app/utils/glob.js index 1952ae6..30bd860 100644 --- a/app/utils/glob.js +++ b/app/utils/glob.js @@ -1,12 +1,12 @@ import to from './to' import is from './is' -import array from './array' -import denodeify from './denodeify' +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 original_glob = denodeify(require('glob')) +const rawGlob = promisify(require('glob')) /// @description @@ -18,9 +18,9 @@ const original_glob = denodeify(require('glob')) /// @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 = [], filter, files_only = true) { - files = array(to.array(files)).map((file) => original_glob(file)) - ignore = array(to.array(ignore)).map((file) => original_glob(file.replace(/!/, ''))) +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) @@ -28,12 +28,15 @@ export default async function glob(files, ignore = [], filter, files_only = true // removed any files that are supposed to be ignored if (ignore.length) { files = files.filter((file) => { - for (let i in ignore) { - if (file.indexOf(ignore[i]) > -1) { - return false - break + for (var i in ignore) { + if (ignore.hasOwnProperty(i)) { + if (file.indexOf(ignore[i]) > -1) { + return false + break + } } } + return true }) } @@ -42,12 +45,12 @@ export default async function glob(files, ignore = [], filter, files_only = true files = files.filter((file) => path.extname(file).indexOf('.') > -1) } - if (is.fn(filter)) { - if (is.promise(filter())) { - return await array(files).filter(filter) + if (is.fn(callback)) { + if (is.promise(callback())) { + return await filter(files, callback) } - return files.filter(filter) + return files.filter(callback) } return files diff --git a/app/utils/index.js b/app/utils/index.js index 8b97345..d8f0176 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,4 +1,3 @@ -export denodeify from './denodeify' export Logger from './logger' export { Purdy } from './purdy' export fs from './fs' @@ -6,4 +5,3 @@ export glob from './glob' export info from './info' export is from './is' export to from './to' -export array from './array' diff --git a/app/utils/is.js b/app/utils/is.js index c549c6b..0f4ffdb 100644 --- a/app/utils/is.js +++ b/app/utils/is.js @@ -5,7 +5,7 @@ /// @page utils/is //// -const to_string = (arg) => Object.prototype.toString.call(arg) +const toString = (arg) => Object.prototype.toString.call(arg) import to from './to.js' import is from 'is_js' @@ -28,15 +28,15 @@ is.fn = is.function /// @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.plain_object(obj) ? to.keys(obj) : obj).indexOf(value) > -1 +is.in = (obj, value) => (is.plainObject(obj) ? to.keys(obj) : obj).indexOf(value) > -1 -/// @name is.plain_object +/// @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.plain_object = (arg) => to_string(arg) === '[object Object]' +is.plainObject = (arg) => toString(arg) === '[object Object]' /// @name is.between diff --git a/app/utils/logger.js b/app/utils/logger.js index 953edc6..71b2766 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -3,10 +3,10 @@ import clor from 'clor' let icon = { - chevron: '\xBB', - check: '\u2713', - warning: '\u26A0', - error: '\u2326' + chevron: '\xBB ', + check: '\u2713 ', + warning: '\u26A0 ', + error: '\u2326 ' } const messaging = { @@ -22,8 +22,10 @@ export default class Logger { constructor(options = {}) { this.events = [] this.times = {} + this.options = options - this.report(options) + + this.report() } /// @description @@ -48,12 +50,12 @@ export default class Logger { return this } - report(options) { + report() { let { debug = true, warning = true, timestamps = true - } = options + } = this.options this.on('annotation_error', ({ annotation, error_message }) => this.error(`with ${annotation}`, error_message)) @@ -62,7 +64,7 @@ export default class Logger { this .on('start', (name) => this.time(name)) .on('complete', (name, format = '%s finished after %dms') => - this.time_end(name, format)) + this.timeEnd(name, format)) } if (debug) { @@ -99,7 +101,7 @@ export default class Logger { return this } - time_end(label, format = '%s completed after %dms') { + timeEnd(label, format = '%s completed after %dms') { let time = this.times[label] if (!time) { diff --git a/app/utils/to.js b/app/utils/to.js index bca509e..262c3dd 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -1,5 +1,5 @@ -const to_string = (arg) => Object.prototype.toString.call(arg) -const array_slice = (arg) => Array.prototype.slice.call(arg) +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' @@ -44,8 +44,8 @@ let to = { return arg + '' } - if (is.plain_object(arg)) { - return to_string(arg) + if (is.plainObject(arg)) { + return toString(arg) } if (is.array(arg)) { @@ -56,7 +56,7 @@ let to = { }, - /// @name to.normal_string + /// @name to.normalString /// @description /// The ` + ""` converts the file from a buffer to a string /// @@ -67,7 +67,7 @@ let to = { /// /// @arg {*} /// @returns {string} That has microsoft crap removed from it - normal_string: (str) => to.string(str).replace(/(?:\\[rn]+)+/g, '\n'), + normalString: (str) => to.string(str).replace(/(?:\\[rn]+)+/g, '\n'), /// @name to.keys /// @description @@ -75,8 +75,29 @@ let to = { /// It also get's symbols if they're set as a key name. /// @arg {object} /// @returns {array} - keys: (arg) => (is.plain_object(arg) || is.symbol(arg)) && - to.flatten([ Object.getOwnPropertySymbols(arg), Object.getOwnPropertyNames(arg) ]), + 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} + /// @returns {array} + values(arg) { + let values = [] + for (var key in arg) { + if (arg.hasOwnProperty(key)) { + values.push(arg[key]) + } + } + + return values + }, /// @name to.entries /// @description @@ -158,13 +179,13 @@ let to = { /// } /// } /// - /// for (let { key, one, two, three } of to.object_entries(example)) { + /// for (let { key, one, two, three } of to.objectEntries(example)) { /// // key -> 'foo' /// // one -> 'Item one' /// // two -> 'Item two' /// // three -> 'Item three' /// } - object_entries(obj, key_name = 'key', index_name = 'i') { + objectEntries(obj, key_name = 'key', index_name = 'i') { let i = 0 let keys = to.keys(obj) let length = keys.length @@ -243,8 +264,8 @@ let to = { let k = to.keys(b) // eslint-disable-line for (let i = 0, l = k.length; i < l; i++) { - if (is.plain_object(b[k[i]])) { - a[k[i]] = is.plain_object(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] + if (is.plainObject(b[k[i]])) { + a[k[i]] = is.plainObject(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] } else { a[k[i]] = b[k[i]] } @@ -362,8 +383,8 @@ let to = { a[k] = b[k] } else if (is.array(a[k])) { a[k].push(b[k]) - } else if (is.plain_object(a[k])) { - a[k] = is.plain_object(b[k]) ? to.merge(a[k], b[k]) : 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] ] } @@ -376,7 +397,7 @@ let to = { } // a) Filter out duplicates - if (unique && !is.plain_object(a[k][0])) { + if (unique && !is.plainObject(a[k][0])) { a[k] = to.unique(a[k]) } } @@ -417,10 +438,10 @@ let to = { if (is.array(arg)) { return arg } else if (is.arguments(arg)) { - return array_slice(arg) + return arraySlice(arg) } else if (is.string(arg)) { return arg.split(glue) - } else if (is.plain_object(arg) || is.number(arg)) { + } else if (is.plainObject(arg) || is.number(arg)) { return [ arg ] } @@ -461,11 +482,11 @@ let to = { /// @arg {array, object} /// @returns {array, object} - The sorted version sort(arg, callback) { - let run_sort = (obj) => is.fn(callback) ? obj.sort.apply(null, callback) : obj.sort() + let runSort = (obj) => is.fn(callback) ? obj.sort.apply(null, callback) : obj.sort() let result - if (is.plain_object(arg)) { + if (is.plainObject(arg)) { let sorted = {} - let keys = run_sort(to.keys(arg)) + let keys = runSort(to.keys(arg)) for (let i = 0, l = keys.length; i < l; i++) { sorted[keys[i]] = arg[keys[i]] @@ -473,7 +494,7 @@ let to = { result = sorted } else if (is.array(arg)) { - result = run_sort(callback) + result = runSort(callback) } return result }, @@ -487,7 +508,7 @@ let to = { for (let [ key, value ] of to.entries(arg)) { let cb_result = callback(value, key) - if (is.truthy(cb_result) && !is.empty(cb_result) && is.plain_object(cb_result)) { + if (is.truthy(cb_result) && !is.empty(cb_result) && is.plainObject(cb_result)) { to.extend(result, cb_result) } } @@ -521,7 +542,7 @@ let to = { return arg } else if (is.array(arg)) { return arg.length - } else if (is.plain_object(arg)) { + } else if (is.plainObject(arg)) { return to.keys(arg).length } diff --git a/package.json b/package.json index 6f47f6b..f03ee72 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "refresh": "rm -rf -- node_modules/ .tmp/ dist/ .nyc_output/ coverage/; npm i", "compile": "npm run clean; babel app/ -d dist/", "watch": "npm run clean; babel app/ -d dist/ --watch", - "unit-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks tests/unit/**/*.js", - "mock-tests": "mocha --compilers js:babel-register --ui tdd --check-leaks --delay tests/run.test.js", + "mocha": "mocha --compilers js:babel-register --ui tdd --check-leaks --colors --delay", + "unit-tests": "npm run mocha -- tests/unit/*.js tests/unit/**/*.js", + "mock-tests": "npm run mocha -- tests/run.test.js", "test": "npm run unit-tests; npm run mock-tests", "coverage": "nyc npm run unit-tests", "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls", @@ -21,7 +22,8 @@ "nyc": { "exclude": [ "node_modules/", - "*/utils/fs.js" + "tests/", + "tools/" ] }, "files": [ @@ -44,13 +46,15 @@ "node": ">=0.12.0" }, "dependencies": { + "async-array-methods": "^2.1.0", "babel-runtime": "^6.5.0", "change-case": "^2.3.1", - "clor": "^1.6.0", + "clor": "^2.0.2", "commander": "^2.9.0", - "fs-extra": "^0.24.0", - "glob": "^5.0.15", - "is_js": "^0.7.6", + "es6-promisify": "^3.0.0", + "fs-extra": "^0.26.5", + "glob": "^7.0.0", + "is_js": "^0.8.0", "marked": "^0.3.5" }, "devDependencies": { @@ -68,7 +72,7 @@ "eslint": "^2.1.0", "eslint-plugin-babel": "^3.1.0", "mocha": "^2.4.5", - "nyc": "^3.2.2", + "nyc": "^5.6.0", "plato": "deedubs/es6-plato", "proxyquire": "^1.7.4", "sinon": "^1.17.3" diff --git a/tests/run.test.js b/tests/run.test.js index a61a34d..decab0a 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -1,9 +1,10 @@ /* eslint-disable no-loop-func */ -/* global run */ import path from 'path' import docs from '../dist/index.js' -import { fs, glob, array, } from '../dist/utils' +import { fs, glob } from '../dist/utils' import assert from 'core-assert' +import { map } from 'async-array-methods' +import asyncSuite from '../tools/async-suite' const test_defaults = { debug: false, @@ -15,8 +16,7 @@ const test_defaults = { addSuite('cases', async ({ paths, expected }) => { - const actual = await array(paths).map((files) => docs({ files, ...test_defaults })) - + const actual = await map(paths, (files) => docs({ files, ...test_defaults })) return () => { for (let i = 0; i < paths.length; i++) { test(`${i}: ${paths[i]}`, () => { @@ -31,7 +31,7 @@ addSuite('cases', async ({ paths, expected }) => { addSuite('annotations', async ({ paths, expected }) => { - const actual = await array(paths).map((files) => docs({ files, raw: true, ...test_defaults })) + const actual = await map(paths, (files) => docs({ files, raw: true, ...test_defaults })) return () => { for (let i = 0; i < paths.length; i++) { @@ -58,38 +58,22 @@ const mochaAsync = (fn) => { // eslint-disable-line } } - -async function addSuite(name, folder, callback) { +function addSuite(name, folder, callback) { if (arguments.length === 2) { callback = folder folder = name } - let cases, tests - - try { - // get the test cases - cases = await getTestCases(folder) - // run any async stuff if needed before the tests. - // this `callback` is a curry function so it has to return a function - tests = await callback({ ...cases }) - } catch (err) { - console.log(err) - } - suite(name, function() { // eslint-disable-line - this.timeout(50000) // eslint-disable-line - tests() - }) - run() // mocha-tests -} - -// console.log(addSuite()) - -async function getTestCases(folder) { - const base = path.join(__dirname, folder) - const paths = await glob(path.join(base, '**', '*'), [ path.join(base, '**', '*.json') ]) - return { - paths, - expected: await array(paths).map((file) => fs.readJson(file.replace(path.extname(file), '.json'))) - } + return asyncSuite( + name, + async () => { + const base = path.join(__dirname, folder) + const paths = await glob(path.join(base, '**', '*'), [ path.join(base, '**', '*.json') ]) + return { + paths, + expected: await map(paths, (file) => fs.readJson(file.replace(path.extname(file), '.json'))) + } + }, + callback + ) } diff --git a/tests/unit/utils/array.test.js b/tests/unit/utils/array.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/utils/denodeify.test.js b/tests/unit/utils/denodeify.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/utils/is.test.js b/tests/unit/utils/is.test.js index e059bbf..5f8550f 100644 --- a/tests/unit/utils/is.test.js +++ b/tests/unit/utils/is.test.js @@ -1,8 +1,9 @@ -import is from '../../../dist/utils/is.js' +import is from '../../../app/utils/is.js' import assert from 'core-assert' +import asyncSuite from '../../../tools/async-suite.js' -suite('is', () => { +asyncSuite.wrap('is', () => { test('is.false', () => { assert.ok(!is.false('foo'), 'should return false if a string is passed') @@ -73,14 +74,14 @@ suite('is', () => { 'should return false because none of the passed arguments are in the string') }) - test('is.plain_object', () => { - assert.ok(is.plain_object({}), + test('is.plainObject', () => { + assert.ok(is.plainObject({}), 'should return true if passed a {}') - assert.ok(!is.plain_object([]), + assert.ok(!is.plainObject([]), 'should return false if passed a []') - assert.ok(!is.plain_object(''), + assert.ok(!is.plainObject(''), 'should return false if passed a string') - assert.ok(!is.plain_object(test), + assert.ok(!is.plainObject(test), 'should return false if passed a function') }) diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js index ab76b80..47ec733 100644 --- a/tests/unit/utils/to.test.js +++ b/tests/unit/utils/to.test.js @@ -1,6 +1,8 @@ -import to from '../../../dist/utils/to.js' -import fs from '../../../dist/utils/fs.js' -import info from '../../../dist/utils/info.js' +import to from '../../../app/utils/to.js' +import asyncSuite from '../../../tools/async-suite.js' +import fs from 'fs-extra' +import promisify from 'es6-promisify' +fs.readFile = promisify(fs.readFile) import assert from 'core-assert' const string = 'yo this is a string' const array = [ 'one', 'two', 'three' ] @@ -8,9 +10,9 @@ const object = { one: 1, two: 2, three: 3 } const buffer = new Buffer(string) const number = 4 const boolean = false -const file = `${info.root}/tests/file-types/coffeescript/test.coffee` +const file = `${process.cwd()}/tests/file-types/coffeescript/test.coffee` -suite('to', () => { +asyncSuite.wrap('to', () => { test('to.string', async () => { assert.strictEqual(typeof to.string(string), 'string', '`string` should be converted to a typeof string') @@ -29,14 +31,14 @@ suite('to', () => { }) - test('to.normal_string', async () => { + test('to.normalString', async () => { let result try { // this file has some stupid ass characters in it // that need to be removed in order to become like the // rest of the fucking world. #microsoftBlowsAtStandards const crappy_windows_file = await fs.readFile(file) - result = to.normal_string(crappy_windows_file).match(/\r/g) + result = to.normalString(crappy_windows_file).match(/\r/g) assert.equal(result, null, 'should be a normal string') } catch (err) { @@ -53,6 +55,13 @@ suite('to', () => { assert.strictEqual(keys[2], 'three', 'should return three') }) + test('to.values', () => { + const values = to.values(object) + assert.strictEqual(values[0], 1) + assert.strictEqual(values[1], 2) + assert.strictEqual(values[2], 3) + }) + test('to.entries', () => { for (const [ i, item ] of to.entries(array)) { @@ -62,8 +71,8 @@ suite('to', () => { }) - test('to.object_entries', () => { - for (const { key, one, two, three } of to.object_entries({ test: object })) { + test('to.objectEntries', () => { + for (const { key, one, two, three } of to.objectEntries({ test: object })) { assert.strictEqual(key, 'test', 'The key should be `test`') assert.strictEqual(one, 1, '`one` should equal 1') assert.strictEqual(two, 2, '`two` should equal 2') @@ -143,7 +152,7 @@ suite('to', () => { test('to.object', async () => { try { - const json = await fs.readFile(`${info.root}/package.json`) + const json = await fs.readFile(`${process.cwd()}/package.json`) assert.ok(to.object(json).author, 'the passed json should now be an object') } catch (err) { diff --git a/tools/async-suite.js b/tools/async-suite.js new file mode 100644 index 0000000..9fa09ea --- /dev/null +++ b/tools/async-suite.js @@ -0,0 +1,31 @@ +/// @name Async Suite +/// @description +/// This is function is used to create async suites for mocha +/// @arg {string} name - the name of the suite +async function asyncSuite(name, ...callbacks) { + let result + + try { + for (let callback of callbacks) { + callback = callback(result) + + result = await (callback && callback.then ? callback : Promise.resolve(callback)) // eslint-disable-line + // if (callback) { + // } else {} + } + } catch (err) { + console.log(err) + } + + suite(name, result) + + // run mocha-tests + run() // eslint-disable-line +} + +asyncSuite.wrap = (name, callback) => { + asyncSuite(name, () => callback) +} + + +export default asyncSuite From 33e9a5eb83331387b405be602d9deba74ae98ef5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 29 Feb 2016 14:40:37 -0500 Subject: [PATCH 202/273] :bugfix: with the parser --- app/parser/get-blocks.js | 22 +++++++------------ app/parser/index.js | 4 +--- ...pace-between-header-and-body-comments.json | 2 +- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index 096bc62..378b54f 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -6,15 +6,13 @@ import { is, to } from '../utils' /// @description Parses the file and returns the comment blocks in an array /// @returns {array} of the comment blocks /// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. -export default function getBlocks(options) { - let { - file, - contents, - comment, - restrict = true, - start_at = 0 - } = options - +export default function getBlocks({ + file, + contents, + comment, + restrict = true, + start_at = 0 +}) { start_at = to.number(start_at) let style = is.all.truthy(comment.start, comment.end) ? 'multi' : 'single' @@ -77,8 +75,6 @@ export default function getBlocks(options) { in_comment = false block.comment.contents.push(line) block.comment.end = i // sets the end line in the comment block - - // @todo might need to remove this i++ // skips end comment line line = lines[i] // updates to be the next line index.end = (line && is.in(line, comment.end)) ? line.indexOf(comment.end) : false @@ -94,8 +90,6 @@ export default function getBlocks(options) { block.comment.contents.push(line) } - // console.log(`${i}: ${line}`); - // a) The last line in the file is a commment if (in_comment && (style === 'multi' && index.end !== false ? i === l : i === l - 1)) { block.comment.end = style === 'multi' ? i - 1 : i @@ -136,7 +130,7 @@ export default function getBlocks(options) { } } } else if (i === l - 1 && is.truthy(block)) { // the last line in the file was an empty line. - block[is.between(block.comment.end) ? 'comment' : 'code'].end = i + block[block.comment.end > -1 ? 'code' : 'comment'].end = i parsed.push(block) } } // end loop diff --git a/app/parser/index.js b/app/parser/index.js index c3b8d3e..c0485cb 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -4,9 +4,7 @@ import getBlocks from './get-blocks' import parseBlocks from './parse-blocks' import replaceAliases from './replace-aliases' -export default async function parser(options = {}) { - let { file_path, comments, annotations, log } = options - +export default async function parser({ file_path, comments, annotations, log }) { // the filetype of the current file let type = path.extname(file_path).replace('.', '') diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index 90074d7..e6defd6 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -38,7 +38,7 @@ "body": [ { "__start": 4, - "__end": 27, + "__end": 16, "name": "moz-only", "description": "

This allows you to write specific styles for mozilla firefox only

\n", "markup": [ From 8dc4771a58d42b6b47c39bf73a4ded8de974eea6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 29 Feb 2016 14:51:35 -0500 Subject: [PATCH 203/273] added test for config.js --- .eslintrc | 1 - tests/unit/config.test.js | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/unit/config.test.js diff --git a/.eslintrc b/.eslintrc index 61ab232..4e7b203 100644 --- a/.eslintrc +++ b/.eslintrc @@ -55,7 +55,6 @@ "babel/no-await-in-loop": 1, - "arrow-body-style": [ 2, "as-needed" ], "arrow-spacing": 2, "block-scoped-var": 2, "block-spacing": [ 2, "always" ], diff --git a/tests/unit/config.test.js b/tests/unit/config.test.js new file mode 100644 index 0000000..1f10f58 --- /dev/null +++ b/tests/unit/config.test.js @@ -0,0 +1,41 @@ +/* eslint-disable no-unused-vars */ +import assert from 'core-assert' +import asyncSuite from '../../tools/async-suite.js' +import getConfig, { + parseComments, + default_options, + default_comment, + comments, + base_config +} from '../../app/config' + +asyncSuite('config', () => { + return () => { + test('parseComments empty', () => { + assert.deepStrictEqual( + parseComments({ + test: {} + }).test, + default_comment + ) + }) + + test('parseComments extend', () => { + let test = parseComments({ + rb: { + header: { start: '###', line: '##', end: '###' }, + body: { line: '#' } + }, + py: { + extend: 'rb' + } + }) + assert.equal(test.rb.header.start, test.py.header.start) + assert.equal(test.rb.header.line, test.py.header.line) + assert.equal(test.rb.header.end, test.py.header.end) + assert.equal(test.rb.body.start, test.py.body.start) + assert.equal(test.rb.body.line, test.py.body.line) + assert.equal(test.rb.body.end, test.py.body.end) + }) + } +}) From 6489a619dc8958a782be579b4e8916fc5e847659 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 29 Feb 2016 16:42:26 -0500 Subject: [PATCH 204/273] fixed a bug with normalString --- app/utils/to.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index 262c3dd..aa86210 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -67,7 +67,7 @@ let to = { /// /// @arg {*} /// @returns {string} That has microsoft crap removed from it - normalString: (str) => to.string(str).replace(/(?:\\[rn]+)+/g, '\n'), + normalString: (str) => to.string(str).replace(/\r\n|\n/g, '\n'), /// @name to.keys /// @description From dd4171a945d0c8fc541463ea583e9fc2d4b255da Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 10:12:06 -0500 Subject: [PATCH 205/273] added a few tools to help with the testing process --- tools/README.md | 3 +++ tools/annotation-test.js | 47 ++++++++++++++++++++++++++++++++++ tools/case-test.js | 55 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 tools/README.md create mode 100755 tools/annotation-test.js create mode 100755 tools/case-test.js diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..7e2f6ab --- /dev/null +++ b/tools/README.md @@ -0,0 +1,3 @@ +# Tools + +This folder contains files that are used to help with the development/testing process. None of these files are used in the app it's self. diff --git a/tools/annotation-test.js b/tools/annotation-test.js new file mode 100755 index 0000000..2383a90 --- /dev/null +++ b/tools/annotation-test.js @@ -0,0 +1,47 @@ +#!/usr/bin/env node +/* eslint-disable prefer-arrow-callback, func-names */ +'use strict' + +var docs = require('..').default +var path = require('path') +var utils = require('../dist/utils') +var argv = process.argv.slice(2).map(function(file_path) { + return path.join('tests', 'annotations', file_path.replace('tests/annotations', '')) +}) + +utils.glob(argv, [ 'tests/annotations/**/*.json' ]) + .then(function(files) { + return docs({ + files, + changed: false, + warning: false, + debug: false, + timestamps: false, + raw: true, + ignore: '.*' + }) + }) + .then(function(parsed) { + var promises = [] + for (var file_path in parsed) { + if (parsed.hasOwnProperty(file_path)) { + promises.push( + utils.fs.outputJson( + file_path.replace(path.extname(file_path), '.json').replace('docs/', ''), + parsed[file_path], + { spaces: 2 } + ) + ) + } + } + return Promise.all([ + Promise.resolve(Object.keys(parsed)), + Promise.all(promises) + ]) + }) + .then(function(data) { + console.log('Annotation test cases created for') + data[0].forEach(function(file_path, i) { + console.log(' ', (i + 1) + ':', file_path) + }) + }) diff --git a/tools/case-test.js b/tools/case-test.js new file mode 100755 index 0000000..cdc1d5a --- /dev/null +++ b/tools/case-test.js @@ -0,0 +1,55 @@ +#!/usr/bin/env node +/* eslint-disable prefer-arrow-callback, func-names */ +'use strict' + + +var docs = require('..').default +var path = require('path') +var utils = require('../dist/utils') +var argv = process.argv.slice(2).map(function(file_path) { + return path.join('tests', 'cases', file_path.replace('tests/cases', '')) +}) + +var file_paths + +utils.glob(argv, [ 'tests/cases/**/*.json' ]) + .then(function(files) { + file_paths = files + var result = [] + for (var i = 0; i < files.length; i++) { + result.push( + docs({ + files: files[i], + changed: false, + warning: false, + debug: false, + timestamps: false, + ignore: '.*' + }) + ) + } + + return Promise.all(result) + }) + .then(function(parsed) { + var promises = [] + for (var i = 0; i < file_paths.length; i++) { + var file = file_paths[i] + utils.fs.outputJson( + file.replace(path.extname(file), '.json'), + parsed[i], + { spaces: 2 } + ) + } + + return Promise.all([ + Promise.resolve(file_paths), + Promise.all(promises) + ]) + }) + .then(function(data) { + console.log('Case test created for:') + data[0].forEach(function(file_path, i) { + console.log(' ', (i + 1) + ':', file_path) + }) + }) From 002b0c9cedf0742435de25602e097b6b67770b84 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 10:12:56 -0500 Subject: [PATCH 206/273] Updated to use the clone package This change was because there were to many issues with the one that was implemented --- app/utils/to.js | 33 ++------------------------------- package.json | 1 + 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index aa86210..067912b 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -4,6 +4,7 @@ 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 @@ -280,37 +281,7 @@ let to = { /// /// @arg {*} - The item you want to clone /// @returns {*} - The copied result - clone(arg) { - // Basis. - if (!(arg instanceof Object)) { - return arg - } - - let clone - - // Filter out special objects. - let Constructor = arg.constructor - switch (Constructor) { - // Implement other special objects here. - /* eslint-disable indent */ - case RegExp: - clone = new Constructor(arg) - break - case Date: - clone = new Constructor(arg.getTime()) - break - default: - clone = new Constructor() - /* eslint-enable indent */ - } - - // Clone each property. - for (var prop in arg) { // eslint-disable-line - clone[prop] = to.clone(arg[prop]) - } - - return clone - }, + clone, /// @name to.merge /// @description diff --git a/package.json b/package.json index f03ee72..22dbdd4 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "async-array-methods": "^2.1.0", "babel-runtime": "^6.5.0", "change-case": "^2.3.1", + "clone": "^1.0.2", "clor": "^2.0.2", "commander": "^2.9.0", "es6-promisify": "^3.0.0", From 91c40f8610263459fbdf65804e4b1806b3d1f1fd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 11:44:29 -0500 Subject: [PATCH 207/273] Updated to be 1 based instead of 0 based This makes more sense since you will see the lines in 1 base format in code editors. So it make's it easier to track down issues, and makes documentation clearer. --- .eslintrc | 2 +- app/annotations.js | 17 ++ app/parser/get-blocks.js | 1 + app/parser/index.js | 5 +- app/parser/parse-blocks.js | 24 +- .../access/access.autofill.body.json | 20 +- .../access/access.autofill.header.json | 22 +- tests/annotations/access/access.header.json | 18 +- tests/annotations/access/access.options.json | 60 ++++- tests/annotations/alias/alias.json | 60 ++++- tests/annotations/arg/arg.aliases.json | 60 ++++- tests/annotations/arg/arg.json | 120 +++++++-- tests/annotations/author/author.alias.json | 20 +- tests/annotations/author/author.body.json | 20 +- tests/annotations/author/author.header.json | 22 +- tests/annotations/author/author.multiple.json | 82 +++++- tests/annotations/chainable/chainable.json | 140 ++++++++-- .../depricated/depricated.body.json | 80 +++++- .../depricated/depricated.header.json | 22 +- .../description/description.alias.json | 240 +++++++++++++++--- .../description/description.body.json | 60 ++++- .../description/description.header.json | 22 +- tests/annotations/markdown/mark.json | 22 +- tests/annotations/markdown/markdown.json | 22 +- tests/annotations/markdown/md.json | 22 +- tests/annotations/markdown/mdml.json | 22 +- tests/annotations/markdown/mdown.json | 22 +- tests/annotations/markdown/mdtext.json | 22 +- tests/annotations/markdown/mdtxt.json | 22 +- tests/annotations/markdown/mdwn.json | 22 +- tests/annotations/markdown/mkd.json | 22 +- tests/annotations/markdown/mkdn.json | 22 +- tests/annotations/markdown/text.json | 22 +- tests/annotations/name/name.aliases.json | 60 ++++- tests/annotations/name/name.json | 20 +- tests/annotations/note/note.alias.json | 40 ++- tests/annotations/note/note.json | 120 +++++++-- tests/annotations/page/page.alias.json | 60 ++++- .../annotations/page/page.body.autofill.json | 20 +- tests/annotations/page/page.body.json | 60 ++++- .../page/page.header.autofill.json | 22 +- tests/annotations/page/page.header.json | 20 +- tests/annotations/readonly/readonly.json | 60 ++++- .../annotations/requires/requires.alias.json | 20 +- tests/annotations/requires/requires.body.json | 140 ++++++++-- .../annotations/requires/requires.header.json | 22 +- tests/annotations/returns/returns.alias.json | 140 ++++++++-- tests/annotations/returns/returns.json | 140 ++++++++-- tests/annotations/since/since.body.json | 80 +++++- tests/annotations/since/since.header.json | 22 +- tests/annotations/throws/throws.alias.json | 80 +++++- tests/annotations/throws/throws.json | 120 +++++++-- tests/annotations/todo/todo.body.json | 120 +++++++-- tests/annotations/todo/todo.header.json | 22 +- tests/annotations/type/type.json | 140 ++++++++-- tests/annotations/version/version.json | 100 ++++++-- tests/cases/header-comment-only.json | 20 +- ...pace-between-header-and-body-comments.json | 40 ++- tests/cases/only-body-comments.json | 20 +- tools/annotation-test.js | 47 ---- tools/case-test.js | 55 ---- tools/generate-test.js | 98 +++++++ 62 files changed, 2693 insertions(+), 574 deletions(-) delete mode 100755 tools/annotation-test.js delete mode 100755 tools/case-test.js create mode 100755 tools/generate-test.js diff --git a/.eslintrc b/.eslintrc index 4e7b203..77371a3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -85,7 +85,7 @@ } ], "id-match": [ 2, "^(?:[a-z]{2,}([A-Z]{1}[a-z]+)*$)|([a-z_]+$)" ], - "indent": [ 2, 2 ], + "indent": [ 2, 2 , { "SwitchCase": 1 } ], "key-spacing": [ 2, { "beforeColon": false, "afterColon": true } ], "linebreak-style": [ 2, "unix" ], "max-depth": [ 2, 5 ], diff --git a/app/annotations.js b/app/annotations.js index 3bb524a..45247f5 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -229,6 +229,23 @@ annotations.alias = { } } + +annotations.blockinfo = { + autofill() { + let comment = this.comment + let code = this.code + let file = this.file + delete comment.contents + delete code.contents + delete file.contents + delete file.name + delete file.type + delete file.comment + + return { comment, code, file } + } +} + /// @name @arg /// @description Parameters from the documented function/mixin /// @note Description runs through markdown diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index 378b54f..0f7618b 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -59,6 +59,7 @@ export default function getBlocks({ // has been parsed. This is for file header comments if (restrict) { block.comment.end = i + block.code.end = -1 return parsed } } diff --git a/app/parser/index.js b/app/parser/index.js index c0485cb..3655cbf 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -26,8 +26,8 @@ export default async function parser({ file_path, comments, annotations, log }) name: path.basename(file_path, '.' + type), // name of the file type, // filetype of the file comment, - start: 0, // starting point of the file - end: to.array(contents).length - 1 // ending point of the file + start: 1, // starting point of the file + end: to.array(contents).length // ending point of the file } // a) The file doesn't contain any header level comments, or body level comments @@ -42,6 +42,7 @@ export default async function parser({ file_path, comments, annotations, log }) return [] } + contents = '\n' + contents let header = getBlocks({ file, diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index c80efca..dd26f71 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -7,15 +7,13 @@ import autofill from './autofill' // Used to parse an array of blocks and runs the annotations function and returns the result // @arg {array} - The block/blocks you want to have parsed // @returns {array} of parsed blocks -export default function parseBlocks(options = {}) { - let { - file, - blocks, - annotations, - comment, - log - } = options - +export default function parseBlocks({ + file, + blocks, + annotations, + comment, + log +}) { if (is.empty(blocks)) { return [] } @@ -29,7 +27,7 @@ export default function parseBlocks(options = {}) { block.comment.contents = to.normalize(block.comment.contents) block.code.contents = to.normalize(block.code.contents) - let parsed = parse_block({ + let parsed = parseBlock({ annotations, block, comment, @@ -41,8 +39,6 @@ export default function parseBlocks(options = {}) { if (!is.empty(parsed)) { parsed_blocks.push({ - __start: block.comment.start, - __end: block.comment.end, ...parsed }) } @@ -52,14 +48,14 @@ export default function parseBlocks(options = {}) { } -// @name parse_block +// @name parseBlock // @description // This parses the content passed to it seperates out each annotation // parses and figures out the annotation line, and the content after it. // Then once it has all the information it calls the annotation function(the annotation one it found) // for this file type or the default function. // @arg {object} - The blocks to parse -function parse_block(options = {}) { +function parseBlock(options = {}) { let { annotations, block, diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json index 73c35a8..9043a61 100644 --- a/tests/annotations/access/access.autofill.body.json +++ b/tests/annotations/access/access.autofill.body.json @@ -2,10 +2,24 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "name": "autofill access", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/access/access.autofill.body.js", + "start": 1, + "end": 2 + } + } } ] } diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json index 642baf5..f381782 100644 --- a/tests/annotations/access/access.autofill.header.json +++ b/tests/annotations/access/access.autofill.header.json @@ -1,10 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, "name": "autofill access", - "page": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/access/access.autofill.header.js", + "start": 1, + "end": 4 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/access/access.header.json b/tests/annotations/access/access.header.json index 5092915..c232b93 100644 --- a/tests/annotations/access/access.header.json +++ b/tests/annotations/access/access.header.json @@ -1,8 +1,22 @@ { "header": { - "__start": 0, - "__end": 2, "access": "private", + "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 + } + }, "page": "other" }, "body": [] diff --git a/tests/annotations/access/access.options.json b/tests/annotations/access/access.options.json index d55bcb6..6110468 100644 --- a/tests/annotations/access/access.options.json +++ b/tests/annotations/access/access.options.json @@ -2,19 +2,61 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/access/access.options.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 2, - "__end": 2, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/access/access.options.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 4, - "__end": 4, - "access": "private" + "access": "private", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/access/access.options.js", + "start": 1, + "end": 6 + } + } } ] } diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json index 0480474..8667099 100644 --- a/tests/annotations/alias/alias.json +++ b/tests/annotations/alias/alias.json @@ -2,30 +2,72 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "alias": [ "foo" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/alias/alias.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 2, - "__end": 2, "alias": [ "foo", "bar" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/alias/alias.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 4, - "__end": 4, "alias": [ "foo", "bar" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/alias/alias.js", + "start": 1, + "end": 6 + } + } } ] } diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json index f377942..dbe1515 100644 --- a/tests/annotations/arg/arg.aliases.json +++ b/tests/annotations/arg/arg.aliases.json @@ -2,8 +2,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "arg": [ { "types": [ @@ -14,11 +12,25 @@ "description": "

argument alias

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.aliases.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 2, - "__end": 2, "arg": [ { "types": [ @@ -29,11 +41,25 @@ "description": "

param alias

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.aliases.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 4, - "__end": 4, "arg": [ { "types": [ @@ -44,7 +70,23 @@ "description": "

parameter alias

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.aliases.js", + "start": 1, + "end": 6 + } + } } ] } diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json index 787b52b..4a73d4a 100644 --- a/tests/annotations/arg/arg.json +++ b/tests/annotations/arg/arg.json @@ -2,8 +2,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "arg": [ { "types": [], @@ -12,11 +10,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + } }, { - "__start": 2, - "__end": 2, "arg": [ { "types": [ @@ -27,11 +39,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + } }, { - "__start": 4, - "__end": 4, "arg": [ { "types": [ @@ -43,11 +69,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + } }, { - "__start": 6, - "__end": 6, "arg": [ { "types": [ @@ -58,11 +98,25 @@ "description": "

description

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + } }, { - "__start": 8, - "__end": 8, "arg": [ { "types": [ @@ -73,11 +127,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 10 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + } }, { - "__start": 10, - "__end": 15, "arg": [ { "types": [ @@ -88,7 +156,23 @@ "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" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 11, + "end": 16, + "type": "body" + }, + "code": { + "start": 17, + "end": 17 + }, + "file": { + "path": "docs/tests/annotations/arg/arg.js", + "start": 1, + "end": 17 + } + } } ] } diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json index 0fd3014..5284ac7 100644 --- a/tests/annotations/author/author.alias.json +++ b/tests/annotations/author/author.alias.json @@ -2,14 +2,28 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "author": [ "Author One", "Author Two", "Author Three" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/author/author.alias.js", + "start": 1, + "end": 2 + } + } } ] } diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json index bfba48d..8d21edf 100644 --- a/tests/annotations/author/author.body.json +++ b/tests/annotations/author/author.body.json @@ -2,12 +2,26 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "author": [ "Tyler Benton" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/author/author.body.js", + "start": 1, + "end": 2 + } + } } ] } diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json index 79b3d01..c04c07b 100644 --- a/tests/annotations/author/author.header.json +++ b/tests/annotations/author/author.header.json @@ -1,12 +1,26 @@ { "header": { - "__start": 0, - "__end": 2, "author": [ "Tyler Benton" ], - "page": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/author/author.header.js", + "start": 1, + "end": 4 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index 15cf31d..b13f296 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -1,41 +1,97 @@ { "header": { - "__start": 0, - "__end": 2, "author": [ "Author One", "Author Two" ], - "page": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + }, + "page": "other" }, "body": [ { - "__start": 4, - "__end": 5, "author": [ "Author One", "Author Two" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 7 + }, + "file": { + "path": "docs/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + } }, { - "__start": 7, - "__end": 7, "author": [ "Author One", "Author Two" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 8, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 10 + }, + "file": { + "path": "docs/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + } }, { - "__start": 10, - "__end": 12, "author": [ "Author One", "Author Two" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 11, + "end": 13, + "type": "body" + }, + "code": { + "start": 14, + "end": 14 + }, + "file": { + "path": "docs/tests/annotations/author/author.multiple.js", + "start": 1, + "end": 14 + } + } } ] } diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json index 97443e6..55e602b 100644 --- a/tests/annotations/chainable/chainable.json +++ b/tests/annotations/chainable/chainable.json @@ -2,57 +2,155 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "chainable": true, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 2, - "__end": 2, "chainable": true, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 4, - "__end": 4, "chainable": false, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 6, - "__end": 6, "chainable": [ "Object.prototype" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 8, - "__end": 8, "chainable": [ "One", "Two" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 10 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 10, - "__end": 12, "chainable": [ "One", "Two" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 11, + "end": 13, + "type": "body" + }, + "code": { + "start": 14, + "end": 14 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 14, - "__end": 16, "chainable": [ "One", "Two" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 15, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 18 + }, + "file": { + "path": "docs/tests/annotations/chainable/chainable.js", + "start": 1, + "end": 18 + } + } } ] } diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json index 8ede92a..6be3310 100644 --- a/tests/annotations/depricated/depricated.body.json +++ b/tests/annotations/depricated/depricated.body.json @@ -2,40 +2,96 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "deprecated": { "version": "0", "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + } }, { - "__start": 2, - "__end": 2, "deprecated": { "version": "0.0.1", "description": "

Lorem

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

Lorem

\n" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + } }, { - "__start": 6, - "__end": 9, "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" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 11 + }, + "file": { + "path": "docs/tests/annotations/depricated/depricated.body.js", + "start": 1, + "end": 11 + } + } } ] } diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json index f31496c..c16d9c8 100644 --- a/tests/annotations/depricated/depricated.header.json +++ b/tests/annotations/depricated/depricated.header.json @@ -1,13 +1,27 @@ { "header": { - "__start": 0, - "__end": 5, "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": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/depricated/depricated.header.js", + "start": 1, + "end": 7 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json index 94434d5..a67b42b 100644 --- a/tests/annotations/description/description.alias.json +++ b/tests/annotations/description/description.alias.json @@ -2,88 +2,256 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 1, "name": "single-line `desc`", "description": "

Lorem ipsum

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

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

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

Lorem ipsum

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

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

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

Lorem ipsum

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

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

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

Lorem ipsum

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

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

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

Lorem ipsum

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

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

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

Lorem ipsum

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

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

\n", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 54, + "end": 57, + "type": "body" + }, + "code": { + "start": 58, + "end": 58 + }, + "file": { + "path": "docs/tests/annotations/description/description.alias.js", + "start": 1, + "end": 58 + } + } } ] } diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json index 2c085bd..46af6e7 100644 --- a/tests/annotations/description/description.body.json +++ b/tests/annotations/description/description.body.json @@ -2,22 +2,64 @@ "header": {}, "body": [ { - "__start": 1, - "__end": 1, "description": "

Lorem ipsum dolor sit amet

\n", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 2, + "end": 2, + "type": "body" + }, + "code": { + "start": 3, + "end": 3 + }, + "file": { + "path": "docs/tests/annotations/description/description.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 3, - "__end": 7, "description": "

Line one\nOther\nlines\nbelow\nit

\n", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 4, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 9 + }, + "file": { + "path": "docs/tests/annotations/description/description.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 9, - "__end": 13, "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", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 10, + "end": 14, + "type": "body" + }, + "code": { + "start": 15, + "end": 15 + }, + "file": { + "path": "docs/tests/annotations/description/description.body.js", + "start": 1, + "end": 15 + } + } } ] } diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json index 3b66075..ff9071d 100644 --- a/tests/annotations/description/description.header.json +++ b/tests/annotations/description/description.header.json @@ -1,10 +1,24 @@ { "header": { - "__start": 0, - "__end": 6, "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": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/description/description.header.js", + "start": 1, + "end": 8 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index 0feed55..551be93 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mark.mark", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 0feed55..000d684 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/markdown.markdown", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index 0feed55..3d26674 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/md.md", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index 0feed55..89a70e5 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mdml.mdml", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index 0feed55..214fe1e 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mdown.mdown", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index 0feed55..a2e044e 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mdtext.mdtext", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index 0feed55..aad83e1 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index 0feed55..78a83a0 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mdwn.mdwn", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index 0feed55..2d1fe82 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index 0feed55..e8dfd56 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/mkdn.mkdn", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index 0feed55..fa52ac3 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -1,8 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n" + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/markdown/text.text", + "start": 1, + "end": 13 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json index 4af84f1..1a71c97 100644 --- a/tests/annotations/name/name.aliases.json +++ b/tests/annotations/name/name.aliases.json @@ -2,22 +2,64 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "name": "Title", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/name/name.aliases.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 2, - "__end": 2, "name": "Heading", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/name/name.aliases.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 4, - "__end": 4, "name": "Header", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/name/name.aliases.js", + "start": 1, + "end": 6 + } + } } ] } diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json index 0067923..d6737cb 100644 --- a/tests/annotations/name/name.json +++ b/tests/annotations/name/name.json @@ -2,10 +2,24 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "name": "Foo", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/name/name.js", + "start": 1, + "end": 2 + } + } } ] } diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json index d778afa..38e77da 100644 --- a/tests/annotations/note/note.alias.json +++ b/tests/annotations/note/note.alias.json @@ -2,26 +2,54 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 3, "note": [ { "importance": "0", "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "body" + }, + "code": { + "start": 5, + "end": 5 + }, + "file": { + "path": "docs/tests/annotations/note/note.alias.js", + "start": 1, + "end": 10 + } + } }, { - "__start": 5, - "__end": 8, "note": [ { "importance": "10", "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 10 + }, + "file": { + "path": "docs/tests/annotations/note/note.alias.js", + "start": 1, + "end": 10 + } + } } ] } diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json index 93d5cb3..f1da9bb 100644 --- a/tests/annotations/note/note.json +++ b/tests/annotations/note/note.json @@ -2,70 +2,154 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "note": [ { "importance": "0", "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + } }, { - "__start": 2, - "__end": 2, "note": [ { "importance": "10", "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + } }, { - "__start": 4, - "__end": 4, "note": [ { "importance": "0", "description": "

Lorem ipsum dolor sit amet

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + } }, { - "__start": 6, - "__end": 10, "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" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 12 + }, + "file": { + "path": "docs/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + } }, { - "__start": 12, - "__end": 12, "note": [ { "importance": "5", "description": "

Lorem ipsum dolor sit amet

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 13, + "end": 13, + "type": "body" + }, + "code": { + "start": 14, + "end": 14 + }, + "file": { + "path": "docs/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + } }, { - "__start": 14, - "__end": 18, "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" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 15, + "end": 19, + "type": "body" + }, + "code": { + "start": 20, + "end": 20 + }, + "file": { + "path": "docs/tests/annotations/note/note.js", + "start": 1, + "end": 20 + } + } } ] } diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json index 55f32ae..a037323 100644 --- a/tests/annotations/page/page.alias.json +++ b/tests/annotations/page/page.alias.json @@ -2,29 +2,71 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "page": [ "level 1" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/page/page.alias.js", + "start": 1, + "end": 7 + } + } }, { - "__start": 2, - "__end": 2, "page": [ "level 1/level 2" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/page/page.alias.js", + "start": 1, + "end": 7 + } + } }, { - "__start": 4, - "__end": 5, "page": [ "page 1/level 2", "page 2/level 2" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 7 + }, + "file": { + "path": "docs/tests/annotations/page/page.alias.js", + "start": 1, + "end": 7 + } + } } ] } diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json index 2ca1162..b5c4e75 100644 --- a/tests/annotations/page/page.body.autofill.json +++ b/tests/annotations/page/page.body.autofill.json @@ -2,10 +2,24 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "description": "

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

\n", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/page/page.body.autofill.js", + "start": 1, + "end": 2 + } + } } ] } diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json index 55f32ae..95783aa 100644 --- a/tests/annotations/page/page.body.json +++ b/tests/annotations/page/page.body.json @@ -2,29 +2,71 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "page": [ "level 1" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/page/page.body.js", + "start": 1, + "end": 7 + } + } }, { - "__start": 2, - "__end": 2, "page": [ "level 1/level 2" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/page/page.body.js", + "start": 1, + "end": 7 + } + } }, { - "__start": 4, - "__end": 5, "page": [ "page 1/level 2", "page 2/level 2" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 7 + }, + "file": { + "path": "docs/tests/annotations/page/page.body.js", + "start": 1, + "end": 7 + } + } } ] } diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json index 2ac8287..3403902 100644 --- a/tests/annotations/page/page.header.autofill.json +++ b/tests/annotations/page/page.header.autofill.json @@ -1,10 +1,24 @@ { "header": { - "__start": 0, - "__end": 2, "name": "page autofill test", - "page": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/page/page.header.autofill.js", + "start": 1, + "end": 4 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/page/page.header.json b/tests/annotations/page/page.header.json index 731d0a0..35bc7ce 100644 --- a/tests/annotations/page/page.header.json +++ b/tests/annotations/page/page.header.json @@ -1,11 +1,25 @@ { "header": { - "__start": 0, - "__end": 2, "page": [ "level 1/level 2" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/page/page.header.js", + "start": 1, + "end": 4 + } + } }, "body": [] } diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json index dc7fd93..b82a752 100644 --- a/tests/annotations/readonly/readonly.json +++ b/tests/annotations/readonly/readonly.json @@ -2,22 +2,64 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "readonly": true, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/readonly/readonly.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 2, - "__end": 2, "readonly": true, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/readonly/readonly.js", + "start": 1, + "end": 6 + } + } }, { - "__start": 4, - "__end": 4, "readonly": false, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/readonly/readonly.js", + "start": 1, + "end": 6 + } + } } ] } diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json index e3473c5..9ac627c 100644 --- a/tests/annotations/requires/requires.alias.json +++ b/tests/annotations/requires/requires.alias.json @@ -2,8 +2,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "requires": [ { "types": [], @@ -11,7 +9,23 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.alias.js", + "start": 1, + "end": 2 + } + } } ] } diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json index 5330ea1..67dffe4 100644 --- a/tests/annotations/requires/requires.body.json +++ b/tests/annotations/requires/requires.body.json @@ -2,8 +2,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "requires": [ { "types": [], @@ -11,11 +9,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 2, - "__end": 2, "requires": [ { "types": [ @@ -25,11 +37,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 4, - "__end": 4, "requires": [ { "types": [ @@ -42,11 +68,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 6, - "__end": 6, "requires": [ { "types": [], @@ -54,11 +94,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 8, - "__end": 8, "requires": [ { "types": [], @@ -66,11 +120,25 @@ "description": "

the path function from node

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 10 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 10, - "__end": 10, "requires": [ { "types": [ @@ -80,11 +148,25 @@ "description": "

the path function from node

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 11, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 12 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 12, - "__end": 13, "requires": [ { "types": [], @@ -97,7 +179,23 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 13, + "end": 14, + "type": "body" + }, + "code": { + "start": 15, + "end": 15 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.body.js", + "start": 1, + "end": 15 + } + } } ] } diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json index c8cb77a..deda215 100644 --- a/tests/annotations/requires/requires.header.json +++ b/tests/annotations/requires/requires.header.json @@ -1,7 +1,5 @@ { "header": { - "__start": 0, - "__end": 2, "requires": [ { "types": [ @@ -11,8 +9,24 @@ "description": "

the path function from node

\n" } ], - "page": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/requires/requires.header.js", + "start": 1, + "end": 4 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json index a8875d4..ac9d2c8 100644 --- a/tests/annotations/returns/returns.alias.json +++ b/tests/annotations/returns/returns.alias.json @@ -2,30 +2,56 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "returns": { "types": [ "undefined" ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 2, - "__end": 2, "returns": { "types": [ "undefined" ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 4, - "__end": 4, "returns": { "types": [ "array", @@ -34,11 +60,25 @@ ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 6, - "__end": 6, "returns": { "types": [ "array", @@ -47,40 +87,98 @@ ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 8, - "__end": 8, "returns": { "types": [ "object" ], "description": "

Lorem ipsum dolor sit amet

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

Lorem ipsum dolor sit amet

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

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 13, + "end": 22, + "type": "body" + }, + "code": { + "start": 23, + "end": 23 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.alias.js", + "start": 1, + "end": 23 + } + } } ] } diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json index a8875d4..fe64497 100644 --- a/tests/annotations/returns/returns.json +++ b/tests/annotations/returns/returns.json @@ -2,30 +2,56 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "returns": { "types": [ "undefined" ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 2, - "__end": 2, "returns": { "types": [ "undefined" ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 4, - "__end": 4, "returns": { "types": [ "array", @@ -34,11 +60,25 @@ ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 6, - "__end": 6, "returns": { "types": [ "array", @@ -47,40 +87,98 @@ ], "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + } }, { - "__start": 8, - "__end": 8, "returns": { "types": [ "object" ], "description": "

Lorem ipsum dolor sit amet

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

Lorem ipsum dolor sit amet

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

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 13, + "end": 22, + "type": "body" + }, + "code": { + "start": 23, + "end": 23 + }, + "file": { + "path": "docs/tests/annotations/returns/returns.js", + "start": 1, + "end": 23 + } + } } ] } diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json index be91e57..2bbc5fc 100644 --- a/tests/annotations/since/since.body.json +++ b/tests/annotations/since/since.body.json @@ -2,40 +2,96 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "since": { "version": "undefined", "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + } }, { - "__start": 2, - "__end": 2, "since": { "version": "0.0.1", "description": "

Lorem

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

Lorem

\n" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + } }, { - "__start": 6, - "__end": 9, "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" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 11 + }, + "file": { + "path": "docs/tests/annotations/since/since.body.js", + "start": 1, + "end": 11 + } + } } ] } diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json index be00333..e2fbf4e 100644 --- a/tests/annotations/since/since.header.json +++ b/tests/annotations/since/since.header.json @@ -1,13 +1,27 @@ { "header": { - "__start": 0, - "__end": 5, "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": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/since/since.header.js", + "start": 1, + "end": 7 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json index b85659e..b6b7c66 100644 --- a/tests/annotations/throws/throws.alias.json +++ b/tests/annotations/throws/throws.alias.json @@ -2,8 +2,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "throws": [ { "types": [ @@ -12,11 +10,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + } }, { - "__start": 2, - "__end": 2, "throws": [ { "types": [ @@ -25,11 +37,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + } }, { - "__start": 4, - "__end": 4, "throws": [ { "types": [ @@ -38,11 +64,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + } }, { - "__start": 6, - "__end": 6, "throws": [ { "types": [ @@ -51,7 +91,23 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.alias.js", + "start": 1, + "end": 8 + } + } } ] } diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json index 33d4482..5f305dd 100644 --- a/tests/annotations/throws/throws.json +++ b/tests/annotations/throws/throws.json @@ -2,19 +2,31 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "throws": [ { "types": [], "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + } }, { - "__start": 2, - "__end": 2, "throws": [ { "types": [ @@ -23,11 +35,25 @@ "description": "" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + } }, { - "__start": 4, - "__end": 4, "throws": [ { "types": [ @@ -36,11 +62,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + } }, { - "__start": 6, - "__end": 6, "throws": [ { "types": [ @@ -49,11 +89,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + } }, { - "__start": 8, - "__end": 11, "throws": [ { "types": [ @@ -62,11 +116,25 @@ "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" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 9, + "end": 12, + "type": "body" + }, + "code": { + "start": 13, + "end": 13 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + } }, { - "__start": 13, - "__end": 14, "throws": [ { "types": [ @@ -81,7 +149,23 @@ "description": "

when something goes wrong

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 14, + "end": 15, + "type": "body" + }, + "code": { + "start": 16, + "end": 16 + }, + "file": { + "path": "docs/tests/annotations/throws/throws.js", + "start": 1, + "end": 16 + } + } } ] } diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json index 55660ed..7c32a6f 100644 --- a/tests/annotations/todo/todo.body.json +++ b/tests/annotations/todo/todo.body.json @@ -2,8 +2,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "todo": [ { "importance": "0", @@ -11,11 +9,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 2, - "__end": 2, "todo": [ { "importance": "5", @@ -23,11 +35,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 4, - "__end": 4, "todo": [ { "importance": "5", @@ -35,11 +61,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 6 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 6, - "__end": 6, "todo": [ { "importance": "10", @@ -49,11 +89,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 8, - "__end": 8, "todo": [ { "importance": "10", @@ -64,11 +118,25 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 9, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 10 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + } }, { - "__start": 10, - "__end": 13, "todo": [ { "importance": "8", @@ -79,7 +147,23 @@ "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" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 11, + "end": 14, + "type": "body" + }, + "code": { + "start": 15, + "end": 15 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.body.js", + "start": 1, + "end": 15 + } + } } ] } diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json index 54c578d..b61b776 100644 --- a/tests/annotations/todo/todo.header.json +++ b/tests/annotations/todo/todo.header.json @@ -1,7 +1,5 @@ { "header": { - "__start": 0, - "__end": 5, "todo": [ { "importance": "8", @@ -12,8 +10,24 @@ "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": "other", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/todo/todo.header.js", + "start": 1, + "end": 7 + } + }, + "page": "other" }, "body": [] } diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json index 7e7f235..1663a2d 100644 --- a/tests/annotations/type/type.json +++ b/tests/annotations/type/type.json @@ -2,67 +2,165 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "type": { "type": "undefined", "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 2, - "__end": 2, "type": { "type": "object", "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 4, - "__end": 4, "type": { "type": "undefined", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

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

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

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

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

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

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 11, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 12 + }, + "file": { + "path": "docs/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + } }, { - "__start": 12, - "__end": 16, "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" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 13, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 18 + }, + "file": { + "path": "docs/tests/annotations/type/type.js", + "start": 1, + "end": 18 + } + } } ] } diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json index 5d9f453..e10459d 100644 --- a/tests/annotations/version/version.json +++ b/tests/annotations/version/version.json @@ -2,49 +2,119 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 0, "version": { "version": "undefined", "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": 2, + "end": 2 + }, + "file": { + "path": "docs/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + } }, { - "__start": 2, - "__end": 2, "version": { "version": "0.0.1", "description": "" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": 4, + "end": 4 + }, + "file": { + "path": "docs/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + } }, { - "__start": 4, - "__end": 4, "version": { "version": "^0.0.1", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

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

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + } }, { - "__start": 8, - "__end": 11, "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" }, - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 9, + "end": 12, + "type": "body" + }, + "code": { + "start": 13, + "end": 13 + }, + "file": { + "path": "docs/tests/annotations/version/version.js", + "start": 1, + "end": 13 + } + } } ] } diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json index 4900a28..919a83d 100644 --- a/tests/cases/header-comment-only.json +++ b/tests/cases/header-comment-only.json @@ -23,14 +23,28 @@ "header-comment-only": { "page": { "header": { - "__start": 0, - "__end": 6, "name": "Header", "author": [ "Tyler Benton" ], "description": "

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

\n", - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/header-comment-only.scss", + "start": 1, + "end": 8 + } + } }, "body": [] } diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index e6defd6..bd50b33 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -28,17 +28,29 @@ "no-space-between-header-and-body-comment": { "page": { "header": { - "__start": 0, - "__end": 3, "author": [ "Tyler Benton" ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", + "start": 1, + "end": 28 + } + } }, "body": [ { - "__start": 4, - "__end": 16, "name": "moz-only", "description": "

This allows you to write specific styles for mozilla firefox only

\n", "markup": [ @@ -51,7 +63,23 @@ "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}" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 5, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 28 + }, + "file": { + "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", + "start": 1, + "end": 28 + } + } } ] } diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index d445900..fc35bb8 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -25,8 +25,6 @@ "header": {}, "body": [ { - "__start": 0, - "__end": 31, "author": [ "Tyler Benton" ], @@ -143,7 +141,23 @@ "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn @state">Button (a.button)</a>\n <button class="c-btn @state">Button (button)</button>\n <input class="c-btn @state" type="button" value="Button (input.button)">\n</div>" } ], - "access": "public" + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 32, + "type": "body" + }, + "code": { + "start": 33, + "end": 33 + }, + "file": { + "path": "docs/tests/cases/only-body-comments.scss", + "start": 1, + "end": 54 + } + } } ] } diff --git a/tools/annotation-test.js b/tools/annotation-test.js deleted file mode 100755 index 2383a90..0000000 --- a/tools/annotation-test.js +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable prefer-arrow-callback, func-names */ -'use strict' - -var docs = require('..').default -var path = require('path') -var utils = require('../dist/utils') -var argv = process.argv.slice(2).map(function(file_path) { - return path.join('tests', 'annotations', file_path.replace('tests/annotations', '')) -}) - -utils.glob(argv, [ 'tests/annotations/**/*.json' ]) - .then(function(files) { - return docs({ - files, - changed: false, - warning: false, - debug: false, - timestamps: false, - raw: true, - ignore: '.*' - }) - }) - .then(function(parsed) { - var promises = [] - for (var file_path in parsed) { - if (parsed.hasOwnProperty(file_path)) { - promises.push( - utils.fs.outputJson( - file_path.replace(path.extname(file_path), '.json').replace('docs/', ''), - parsed[file_path], - { spaces: 2 } - ) - ) - } - } - return Promise.all([ - Promise.resolve(Object.keys(parsed)), - Promise.all(promises) - ]) - }) - .then(function(data) { - console.log('Annotation test cases created for') - data[0].forEach(function(file_path, i) { - console.log(' ', (i + 1) + ':', file_path) - }) - }) diff --git a/tools/case-test.js b/tools/case-test.js deleted file mode 100755 index cdc1d5a..0000000 --- a/tools/case-test.js +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable prefer-arrow-callback, func-names */ -'use strict' - - -var docs = require('..').default -var path = require('path') -var utils = require('../dist/utils') -var argv = process.argv.slice(2).map(function(file_path) { - return path.join('tests', 'cases', file_path.replace('tests/cases', '')) -}) - -var file_paths - -utils.glob(argv, [ 'tests/cases/**/*.json' ]) - .then(function(files) { - file_paths = files - var result = [] - for (var i = 0; i < files.length; i++) { - result.push( - docs({ - files: files[i], - changed: false, - warning: false, - debug: false, - timestamps: false, - ignore: '.*' - }) - ) - } - - return Promise.all(result) - }) - .then(function(parsed) { - var promises = [] - for (var i = 0; i < file_paths.length; i++) { - var file = file_paths[i] - utils.fs.outputJson( - file.replace(path.extname(file), '.json'), - parsed[i], - { spaces: 2 } - ) - } - - return Promise.all([ - Promise.resolve(file_paths), - Promise.all(promises) - ]) - }) - .then(function(data) { - console.log('Case test created for:') - data[0].forEach(function(file_path, i) { - console.log(' ', (i + 1) + ':', file_path) - }) - }) diff --git a/tools/generate-test.js b/tools/generate-test.js new file mode 100755 index 0000000..22525ec --- /dev/null +++ b/tools/generate-test.js @@ -0,0 +1,98 @@ +#!/usr/bin/env node +/* eslint-disable prefer-arrow-callback, func-names, no-shadow, babel/object-shorthand */ +'use strict' + + +var docs = require('..').default +var path = require('path') +var clor = require('clor') +var utils = require('../dist/utils') +var argv = process.argv.slice(2) + +utils.glob(argv, [ 'tests/**/*.json' ]) + .then(function(files) { + var promises = [] + for (var i = 0; i < files.length; i++) { + promises.push(sortTest(files[i])) + } + + return Promise.all(promises) + }) + .then(function(parsed) { + for (var i = 0; i < parsed.length; i++) { + console.log(' ', (i + 1) + ':', parsed[i]) + } + }) + + + +function sortTest(file) { + var type = file.match(/(?:tests\/)([a-z\-]*)/)[1] + + switch (type) { + case 'cases': + case 'file-types': + return caseTest(file) + case 'annotations': + return annotationTest(file) + default: + return Promise.resolve(clor.yellow(file + " isn't a test")) + } +} + + + +function annotationTest(file) { + return new Promise(function(resolve) { + docs({ + files: file, + changed: false, + warning: false, + debug: false, + timestamps: false, + raw: true, + ignore: '.*' + }) + .then(function(parsed) { + return utils.fs.outputJson( + file.replace(path.extname(file), '.json').replace('docs/', ''), + parsed[path.join('docs', file)], + { spaces: 2 } + ) + }) + .then(function() { + resolve(clor.green(file) + '') + }) + .catch(function() { + resolve(clor.red(file) + '') + }) + }) +} + + + +function caseTest(file) { + return new Promise(function(resolve) { + docs({ + files: file, + changed: false, + warning: false, + debug: false, + timestamps: false, + ignore: '.*' + }) + .then(function(parsed) { + return utils.fs.outputJson( + file.replace(path.extname(file), '.json'), + parsed, + { spaces: 2 } + ) + }) + .then(function() { + resolve(clor.green(file) + '') + }) + .catch(function() { + resolve(clor.red(file) + '') + }) + }) +} From 9ca50c272ba7cab674185005dfcf3c0f66431657 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 12:51:25 -0500 Subject: [PATCH 208/273] Added the blank line functionality When there're nth blank lines the parser stops adding lines to the current block and a new block doesn't start until the next comment is found. --- app/annotations.js | 6 ++++++ app/parser/get-blocks.js | 11 ++++++++++- app/parser/index.js | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 45247f5..b33fb6e 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -495,6 +495,12 @@ annotations.markup = { } } +annotations['raw-code'] = { + parse() { + return this.code.contents + } +} + /// @name @name /// @alias @title, @heading, @header /// @description Name of the documented item diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index 0f7618b..46ba0e9 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -11,6 +11,7 @@ export default function getBlocks({ contents, comment, restrict = true, + blank_lines, start_at = 0 }) { start_at = to.number(start_at) @@ -25,6 +26,7 @@ export default function getBlocks({ let lines = to.array(contents) let parsed = [] + let current_blank_lines = 0 let block let in_comment = false // used to determin that you are in a comment let in_code = false // used to determin if you are in the code after the comment block @@ -43,6 +45,7 @@ export default function getBlocks({ // a) The line isn't empty so parse it. if (!is.empty(line)) { + current_blank_lines = 0 // a) is the start and end style or there was an instance of a comment line if (style === 'multi' && (index.start !== false || in_comment) || index.line !== false) { // a) is the start of a new block @@ -130,9 +133,15 @@ export default function getBlocks({ parsed.push(block) } } - } else if (i === l - 1 && is.truthy(block)) { // the last line in the file was an empty line. + } else if ( + !is.undefined(block) && ( + ++current_blank_lines === blank_lines || // there were 4 consecutive blank lines so the code is skipped + i === l - 1 && is.truthy(block) // the last line in the file was an empty line. + ) + ) { block[block.comment.end > -1 ? 'code' : 'comment'].end = i parsed.push(block) + block = undefined } } // end loop diff --git a/app/parser/index.js b/app/parser/index.js index 3655cbf..d180795 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -4,7 +4,7 @@ import getBlocks from './get-blocks' import parseBlocks from './parse-blocks' import replaceAliases from './replace-aliases' -export default async function parser({ file_path, comments, annotations, log }) { +export default async function parser({ file_path, comments, annotations, blank_lines, log }) { // the filetype of the current file let type = path.extname(file_path).replace('.', '') @@ -47,12 +47,14 @@ export default async function parser({ file_path, comments, annotations, log }) let header = getBlocks({ file, contents, + blank_lines, comment: comment.header }) let body = getBlocks({ file, contents, + blank_lines, comment: comment.body, restrict: false, start_at: !is.empty(header) ? header[0].comment.end + 1 : 0 From e64802f18e44979cbc45de4bc121f8130f00a4cd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 12:51:53 -0500 Subject: [PATCH 209/273] added more test cases --- .../4-blank-lines-between-code-blocks.json | 39 ++++++ .../4-blank-lines-between-code-blocks.scss | 32 +++++ tests/cases/header-comment-only.json | 69 +++++------ tests/cases/header-comment-only.scss | 2 +- ...pace-between-header-and-body-comments.json | 115 ++++++++---------- ...pace-between-header-and-body-comments.scss | 4 +- tests/cases/only-comments.json | 106 ++++++++++++++++ .../edge-cases => cases}/only-comments.scss | 18 ++- tests/cases/preserves-blank-lines.json | 54 ++++++++ .../preserves-blank-lines.scss | 3 +- tests/cases/single-body-comment-no-code.json | 45 +++++++ .../single-body-comment-no-code.scss | 8 +- tests/cases/single-body-comment.json | 60 +++++++++ tests/cases/single-body-comment.scss | 26 ++++ .../cases/space-between-comment-and-code.json | 63 ++++++++++ .../cases/space-between-comment-and-code.scss | 27 ++++ tests/cases/starts-and-ends-with-spaces.json | 60 +++++++++ .../starts-and-ends-with-spaces.scss | 12 +- .../4-blank-lines-between-code-blocks.scss | 47 ------- .../edge-cases/single-body-comment.scss | 24 ---- .../space-between-comment-and-code.scss | 57 --------- .../edge-cases/starts-with-empty-lines.scss | 32 ----- 22 files changed, 613 insertions(+), 290 deletions(-) create mode 100644 tests/cases/4-blank-lines-between-code-blocks.json create mode 100644 tests/cases/4-blank-lines-between-code-blocks.scss create mode 100644 tests/cases/only-comments.json rename tests/{file-types/edge-cases => cases}/only-comments.scss (60%) create mode 100644 tests/cases/preserves-blank-lines.json rename tests/{file-types/edge-cases => cases}/preserves-blank-lines.scss (84%) create mode 100644 tests/cases/single-body-comment-no-code.json rename tests/{file-types/edge-cases => cases}/single-body-comment-no-code.scss (70%) create mode 100644 tests/cases/single-body-comment.json create mode 100644 tests/cases/single-body-comment.scss create mode 100644 tests/cases/space-between-comment-and-code.json create mode 100644 tests/cases/space-between-comment-and-code.scss create mode 100644 tests/cases/starts-and-ends-with-spaces.json rename tests/{file-types/edge-cases => cases}/starts-and-ends-with-spaces.scss (83%) delete mode 100644 tests/file-types/edge-cases/4-blank-lines-between-code-blocks.scss delete mode 100644 tests/file-types/edge-cases/single-body-comment.scss delete mode 100644 tests/file-types/edge-cases/space-between-comment-and-code.scss delete mode 100644 tests/file-types/edge-cases/starts-with-empty-lines.scss 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..2505335 --- /dev/null +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -0,0 +1,39 @@ +{ + "nav": [ + { + "title": "4 Blank Lines Between Code Blocks", + "href": "/4-blank-lines-between-code-blocks", + "body": [], + "subpages": [] + } + ], + "pages": { + "4-blank-lines-between-code-blocks": { + "page": { + "header": {}, + "body": [ + { + "raw-code": "@mixin moz-only() {\n $selector: &;\n @at-root {\n @-moz-document url-prefix() {\n #{$selector} {\n @content;\n }\n }\n }\n}", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 2, + "type": "body" + }, + "code": { + "start": 3, + "end": 16 + }, + "file": { + "path": "docs/tests/cases/4-blank-lines-between-code-blocks.scss", + "start": 1, + "end": 33 + } + } + } + ] + } + } + } +} 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..1667b17 --- /dev/null +++ b/tests/cases/4-blank-lines-between-code-blocks.scss @@ -0,0 +1,32 @@ +/// @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/header-comment-only.json b/tests/cases/header-comment-only.json index 919a83d..c0018d3 100644 --- a/tests/cases/header-comment-only.json +++ b/tests/cases/header-comment-only.json @@ -1,53 +1,40 @@ { "nav": [ { - "title": "Edge Cases", - "href": "/edge-cases", + "title": "Header Comment Only", + "href": "/header-comment-only", "body": [], - "subpages": [ - { - "title": "Header", - "href": "/edge-cases/header-comment-only", - "body": [], - "subpages": [] - } - ] + "subpages": [] } ], "pages": { - "edge-cases": { + "header-comment-only": { "page": { - "header": {}, - "body": [] - }, - "header-comment-only": { - "page": { - "header": { - "name": "Header", - "author": [ - "Tyler Benton" - ], - "description": "

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

\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 7, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/cases/header-comment-only.scss", - "start": 1, - "end": 8 - } + "header": { + "name": "Header", + "author": [ + "Tyler Benton" + ], + "description": "

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

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/header-comment-only.scss", + "start": 1, + "end": 8 } - }, - "body": [] - } + } + }, + "body": [] } } } diff --git a/tests/cases/header-comment-only.scss b/tests/cases/header-comment-only.scss index a6a389e..e564273 100644 --- a/tests/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. //// diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index bd50b33..6c592c5 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -1,46 +1,68 @@ { "nav": [ { - "title": "Edge Cases", - "href": "/edge-cases", - "body": [], - "subpages": [ + "title": "No Space Between Header And Body Comment", + "href": "/no-space-between-header-and-body-comment", + "body": [ { - "title": "No Space Between Header And Body Comment", - "href": "/edge-cases/no-space-between-header-and-body-comment", - "body": [ - { - "title": "moz-only", - "href": "/edge-cases/no-space-between-header-and-body-comment#moz-only" - } - ], - "subpages": [] + "title": "moz-only", + "href": "/no-space-between-header-and-body-comment#moz-only" } - ] + ], + "subpages": [] } ], "pages": { - "edge-cases": { + "no-space-between-header-and-body-comment": { "page": { - "header": {}, - "body": [] - }, - "no-space-between-header-and-body-comment": { - "page": { - "header": { - "author": [ - "Tyler Benton" + "header": { + "author": [ + "Tyler Benton" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", + "start": 1, + "end": 28 + } + } + }, + "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}" + } ], "access": "public", "blockinfo": { "comment": { - "start": 1, - "end": 4, - "type": "header" + "start": 5, + "end": 17, + "type": "body" }, "code": { - "start": -1, - "end": -1 + "start": 18, + "end": 28 }, "file": { "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", @@ -48,41 +70,8 @@ "end": 28 } } - }, - "body": [ - { - "name": "moz-only", - "description": "

This allows you to write specific styles for mozilla firefox only

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

(example="false") 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}" - } - ], - "access": "public", - "blockinfo": { - "comment": { - "start": 5, - "end": 17, - "type": "body" - }, - "code": { - "start": 18, - "end": 28 - }, - "file": { - "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", - "start": 1, - "end": 28 - } - } - } - ] - } + } + ] } } } diff --git a/tests/cases/no-space-between-header-and-body-comments.scss b/tests/cases/no-space-between-header-and-body-comments.scss index 3c48d0a..c3be0c2 100644 --- a/tests/cases/no-space-between-header-and-body-comments.scss +++ b/tests/cases/no-space-between-header-and-body-comments.scss @@ -1,10 +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 /// @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; diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json new file mode 100644 index 0000000..ef3a4b0 --- /dev/null +++ b/tests/cases/only-comments.json @@ -0,0 +1,106 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/only-comments.scss", + "start": 1, + "end": 27 + } + } + }, + "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}" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 19, + "type": "body" + }, + "code": { + "start": 20, + "end": 20 + }, + "file": { + "path": "docs/tests/cases/only-comments.scss", + "start": 1, + "end": 27 + } + } + }, + { + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 21, + "end": 26, + "type": "body" + }, + "code": { + "start": 27, + "end": 27 + }, + "file": { + "path": "docs/tests/cases/only-comments.scss", + "start": 1, + "end": 27 + } + } + } + ] + } + } + } +} diff --git a/tests/file-types/edge-cases/only-comments.scss b/tests/cases/only-comments.scss similarity index 60% rename from tests/file-types/edge-cases/only-comments.scss rename to tests/cases/only-comments.scss index e73fc62..7d37f0d 100644 --- a/tests/file-types/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..2236212 --- /dev/null +++ b/tests/cases/preserves-blank-lines.json @@ -0,0 +1,54 @@ +{ + "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)">" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 12, + "type": "body" + }, + "code": { + "start": 13, + "end": 13 + }, + "file": { + "path": "docs/tests/cases/preserves-blank-lines.scss", + "start": 1, + "end": 13 + } + } + } + ] + } + } + } +} diff --git a/tests/file-types/edge-cases/preserves-blank-lines.scss b/tests/cases/preserves-blank-lines.scss similarity index 84% rename from tests/file-types/edge-cases/preserves-blank-lines.scss rename to tests/cases/preserves-blank-lines.scss index 40f999b..2aaf5b3 100644 --- a/tests/file-types/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..3fccf7d --- /dev/null +++ b/tests/cases/single-body-comment-no-code.json @@ -0,0 +1,45 @@ +{ + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 8 + }, + "file": { + "path": "docs/tests/cases/single-body-comment-no-code.scss", + "start": 1, + "end": 8 + } + } + } + ] + } + } + } +} diff --git a/tests/file-types/edge-cases/single-body-comment-no-code.scss b/tests/cases/single-body-comment-no-code.scss similarity index 70% rename from tests/file-types/edge-cases/single-body-comment-no-code.scss rename to tests/cases/single-body-comment-no-code.scss index 2d2705f..e2f6635 100644 --- a/tests/file-types/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..4311da1 --- /dev/null +++ b/tests/cases/single-body-comment.json @@ -0,0 +1,60 @@ +{ + "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}" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 15, + "type": "body" + }, + "code": { + "start": 16, + "end": 27 + }, + "file": { + "path": "docs/tests/cases/single-body-comment.scss", + "start": 1, + "end": 27 + } + } + } + ] + } + } + } +} 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..bac0fe1 --- /dev/null +++ b/tests/cases/space-between-comment-and-code.json @@ -0,0 +1,63 @@ +{ + "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}" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 15, + "type": "body" + }, + "code": { + "start": 16, + "end": 28 + }, + "file": { + "path": "docs/tests/cases/space-between-comment-and-code.scss", + "start": 1, + "end": 28 + } + } + } + ] + } + } + } +} 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..333825e --- /dev/null +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -0,0 +1,60 @@ +{ + "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}" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 22, + "type": "body" + }, + "code": { + "start": 23, + "end": 36 + }, + "file": { + "path": "docs/tests/cases/starts-and-ends-with-spaces.scss", + "start": 1, + "end": 38 + } + } + } + ] + } + } + } +} diff --git a/tests/file-types/edge-cases/starts-and-ends-with-spaces.scss b/tests/cases/starts-and-ends-with-spaces.scss similarity index 83% rename from tests/file-types/edge-cases/starts-and-ends-with-spaces.scss rename to tests/cases/starts-and-ends-with-spaces.scss index d4e2f75..88f57d6 100644 --- a/tests/file-types/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/file-types/edge-cases/4-blank-lines-between-code-blocks.scss b/tests/file-types/edge-cases/4-blank-lines-between-code-blocks.scss deleted file mode 100644 index 77c64af..0000000 --- a/tests/file-types/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/file-types/edge-cases/single-body-comment.scss b/tests/file-types/edge-cases/single-body-comment.scss deleted file mode 100644 index 4063797..0000000 --- a/tests/file-types/edge-cases/single-body-comment.scss +++ /dev/null @@ -1,24 +0,0 @@ -/// @name moz-only -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} \ No newline at end of file diff --git a/tests/file-types/edge-cases/space-between-comment-and-code.scss b/tests/file-types/edge-cases/space-between-comment-and-code.scss deleted file mode 100644 index 72f615e..0000000 --- a/tests/file-types/edge-cases/space-between-comment-and-code.scss +++ /dev/null @@ -1,57 +0,0 @@ -//// -/// @author Tyler Benton -/// @page edge-cases/ends-with-empty-lines -//// - -/// @name Space between comment bock and code block -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } - -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} - - - -/// @name No space between -/// @description -/// A simple nav component, used to help with navigation -/// @markup -/// -.nav{ - height: 40px; - width: 100%; - background: #455868; - border-bottom: 2px solid #283744; - li{ - width: 600px; - height: 40px; - a{ - color: #fff; - line-height: 40px; - text-shadow: 1px 1px 0px #283744; - } - } -} \ No newline at end of file diff --git a/tests/file-types/edge-cases/starts-with-empty-lines.scss b/tests/file-types/edge-cases/starts-with-empty-lines.scss deleted file mode 100644 index 79d9a0d..0000000 --- a/tests/file-types/edge-cases/starts-with-empty-lines.scss +++ /dev/null @@ -1,32 +0,0 @@ - - - -//// -/// @author Tyler Benton -/// @page edge-cases/starts-with-empty-lines -//// - -/// @name Only block in body -/// @author Tyler Benton -/// @description This allows you to write specific styles for mozilla firefox only -/// @markup {scss} (example="false") **Example:** -/// @include moz-only(){ -/// // removes the weird styling in firefox -/// -moz-appearance: none; -/// padding: { -/// top: nth-val(get($form-config, padding), 1) - .2em; -/// bottom: nth-val(get($form-config, padding), 3) - .2em; -/// }; -/// text-indent: 0.01px; -/// text-overflow: ""; -/// } -@mixin moz-only(){ - $selector: &; - @at-root{ - @-moz-document url-prefix(){ - #{$selector}{ - @content; - } - } - } -} \ No newline at end of file From 7071266378e2021cc5306e27fa6de7f223c9f4b4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 13:47:22 -0500 Subject: [PATCH 210/273] Updated markdown, coldfusion, and html end comment styles This was just so that things are more consistent across the board and it make's it easier to type the comment --- README.md | 2 +- app/annotations.js | 2 +- app/config.js | 8 ++++---- tests/file-types/coldfusion/test.cfm | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 22f8351..ecc5a60 100644 --- a/README.md +++ b/README.md @@ -492,7 +492,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 diff --git a/app/annotations.js b/app/annotations.js index b33fb6e..204bb07 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -388,7 +388,7 @@ annotations.description = { /// @markup Usage /// +/// ----> annotations.markdown = { filetypes: [ 'markdown', 'mark', 'mdown', diff --git a/app/config.js b/app/config.js index 7de38a7..3a57efa 100644 --- a/app/config.js +++ b/app/config.js @@ -51,12 +51,12 @@ export const comments = { body: { line: '#' } }, 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { - header: { start: '' }, - body: { start: '' } + header: { start: '' }, + body: { start: '' } }, cfm: { - header: { start: '' }, - body: { start: '' } + header: { start: '' }, + body: { start: '' } } } diff --git a/tests/file-types/coldfusion/test.cfm b/tests/file-types/coldfusion/test.cfm index 8f91da4..de25618 100755 --- a/tests/file-types/coldfusion/test.cfm +++ b/tests/file-types/coldfusion/test.cfm @@ -1,13 +1,13 @@ +-----> +-----> @@ -19,7 +19,7 @@ main method @name John Doe @description This is a normal multi-line coldfusion comment. -/---> +----> SELECT A.PRICE FROM ART A @@ -36,7 +36,7 @@ This is a normal multi-line coldfusion comment. @description This is another multi-line normal Coldfusion Script comment made of single-line comments. -/---> +----> component extends="Fruit" output="false" { property name="variety" type="string"; public boolean function isGood() { @@ -52,7 +52,7 @@ component extends="Fruit" output="false" { @name Bob @description This is another normal multi-line coldfusion comment. -/---> +----> list: #priceList#
sum: #numberFormat(arraySum(priceArr))#
From 5a85dde9b34d91a3f37d8cf682327e78ef8d633d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 13:48:18 -0500 Subject: [PATCH 211/273] added `coffee`, `sh`, and `bash` comment styles --- app/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config.js b/app/config.js index 3a57efa..5c6a87e 100644 --- a/app/config.js +++ b/app/config.js @@ -46,9 +46,9 @@ export const comments = { header: { start: '/***', line: '*', end: '***/' }, body: { start: '/**', line: '*', end: '**/' } }, - 'rb, py': { + 'rb, py, coffee, sh, bash': { header: { start: '###', line: '##', end: '###' }, - body: { line: '#' } + body: { line: '##' } }, 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { header: { start: '' }, From b90b9a7d8691877dd989fa30080fd08deef587af Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 14:07:00 -0500 Subject: [PATCH 212/273] :bugfix: for multi line comments The end comment was being pushed onto comment contents when it shouldn't have been added --- app/parser/get-blocks.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index 46ba0e9..f583a3c 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -55,7 +55,7 @@ export default function getBlocks({ // a) There was block that has already been processed if (!is.undefined(block)) { // holds the current block information - block.code.end = i - 1 // @todo check to make sure this is correct + block.code.end = i - 1 parsed.push(block) // Stops the loop after the first comment block @@ -77,7 +77,6 @@ export default function getBlocks({ // a) check for the end comment if (style === 'multi' && block.comment.start !== i && index.end !== false) { in_comment = false - block.comment.contents.push(line) block.comment.end = i // sets the end line in the comment block i++ // skips end comment line line = lines[i] // updates to be the next line From ca3a7ec4910c023f42231738835db39ff7f8cd46 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 14:32:34 -0500 Subject: [PATCH 213/273] :bugfix: Prevents nested documentation comments from being parsed This works correctly now ``` /// @markup /// /// @author ``` --- app/annotations.js | 1 - app/parser/get-blocks.js | 7 ++++++- app/parser/parse-blocks.js | 14 +++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 204bb07..c127142 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -177,7 +177,6 @@ function logAnnotationError(obj, expected) { let annotations = {} -export default /// @name @access /// @arg {string} line [public] - public, private, protected diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index f583a3c..bac68ca 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -75,7 +75,12 @@ export default function getBlocks({ } // a) check for the end comment - if (style === 'multi' && block.comment.start !== i && index.end !== false) { + if ( + block && + style === 'multi' && + block.comment.start !== i && + index.end !== false + ) { in_comment = false block.comment.end = i // sets the end line in the comment block i++ // skips end comment line diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index dd26f71..6137e35 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -75,7 +75,19 @@ function parseBlock(options = {}) { // loop over each line in the comment block for (let i = 0, l = contents.length; i < l; i++) { let line = contents[i] - let prefix_index = line.indexOf(comment.prefix) + let prefix_index = -1 + + if ( + !is.any.in( + line, + `${comment.header.line} ${comment.prefix}`, + `${comment.body.line} ${comment.prefix}`, + `\\${comment.prefix}` + ) + ) { + prefix_index = line.indexOf(comment.prefix) + } + // a) there is an index of the annotation prefix if (prefix_index >= 0) { From e9992c2c2c0f0dc25ddc33a06219f40e4dc836a4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 1 Mar 2016 15:26:13 -0500 Subject: [PATCH 214/273] added tests for several different' filetypes --- app/config.js | 6 +- tests/annotations/markdown/mark.mark | 2 +- tests/annotations/markdown/markdown.markdown | 2 +- tests/annotations/markdown/md.md | 2 +- tests/annotations/markdown/mdml.mdml | 2 +- tests/annotations/markdown/mdown.mdown | 2 +- tests/annotations/markdown/mdtext.mdtext | 2 +- tests/annotations/markdown/mdtxt.mdtxt | 2 +- tests/annotations/markdown/mdwn.mdwn | 2 +- tests/annotations/markdown/mkd.mkd | 2 +- tests/annotations/markdown/mkdn.mkdn | 2 +- tests/annotations/markdown/text.text | 2 +- tests/file-types/c#/README.md | 54 ----- tests/file-types/c++/README.md | 54 ----- tests/file-types/c++/test.c | 20 +- tests/file-types/c++/test.json | 129 +++++++++++ tests/file-types/c/README.md | 54 ----- tests/file-types/c/test.c | 8 +- tests/file-types/c/test.json | 129 +++++++++++ tests/file-types/coffeescript/README.md | 46 ---- tests/file-types/coffeescript/test.coffee | 8 +- tests/file-types/coffeescript/test.json | 129 +++++++++++ tests/file-types/coldfusion/README.md | 61 ----- tests/file-types/coldfusion/test.cfm | 30 +-- tests/file-types/coldfusion/test.json | 154 +++++++++++++ tests/file-types/{c# => cs}/test.cs | 14 +- tests/file-types/cs/test.json | 130 +++++++++++ tests/file-types/css/test.json | 104 +++++++++ tests/file-types/html/README.md | 23 -- tests/file-types/html/test.html | 6 +- tests/file-types/html/test.json | 105 +++++++++ tests/file-types/jade/test.jade | 15 ++ tests/file-types/jade/test.json | 79 +++++++ tests/file-types/java/README.md | 48 ---- tests/file-types/java/test.java | 6 +- tests/file-types/java/test.json | 129 +++++++++++ tests/file-types/js/test.js | 27 +++ tests/file-types/js/test.json | 98 ++++++++ tests/file-types/less/README.md | 46 ---- tests/file-types/less/test.json | 172 ++++++++++++++ tests/file-types/less/test.less | 211 +++--------------- tests/file-types/markdown/mark.json | 51 +++++ .../{md/markdown.md => markdown/mark.mark} | 7 +- tests/file-types/markdown/markdown.json | 51 +++++ tests/file-types/markdown/markdown.markdown | 20 ++ tests/file-types/markdown/md.json | 51 +++++ tests/file-types/markdown/md.md | 20 ++ tests/file-types/markdown/mdml.json | 51 +++++ tests/file-types/markdown/mdml.mdml | 20 ++ tests/file-types/markdown/mdown.json | 51 +++++ tests/file-types/markdown/mdown.mdown | 20 ++ tests/file-types/markdown/mdtext.json | 51 +++++ tests/file-types/markdown/mdtext.mdtext | 20 ++ tests/file-types/markdown/mdtxt.json | 161 +++++++++++++ tests/file-types/markdown/mdtxt.mdtxt | 12 + tests/file-types/markdown/mdwn.json | 51 +++++ tests/file-types/markdown/mdwn.mdwn | 20 ++ tests/file-types/markdown/mkd.json | 161 +++++++++++++ tests/file-types/markdown/mkd.mkd | 12 + tests/file-types/markdown/mkdn.json | 51 +++++ tests/file-types/markdown/mkdn.mkdn | 20 ++ tests/file-types/markdown/text.json | 51 +++++ tests/file-types/markdown/text.text | 20 ++ tests/file-types/php/README.md | 69 ------ tests/file-types/php/test.json | 130 +++++++++++ tests/file-types/php/test.php | 42 ++-- tests/file-types/python/README.md | 63 ------ tests/file-types/python/test.json | 129 +++++++++++ tests/file-types/ruby/README.md | 47 ---- tests/file-types/ruby/test.json | 129 +++++++++++ tests/file-types/ruby/test.rb | 29 ++- tests/file-types/scss/test.json | 141 ++++++++++++ tests/file-types/scss/test.scss | 97 +------- tests/file-types/stylus/README.md | 48 ---- tests/file-types/stylus/test.json | 129 +++++++++++ tests/file-types/stylus/test.styl | 12 +- tests/file-types/swift/README.md | 47 ---- tests/file-types/swift/test.json | 129 +++++++++++ tests/file-types/swift/test.swift | 7 +- tests/run.test.js | 15 ++ 80 files changed, 3309 insertions(+), 1043 deletions(-) delete mode 100755 tests/file-types/c#/README.md delete mode 100755 tests/file-types/c++/README.md create mode 100644 tests/file-types/c++/test.json delete mode 100755 tests/file-types/c/README.md create mode 100644 tests/file-types/c/test.json delete mode 100755 tests/file-types/coffeescript/README.md create mode 100644 tests/file-types/coffeescript/test.json delete mode 100755 tests/file-types/coldfusion/README.md create mode 100644 tests/file-types/coldfusion/test.json rename tests/file-types/{c# => cs}/test.cs (94%) mode change 100755 => 100644 create mode 100644 tests/file-types/cs/test.json create mode 100644 tests/file-types/css/test.json delete mode 100755 tests/file-types/html/README.md create mode 100644 tests/file-types/html/test.json create mode 100644 tests/file-types/jade/test.jade create mode 100644 tests/file-types/jade/test.json delete mode 100755 tests/file-types/java/README.md create mode 100644 tests/file-types/java/test.json create mode 100644 tests/file-types/js/test.json delete mode 100755 tests/file-types/less/README.md create mode 100644 tests/file-types/less/test.json create mode 100644 tests/file-types/markdown/mark.json rename tests/file-types/{md/markdown.md => markdown/mark.mark} (87%) create mode 100644 tests/file-types/markdown/markdown.json create mode 100644 tests/file-types/markdown/markdown.markdown create mode 100644 tests/file-types/markdown/md.json create mode 100644 tests/file-types/markdown/md.md create mode 100644 tests/file-types/markdown/mdml.json create mode 100644 tests/file-types/markdown/mdml.mdml create mode 100644 tests/file-types/markdown/mdown.json create mode 100644 tests/file-types/markdown/mdown.mdown create mode 100644 tests/file-types/markdown/mdtext.json create mode 100644 tests/file-types/markdown/mdtext.mdtext create mode 100644 tests/file-types/markdown/mdtxt.json create mode 100644 tests/file-types/markdown/mdtxt.mdtxt create mode 100644 tests/file-types/markdown/mdwn.json create mode 100644 tests/file-types/markdown/mdwn.mdwn create mode 100644 tests/file-types/markdown/mkd.json create mode 100644 tests/file-types/markdown/mkd.mkd create mode 100644 tests/file-types/markdown/mkdn.json create mode 100644 tests/file-types/markdown/mkdn.mkdn create mode 100644 tests/file-types/markdown/text.json create mode 100644 tests/file-types/markdown/text.text delete mode 100755 tests/file-types/php/README.md create mode 100644 tests/file-types/php/test.json delete mode 100755 tests/file-types/python/README.md create mode 100644 tests/file-types/python/test.json delete mode 100755 tests/file-types/ruby/README.md create mode 100644 tests/file-types/ruby/test.json create mode 100644 tests/file-types/scss/test.json delete mode 100755 tests/file-types/stylus/README.md create mode 100644 tests/file-types/stylus/test.json delete mode 100755 tests/file-types/swift/README.md create mode 100644 tests/file-types/swift/test.json diff --git a/app/config.js b/app/config.js index 5c6a87e..d57df95 100644 --- a/app/config.js +++ b/app/config.js @@ -46,7 +46,7 @@ export const comments = { header: { start: '/***', line: '*', end: '***/' }, body: { start: '/**', line: '*', end: '**/' } }, - 'rb, py, coffee, sh, bash': { + 'rb, py, coffee, sh, bash, pl': { header: { start: '###', line: '##', end: '###' }, body: { line: '##' } }, @@ -54,6 +54,10 @@ export const comments = { header: { start: '' }, body: { start: '' } }, + jade: { + header: { start: '//-//', line: '//-/', end: '//-//' }, + body: { line: '//-/' } + }, cfm: { header: { start: '' }, body: { start: '' } diff --git a/tests/annotations/markdown/mark.mark b/tests/annotations/markdown/mark.mark index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mark.mark +++ b/tests/annotations/markdown/mark.mark @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/markdown.markdown b/tests/annotations/markdown/markdown.markdown index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/markdown.markdown +++ b/tests/annotations/markdown/markdown.markdown @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/md.md b/tests/annotations/markdown/md.md index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/md.md +++ b/tests/annotations/markdown/md.md @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mdml.mdml b/tests/annotations/markdown/mdml.mdml index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mdml.mdml +++ b/tests/annotations/markdown/mdml.mdml @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mdown.mdown b/tests/annotations/markdown/mdown.mdown index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mdown.mdown +++ b/tests/annotations/markdown/mdown.mdown @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mdtext.mdtext b/tests/annotations/markdown/mdtext.mdtext index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mdtext.mdtext +++ b/tests/annotations/markdown/mdtext.mdtext @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mdtxt.mdtxt b/tests/annotations/markdown/mdtxt.mdtxt index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mdtxt.mdtxt +++ b/tests/annotations/markdown/mdtxt.mdtxt @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mdwn.mdwn b/tests/annotations/markdown/mdwn.mdwn index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mdwn.mdwn +++ b/tests/annotations/markdown/mdwn.mdwn @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mkd.mkd b/tests/annotations/markdown/mkd.mkd index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mkd.mkd +++ b/tests/annotations/markdown/mkd.mkd @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/mkdn.mkdn b/tests/annotations/markdown/mkdn.mkdn index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/mkdn.mkdn +++ b/tests/annotations/markdown/mkdn.mkdn @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/annotations/markdown/text.text b/tests/annotations/markdown/text.text index e099e21..b0df59e 100644 --- a/tests/annotations/markdown/text.text +++ b/tests/annotations/markdown/text.text @@ -1,6 +1,6 @@ +----> # H1 Tag ```scss diff --git a/tests/file-types/c#/README.md b/tests/file-types/c#/README.md deleted file mode 100755 index b238fd9..0000000 --- a/tests/file-types/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/file-types/c++/README.md b/tests/file-types/c++/README.md deleted file mode 100755 index 2ab52ca..0000000 --- a/tests/file-types/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/file-types/c++/test.c b/tests/file-types/c++/test.c index 36752b8..e913e77 100755 --- a/tests/file-types/c++/test.c +++ b/tests/file-types/c++/test.c @@ -3,9 +3,8 @@ /// @page tests/c++-file //// -/// @name main -/// @description -/// main method +/// @name one +/// @description Lorem ipsum dolor sit amet, consectetur adipisicing elit. #include int main(){ char name[50]; @@ -33,13 +32,16 @@ int main(){ // This is a normal single-line comment, and shouldn't start a new block -/// @name Something +/// @name Two /// @description -/// This is a normal multi-line comment. +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque non fugit, +/// aspernatur! Quos consequatur libero, fugiat tempora maxime maiores quia +/// aspernatur praesentium voluptatum incidunt! Tempora rem aperiam +/// consectetur aut, fugiat. #include struct s{ - char name[50]; - int height; + char name[50]; + int height; }; int main(){ struct s a[5],b[5]; @@ -63,7 +65,7 @@ int main(){ fclose(fptr); } -/// @name Something else +/// @name Three /// @description /// This is another normal multi-line comment. #include @@ -87,4 +89,4 @@ int main(){ } fclose(fptr); return 0; -} \ No newline at end of file +} diff --git a/tests/file-types/c++/test.json b/tests/file-types/c++/test.json new file mode 100644 index 0000000..48a4889 --- /dev/null +++ b/tests/file-types/c++/test.json @@ -0,0 +1,129 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "C File", + "href": "/tests/c++-file", + "body": [ + { + "title": "one", + "href": "/tests/c++-file#one" + }, + { + "title": "Two", + "href": "/tests/c++-file#two" + }, + { + "title": "Three", + "href": "/tests/c++-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "c++-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + } + }, + "body": [ + { + "name": "one", + "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 34 + }, + "file": { + "path": "docs/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + } + }, + { + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 35, + "end": 40, + "type": "body" + }, + "code": { + "start": 41, + "end": 67 + }, + "file": { + "path": "docs/tests/file-types/c++/test.c", + "start": 1, + "end": 93 + } + } + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

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

main method

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

This is a normal multi-line comment.

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

This is another normal multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 64, + "end": 66, + "type": "body" + }, + "code": { + "start": 67, + "end": 89 + }, + "file": { + "path": "docs/tests/file-types/c/test.c", + "start": 1, + "end": 89 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/coffeescript/README.md b/tests/file-types/coffeescript/README.md deleted file mode 100755 index 171cb02..0000000 --- a/tests/file-types/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/file-types/coffeescript/test.coffee b/tests/file-types/coffeescript/test.coffee index a2a24e1..fd31154 100755 --- a/tests/file-types/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..49b8037 --- /dev/null +++ b/tests/file-types/coffeescript/test.json @@ -0,0 +1,129 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/coffeescript/test.coffee", + "start": 1, + "end": 40 + } + } + }, + "body": [ + { + "name": "One", + "description": "

main method

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

This is a normal multi-line comment.

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

This is another normla multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 31, + "end": 33, + "type": "body" + }, + "code": { + "start": 34, + "end": 40 + }, + "file": { + "path": "docs/tests/file-types/coffeescript/test.coffee", + "start": 1, + "end": 40 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/coldfusion/README.md b/tests/file-types/coldfusion/README.md deleted file mode 100755 index 1a71abe..0000000 --- a/tests/file-types/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/file-types/coldfusion/test.cfm b/tests/file-types/coldfusion/test.cfm index de25618..836e998 100755 --- a/tests/file-types/coldfusion/test.cfm +++ b/tests/file-types/coldfusion/test.cfm @@ -4,10 +4,10 @@ -----> +----> @@ -16,7 +16,7 @@ main method @@ -32,29 +32,29 @@ This is a normal multi-line coldfusion comment. component extends="Fruit" output="false" { - property name="variety" type="string"; - public boolean function isGood() { - return true; - } - private void eat(required numeric bites) { - //do stuff - } + property name="variety" type="string"; + public boolean function isGood() { + return true; + } + private void eat(required numeric bites) { + //do stuff + } } -list: #priceList#
-sum: #numberFormat(arraySum(priceArr))#
-avg: #numberFormat(arrayAvg(priceArr))#
+ list: #priceList#
+ sum: #numberFormat(arraySum(priceArr))#
+ avg: #numberFormat(arrayAvg(priceArr))#
diff --git a/tests/file-types/coldfusion/test.json b/tests/file-types/coldfusion/test.json new file mode 100644 index 0000000..7a2007f --- /dev/null +++ b/tests/file-types/coldfusion/test.json @@ -0,0 +1,154 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Cfm File", + "href": "/tests/cfm-file", + "body": [ + { + "title": "One", + "href": "/tests/cfm-file#one" + }, + { + "title": "Two", + "href": "/tests/cfm-file#two" + }, + { + "title": "Three", + "href": "/tests/cfm-file#three" + }, + { + "title": "Four", + "href": "/tests/cfm-file#four" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "cfm-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + } + }, + "body": [ + { + "name": "One", + "description": "

main method

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

This is a normal multi-line coldfusion comment.

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

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

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

This is another normal multi-line coldfusion comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 51, + "end": 55, + "type": "body" + }, + "code": { + "start": 56, + "end": 61 + }, + "file": { + "path": "docs/tests/file-types/coldfusion/test.cfm", + "start": 1, + "end": 61 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/c#/test.cs b/tests/file-types/cs/test.cs old mode 100755 new mode 100644 similarity index 94% rename from tests/file-types/c#/test.cs rename to tests/file-types/cs/test.cs index 442e0b2..a3ce180 --- a/tests/file-types/c#/test.cs +++ b/tests/file-types/cs/test.cs @@ -1,13 +1,13 @@ //// /// @author Tyler Benton -/// @page tests/c#-file +/// @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 main +/// @name One /// @description /// Lorem ipsum dolor sit amet, consectetur adipisicing elit. /// Eaque temporibus praesentium iure, qui dolorem blanditiis @@ -37,13 +37,13 @@ int main(){ // This is a normal single-line comment, and shouldn't start a new block -/// @name Something +/// @name Two /// @description /// This is a normal multi-line comment. #include struct s{ - char name[50]; - int height; + char name[50]; + int height; }; int main(){ struct s a[5],b[5]; @@ -67,7 +67,7 @@ struct s a[5],b[5]; fclose(fptr); } -/// @name Something else +/// @name Three /// @description /// This is another normal multi-line comment. #include @@ -91,4 +91,4 @@ int main(){ } fclose(fptr); return 0; -} \ No newline at end of file +} diff --git a/tests/file-types/cs/test.json b/tests/file-types/cs/test.json new file mode 100644 index 0000000..a68bcb9 --- /dev/null +++ b/tests/file-types/cs/test.json @@ -0,0 +1,130 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Cs File", + "href": "/tests/cs-file", + "body": [ + { + "title": "One", + "href": "/tests/cs-file#one" + }, + { + "title": "Two", + "href": "/tests/cs-file#two" + }, + { + "title": "Three", + "href": "/tests/cs-file#three" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "cs-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "description": "

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

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

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

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

This is a normal multi-line comment.

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

This is another normal multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 70, + "end": 72, + "type": "body" + }, + "code": { + "start": 73, + "end": 95 + }, + "file": { + "path": "docs/tests/file-types/cs/test.cs", + "start": 1, + "end": 95 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/css/test.json b/tests/file-types/css/test.json new file mode 100644 index 0000000..8cc7559 --- /dev/null +++ b/tests/file-types/css/test.json @@ -0,0 +1,104 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/css/test.css", + "start": 1, + "end": 31 + } + } + }, + "body": [ + { + "name": "Base Styles", + "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 12, + "type": "body" + }, + "code": { + "start": 13, + "end": 19 + }, + "file": { + "path": "docs/tests/file-types/css/test.css", + "start": 1, + "end": 31 + } + } + }, + { + "name": "Input", + "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 20, + "end": 26, + "type": "body" + }, + "code": { + "start": 27, + "end": 31 + }, + "file": { + "path": "docs/tests/file-types/css/test.css", + "start": 1, + "end": 31 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/html/README.md b/tests/file-types/html/README.md deleted file mode 100755 index daa602e..0000000 --- a/tests/file-types/html/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## HTML -Reference: [http://www.w3schools.com/html/html_comments.asp](http://www.w3schools.com/html/html_comments.asp) - -In brief, there one way to comment in HTML: - -1. type1: Using `` - -This are explained in detail below. - -### html-type1.html -> For this type, comments *normally* begin with ``. *File-level* comments contain five `-` instead of two. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line HTML comment with ``: - - - -A *normal* multi-line HTML comment with ``: - - diff --git a/tests/file-types/html/test.html b/tests/file-types/html/test.html index 43c0a0d..69f56bd 100755 --- a/tests/file-types/html/test.html +++ b/tests/file-types/html/test.html @@ -8,13 +8,13 @@ @name Header @author Tyler Benton @page tests/html-file - /---> + ----> + --->
Home My Account @@ -27,7 +27,7 @@ @name Body Block 2 @description This is the main footer of the site - /--> + --->
diff --git a/tests/file-types/html/test.json b/tests/file-types/html/test.json new file mode 100644 index 0000000..2d8d7b2 --- /dev/null +++ b/tests/file-types/html/test.json @@ -0,0 +1,105 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Header", + "href": "/tests/html-file", + "body": [ + { + "title": "Body Block 1", + "href": "/tests/html-file#body-block-1" + }, + { + "title": "Body Block 2", + "href": "/tests/html-file#body-block-2" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "html-file": { + "page": { + "header": { + "name": "Header", + "author": [ + "Tyler Benton" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 11, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/html/test.html", + "start": 1, + "end": 36 + } + } + }, + "body": [ + { + "name": "Body Block 1", + "description": "

This is the main header of the site

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

This is the main footer of the site

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 26, + "end": 30, + "type": "body" + }, + "code": { + "start": 31, + "end": 36 + }, + "file": { + "path": "docs/tests/file-types/html/test.html", + "start": 1, + "end": 36 + } + } + } + ] + } + } + } + } +} 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..e93b94f --- /dev/null +++ b/tests/file-types/jade/test.json @@ -0,0 +1,79 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/jade/test.jade", + "start": 1, + "end": 16 + } + } + }, + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 7, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 16 + }, + "file": { + "path": "docs/tests/file-types/jade/test.jade", + "start": 1, + "end": 16 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/java/README.md b/tests/file-types/java/README.md deleted file mode 100755 index 32dba2d..0000000 --- a/tests/file-types/java/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## Java -*Reference: [http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html](http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html) - -In brief, there are 2 different ways to comment in Java: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single line comments, `//` - -These are explained in detail below. - -### java-type1.java -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments have five `*` instead of one. For style's sake, usually you put a `*` to begin each new comment line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Java comment with `/*` and `*/` : - - /***** - * stuff - * more stuff - * even more stuff - *****/ - -A *normal* multi-line Java comment with `/*` and `*/` : - - /* - * stuff - */ - ----------------------------------- -### java-type2.java -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Java comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Java comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Java comment with `/` : - - // stuff \ No newline at end of file diff --git a/tests/file-types/java/test.java b/tests/file-types/java/test.java index 7d9cb71..d13d9d0 100755 --- a/tests/file-types/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..7b78beb --- /dev/null +++ b/tests/file-types/java/test.json @@ -0,0 +1,129 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/java/test.java", + "start": 1, + "end": 34 + } + } + }, + "body": [ + { + "name": "One", + "description": "

A very simple class to print out Hello World

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

This is a normal multi-line comment.

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

This is another normal multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 26, + "end": 28, + "type": "body" + }, + "code": { + "start": 29, + "end": 34 + }, + "file": { + "path": "docs/tests/file-types/java/test.java", + "start": 1, + "end": 34 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/js/test.js b/tests/file-types/js/test.js index e69de29..072804a 100644 --- a/tests/file-types/js/test.js +++ 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..12593ca --- /dev/null +++ b/tests/file-types/js/test.json @@ -0,0 +1,98 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/js/test.js", + "start": 1, + "end": 28 + } + } + }, + "body": [ + { + "name": "@author", + "alias": [ + "@author" + ], + "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" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 8, + "end": 18, + "type": "body" + }, + "code": { + "start": 19, + "end": 28 + }, + "file": { + "path": "docs/tests/file-types/js/test.js", + "start": 1, + "end": 28 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/less/README.md b/tests/file-types/less/README.md deleted file mode 100755 index edc1136..0000000 --- a/tests/file-types/less/README.md +++ /dev/null @@ -1,46 +0,0 @@ -## Less -*Reference: [http://www.ibm.com/developerworks/library/wa-less/](http://www.ibm.com/developerworks/library/wa-less/) - -In brief, there are 2 different ways to comment in Less: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single line comments, `//` - -These are explained in detail below. - -### less-type1.less -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Less comment with `/*` and `*/`: - - /***** - stuff - *****/ - -A *normal* multi-line Less comment with `/*` and `*/`: - - /* - stuff - */ - ----------------------------------- -### less-type2.less -> For this type, comments are composed of several single lined comments, which are made from `/`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Less comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Less comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Less comment with `/` : - - // stuff diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json new file mode 100644 index 0000000..d62ad97 --- /dev/null +++ b/tests/file-types/less/test.json @@ -0,0 +1,172 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + } + }, + "body": [ + { + "name": "One", + "type": { + "type": "color", + "description": "" + }, + "markup": [ + { + "id": "0", + "language": "less", + "settings": {}, + "description": "", + "raw": "\\@name", + "escaped": "\\@name" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 9, + "type": "body" + }, + "code": { + "start": 10, + "end": 15 + }, + "file": { + "path": "docs/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + } + }, + { + "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>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 16, + "end": 24, + "type": "body" + }, + "code": { + "start": 25, + "end": 42 + }, + "file": { + "path": "docs/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + } + }, + { + "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}" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 43, + "end": 50, + "type": "body" + }, + "code": { + "start": 51, + "end": 59 + }, + "file": { + "path": "docs/tests/file-types/less/test.less", + "start": 1, + "end": 59 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/less/test.less b/tests/file-types/less/test.less index 267dfb7..cfb5f8b 100755 --- a/tests/file-types/less/test.less +++ b/tests/file-types/less/test.less @@ -3,209 +3,50 @@ /// @page tests/less-test //// -/// @name base color +/// @name One /// @type {color} -@color-base: #2d5e8b; +/// @markup +/// \@name +@name: #2d5e8b; -main{ - background-color: @color-base; +main { + background-color: @name; } -/// @name Nav +/// @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; +.nav { height: 40px; - a{ - color: #fff; - line-height: 40px; - text-shadow: 1px 1px 0px #283744; - } - } -} - -/// @author Tyler Benton -/// @page components/buttons -/// -/// @description Your standard form button. -/// -/// @state :hover -/// @state :active -/// @state :disabled - Dims the button when disabled. -/// @state .c-btn--mini - A mini button -/// @state .c-btn--tiny - A tiny button -/// @state .c-btn--medium - A medium button -/// @state .c-btn--large - A large button -/// @state .c-btn--primary - Primary action -/// @state .c-btn--primary:hover -/// @state .c-btn--primary:active -/// @state .c-btn--secondary - Secondary action -/// @state .c-btn--secondary:hover -/// @state .c-btn--secondary:active -/// @state .c-btn--tertiary - Tertiary action -/// @state .c-btn--tertiary:hover -/// @state .c-btn--tertiary:active -/// @state .c-btn--text - It's a text link as a button -/// @state .c-btn--text:hover -/// @state .c-btn--text:active -/// -/// @markup -///
-/// Button (a.button) -/// -/// -///
-.c-btn{ - background: color(a); - border: none; - border-radius: 6px; - color: #fff; - display: inline-block; - font-size: 1em; - font-weight: bold; - line-height: 1em; - padding: 13px 1.5em; - text-align: center; - text-decoration: none; - transition: background .25s ease-out, color .25s ease-out; - vertical-align: middle; - width: auto; // this resets the input style of 100% - &:hover, &:active, &:focus{ // had to write it like this to over ride the styles on the anchor tags without using important - color: #fff; - text-decoration: none; - } - &:hover{ - background: color(a, -2); - } - &:active, &:focus{ - background: color(a, 2); - } - &:disabled{ - opacity: .5; - } - - &--mini{ - font-size: .8rem; - padding: .6em .8em; - } - - &--tiny{ - font-size: .875rem; - padding: .6em .8em; - } - - &--small{ - font-size: .875rem; - } - - &--medium{ - font-size: 1rem; - } - - &--large{ - font-size: 1.125rem; - } - - &--primary{ - background: color(f); - &:hover{ - background: color(f, -2); - } - &:active, &:focus{ - background: color(f, 2); - } - .c-badge{ - color: color(f); - } - } - - &--secondary{ - background: color(b); - &:hover{ - background: color(b, -2); - } - &:active, &:focus{ - background: color(b, 2); - } - .c-badge{ - color: color(b); - } - } - - &--tertiary{ - background: color(a, -7); - &, &:hover, &:active, &:focus{ - color: color(a, 3); - } - &:hover{ - background: color(a, -5); - } - &:active, &:focus{ - background: color(a, -3); - } - .c-badge{ - color: color(a); - } - } + width: 100%; + background: #455868; + border-bottom: 2px solid #283744; - &--text{ - color: color(b, 0); - &, &:hover, &:active, &:focus{ - background: none; - } - &:hover{ - color: color(b, -2); - } - &:active, &:focus{ - color: color(b, 2); - } - - .c-badge{ - color: color(b); - } - } - - .c-badge{ - background: #fff; - } + li { + width: 600px; + height: 40px; - /// @name Button group - /// @description - /// Used when there's a group of buttons that need to be on the same line. - /// - /// @markup - ///
- /// Button (a.button) - /// - /// - ///
- &-group{ - > *{ - margin-top: 0; + a { + color: #fff; + line-height: 40px; + text-shadow: 1px 1px 0px #283744; + } } - } } - -/// @name Opacity +/// @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); +/// .foo { +/// .opacity(.3); /// } .opacity(@opacity: 0.5){ -webkit-opacity: @opacity; @@ -214,4 +55,4 @@ main{ @opperc: @opacity * 100; -ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=@{opperc})"; filter: ~"alpha(opacity=@{opperc})"; -} \ No newline at end of file +} diff --git a/tests/file-types/markdown/mark.json b/tests/file-types/markdown/mark.json new file mode 100644 index 0000000..71748d5 --- /dev/null +++ b/tests/file-types/markdown/mark.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mark", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mark", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mark.mark", + "start": 1, + "end": 21 + } + } + }, + "body": [] + } + } + } + } +} diff --git a/tests/file-types/md/markdown.md b/tests/file-types/markdown/mark.mark similarity index 87% rename from tests/file-types/md/markdown.md rename to tests/file-types/markdown/mark.mark index e3e67b8..468a00c 100644 --- a/tests/file-types/md/markdown.md +++ b/tests/file-types/markdown/mark.mark @@ -1,7 +1,8 @@ +----> ## Default Annotations ### @name @@ -16,4 +17,4 @@ Autofilled | - ###### Example ```scss /// @name Name -``` \ No newline at end of file +``` diff --git a/tests/file-types/markdown/markdown.json b/tests/file-types/markdown/markdown.json new file mode 100644 index 0000000..25790f0 --- /dev/null +++ b/tests/file-types/markdown/markdown.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "markdown", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "markdown", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/markdown.markdown", + "start": 1, + "end": 21 + } + } + }, + "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..82b47e3 --- /dev/null +++ b/tests/file-types/markdown/md.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "md", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "md", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/md.md", + "start": 1, + "end": 21 + } + } + }, + "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..b54f037 --- /dev/null +++ b/tests/file-types/markdown/mdml.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdml", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdml", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdml.mdml", + "start": 1, + "end": 21 + } + } + }, + "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..7b7b904 --- /dev/null +++ b/tests/file-types/markdown/mdown.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdown", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdown", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdown.mdown", + "start": 1, + "end": 21 + } + } + }, + "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..7b43fb0 --- /dev/null +++ b/tests/file-types/markdown/mdtext.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdtext", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdtext", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtext.mdtext", + "start": 1, + "end": 21 + } + } + }, + "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..f54abe4 --- /dev/null +++ b/tests/file-types/markdown/mdtxt.json @@ -0,0 +1,161 @@ +{ + "nav": [ + { + "title": "O", + "href": "/o", + "body": [], + "subpages": [] + }, + { + "title": "T", + "href": "/t", + "body": [], + "subpages": [] + }, + { + "title": "H", + "href": "/h", + "body": [], + "subpages": [] + }, + { + "title": "E", + "href": "/e", + "body": [], + "subpages": [] + }, + { + "title": "R", + "href": "/r", + "body": [], + "subpages": [] + } + ], + "pages": { + "o": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "t": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "h": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "e": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "r": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + } + } +} diff --git a/tests/file-types/markdown/mdtxt.mdtxt b/tests/file-types/markdown/mdtxt.mdtxt new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/file-types/markdown/mdtxt.mdtxt @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/file-types/markdown/mdwn.json b/tests/file-types/markdown/mdwn.json new file mode 100644 index 0000000..601b9a4 --- /dev/null +++ b/tests/file-types/markdown/mdwn.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mdwn", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mdwn", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdwn.mdwn", + "start": 1, + "end": 21 + } + } + }, + "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..4f4bb05 --- /dev/null +++ b/tests/file-types/markdown/mkd.json @@ -0,0 +1,161 @@ +{ + "nav": [ + { + "title": "O", + "href": "/o", + "body": [], + "subpages": [] + }, + { + "title": "T", + "href": "/t", + "body": [], + "subpages": [] + }, + { + "title": "H", + "href": "/h", + "body": [], + "subpages": [] + }, + { + "title": "E", + "href": "/e", + "body": [], + "subpages": [] + }, + { + "title": "R", + "href": "/r", + "body": [], + "subpages": [] + } + ], + "pages": { + "o": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "t": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "h": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "e": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + }, + "r": { + "page": { + "header": { + "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 3, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 13 + } + } + }, + "body": [] + } + } + } +} diff --git a/tests/file-types/markdown/mkd.mkd b/tests/file-types/markdown/mkd.mkd new file mode 100644 index 0000000..b0df59e --- /dev/null +++ b/tests/file-types/markdown/mkd.mkd @@ -0,0 +1,12 @@ + +# H1 Tag + +```scss +.foo { + .bar { + background: blue; + } +} +``` diff --git a/tests/file-types/markdown/mkdn.json b/tests/file-types/markdown/mkdn.json new file mode 100644 index 0000000..59303da --- /dev/null +++ b/tests/file-types/markdown/mkdn.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "mkdn", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "mkdn", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkdn.mkdn", + "start": 1, + "end": 21 + } + } + }, + "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..cd58ead --- /dev/null +++ b/tests/file-types/markdown/text.json @@ -0,0 +1,51 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "text", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "markdown": { + "page": { + "header": { + "name": "text", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/text.text", + "start": 1, + "end": 21 + } + } + }, + "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/README.md b/tests/file-types/php/README.md deleted file mode 100755 index 5802539..0000000 --- a/tests/file-types/php/README.md +++ /dev/null @@ -1,69 +0,0 @@ -## php -*Reference: [http://php.net/manual/en/language.basic-syntax.comments.php](http://php.net/manual/en/language.basic-syntax.comments.php) - -In brief, there are 3 different ways to comment in php: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` -3. type3: Using multiple single-line comments, `#` - -These are explained in detail below. - -### php-type1.php -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line php comment with `/*` and `*/` : - - /***** - stuff - *****/ - -A *normal* multi-line php comment with `/*` and `*/`: - - /* - stuff - */ - ----------------------------------- -### php-type2.php -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line php comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line php comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line php comment with `/` : - - // stuff - ----------------------------------- -### php-type3.php -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line php comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal* multi-line php comment with `#` : - - ## - ## stuff - ## - -A *normal* single-line php comment with `#` : - - # stuff diff --git a/tests/file-types/php/test.json b/tests/file-types/php/test.json new file mode 100644 index 0000000..c5bcec7 --- /dev/null +++ b/tests/file-types/php/test.json @@ -0,0 +1,130 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 2, + "end": 6, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/php/test.php", + "start": 1, + "end": 37 + } + } + }, + "body": [ + { + "name": "One", + "description": "

main method

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

This is a normal multi-line comment.

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

This is another normal multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 27, + "end": 29, + "type": "body" + }, + "code": { + "start": 30, + "end": 37 + }, + "file": { + "path": "docs/tests/file-types/php/test.php", + "start": 1, + "end": 37 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/php/test.php b/tests/file-types/php/test.php index e9afcaa..1cbfd5d 100755 --- a/tests/file-types/php/test.php +++ b/tests/file-types/php/test.php @@ -1,19 +1,19 @@ "; - echo "My house is " . $COLOR . "
"; - echo "My boat is " . $coLOR . "
"; + /// @name Three + /// @description + /// This is another normal multi-line comment. + $color = "red"; + echo "My car is " . $color . "
"; + echo "My house is " . $COLOR . "
"; + echo "My boat is " . $coLOR . "
"; - // 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/python/README.md b/tests/file-types/python/README.md deleted file mode 100755 index e9c4b25..0000000 --- a/tests/file-types/python/README.md +++ /dev/null @@ -1,63 +0,0 @@ -## Python -*Reference: [http://www.pythonforbeginners.com/comments/comments-in-python](http://www.pythonforbeginners.com/comments/comments-in-python), [http://www.afterhoursprogramming.com/tutorial/Python/Comments/](http://www.afterhoursprogramming.com/tutorial/Python/Comments/) - -In brief, there are 3 different ways to comment in Python: - -1. type1: Using `"""` -2. type2: Using `'''` -3. type3: Using multiple single line comments, `#` - -These are explained in detail below. - -### python-type1.py -> For this type, comments *normally* begin with `"""` and end with `"""`. *File-level* comments contain five `"` instead of three. For style's sake, the `"` are on their own line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Python comment with `"` : - - """"" - stuff - """"" - -A *normal* multi-line Python comment with `"` : - - """ - stuff - """ - ----------------------------------- -### python-type2.py -> For this type, comments normally begin with `'''` and end with `'''`. *File-level* comments contain five `'` instead of three. For style's sake, the `'` are on their own line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Python comment with `'` : - - ''''' - stuff - ''''' - -A *normal* multi-line Python comment with `'` : - - ''' - stuff - ''' - ----------------------------------- -### python-type3.py -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Python comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal* multi-line Python comment with `#` : - - ## - ## stuff - ## - -A *normal* single-line Python comment with `#` : - - # stuff diff --git a/tests/file-types/python/test.json b/tests/file-types/python/test.json new file mode 100644 index 0000000..b9509d8 --- /dev/null +++ b/tests/file-types/python/test.json @@ -0,0 +1,129 @@ +{ + "nav": [ + { + "title": "Tests", + "href": "/tests", + "body": [], + "subpages": [ + { + "title": "Py File", + "href": "/tests/py-file", + "body": [ + { + "title": "main", + "href": "/tests/py-file#main" + }, + { + "title": "something", + "href": "/tests/py-file#something" + }, + { + "title": "something else", + "href": "/tests/py-file#something-else" + } + ], + "subpages": [] + } + ] + } + ], + "pages": { + "tests": { + "page": { + "header": {}, + "body": [] + }, + "py-file": { + "page": { + "header": { + "author": [ + "Tyler Benton" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/python/test.py", + "start": 1, + "end": 43 + } + } + }, + "body": [ + { + "name": "main", + "description": "

main method

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

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

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

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

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 32, + "end": 34, + "type": "body" + }, + "code": { + "start": 35, + "end": 43 + }, + "file": { + "path": "docs/tests/file-types/python/test.py", + "start": 1, + "end": 43 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/ruby/README.md b/tests/file-types/ruby/README.md deleted file mode 100755 index e34d902..0000000 --- a/tests/file-types/ruby/README.md +++ /dev/null @@ -1,47 +0,0 @@ -## Ruby -Reference: [http://www.tutorialspoint.com/ruby/ruby_comments.htm](http://www.tutorialspoint.com/ruby/ruby_comments.htm) - -In brief, there are 2 different ways to comment in Ruby: - -1. type1: Using `=begin` `=end` -2. type2: Using multiple single line comments, `#` - -These are explained in detail below. - -### ruby-type1.rb -> For this type, comments *normally* begin with `=begin` and end with `=end`. *File-level* comments contain five `=` after `begin`. It is important to note that `=begin` and `=end` both start on a new line. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Ruby comment with `=begin` and `=end`: - - =begin===== - stuff - =end - -A *normal* multi-line Ruby comment with `=begin` and `=end`: - - =begin - stuff - =end - ----------------------------------- -### ruby-type2.rb -> For this type, comments are composed of several single lined comments, which are made from `#`. *File-level* comments will begin with five `#`, followed by single line comments with two `#`, and ended with five more `#` on a new line. Furthermore, *normal* multi-line comments also feature two `#`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - - -A *file-level multi-line* Ruby comment with `#` : - - ##### - ## - ## stuff - ## - ##### - -A *normal multi-line* Ruby comment with `#` : - - ## - ## stuff - ## - -A *normal single-line* Ruby comment with `#` : - - # stuff diff --git a/tests/file-types/ruby/test.json b/tests/file-types/ruby/test.json new file mode 100644 index 0000000..fa94902 --- /dev/null +++ b/tests/file-types/ruby/test.json @@ -0,0 +1,129 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + } + }, + "body": [ + { + "name": "One", + "description": "

main method

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

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

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 15, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 23 + }, + "file": { + "path": "docs/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + } + }, + { + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 24, + "end": 29, + "type": "body" + }, + "code": { + "start": 30, + "end": 38 + }, + "file": { + "path": "docs/tests/file-types/ruby/test.rb", + "start": 1, + "end": 43 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/ruby/test.rb b/tests/file-types/ruby/test.rb index 991e4aa..d5387f7 100755 --- a/tests/file-types/ruby/test.rb +++ b/tests/file-types/ruby/test.rb @@ -3,35 +3,40 @@ ## @page tests/rb-file ### -## @name main +## @name One ## @description ## main method - for i in (1..4) print i," " end print "\n" -## @name Something + +## @name Two ## @description ## This is a normal multi-line comment made of single line comments. - for i in (1...4) - print i," " + print i," " end print "\n" -## @name Something else -## @description -## This is another normal multi-line comment made of single line comments. +## @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, " " + print it, " " end print "\n" -# A simple single line comment + + + +# This shouldn't be parsed for i in (0...items.length) - print items[0..i].join(" "), "\n" -end \ No newline at end of file + print items[0..i].join(" "), "\n" +end diff --git a/tests/file-types/scss/test.json b/tests/file-types/scss/test.json new file mode 100644 index 0000000..7e94aec --- /dev/null +++ b/tests/file-types/scss/test.json @@ -0,0 +1,141 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/scss/test.scss", + "start": 1, + "end": 39 + } + } + }, + "body": [ + { + "name": "One", + "type": { + "type": "color", + "description": "" + }, + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 7, + "type": "body" + }, + "code": { + "start": 8, + "end": 11 + }, + "file": { + "path": "docs/tests/file-types/scss/test.scss", + "start": 1, + "end": 39 + } + } + }, + { + "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}" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 12, + "end": 28, + "type": "body" + }, + "code": { + "start": 29, + "end": 39 + }, + "file": { + "path": "docs/tests/file-types/scss/test.scss", + "start": 1, + "end": 39 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/scss/test.scss b/tests/file-types/scss/test.scss index c14c501..d517563 100755 --- a/tests/file-types/scss/test.scss +++ b/tests/file-types/scss/test.scss @@ -3,42 +3,13 @@ /// @page tests/scss-file //// -/// @name state test -/// @state (ermahgerd) -/// {:hover, :focus} - pseudo class stuff -/// {.something-else} [unique_identifier] - some really cool shit -/// -/// @state (ermahgerd) -/// {:active} - pseudo class stuff -/// {.something-else} [unique_identifier] - some other really cool shit -/// -/// @markup (ermahgerd) {html} **Example** Some example -///
-///
-/// {@state.unique_identifier.description} -///
-///
-/// -/// @state (ermahgerd-two) -/// {:hover, :focus} - pseudo class stuff -/// {.something-else} - some really cool shit -/// -/// @state (ermahgerd-two) -/// {:active} - pseudo class stuff -/// {.something-else} - some other really cool shit -/// -/// @markup (ermahgerd-two) {html} **Example** Some other example -///
-///
-/// {@state[1].description} -///
-///
- +/// @name One +/// @type {color} +$color: #2d5e8b; /// @name moz-only -/// @access someshit /// @author Tyler Benton /// @description This allows you to write specific styles for mozilla firefox only /// @arg {function, object} callbacks [something super sweet] - Functions @@ -65,65 +36,3 @@ } } } - -// @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--small} - A tiny button -// @state {.c-btn--medium} - A medium button -// @state {.c-btn--large} - A large button -// @state {.c-btn--huge} - A huge button -// @state {.c-btn--massive} - A massive button -// @state {.c-btn--primary} - Primary action -// @state {.c-btn--primary:hover} -// @state {.c-btn--primary:active} -// @state {.c-btn--secondary} - Secondary action -// @state {.c-btn--secondary:hover} -// @state {.c-btn--secondary:active} -// @state {.c-btn--tertiary} - Tertiary action -// @state {.c-btn--tertiary}:hover -// @state {.c-btn--tertiary}:active -// @state {.c-btn--text} - It's a text link as a button -// @state {.c-btn--text:hover} -// @state {.c-btn--text:active} -// -// @markup -//
-// Button (anchor) -// -// -//
-.c-btn { - background: color(a); - border: none; - border-radius: get($config, border-radius); - display: inline-block; - font-size: 1em; - font-weight: bold; - line-height: 1em; - padding: em(13px) 1.5em; - text-align: center; - transition: background 0.25s ease-out, color 0.25s ease-out; - vertical-align: middle; - width: auto; // this resets the input style of 100% - &, &:hover, &:active, &:focus { - color: #fff; - text-decoration: none; - } - &:hover { - background: color(a, -2); - } - &:active, &:focus { - background: color(a, 2); - } - &:disabled { - opacity: 0.5; - } -} \ No newline at end of file diff --git a/tests/file-types/stylus/README.md b/tests/file-types/stylus/README.md deleted file mode 100755 index 59129cc..0000000 --- a/tests/file-types/stylus/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## Stylus -*Reference: [https://learnboost.github.io/stylus/docs/comments.html](https://learnboost.github.io/stylus/docs/comments.html) - -In brief, there are 2 different ways to comment in Stylus: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### stylus-type1.styl -> For this type, comments *normally* begin with `/*` and end with `*/`, with `*` on each new line in between. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Stylus comment with `/*` and `*/`: - - /***** - * - * stuff - * - *****/ - -A *normal* multi-line Stylus comment with `/*` and `*/`: - - /* - * stuff - */ - ----------------------------------- -### stylus-type2.styl -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Stylus comment with `/` : - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Stylus comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Stylus comment with `/` : - - // stuff diff --git a/tests/file-types/stylus/test.json b/tests/file-types/stylus/test.json new file mode 100644 index 0000000..c249d27 --- /dev/null +++ b/tests/file-types/stylus/test.json @@ -0,0 +1,129 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + } + }, + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 10, + "type": "body" + }, + "code": { + "start": 11, + "end": 15 + }, + "file": { + "path": "docs/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + } + }, + { + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 16, + "end": 21, + "type": "body" + }, + "code": { + "start": 22, + "end": 26 + }, + "file": { + "path": "docs/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + } + }, + { + "name": "Three", + "description": "

This is another normal multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 27, + "end": 29, + "type": "body" + }, + "code": { + "start": 30, + "end": 37 + }, + "file": { + "path": "docs/tests/file-types/stylus/test.styl", + "start": 1, + "end": 37 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/stylus/test.styl b/tests/file-types/stylus/test.styl index 517d140..4613c6c 100755 --- a/tests/file-types/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/README.md b/tests/file-types/swift/README.md deleted file mode 100755 index dfa38a6..0000000 --- a/tests/file-types/swift/README.md +++ /dev/null @@ -1,47 +0,0 @@ -## Swift -*Reference: [https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html) - -In brief, there are 2 different ways to comment in Swift: - -1. type1: Using `/*` `*/` -2. type2: Using multiple single-line comments, `//` - -These are explained in detail below. - -### swift-type1.swift -> For this type, comments *normally* begin with `/*` and end with `*/`. *File-level* comments contain five `*` instead of one. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Swift comment with `/*` and `*/` : - - /***** - stuff - *****/ - -A *normal* multi-line Swift comment with `/*` and `*/` : - - /* - stuff - */ - ----------------------------------- -### swift-type2.swift -> For this type, comments are composed of several single lined comments, which are made from `//`. *File-level* comments will begin with five `/`, followed by single line comments with three `/`, and ended with five more `/` on a new line. Furthermore, *normal* multi-line comments also feature three `/`. It is up to you how you want to `tab` or `space` stuff inside. The comments are as follows: - -A *file-level* multi-line Swift comment with `/` : - - - //// - /// - /// stuff - /// - //// - -A *normal* multi-line Swift comment with `/` : - - /// - /// stuff - /// - -A *normal* single-line Swift comment with `/` : - - // stuff diff --git a/tests/file-types/swift/test.json b/tests/file-types/swift/test.json new file mode 100644 index 0000000..cd3cf35 --- /dev/null +++ b/tests/file-types/swift/test.json @@ -0,0 +1,129 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/swift/test.swift", + "start": 1, + "end": 49 + } + } + }, + "body": [ + { + "name": "main", + "description": "

main method

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

This is a normal multi-line comment.

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

This is another normal multi-line comment.

\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 34, + "end": 36, + "type": "body" + }, + "code": { + "start": 37, + "end": 49 + }, + "file": { + "path": "docs/tests/file-types/swift/test.swift", + "start": 1, + "end": 49 + } + } + } + ] + } + } + } + } +} diff --git a/tests/file-types/swift/test.swift b/tests/file-types/swift/test.swift index 56d27ea..1302442 100755 --- a/tests/file-types/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/run.test.js b/tests/run.test.js index decab0a..fca8ba4 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -30,6 +30,21 @@ addSuite('cases', async ({ paths, expected }) => { }) +addSuite('file-types', async ({ paths, expected }) => { + const actual = await map(paths, (files) => docs({ files, ...test_defaults })) + return () => { + for (let i = 0; i < paths.length; i++) { + test(`${i}: ${paths[i]}`, () => { + assert.deepStrictEqual( + actual[i], + expected[i] + ) + }) + } + } +}) + + addSuite('annotations', async ({ paths, expected }) => { const actual = await map(paths, (files) => docs({ files, raw: true, ...test_defaults })) From c9b28417d7e6fc1c67fe1d75c1b5aa49e1b0e254 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 2 Mar 2016 15:03:35 -0500 Subject: [PATCH 215/273] added a new function to the `to` util Also updated a couple exisiting functions --- app/utils/to.js | 59 +++++++++++++++++++++++++++++++------ tests/unit/utils/to.test.js | 27 ++++++++++++----- 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index 067912b..9ecd6f2 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -16,6 +16,21 @@ let to = { ...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 @@ -87,13 +102,36 @@ let to = { /// @name to.keys /// @description /// Converts an object to an array of it's values names. - /// @arg {object} + /// @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} - values(arg) { + /// @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 = [] - for (var key in arg) { - if (arg.hasOwnProperty(key)) { - values.push(arg[key]) + 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]]) } } @@ -424,7 +462,11 @@ let to = { /// Flattens an array, and arrays inside of it into a single array /// @arg {array} /// @returnes {array} - single dimensional - flatten: (arg) => is.array(arg) ? [].concat(...arg.map(to.flatten)) : arg, + // flatten: (arg) => is.array(arg) ? [].concat(...arg.map(to.flatten)) : arg, + flatten(...args) { + let _flatten = (arg) => is.array(arg) ? [].concat(...arg.map(_flatten)) : arg + return _flatten(args.map(_flatten)) + }, /// @name to.unique /// @description @@ -453,11 +495,10 @@ let to = { /// @arg {array, object} /// @returns {array, object} - The sorted version sort(arg, callback) { - let runSort = (obj) => is.fn(callback) ? obj.sort.apply(null, callback) : obj.sort() let result if (is.plainObject(arg)) { let sorted = {} - let keys = runSort(to.keys(arg)) + let keys = to.keys(arg).sort(callback) for (let i = 0, l = keys.length; i < l; i++) { sorted[keys[i]] = arg[keys[i]] @@ -465,7 +506,7 @@ let to = { result = sorted } else if (is.array(arg)) { - result = runSort(callback) + result = arg.sort(callback) } return result }, diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js index 47ec733..58a1fee 100644 --- a/tests/unit/utils/to.test.js +++ b/tests/unit/utils/to.test.js @@ -48,6 +48,16 @@ asyncSuite.wrap('to', () => { }) + test('to.type', () => { + assert.strictEqual(to.type(string), 'string') + assert.strictEqual(to.type(array), 'array') + assert.strictEqual(to.type(object), 'object') + assert.strictEqual(to.type(buffer), 'buffer') + assert.strictEqual(to.type(number), 'number') + assert.strictEqual(to.type(boolean), 'boolean') + }) + + test('to.keys', () => { const keys = to.keys(object) assert.strictEqual(keys[0], 'one', 'should return one') @@ -56,10 +66,9 @@ asyncSuite.wrap('to', () => { }) test('to.values', () => { - const values = to.values(object) - assert.strictEqual(values[0], 1) - assert.strictEqual(values[1], 2) - assert.strictEqual(values[2], 3) + assert.deepStrictEqual(to.values(object), [ 1, 2, 3 ]) + assert.deepStrictEqual(to.values(object, '!one'), [ 2, 3 ]) + assert.deepStrictEqual(to.values(object, 'one', 'two'), [ 1, 2 ]) }) @@ -203,16 +212,20 @@ asyncSuite.wrap('to', () => { test('to.sort', () => { - const actual = { + const acutal_object = { c: 1, b: 2, a: 3 } + const actual_array = [ 3, 2, 1 ] - assert.strictEqual(Object.keys(actual)[0], 'c', + assert.strictEqual(Object.keys(acutal_object)[0], 'c', 'c should be the first key in the object') - assert.strictEqual(Object.keys(to.sort(actual))[0], 'a', + assert.strictEqual(Object.keys(to.sort(acutal_object))[0], 'a', 'a should be the first key in the object after it\'s sorted') + + assert.strictEqual(actual_array[0], 3) + assert.strictEqual(to.sort(actual_array)[0], 1) }) From 2c06087a7599ab9dbc961e0cff3260621f63614b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 12:41:34 -0500 Subject: [PATCH 216/273] dependencies --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 22dbdd4..6040610 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "refresh": "rm -rf -- node_modules/ .tmp/ dist/ .nyc_output/ coverage/; npm i", "compile": "npm run clean; babel app/ -d dist/", "watch": "npm run clean; babel app/ -d dist/ --watch", - "mocha": "mocha --compilers js:babel-register --ui tdd --check-leaks --colors --delay", + "mocha": "mocha --compilers js:babel-register --ui tdd --check-leaks --colors --delay --bail", "unit-tests": "npm run mocha -- tests/unit/*.js tests/unit/**/*.js", "mock-tests": "npm run mocha -- tests/run.test.js", "test": "npm run unit-tests; npm run mock-tests", @@ -47,7 +47,7 @@ }, "dependencies": { "async-array-methods": "^2.1.0", - "babel-runtime": "^6.5.0", + "babel-runtime": "^6.6.1", "change-case": "^2.3.1", "clone": "^1.0.2", "clor": "^2.0.2", @@ -59,17 +59,17 @@ "marked": "^0.3.5" }, "devDependencies": { - "babel-cli": "^6.5.1", + "babel-cli": "^6.6.4", "babel-eslint": "^5.0.0", "babel-plugin-syntax-async-functions": "^6.5.0", "babel-plugin-transform-async-to-generator": "^6.5.0", - "babel-plugin-transform-regenerator": "^6.5.2", - "babel-plugin-transform-runtime": "^6.5.2", - "babel-preset-es2015": "^6.5.0", + "babel-plugin-transform-regenerator": "^6.6.0", + "babel-plugin-transform-runtime": "^6.6.0", + "babel-preset-es2015": "^6.6.0", "babel-preset-stage-0": "^6.5.0", - "babel-register": "^6.5.2", + "babel-register": "^6.6.0", "core-assert": "^0.1.3", - "coveralls": "^2.11.6", + "coveralls": "^2.11.8", "eslint": "^2.1.0", "eslint-plugin-babel": "^3.1.0", "mocha": "^2.4.5", From 5937f07ace52b1f336de5196470662db4352b343 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 12:42:46 -0500 Subject: [PATCH 217/273] Added documentation for the block info annotation --- app/annotations.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index c127142..0edb795 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -229,11 +229,38 @@ annotations.alias = { } + +/// @name blockinfo +/// @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 +/// } +/// } +/// ``` annotations.blockinfo = { autofill() { - let comment = this.comment - let code = this.code - let file = this.file + let obj = to.clone(this) + let comment = obj.comment + let code = obj.code + let file = obj.file delete comment.contents delete code.contents delete file.contents @@ -242,6 +269,10 @@ annotations.blockinfo = { delete file.comment return { comment, code, file } + }, + parse() { + this.log.emit('warning', "Passed @blockinfo, it's only supposed to be an autofilled annotation", logAnnotationError(this, '')) + return } } From 3e5b7c0fd179f62d7077f414c6b3bcd2ab546155 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 12:46:13 -0500 Subject: [PATCH 218/273] :bugfix: for the @page annotation --- app/annotations.js | 2 +- .../access/access.autofill.header.json | 4 +- tests/annotations/access/access.header.json | 4 +- tests/annotations/author/author.header.json | 4 +- tests/annotations/author/author.multiple.json | 4 +- .../depricated/depricated.header.json | 4 +- .../description/description.header.json | 4 +- tests/annotations/markdown/mark.json | 4 +- tests/annotations/markdown/markdown.json | 4 +- tests/annotations/markdown/md.json | 4 +- tests/annotations/markdown/mdml.json | 4 +- tests/annotations/markdown/mdown.json | 4 +- tests/annotations/markdown/mdtext.json | 4 +- tests/annotations/markdown/mdtxt.json | 4 +- tests/annotations/markdown/mdwn.json | 4 +- tests/annotations/markdown/mkd.json | 4 +- tests/annotations/markdown/mkdn.json | 4 +- tests/annotations/markdown/text.json | 4 +- .../page/page.header.autofill.json | 4 +- .../annotations/requires/requires.header.json | 4 +- tests/annotations/since/since.header.json | 4 +- tests/annotations/todo/todo.header.json | 4 +- tests/file-types/markdown/mdtxt.json | 184 ++++-------------- tests/file-types/markdown/mdtxt.mdtxt | 22 ++- tests/file-types/markdown/mkd.json | 184 ++++-------------- tests/file-types/markdown/mkd.mkd | 22 ++- 26 files changed, 168 insertions(+), 330 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 0edb795..186907f 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -615,7 +615,7 @@ annotations.page = { autofill() { // autofill header comments if (this.comment.type === 'header') { - return 'other' + return [ 'other' ] } // don't autofill body comments return diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json index f381782..6e4b82d 100644 --- a/tests/annotations/access/access.autofill.header.json +++ b/tests/annotations/access/access.autofill.header.json @@ -18,7 +18,9 @@ "end": 4 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/access/access.header.json b/tests/annotations/access/access.header.json index c232b93..1074d28 100644 --- a/tests/annotations/access/access.header.json +++ b/tests/annotations/access/access.header.json @@ -17,7 +17,9 @@ "end": 4 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json index c04c07b..33e0ed3 100644 --- a/tests/annotations/author/author.header.json +++ b/tests/annotations/author/author.header.json @@ -20,7 +20,9 @@ "end": 4 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index b13f296..fd71274 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -21,7 +21,9 @@ "end": 14 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [ { diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json index c16d9c8..6e716c4 100644 --- a/tests/annotations/depricated/depricated.header.json +++ b/tests/annotations/depricated/depricated.header.json @@ -21,7 +21,9 @@ "end": 7 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json index ff9071d..e7773a6 100644 --- a/tests/annotations/description/description.header.json +++ b/tests/annotations/description/description.header.json @@ -18,7 +18,9 @@ "end": 8 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index 551be93..14398b4 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 000d684..3ef294b 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index 3d26674..3d43ba6 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index 89a70e5..65fe6bc 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index 214fe1e..caad7ae 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index a2e044e..0600eee 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index aad83e1..b3b6e92 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index 78a83a0..40d17f2 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index 2d1fe82..cdc6f54 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index e8dfd56..437425e 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index fa52ac3..a92bced 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -18,7 +18,9 @@ "end": 13 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json index 3403902..5efe48f 100644 --- a/tests/annotations/page/page.header.autofill.json +++ b/tests/annotations/page/page.header.autofill.json @@ -18,7 +18,9 @@ "end": 4 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json index deda215..4ba7467 100644 --- a/tests/annotations/requires/requires.header.json +++ b/tests/annotations/requires/requires.header.json @@ -26,7 +26,9 @@ "end": 4 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json index e2fbf4e..06ccc72 100644 --- a/tests/annotations/since/since.header.json +++ b/tests/annotations/since/since.header.json @@ -21,7 +21,9 @@ "end": 7 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json index b61b776..82381a2 100644 --- a/tests/annotations/todo/todo.header.json +++ b/tests/annotations/todo/todo.header.json @@ -27,7 +27,9 @@ "end": 7 } }, - "page": "other" + "page": [ + "other" + ] }, "body": [] } diff --git a/tests/file-types/markdown/mdtxt.json b/tests/file-types/markdown/mdtxt.json index f54abe4..2d18726 100644 --- a/tests/file-types/markdown/mdtxt.json +++ b/tests/file-types/markdown/mdtxt.json @@ -1,160 +1,50 @@ { "nav": [ { - "title": "O", - "href": "/o", + "title": "Tests", + "href": "/tests", "body": [], - "subpages": [] - }, - { - "title": "T", - "href": "/t", - "body": [], - "subpages": [] - }, - { - "title": "H", - "href": "/h", - "body": [], - "subpages": [] - }, - { - "title": "E", - "href": "/e", - "body": [], - "subpages": [] - }, - { - "title": "R", - "href": "/r", - "body": [], - "subpages": [] + "subpages": [ + { + "title": "mdtxt", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] } ], "pages": { - "o": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", - "start": 1, - "end": 13 - } - } - }, - "body": [] - } - }, - "t": { + "tests": { "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", - "start": 1, - "end": 13 - } - } - }, - "body": [] - } - }, - "h": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", - "start": 1, - "end": 13 - } - } - }, - "body": [] - } - }, - "e": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", - "start": 1, - "end": 13 - } - } - }, + "header": {}, "body": [] - } - }, - "r": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", - "start": 1, - "end": 13 + }, + "markdown": { + "page": { + "header": { + "name": "mdtxt", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "start": 1, + "end": 21 + } } - } - }, - "body": [] + }, + "body": [] + } } } } diff --git a/tests/file-types/markdown/mdtxt.mdtxt b/tests/file-types/markdown/mdtxt.mdtxt index b0df59e..e9e4e0c 100644 --- a/tests/file-types/markdown/mdtxt.mdtxt +++ b/tests/file-types/markdown/mdtxt.mdtxt @@ -1,12 +1,20 @@ -# H1 Tag +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example ```scss -.foo { - .bar { - background: blue; - } -} +/// @name Name ``` diff --git a/tests/file-types/markdown/mkd.json b/tests/file-types/markdown/mkd.json index 4f4bb05..2519cac 100644 --- a/tests/file-types/markdown/mkd.json +++ b/tests/file-types/markdown/mkd.json @@ -1,160 +1,50 @@ { "nav": [ { - "title": "O", - "href": "/o", + "title": "Tests", + "href": "/tests", "body": [], - "subpages": [] - }, - { - "title": "T", - "href": "/t", - "body": [], - "subpages": [] - }, - { - "title": "H", - "href": "/h", - "body": [], - "subpages": [] - }, - { - "title": "E", - "href": "/e", - "body": [], - "subpages": [] - }, - { - "title": "R", - "href": "/r", - "body": [], - "subpages": [] + "subpages": [ + { + "title": "mkd", + "href": "/tests/markdown", + "body": [], + "subpages": [] + } + ] } ], "pages": { - "o": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mkd.mkd", - "start": 1, - "end": 13 - } - } - }, - "body": [] - } - }, - "t": { + "tests": { "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mkd.mkd", - "start": 1, - "end": 13 - } - } - }, - "body": [] - } - }, - "h": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mkd.mkd", - "start": 1, - "end": 13 - } - } - }, - "body": [] - } - }, - "e": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mkd.mkd", - "start": 1, - "end": 13 - } - } - }, + "header": {}, "body": [] - } - }, - "r": { - "page": { - "header": { - "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", - "blockinfo": { - "comment": { - "start": 1, - "end": 3, - "type": "header" - }, - "code": { - "start": -1, - "end": -1 - }, - "file": { - "path": "docs/tests/file-types/markdown/mkd.mkd", - "start": 1, - "end": 13 + }, + "markdown": { + "page": { + "header": { + "name": "mkd", + "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 5, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/markdown/mkd.mkd", + "start": 1, + "end": 21 + } } - } - }, - "body": [] + }, + "body": [] + } } } } diff --git a/tests/file-types/markdown/mkd.mkd b/tests/file-types/markdown/mkd.mkd index b0df59e..c579968 100644 --- a/tests/file-types/markdown/mkd.mkd +++ b/tests/file-types/markdown/mkd.mkd @@ -1,12 +1,20 @@ -# H1 Tag +## Default Annotations +### @name +Attribute | Value +---------------|---------------------------------------------------------- +Description | Name of the documented item +Multiple | false +Default | - +Aliases | - +Autofilled | - + +###### Example ```scss -.foo { - .bar { - background: blue; - } -} +/// @name Name ``` From 93019ab49ea8baee4eee569874a821f88fa239a1 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 12:48:36 -0500 Subject: [PATCH 219/273] Updated annotations api to have a single list function This change is to make things simpler when the resolve functions are added for the annotations --- app/annotation-api.js | 27 ++++++++++----------------- app/parser/parse-blocks.js | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/app/annotation-api.js b/app/annotation-api.js index 1262a05..a449c41 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -176,26 +176,25 @@ export default class AnnotationApi { /// 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) { + list(filetype, type) { + let list = this.annotations.default if (!is.undefined(this.annotations[filetype])) { - return to.extend(to.clone(this.annotations.default), this.annotations[filetype]) + list = to.extend(to.clone(this.annotations.default), this.annotations[filetype]) } - return this.annotations.default - } + if (is.undefined(type)) { + return list + } - autofillList(filetype) { - return to.map(this.list(filetype), (annotation, name) => { - if (is.truthy(annotation.autofill)) { - return { [name]: annotation.autofill } + return to.map(list, (annotation, name) => { + if (is.truthy(annotation[type])) { + return { [name]: annotation[type] } } return false }) } - resolve_list(filetype) {} // eslint-disable-line - /// @name run_annotation /// @access private /// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) @@ -257,13 +256,7 @@ export default class AnnotationApi { result.default = this.file_list.default[annotation.name].parse.call(result) } - result = annotations_list[annotation.name].parse.call(result) - - if (!is.fn(annotations_list[annotation.name].resolve)) { - return result - } - - return annotations_list[annotation.name].resolve.call(result) + return annotations_list[annotation.name].parse.call(result) } /// @name file_list diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index 6137e35..b1a2ed4 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -20,7 +20,7 @@ export default function parseBlocks({ let parsed_blocks = [] - let autofill_list = annotations.autofillList(file.type) + let autofill_list = annotations.list(file.type, 'autofill') // loop over each block for (let block of blocks) { From d80a1bd3152bdf88450c4871d307b73603397a54 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 12:50:10 -0500 Subject: [PATCH 220/273] :bugfix: getBlocks This bugfix was to ensure that if a user passes in `''` for the `comment.line` it won't actually match every line in the file --- app/parser/get-blocks.js | 52 ++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index bac68ca..1803881 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -18,16 +18,22 @@ export default function getBlocks({ let style = is.all.truthy(comment.start, comment.end) ? 'multi' : 'single' + // this ensures there aren't any errors looking comment lines + // because `''` will always have an index of `0` + if (comment.line === '') { + comment.line = undefined + } + let block_base = { comment: { contents: [], start: -1, end: -1, type: comment.type }, code: { contents: [], start: -1, end: -1 }, file } - let lines = to.array(contents) - let parsed = [] - let current_blank_lines = 0 - let block + let lines = to.array(contents) // lines of the file + let parsed = [] // holds the parsed blocks + let current_blank_lines = 0 // stores the current count of blank lines + let block // stores the current block let in_comment = false // used to determin that you are in a comment let in_code = false // used to determin if you are in the code after the comment block @@ -35,7 +41,23 @@ export default function getBlocks({ return [] } + // used for debuging files. to debug a file just change this to false + // @note THIS SHOULD NEVER BE COMMITTED AS `TRUE` + let debug_file = false + function debug(...args) { + if (debug_file && args.length > 0) { + console.log(...args) + } + return debug_file + } + for (let i = start_at, l = lines.length; i < l; i++) { + // If you're trying to debug something between specific lines you + // can use this to narrow down the longs to the lines you're wanting debug + // just pass in the starting line number and end line number both should be 1 + // less that what you're looking for since this is zero based. + // debug = is.between(i, [start line], [end line]) + debug_file = debug_file && is.between(i, 0, 8) let line = lines[i] let index = { start: style === 'multi' && is.in(line, comment.start) ? line.indexOf(comment.start) : false, @@ -43,13 +65,22 @@ export default function getBlocks({ end: style === 'multi' && is.in(line, comment.end) ? line.indexOf(comment.end) : false } + debug('') + debug('') + debug(`line ${i}:`) + debug(line) + debug('index:', index) + // a) The line isn't empty so parse it. if (!is.empty(line)) { + // reset the current blank line count back to 0 because this line wasn't empty current_blank_lines = 0 + // a) is the start and end style or there was an instance of a comment line if (style === 'multi' && (index.start !== false || in_comment) || index.line !== false) { // a) is the start of a new block - if (index.start !== false || style !== 'multi' && !in_comment) { + if (index.start !== false || (style !== 'multi' && !in_comment)) { + debug('start of new block') // reset code to false in_code = false @@ -74,13 +105,14 @@ export default function getBlocks({ in_comment = true } - // a) check for the end comment + // check for the end comment if ( block && style === 'multi' && block.comment.start !== i && index.end !== false ) { + debug('is end comment') in_comment = false block.comment.end = i // sets the end line in the comment block i++ // skips end comment line @@ -93,13 +125,19 @@ export default function getBlocks({ // a) removes the `comment.line` from the line. if (index.line !== false) { line = line.slice(index.line + comment.line.length) + } else if (index.start !== false) { + line = line.slice(index.start + comment.start.length) } - block.comment.contents.push(line) + if (!is.empty(line)) { + debug('line was pushed') + block.comment.contents.push(line) + } } // a) The last line in the file is a commment if (in_comment && (style === 'multi' && index.end !== false ? i === l : i === l - 1)) { + debug('the last line in the file is a comment') block.comment.end = style === 'multi' ? i - 1 : i parsed.push(block) break // ensures that the loop stops because it's the last line in the file From d7df9bae95f7da94d4713cc148d857ff7c1aa055 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 13:01:25 -0500 Subject: [PATCH 221/273] added `resolve` functionality This functionality allows annotations to have a resolve feature where annotations can resolve them selves before the data is returned --- app/config.js | 8 ++++++++ app/docs.js | 1 + app/parser/index.js | 11 ++++++++++- app/parser/parse-blocks.js | 15 ++++++++++++--- app/parser/resolve.js | 26 ++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 app/parser/resolve.js diff --git a/app/config.js b/app/config.js index d57df95..45bab62 100644 --- a/app/config.js +++ b/app/config.js @@ -28,6 +28,14 @@ export const default_options = { timestamps: true, raw: false, // this will return the raw data by file, aka data won't be sorted annotations + // this is used to sort the annotations to be in a specific order after + // the block has been parsed initial and before the the resolve functions run + // for each annotation. You can manipulate this list to ensure that a specific + // annotation resolves before another one does, this is used in the event that + // one annotation depends on another annotation to be resolved first + sort(a, b) { + return a.localeCompare(b) // same as the default sort function + }, } export const default_comment = { diff --git a/app/docs.js b/app/docs.js index 9776d5f..ef7858d 100644 --- a/app/docs.js +++ b/app/docs.js @@ -34,6 +34,7 @@ export default async function docs(options = {}) { warning, timestamps, raw, + sort, annotations, comments, } = options diff --git a/app/parser/index.js b/app/parser/index.js index d180795..84d2e3d 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -4,7 +4,14 @@ import getBlocks from './get-blocks' import parseBlocks from './parse-blocks' import replaceAliases from './replace-aliases' -export default async function parser({ file_path, comments, annotations, blank_lines, log }) { +export default async function parser({ + file_path, + comments, + annotations, + blank_lines, + sort, + log +}) { // the filetype of the current file let type = path.extname(file_path).replace('.', '') @@ -65,6 +72,7 @@ export default async function parser({ file_path, comments, annotations, blank_l blocks: header, annotations, comment, + sort, log })[0] || {} @@ -73,6 +81,7 @@ export default async function parser({ file_path, comments, annotations, blank_l blocks: body, annotations, comment, + sort, log }) diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index b1a2ed4..0577016 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -1,5 +1,6 @@ import { is, to } from '../utils' import autofill from './autofill' +import resolve from './resolve' // @name parsed_blocks // @access private @@ -12,6 +13,7 @@ export default function parseBlocks({ blocks, annotations, comment, + sort, log }) { if (is.empty(blocks)) { @@ -21,6 +23,12 @@ export default function parseBlocks({ let parsed_blocks = [] let autofill_list = annotations.list(file.type, 'autofill') + // sort the parsed object before the annotations are resolved + if (is.fn(sort)) { + resolve_list = to.sort(resolve_list, sort) + } + + let resolve_list = annotations.list(file.type, 'resolve') // loop over each block for (let block of blocks) { @@ -35,12 +43,13 @@ export default function parseBlocks({ log }) + // run the autofill functions for all the annotations that have a autofill function parsed = autofill({ autofill_list, parsed, block, log }) if (!is.empty(parsed)) { - parsed_blocks.push({ - ...parsed - }) + // run the resolve function for all the annotations that have a resolve function + parsed = resolve({ resolve_list, parsed, block, log }) + parsed_blocks.push(parsed) } } // end blocks loop diff --git a/app/parser/resolve.js b/app/parser/resolve.js new file mode 100644 index 0000000..ba92662 --- /dev/null +++ b/app/parser/resolve.js @@ -0,0 +1,26 @@ +import { is, to } from '../utils' + +// @name autofill +// @access private +// @description +// This function is used to run the all the functions that autofill if not defined. +export default function resolve(options) { + let { resolve_list, parsed, block, log } = options + + let parsed_keys = to.keys(parsed) + + for (let [ annotation, annotation_resolve ] of to.entries(resolve_list)) { + if (is.in(parsed_keys, annotation)) { + let result = annotation_resolve + if (is.fn(annotation_resolve)) { + result = annotation_resolve.call(parsed[annotation], { parsed, block, log }) + } + + if (result != null) { + parsed[annotation] = result + } + } + } + + return parsed +} From 8096837d58ce1aea5c19535c155acaac682f0677 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 13:03:58 -0500 Subject: [PATCH 222/273] Updated the @markup annotation, and test cases The update to the test cases reflect the changes to `@markup` --- app/annotations.js | 18 ++++++++++++++++-- ...space-between-header-and-body-comments.json | 4 +++- tests/cases/only-comments.json | 4 +++- tests/cases/preserves-blank-lines.json | 6 ++++-- tests/cases/single-body-comment.json | 4 +++- .../cases/space-between-comment-and-code.json | 4 +++- tests/cases/starts-and-ends-with-spaces.json | 4 +++- tests/file-types/js/test.json | 8 +++++--- tests/file-types/less/test.json | 12 +++++++++--- tests/file-types/scss/test.json | 4 +++- 10 files changed, 52 insertions(+), 16 deletions(-) diff --git a/app/annotations.js b/app/annotations.js index 186907f..674d73c 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -491,7 +491,7 @@ annotations.markup = { } let [ - id = '0', + id = null, language = this.file.type, settings = {}, description @@ -508,6 +508,10 @@ annotations.markup = { ) .join('\n') + const state_interpolation = /\s*\{@states?[^\}]*\}\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('='))) } @@ -519,9 +523,19 @@ annotations.markup = { settings, description: markdown(description), raw, - escaped + escaped, + raw_stateless, + escaped_stateless, } ] + }, + resolve() { + return this.map((obj, i) => { + if (obj.id === null) { + obj.id = `${i}` + } + return obj + }) } } diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index 6c592c5..5fd5f66 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -50,7 +50,9 @@ }, "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}" + "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}" } ], "access": "public", diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json index ef3a4b0..5792b59 100644 --- a/tests/cases/only-comments.json +++ b/tests/cases/only-comments.json @@ -57,7 +57,9 @@ }, "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}" + "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}" } ], "access": "public", diff --git a/tests/cases/preserves-blank-lines.json b/tests/cases/preserves-blank-lines.json index 2236212..be9d9ba 100644 --- a/tests/cases/preserves-blank-lines.json +++ b/tests/cases/preserves-blank-lines.json @@ -25,8 +25,10 @@ "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": "Button (a.button)\n\n", + "escaped": "<a href="#" class="c-btn @state">Button (a.button)</a>\n<button class="c-btn @state">Button (button)</button>\n<input class="c-btn @state" type="button" value="Button (input.button)">", + "raw_stateless": "Button (a.button)\n\n", + "escaped_stateless": "<a href="#" class="c-btn @state">Button (a.button)</a>\n<button class="c-btn @state">Button (button)</button>\n<input class="c-btn @state" type="button" value="Button (input.button)">" } ], "access": "public", diff --git a/tests/cases/single-body-comment.json b/tests/cases/single-body-comment.json index 4311da1..408e382 100644 --- a/tests/cases/single-body-comment.json +++ b/tests/cases/single-body-comment.json @@ -32,7 +32,9 @@ }, "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}" + "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}" } ], "access": "public", diff --git a/tests/cases/space-between-comment-and-code.json b/tests/cases/space-between-comment-and-code.json index bac0fe1..f6c91d1 100644 --- a/tests/cases/space-between-comment-and-code.json +++ b/tests/cases/space-between-comment-and-code.json @@ -35,7 +35,9 @@ }, "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}" + "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}" } ], "access": "public", diff --git a/tests/cases/starts-and-ends-with-spaces.json b/tests/cases/starts-and-ends-with-spaces.json index 333825e..bfabfe9 100644 --- a/tests/cases/starts-and-ends-with-spaces.json +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -32,7 +32,9 @@ }, "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}" + "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}" } ], "access": "public", diff --git a/tests/file-types/js/test.json b/tests/file-types/js/test.json index 12593ca..e18e8f6 100644 --- a/tests/file-types/js/test.json +++ b/tests/file-types/js/test.json @@ -53,7 +53,7 @@ { "name": "@author", "alias": [ - "@author" + "@authors" ], "description": "

Author of the documented item

\n", "returns": { @@ -68,8 +68,10 @@ "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": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two", + "escaped": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two", + "raw_stateless": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two", + "escaped_stateless": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two" } ], "access": "public", diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json index d62ad97..4830131 100644 --- a/tests/file-types/less/test.json +++ b/tests/file-types/less/test.json @@ -71,7 +71,9 @@ "settings": {}, "description": "", "raw": "\\@name", - "escaped": "\\@name" + "escaped": "\\@name", + "raw_stateless": "\\@name", + "escaped_stateless": "\\@name" } ], "access": "public", @@ -102,7 +104,9 @@ "settings": {}, "description": "", "raw": "", - "escaped": "<nav>\n <a href="">One</a>\n <a href="">Two</a>\n <a href="">Three</a>\n</nav>" + "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>" } ], "access": "public", @@ -143,7 +147,9 @@ "settings": {}, "description": "", "raw": ".foo {\n .opacity(.3);\n}", - "escaped": ".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}" } ], "access": "public", diff --git a/tests/file-types/scss/test.json b/tests/file-types/scss/test.json index 7e94aec..c9e20a6 100644 --- a/tests/file-types/scss/test.json +++ b/tests/file-types/scss/test.json @@ -112,7 +112,9 @@ }, "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}" + "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}" } ], "access": "public", From 6a9b4665c9605ddcbeb7c1fd7467b239abc4350d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 13:05:53 -0500 Subject: [PATCH 223/273] Simplified the `only-body-comments` test This test was to complex for the purpose of the test. It had @state and @markup which have the potential to change constantly because of their complexity. --- tests/cases/only-body-comments.json | 120 +--------------------------- tests/cases/only-body-comments.scss | 35 -------- 2 files changed, 4 insertions(+), 151 deletions(-) diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index fc35bb8..51126bf 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -29,133 +29,21 @@ "Tyler Benton" ], "description": "

Your standard form button.

\n", - "state": [ - { - "markup_id": "0", - "states": [ - { - "state": ":hover", - "state_id": "0", - "description": "" - }, - { - "state": ":active", - "state_id": "1", - "description": "" - }, - { - "state": ":disabled", - "state_id": "2", - "description": "

Dims the button when disabled.

\n" - }, - { - "state": ".c-btn--mini", - "state_id": "3", - "description": "

A mini button

\n" - }, - { - "state": ".c-btn--tiny", - "state_id": "4", - "description": "

A tiny button

\n" - }, - { - "state": ".c-btn--medium", - "state_id": "5", - "description": "

A medium button

\n" - }, - { - "state": ".c-btn--large", - "state_id": "6", - "description": "

A large button

\n" - }, - { - "state": ".c-btn--primary", - "state_id": "7", - "description": "

Primary action

\n" - }, - { - "state": ".c-btn--primary:hover", - "state_id": "8", - "description": "" - }, - { - "state": ".c-btn--primary:active", - "state_id": "9", - "description": "" - }, - { - "state": ".c-btn--secondary", - "state_id": "10", - "description": "

Secondary action

\n" - }, - { - "state": ".c-btn--secondary:hover", - "state_id": "11", - "description": "" - }, - { - "state": ".c-btn--secondary:active", - "state_id": "12", - "description": "" - }, - { - "state": ".c-btn--tertiary", - "state_id": "13", - "description": "

Tertiary action

\n" - }, - { - "state": ".c-btn--tertiary:hover", - "state_id": "14", - "description": "" - }, - { - "state": ".c-btn--tertiary:active", - "state_id": "15", - "description": "" - }, - { - "state": ".c-btn--text", - "state_id": "16", - "description": "

It's a text link as a button

\n" - }, - { - "state": ".c-btn--text:hover", - "state_id": "17", - "description": "" - }, - { - "state": ".c-btn--text:active", - "state_id": "18", - "description": "" - } - ] - } - ], - "markup": [ - { - "id": "0", - "language": "scss", - "settings": {}, - "description": "", - "raw": "
\n Button (a.button)\n \n \n
", - "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn @state">Button (a.button)</a>\n <button class="c-btn @state">Button (button)</button>\n <input class="c-btn @state" type="button" value="Button (input.button)">\n</div>" - } - ], "access": "public", "blockinfo": { "comment": { "start": 1, - "end": 32, + "end": 4, "type": "body" }, "code": { - "start": 33, - "end": 33 + "start": 5, + "end": 5 }, "file": { "path": "docs/tests/cases/only-body-comments.scss", "start": 1, - "end": 54 + "end": 19 } } } diff --git a/tests/cases/only-body-comments.scss b/tests/cases/only-body-comments.scss index 813669b..e40ea51 100644 --- a/tests/cases/only-body-comments.scss +++ b/tests/cases/only-body-comments.scss @@ -2,45 +2,10 @@ /// @page components/buttons /// /// @description Your standard form button. -/// -/// @state -/// {:hover} -/// {:active} -/// {:disabled} - Dims the button when disabled. -/// {.c-btn--mini} - A mini button -/// {.c-btn--tiny} - A tiny button -/// {.c-btn--medium} - A medium button -/// {.c-btn--large} - A large button -/// {.c-btn--primary} - Primary action -/// {.c-btn--primary:hover} -/// {.c-btn--primary:active} -/// {.c-btn--secondary} - Secondary action -/// {.c-btn--secondary:hover} -/// {.c-btn--secondary:active} -/// {.c-btn--tertiary} - Tertiary action -/// {.c-btn--tertiary:hover} -/// {.c-btn--tertiary:active} -/// {.c-btn--text} - It's a text link as a button -/// {.c-btn--text:hover} -/// {.c-btn--text:active} -/// -/// @markup -///
-/// Button (a.button) -/// -/// -///
/// @name Button group /// @description /// Used when there's a group of buttons that need to be on the same line. -/// -/// @markup -///
-/// Button (a.button) -/// -/// -///
/// @name Test /// @state .state-1 From 36c639b757063aff3ed71a581279a803076b8131 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 13:06:33 -0500 Subject: [PATCH 224/273] added more comments to the config file --- app/config.js | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/app/config.js b/app/config.js index 45bab62..9e7e685 100644 --- a/app/config.js +++ b/app/config.js @@ -9,7 +9,10 @@ let log = new Logger() // changed by `options` key export const default_options = { config: `${info.root}/.docsfile.js`, - files: [ 'app/**/*', 'src/**/*', '*.md' ], // files to search + + // files to parse for documentation + files: [ 'app/**/*', 'src/**/*', '*.md' ], + // files to be ignored ignore: [ '.*', // all dot files @@ -18,16 +21,24 @@ export const default_options = { 'tests/', 'coverage/' // unit tests and coverage results ], page_fallback: 'general', // used if `@page` isn't defined + // add gitignore files to the ignore list. Depending on ignored files it // could cause things to ge parsed slower, that's why it's defaulted to `false` gitignore: false, - changed: true, // determins if only changed files should be parsed or not - blank_lines: 4, // @todo this stops the current block from adding lines if there're `n` blank line lines between code, and starts a new block. + + // determins if only changed files should be parsed or not + changed: true, + + // this stops the current block from adding lines if there're `n` + // blank line lines between code, and starts a new block. + blank_lines: 4, debug: true, warning: true, timestamps: true, - raw: false, // this will return the raw data by file, aka data won't be sorted - annotations + + // this will return the raw data by file, aka data won't be sorted + raw: false, + // this is used to sort the annotations to be in a specific order after // the block has been parsed initial and before the the resolve functions run // for each annotation. You can manipulate this list to ensure that a specific @@ -36,6 +47,9 @@ export const default_options = { sort(a, b) { return a.localeCompare(b) // same as the default sort function }, + + // default annotation list + annotations, } export const default_comment = { @@ -44,7 +58,15 @@ export const default_comment = { // file level comment block identifier header: { start: '////', line: '///', end: '////', type: 'header' }, // block level comment block identifier - body: { start: '', line: '///', end: '', type: 'body' } + body: { start: '', line: '///', end: '', type: 'body' }, + // this is used for any interpolations that might occur in + // annotations. I don't see this needing to change but just incase + // I'm making it a setting. + // @note {10} This setting is used to create a RegExp so certain characters need to be escaped + interpolation: { + start: '\${', + end: '}' + }, } // some defaults for common languages @@ -59,16 +81,16 @@ export const comments = { body: { line: '##' } }, 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { - header: { start: '' }, - body: { start: '' } + header: { start: '' }, + body: { start: '' } }, jade: { header: { start: '//-//', line: '//-/', end: '//-//' }, body: { line: '//-/' } }, cfm: { - header: { start: '' }, - body: { start: '' } + header: { start: '' }, + body: { start: '' } } } @@ -148,6 +170,7 @@ export function parseComments(comments) { } } + // extend any languages that have the extend option for (let [ lang, value ] of to.entries(parsed_comments)) { if ( lang !== '_' && From 686fdebebb77539921a116bdfb834caa088ebff4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 18:36:11 -0500 Subject: [PATCH 225/273] update the `to` util This update addes documentation to a few functions that didn't have it, also adds a few functions, along with updated tests --- app/annotation-api.js | 4 +- app/utils/to.js | 73 +++++++++++++++++++++++++------------ tests/unit/utils/to.test.js | 46 +++++++++++++++++++++++ 3 files changed, 97 insertions(+), 26 deletions(-) diff --git a/app/annotation-api.js b/app/annotation-api.js index a449c41..1f67c85 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -186,8 +186,8 @@ export default class AnnotationApi { return list } - return to.map(list, (annotation, name) => { - if (is.truthy(annotation[type])) { + return to.map(list, ({ key: name, value: annotation }) => { + if (is.truthy(annotation[type]) && !is.empty(annotation[type])) { return { [name]: annotation[type] } } diff --git a/app/utils/to.js b/app/utils/to.js index 9ecd6f2..9500644 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -188,7 +188,7 @@ let to = { let key = keys[index] index++ return { - value: [ key, obj[key] ] + value: [ key, obj[key], index - 1 ] } } @@ -494,32 +494,35 @@ let to = { /// 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 result - if (is.plainObject(arg)) { - let sorted = {} - let keys = to.keys(arg).sort(callback) + sort(obj, callback) { + if (is.array(obj)) { + return obj.sort(callback) + } - for (let i = 0, l = keys.length; i < l; i++) { - sorted[keys[i]] = arg[keys[i]] - } + let sorted = {} + let keys = to.keys(obj).sort(callback) - result = sorted - } else if (is.array(arg)) { - result = arg.sort(callback) + for (let i = 0, l = keys.length; i < l; i++) { + sorted[keys[i]] = obj[keys[i]] } - return result + + return sorted }, - map(arg, callback) { - if (is.array(arg)) { - return arg.map.apply(null, callback) + /// @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, this_arg) { + if (is.array(obj)) { + return obj.map(callback, this_arg) } let result = {} - for (let [ key, value ] of to.entries(arg)) { - let cb_result = callback(value, key) + for (let [ key, value, i ] of to.entries(obj)) { + let cb_result = callback({ key, value }, i, obj) if (is.truthy(cb_result) && !is.empty(cb_result) && is.plainObject(cb_result)) { to.extend(result, cb_result) } @@ -528,16 +531,38 @@ let to = { return result }, - filter(arg, callback) { - if (is.array(arg)) { - return arg.filter.apply(null, callback) + /// @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 + /// @returns {array, object} that was filtered + filter(obj, callback, this_arg = null) { + if (is.array(obj)) { + return obj.filter(callback, this_arg) } let result = {} - for (let [ key, value ] of to.entries(arg)) { - if (is.truthy(callback(value, key, arg))) { - to.extend(result, { key: value }) + for (let [ key, value, i ] of to.entries(obj)) { + if (is.truthy(callback.call(this_arg, { key, value }, i, obj))) { + to.extend(result, { [key]: value }) } } diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js index 58a1fee..a2fe21c 100644 --- a/tests/unit/utils/to.test.js +++ b/tests/unit/utils/to.test.js @@ -158,6 +158,52 @@ asyncSuite.wrap('to', () => { 'a.foo.quux.garply.waldo should be an array') }) + test('to.filter', () => { + assert.deepStrictEqual( + to.filter(array, (obj) => obj !== 'one'), + [ 'two', 'three' ] + ) + assert.deepStrictEqual( + to.filter(array, (obj) => obj !== 'two'), + [ 'one', 'three' ] + ) + assert.deepStrictEqual( + to.filter(object, ({ key }) => key !== 'one'), + { two: 2, three: 3 } + ) + assert.deepStrictEqual( + to.filter(object, ({ value }) => value !== 1), + { two: 2, three: 3 } + ) + }) + + test('to.map', () => { + assert.deepStrictEqual( + to.map(array, (item) => item + ' test'), + [ 'one test', 'two test', 'three test' ] + ) + assert.deepStrictEqual( + to.map(object, ({ key, value }) => { + return { [`${key} test`]: value } + }), + { 'one test': 1, 'two test': 2, 'three test': 3 } + ) + }) + + test('to.reduce', () => { + assert.deepStrictEqual( + to.reduce([ object, object, object ], (previous, next) => to.extend(previous, next), {}), + object + ) + + assert.deepStrictEqual( + to.reduce(object, (previous, { key }) => { + return [ ...previous, key ] + }, []), + array + ) + }) + test('to.object', async () => { try { From 538c17c98212661102a2d1bab91ea57bf3a8be20 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 18:53:55 -0500 Subject: [PATCH 226/273] :bugfix: replaceAliases This update is to make replacing aliases more efficent, and accurate --- app/parser/get-blocks.js | 3 +-- app/parser/index.js | 26 ++++++++++++------------- app/parser/parse-blocks.js | 3 +-- app/parser/replace-aliases.js | 36 ++++++++++++++++++++--------------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index 1803881..0f36285 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -8,7 +8,6 @@ import { is, to } from '../utils' /// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. export default function getBlocks({ file, - contents, comment, restrict = true, blank_lines, @@ -30,7 +29,7 @@ export default function getBlocks({ file } - let lines = to.array(contents) // lines of the file + let lines = to.array(file.contents) // lines of the file let parsed = [] // holds the parsed blocks let current_blank_lines = 0 // stores the current count of blank lines let block // stores the current block diff --git a/app/parser/index.js b/app/parser/index.js index 84d2e3d..5cba45c 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -18,14 +18,7 @@ export default async function parser({ // gets the comments to use on this file let comment = comments[type] ? comments[type] : comments._ - let contents = to.normalString(await fs.readFile(file_path)) - - contents = replaceAliases({ - contents, - annotations: annotations.list(type), - comment, - log - }) + let contents = '\n' + to.normalString(await fs.readFile(file_path)) let file = { contents, // all of the contents of the file @@ -34,13 +27,22 @@ export default async function parser({ type, // filetype of the file comment, start: 1, // starting point of the file - end: to.array(contents).length // ending point of the file + end: to.array(contents).length - 1 // ending point of the file } + file.contents = replaceAliases({ + file, + annotations, + comment, + log + }) + + + // a) The file doesn't contain any header level comments, or body level comments if ( !is.any.in( - contents, + file.contents, ...to.values(comment.header).slice(0, -1), ...to.values(comment.body).slice(0, -1) ) @@ -49,18 +51,14 @@ export default async function parser({ return [] } - contents = '\n' + contents - let header = getBlocks({ file, - contents, blank_lines, comment: comment.header }) let body = getBlocks({ file, - contents, blank_lines, comment: comment.body, restrict: false, diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index 0577016..03cf8a3 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -23,13 +23,12 @@ export default function parseBlocks({ let parsed_blocks = [] let autofill_list = annotations.list(file.type, 'autofill') + let resolve_list = annotations.list(file.type, 'resolve') // sort the parsed object before the annotations are resolved if (is.fn(sort)) { resolve_list = to.sort(resolve_list, sort) } - let resolve_list = annotations.list(file.type, 'resolve') - // loop over each block for (let block of blocks) { block.comment.contents = to.normalize(block.comment.contents) diff --git a/app/parser/replace-aliases.js b/app/parser/replace-aliases.js index 5c84acd..4644a33 100644 --- a/app/parser/replace-aliases.js +++ b/app/parser/replace-aliases.js @@ -6,25 +6,31 @@ import { is, to } from '../utils' /// This function is used to replace all instances of aliases in a file /// @returns {string} - The file with the instances of aliases removed export default function aliases(options = {}) { - let { contents, annotations, comment } = options /* , log */ + let { file, annotations, comment } = options /* , log */ - let main_annotation_list = to.keys(annotations) + let main_annotation_list = to.keys(annotations.list(file.type)) - annotations = to.map(annotations, (annotation, name) => { - if (is.truthy(annotation.alias) && !is.empty(annotation.alias)) { - return { [name]: annotation.alias } - } + let comment_types = [ + to.values(comment.header, '!type', '!end'), + to.values(comment.body, '!type', '!end') + ] - return false - }) + comment_types = to.flatten(comment_types) + .filter(Boolean) + .map((comment_type) => '\\' + comment_type.split('').join('\\')) + comment_types = `(?:${comment_types.join('|')})` + let block_comment = `(?:^(?:\\s*${comment_types})?\\s*)` + let inline_comment = `(?:${comment_types}?${comment.inline_prefix}\\s+)` + let comment_regex = `((?:${block_comment}|${inline_comment})${comment.prefix})` - for (let [ annotation, alias_list ] of to.entries(annotations)) { - // filter out any aliases that are already in the main annotation list - alias_list = alias_list.filter((alias) => !is.in(main_annotation_list, alias)) + let alias_obj = to.reduce(annotations.list(file.type, 'alias'), (previous, { key, value }) => { + value = value + .filter((alias) => !is.in(main_annotation_list, alias)) + .reduce((a, b) => to.extend(a, { [b]: key }), {}) + return to.extend(previous, value) + }, {}) - const alias_list_regex = new RegExp(`(?:${comment.prefix})(${alias_list.join('|')})\\b`, 'g') - contents = contents.replace(alias_list_regex, comment.prefix + annotation + ' ') - } + const alias_list_regex = new RegExp(`${comment_regex}(${to.keys(alias_obj).join('|')})\\b`, 'gm') - return contents + return file.contents.replace(alias_list_regex, (match, comment_match, alias) => comment_match + alias_obj[alias]) } From 54932ef19e3275f40cc403a5d3f3074930f80021 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 3 Mar 2016 19:24:47 -0500 Subject: [PATCH 227/273] updated @state to be awesome --- app/annotations.js | 184 ++++++++++--- ...e-markup-blocks-with-different-states.json | 116 ++++++++ ...e-markup-blocks-with-different-states.scss | 26 ++ .../state/state-multiple-markup-blocks.json | 82 ++++++ .../state/state-multiple-markup-blocks.scss | 23 ++ ...ltiple-stupid-simple-with-description.json | 254 ++++++++++++++++++ ...ltiple-stupid-simple-with-description.scss | 73 +++++ ...multiple-stupid-simple-with-notations.json | 254 ++++++++++++++++++ ...multiple-stupid-simple-with-notations.scss | 73 +++++ .../state/state-multiple-stupid-simple.json | 88 ++++++ .../state/state-multiple-stupid-simple.scss | 23 ++ .../state-stupid-simple-with-description.json | 158 +++++++++++ .../state-stupid-simple-with-description.scss | 42 +++ .../state-stupid-simple-with-notations.json | 158 +++++++++++ .../state-stupid-simple-with-notations.scss | 43 +++ .../state/state-stupid-simple.json | 56 ++++ .../state/state-stupid-simple.scss | 13 + tests/annotations/state/state.js | 0 tests/annotations/state/state.json | 4 - 19 files changed, 1630 insertions(+), 40 deletions(-) create mode 100644 tests/annotations/state/state-multiple-markup-blocks-with-different-states.json create mode 100644 tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss create mode 100644 tests/annotations/state/state-multiple-markup-blocks.json create mode 100644 tests/annotations/state/state-multiple-markup-blocks.scss create mode 100644 tests/annotations/state/state-multiple-stupid-simple-with-description.json create mode 100644 tests/annotations/state/state-multiple-stupid-simple-with-description.scss create mode 100644 tests/annotations/state/state-multiple-stupid-simple-with-notations.json create mode 100644 tests/annotations/state/state-multiple-stupid-simple-with-notations.scss create mode 100644 tests/annotations/state/state-multiple-stupid-simple.json create mode 100644 tests/annotations/state/state-multiple-stupid-simple.scss create mode 100644 tests/annotations/state/state-stupid-simple-with-description.json create mode 100644 tests/annotations/state/state-stupid-simple-with-description.scss create mode 100644 tests/annotations/state/state-stupid-simple-with-notations.json create mode 100644 tests/annotations/state/state-stupid-simple-with-notations.scss create mode 100644 tests/annotations/state/state-stupid-simple.json create mode 100644 tests/annotations/state/state-stupid-simple.scss delete mode 100644 tests/annotations/state/state.js delete mode 100644 tests/annotations/state/state.json diff --git a/app/annotations.js b/app/annotations.js index 674d73c..8933ab4 100644 --- a/app/annotations.js +++ b/app/annotations.js @@ -508,7 +508,8 @@ annotations.markup = { ) .join('\n') - const state_interpolation = /\s*\{@states?[^\}]*\}\s*/gi + // @todo {10} update this use use the user defined options + const state_interpolation = /\s*\${@states?[^\}]*\}\s*/gi let raw_stateless = raw.replace(state_interpolation, '') let escaped_stateless = escaped.replace(state_interpolation, '') @@ -516,18 +517,21 @@ annotations.markup = { settings = to.object(list(settings).map((setting) => setting.split('='))) } - return [ - { - id, - language, - settings, - description: markdown(description), - raw, - escaped, - raw_stateless, - escaped_stateless, - } - ] + + let result = { + id, + language, + settings, + description: markdown(description), + raw, + escaped, + raw_stateless, + escaped_stateless, + } + + Object.defineProperty(result, '__details', { __proto__: null, value: this }) + + return [ result ] }, resolve() { return this.map((obj, i) => { @@ -752,44 +756,152 @@ annotations.since = { } } -/// @name @state +/// @name @states +/// @alias @state /// @page annotations /// @description A state of a the documented item /// @returns {hashmap} +/// @note {10} This annotation must be used with @markup /// @markup Usage -/// /// @states (id) {state} [state_id] - description +/// /// @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 /// -/// /// @states (id) {state} [state_id] - description -/// /// @states (id) {state} [state_id] - description -/// /// @states (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 -annotations.state = { +annotations.states = { + alias: [ 'state' ], parse() { - let states = this.annotation.contents.split('\n') - let [ markup_id = '0', state_line ] = regex('state_id', this.annotation.line) - states.unshift(state_line) + let [ markup_id = null, state_line ] = regex('state_id', this.annotation.line) + let state = [ state_line, ...to.array(this.annotation.contents) ].filter(Boolean) - states = states.filter(Boolean).map((line, i) => { - let [ state = '', state_id = `${i}`, description = '' ] = regex('state', line) + state = state.reduce((previous, current, i) => { + let [ state = '', id = `${i}`, description = '' ] = regex('state', current) // eslint-disable-line + return to.extend(previous, { + [id]: { state, description: markdown(description) } + }) + }, {}) - return { - state, - state_id, - description: markdown(description) - } - }) + Object.defineProperty(state, '__details', { __proto__: null, value: this }) - return [ - { markup_id, states } - ] + return [ { markup_id, state } ] }, - // resolve() { - // /// @todo {10} - add code to that adds the markup code for this stuff. - // } + resolve({ parsed, block, log }) { + return this.reduce((previous, { markup_id, state }) => { + let markup + let start_at = state.__details.annotation.start + + // throw an error because a state should always be accompanied by a `@markup` block + if (!parsed.markup) { + log.emit('error', "There's no instance of a '@markup' annotation") + } else if (is.falsy(markup_id)) { + markup = findMarkupAfter(parsed.markup, start_at) + markup_id = markup.id + + if (!markup) { + log.emit('error', to.normalize(` + There's no instance of a '@markup' annotation after line ${block.comment.start + start_at} + in ${block.file.path} + `)) + } + } else { + markup = findMarkupById(parsed.markup, markup_id) + if (!markup) { + log.emit('error', to.normalize(` + There's no instance of a '@markup' annotation with an id of ${markup_id} + in ${block.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) + to.extend(_state, _state[to.keys(_state)[0]]) + markup.raw = replaceStates(markup.raw, _state) + markup.escaped = replaceStates(markup.escaped, _state) + + return to.merge(previous, { + [markup_id]: [ { state, markup } ] + }) + }, {}) + + + function replaceStates(str, states) { + // @todo {5} - Update this to use language settings + // - annotation name and it's aliases + // - interpolation + // - annotation prefix + // const state_interpolation = new RegExp(`${settings.interpolation.start}${settings.annotation.prefix}etc....`, 'gi') + const state_interpolation = /\${@(?:state|states)[^\}]*\}/g + return str.replace(state_interpolation, (original_match) => { + let match = original_match.replace(/\${@(?:states|state)|}/g, '').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] + } + + return states[clean(match)] + }) + } + + 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 markup_block of markup) { + if (start_at < markup_block.__details.annotation.start) { + return markup_block + } + } + return + } + } } /// @name @throws diff --git a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json new file mode 100644 index 0000000..fc7fcd6 --- /dev/null +++ b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json @@ -0,0 +1,116 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Hover state for example 1

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

Example 1

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

Focus state for example 1

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

Example 1

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

Hover state for example 2

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

Example 2

\n", + "raw": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", + "escaped": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "

Focus state for example 2

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

Example 2

\n", + "raw": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", + "escaped": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "

Example 1

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

Example 2

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

Some super awesome description for the hover state

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

Example 1

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

Some super awesome description for the focus state

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

Example 1

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

Example 1

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

Example 2

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

Some super awesome description for the hover state

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

Some super awesome description for the hover state

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

Some super awesome description for the hover state

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

Some super awesome description for the focus state

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

Some super awesome description for the focus state

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

Some super awesome description for the focus state

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

Some super awesome description for the active state

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

Some super awesome description for the active state

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

Some super awesome description for the active state

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

Some super awesome description for the hover state

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

Some super awesome description for the hover state

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

Some super awesome description for the hover state

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

Some super awesome description for the focus state

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

Some super awesome description for the focus state

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

Some super awesome description for the focus state

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

Some super awesome description for the active state

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

Some super awesome description for the active state

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

Some super awesome description for the active state

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

Some super awesome description for the hover state

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

Some super awesome description for the hover state

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

Some super awesome description for the hover state

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

Some super awesome description for the focus state

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

Some super awesome description for the focus state

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

Some super awesome description for the focus state

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

Some super awesome description for the active state

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

Some super awesome description for the active state

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

Some super awesome description for the active state

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state[description]}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state[description]}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 51, + "end": 58, + "type": "body" + }, + "code": { + "start": 59, + "end": 74 + }, + "file": { + "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-description.scss", + "start": 1, + "end": 74 + } + } + } + ] +} diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-description.scss b/tests/annotations/state/state-multiple-stupid-simple-with-description.scss new file mode 100644 index 0000000..c07f6f2 --- /dev/null +++ b/tests/annotations/state/state-multiple-stupid-simple-with-description.scss @@ -0,0 +1,73 @@ +/// @state {:hover} Some super awesome description for the hover state +/// @state {:focus} Some super awesome description for the focus state +/// @state {:active} Some super awesome description for the active state +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} Some super awesome description for the hover state +/// @state {:focus} Some super awesome description for the focus state +/// @state {:active} Some super awesome description for the active state +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} - Some super awesome description for the hover state +/// @state {:focus} - Some super awesome description for the focus state +/// @state {:active} - Some super awesome description for the active state +/// +/// @markup {html} +///
+/// ${@state[description]} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-notations.json b/tests/annotations/state/state-multiple-stupid-simple-with-notations.json new file mode 100644 index 0000000..d50e947 --- /dev/null +++ b/tests/annotations/state/state-multiple-stupid-simple-with-notations.json @@ -0,0 +1,254 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 25 + }, + "file": { + "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss", + "start": 1, + "end": 74 + } + } + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state.state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 26, + "end": 33, + "type": "body" + }, + "code": { + "start": 34, + "end": 50 + }, + "file": { + "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss", + "start": 1, + "end": 74 + } + } + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state[state]}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 51, + "end": 58, + "type": "body" + }, + "code": { + "start": 59, + "end": 74 + }, + "file": { + "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss", + "start": 1, + "end": 74 + } + } + } + ] +} diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss b/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss new file mode 100644 index 0000000..a6ae5b4 --- /dev/null +++ b/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss @@ -0,0 +1,73 @@ +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} + + +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: blue; + } + + &:active { + background: green; + } +} diff --git a/tests/annotations/state/state-multiple-stupid-simple.json b/tests/annotations/state/state-multiple-stupid-simple.json new file mode 100644 index 0000000..2a149cf --- /dev/null +++ b/tests/annotations/state/state-multiple-stupid-simple.json @@ -0,0 +1,88 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":focus", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :focus">\n Mind blown\n</div>" + } + }, + { + "state": { + "0": { + "state": ":active", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :active">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 8, + "type": "body" + }, + "code": { + "start": 9, + "end": 24 + }, + "file": { + "path": "docs/tests/annotations/state/state-multiple-stupid-simple.scss", + "start": 1, + "end": 24 + } + } + } + ] +} diff --git a/tests/annotations/state/state-multiple-stupid-simple.scss b/tests/annotations/state/state-multiple-stupid-simple.scss new file mode 100644 index 0000000..4399672 --- /dev/null +++ b/tests/annotations/state/state-multiple-stupid-simple.scss @@ -0,0 +1,23 @@ +/// @state {:hover} +/// @state {:focus} +/// @state {:active} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &:focus { + background: green; + } + + &:active { + background: green; + } +} diff --git a/tests/annotations/state/state-stupid-simple-with-description.json b/tests/annotations/state/state-stupid-simple-with-description.json new file mode 100644 index 0000000..734b5e2 --- /dev/null +++ b/tests/annotations/state/state-stupid-simple-with-description.json @@ -0,0 +1,158 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "

Some super awesome description

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

Some super awesome description

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

Some super awesome description

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

Some super awesome description

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

Some super awesome description

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

Some super awesome description

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

Some super awesome description

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

Some super awesome description

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

Some super awesome description

\n\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n ${@state[description]}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state[description]}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 30, + "end": 35, + "type": "body" + }, + "code": { + "start": 36, + "end": 43 + }, + "file": { + "path": "docs/tests/annotations/state/state-stupid-simple-with-description.scss", + "start": 1, + "end": 43 + } + } + } + ] +} diff --git a/tests/annotations/state/state-stupid-simple-with-description.scss b/tests/annotations/state/state-stupid-simple-with-description.scss new file mode 100644 index 0000000..cd73f4e --- /dev/null +++ b/tests/annotations/state/state-stupid-simple-with-description.scss @@ -0,0 +1,42 @@ +/// @state {:hover} Some super awesome description +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + + +/// @state {:hover} Some super awesome description +/// +/// @markup {html} +///
+/// ${@state.description} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + +/// @state {:hover} - Some super awesome description +/// +/// @markup {html} +///
+/// ${@state[description]} +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/state/state-stupid-simple-with-notations.json b/tests/annotations/state/state-stupid-simple-with-notations.json new file mode 100644 index 0000000..207d0d7 --- /dev/null +++ b/tests/annotations/state/state-stupid-simple-with-notations.json @@ -0,0 +1,158 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 15 + }, + "file": { + "path": "docs/tests/annotations/state/state-stupid-simple-with-notations.scss", + "start": 1, + "end": 44 + } + } + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state.state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 16, + "end": 21, + "type": "body" + }, + "code": { + "start": 22, + "end": 30 + }, + "file": { + "path": "docs/tests/annotations/state/state-stupid-simple-with-notations.scss", + "start": 1, + "end": 44 + } + } + }, + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state[state]}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 31, + "end": 36, + "type": "body" + }, + "code": { + "start": 37, + "end": 44 + }, + "file": { + "path": "docs/tests/annotations/state/state-stupid-simple-with-notations.scss", + "start": 1, + "end": 44 + } + } + } + ] +} diff --git a/tests/annotations/state/state-stupid-simple-with-notations.scss b/tests/annotations/state/state-stupid-simple-with-notations.scss new file mode 100644 index 0000000..ee980d2 --- /dev/null +++ b/tests/annotations/state/state-stupid-simple-with-notations.scss @@ -0,0 +1,43 @@ +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + + +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} + + +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/state/state-stupid-simple.json b/tests/annotations/state/state-stupid-simple.json new file mode 100644 index 0000000..aeed4c0 --- /dev/null +++ b/tests/annotations/state/state-stupid-simple.json @@ -0,0 +1,56 @@ +{ + "header": {}, + "body": [ + { + "states": { + "0": [ + { + "state": { + "0": { + "state": ":hover", + "description": "" + } + }, + "markup": { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome :hover">\n Mind blown\n</div>" + } + } + ] + }, + "markup": [ + { + "id": "0", + "language": "html", + "settings": {}, + "description": "", + "raw": "
\n Mind blown\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n Mind blown\n</div>", + "raw_stateless": "
\n Mind blown\n
", + "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 6, + "type": "body" + }, + "code": { + "start": 7, + "end": 14 + }, + "file": { + "path": "docs/tests/annotations/state/state-stupid-simple.scss", + "start": 1, + "end": 14 + } + } + } + ] +} diff --git a/tests/annotations/state/state-stupid-simple.scss b/tests/annotations/state/state-stupid-simple.scss new file mode 100644 index 0000000..e527198 --- /dev/null +++ b/tests/annotations/state/state-stupid-simple.scss @@ -0,0 +1,13 @@ +/// @state {:hover} +/// +/// @markup {html} +///
+/// Mind blown +///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } +} diff --git a/tests/annotations/state/state.js b/tests/annotations/state/state.js deleted file mode 100644 index e69de29..0000000 diff --git a/tests/annotations/state/state.json b/tests/annotations/state/state.json deleted file mode 100644 index e7c86d2..0000000 --- a/tests/annotations/state/state.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "header": {}, - "body": [] -} From 61d512ec043a9d00ef30be5e68d0a3fad1fe6d10 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 4 Mar 2016 15:50:11 -0500 Subject: [PATCH 228/273] Seperated out the annotations to be in individual files --- app/annotations.js | 1042 ----------------- app/annotations/access.js | 27 + app/annotations/alias.js | 23 + app/annotations/annotation-utils.js | 167 +++ app/annotations/arg.js | 32 + app/annotations/author.js | 18 + app/annotations/blockinfo.js | 47 + app/annotations/chainable.js | 29 + app/annotations/deprecated.js | 28 + app/annotations/description.js | 22 + app/annotations/index.js | 51 + app/annotations/markdown.js | 34 + app/annotations/markup.js | 109 ++ app/annotations/name.js | 10 + app/annotations/note.js | 29 + app/annotations/page.js | 53 + app/annotations/raw-code.js | 5 + app/annotations/readonly.js | 26 + app/annotations/requires.js | 31 + app/annotations/returns.js | 37 + app/annotations/since.js | 26 + app/annotations/states.js | 150 +++ app/annotations/throws.js | 33 + app/annotations/todo.js | 36 + app/annotations/type.js | 36 + app/annotations/version.js | 36 + app/config.js | 2 +- .../access/access.autofill.body.json | 4 +- .../access/access.autofill.header.json | 2 +- tests/annotations/alias/alias.json | 12 +- tests/annotations/arg/arg.aliases.json | 12 +- tests/annotations/arg/arg.json | 24 +- tests/annotations/author/author.alias.json | 4 +- tests/annotations/author/author.body.json | 4 +- tests/annotations/author/author.header.json | 2 +- tests/annotations/author/author.multiple.json | 14 +- tests/annotations/chainable/chainable.json | 28 +- .../depricated/depricated.body.json | 16 +- .../depricated/depricated.header.json | 2 +- .../description/description.alias.json | 48 +- .../description/description.body.json | 12 +- .../description/description.header.json | 2 +- tests/annotations/markdown/mark.json | 2 +- tests/annotations/markdown/markdown.json | 2 +- tests/annotations/markdown/md.json | 2 +- tests/annotations/markdown/mdml.json | 2 +- tests/annotations/markdown/mdown.json | 2 +- tests/annotations/markdown/mdtext.json | 2 +- tests/annotations/markdown/mdtxt.json | 2 +- tests/annotations/markdown/mdwn.json | 2 +- tests/annotations/markdown/mkd.json | 2 +- tests/annotations/markdown/mkdn.json | 2 +- tests/annotations/markdown/text.json | 2 +- tests/annotations/name/name.aliases.json | 12 +- tests/annotations/name/name.json | 4 +- tests/annotations/note/note.alias.json | 8 +- tests/annotations/note/note.json | 24 +- tests/annotations/page/page.alias.json | 12 +- .../annotations/page/page.body.autofill.json | 4 +- tests/annotations/page/page.body.json | 12 +- .../page/page.header.autofill.json | 2 +- tests/annotations/page/page.header.json | 4 +- tests/annotations/readonly/readonly.json | 12 +- .../annotations/requires/requires.alias.json | 4 +- tests/annotations/requires/requires.body.json | 28 +- .../annotations/requires/requires.header.json | 2 +- tests/annotations/returns/returns.alias.json | 28 +- tests/annotations/returns/returns.json | 28 +- tests/annotations/since/since.body.json | 16 +- tests/annotations/since/since.header.json | 2 +- ...e-markup-blocks-with-different-states.json | 4 +- .../state/state-multiple-markup-blocks.json | 4 +- ...ltiple-stupid-simple-with-description.json | 12 +- ...multiple-stupid-simple-with-notations.json | 12 +- .../state/state-multiple-stupid-simple.json | 4 +- .../state-stupid-simple-with-description.json | 12 +- .../state-stupid-simple-with-notations.json | 12 +- .../state/state-stupid-simple.json | 4 +- tests/annotations/throws/throws.alias.json | 16 +- tests/annotations/throws/throws.json | 24 +- tests/annotations/todo/todo.body.json | 24 +- tests/annotations/todo/todo.header.json | 2 +- tests/annotations/type/type.json | 28 +- tests/annotations/version/version.json | 20 +- .../4-blank-lines-between-code-blocks.json | 4 +- tests/cases/header-comment-only.json | 4 +- ...pace-between-header-and-body-comments.json | 8 +- tests/cases/only-body-comments.json | 4 +- tests/cases/only-comments.json | 12 +- tests/cases/preserves-blank-lines.json | 4 +- tests/cases/single-body-comment-no-code.json | 4 +- tests/cases/single-body-comment.json | 4 +- .../cases/space-between-comment-and-code.json | 4 +- tests/cases/starts-and-ends-with-spaces.json | 4 +- tests/file-types/c++/test.json | 16 +- tests/file-types/c/test.json | 16 +- tests/file-types/coffeescript/test.json | 16 +- tests/file-types/coldfusion/test.json | 20 +- tests/file-types/cs/test.json | 16 +- tests/file-types/css/test.json | 12 +- tests/file-types/html/test.json | 12 +- tests/file-types/jade/test.json | 8 +- tests/file-types/java/test.json | 16 +- tests/file-types/js/test.json | 8 +- tests/file-types/less/test.json | 16 +- tests/file-types/markdown/mark.json | 4 +- tests/file-types/markdown/markdown.json | 4 +- tests/file-types/markdown/md.json | 4 +- tests/file-types/markdown/mdml.json | 4 +- tests/file-types/markdown/mdown.json | 4 +- tests/file-types/markdown/mdtext.json | 4 +- tests/file-types/markdown/mdtxt.json | 4 +- tests/file-types/markdown/mdwn.json | 4 +- tests/file-types/markdown/mkd.json | 4 +- tests/file-types/markdown/mkdn.json | 4 +- tests/file-types/markdown/text.json | 4 +- tests/file-types/php/test.json | 16 +- tests/file-types/python/test.json | 16 +- tests/file-types/ruby/test.json | 16 +- tests/file-types/scss/test.json | 12 +- tests/file-types/stylus/test.json | 16 +- tests/file-types/swift/test.json | 16 +- 122 files changed, 1562 insertions(+), 1509 deletions(-) delete mode 100644 app/annotations.js create mode 100644 app/annotations/access.js create mode 100644 app/annotations/alias.js create mode 100644 app/annotations/annotation-utils.js create mode 100644 app/annotations/arg.js create mode 100644 app/annotations/author.js create mode 100644 app/annotations/blockinfo.js create mode 100644 app/annotations/chainable.js create mode 100644 app/annotations/deprecated.js create mode 100644 app/annotations/description.js create mode 100644 app/annotations/index.js create mode 100644 app/annotations/markdown.js create mode 100644 app/annotations/markup.js create mode 100644 app/annotations/name.js create mode 100644 app/annotations/note.js create mode 100644 app/annotations/page.js create mode 100644 app/annotations/raw-code.js create mode 100644 app/annotations/readonly.js create mode 100644 app/annotations/requires.js create mode 100644 app/annotations/returns.js create mode 100644 app/annotations/since.js create mode 100644 app/annotations/states.js create mode 100644 app/annotations/throws.js create mode 100644 app/annotations/todo.js create mode 100644 app/annotations/type.js create mode 100644 app/annotations/version.js diff --git a/app/annotations.js b/app/annotations.js deleted file mode 100644 index 8933ab4..0000000 --- a/app/annotations.js +++ /dev/null @@ -1,1042 +0,0 @@ -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+)?(.*)?' - - regexes = { - arg: new RegExp(types + space + name + space + value + space + description, 'i'), - deprecated: new RegExp(types + space + description, 'i'), - markup: new RegExp(id + space + types + space + value + space + description, 'i'), - note: new RegExp(types + space + description, 'i'), - throws: new RegExp(types + space + description, 'i'), - requires: new RegExp(types + space + name + description, 'i'), - returns: new RegExp(types + space + description, 'i'), - since: new RegExp(types + space + description, 'i'), - state_id: new RegExp(`${id}${space}(.*)`, 'i'), - state: new RegExp(types + space + value + space + description, 'i'), - todo: new RegExp(types + space + value + space + description, 'i'), - type: new RegExp(types + space + description, 'i'), - version: new RegExp(types + space + description, 'i'), - } -} - - -function list(str) { - return to.array(str, ',').map((item) => item.trim()).filter(Boolean) -} - -function regex(name, str) { - return regexes[name].exec(str).slice(1) -} - -function multiple(annotation) { - return to.flatten([ - ...(annotation.line.split(',')), - ...(annotation.contents.split('\n').map((item) => item.split(','))) - ]) - .map((author) => author.trim()) - .filter(Boolean) -} - -function toBoolean(annotation) { - let line = annotation.line - - if (annotation.contents.length > 0) { - return undefined - } - - if (line === 'false') { - return false - } else if (line.length === 0 || line === 'true') { - return true - } - - return undefined -} - -function markdown(...args) { - return to.markdown([ ...args ].filter(Boolean).join('\n')) -} - -function logAnnotationError(obj, expected) { - expected = to.array(expected) - const { - annotation, - comment, - code, - file - } = 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 = comment.contents.split('\n') - code.contents = code.contents.split('\n') - - // 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 = file.comment[comment.type].line - // 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') -} - - -//// -/// @name Annotations -/// @page annotations -/// @description -/// These are the default annotations for the docs -/// @type {object} -//// -let annotations = {} - - - -/// @name @access -/// @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 header or body comment -annotations.access = { - autofill() { - return 'public' - }, - parse() { - const line = this.annotation.line - if ( - line === 'private' || - line === 'protected' - ) { - return line - } - - return 'public' - } -} - -/// @name @alias -/// @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 -annotations.alias = { - parse() { - let alias_list = list(this.annotation.line) - 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 - } -} - - - -/// @name blockinfo -/// @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 -/// } -/// } -/// ``` -annotations.blockinfo = { - autofill() { - let obj = to.clone(this) - let comment = obj.comment - let code = obj.code - let file = obj.file - delete comment.contents - delete code.contents - delete file.contents - delete file.name - delete file.type - delete file.comment - - return { comment, code, file } - }, - parse() { - this.log.emit('warning', "Passed @blockinfo, it's only supposed to be an autofilled annotation", logAnnotationError(this, '')) - return - } -} - -/// @name @arg -/// @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 -annotations.arg = { - alias: [ 'argument', 'param', 'parameter' ], - parse() { - let [ - types = [], - name = '', - value = '', - description = '', - ] = regex('arg', this.annotation.line) - - return [ - { - types: list(types), - name, - value, - description: markdown(description, this.annotation.contents) - } - ] - } -} - -/// @name @author -/// @alias @authors -/// @description Author of the documented item -/// @returns {string} -/// @markup Usage -/// /// @author Author's name -/// -/// /// @author Author One, Author Two -/// -/// /// @author Author One -/// /// @author Author Two -annotations.author = { - alias: [ 'authors' ], - parse() { - return multiple(this.annotation) - } -} - -/// @name @chainable -/// @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 -annotations.chainable = { - alias: [ 'chain' ], - parse() { - let bool = toBoolean(this.annotation) - - if (bool !== undefined) { - return bool - } - - return multiple(this.annotation) - } -} - -/// @name @deprecated -/// @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 -annotations.deprecated = { - parse() { - let [ version = '0', description ] = regex('deprecated', this.annotation.line) - return { - version, - description: markdown(description, this.annotation.contents) - } - } -} - -/// @name @description -/// @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. -annotations.description = { - alias: [ - 'desc', 'definition', 'explanation', - 'writeup', 'summary', 'summarization' - ], - parse() { - return markdown(this.annotation.line, this.annotation.contents) - } -} - - -/// @name @markdown -/// @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 -/// -annotations.markdown = { - filetypes: [ - 'markdown', 'mark', 'mdown', - 'mkdn', 'mdtxt', 'mkd', - 'mdml', 'mdwn', 'mdtext', - 'text', 'md' - ], - parse() { - const comment = this.file.comment - const start = `(?:${comment.header.start}|${comment.body.start})`.replace('\\', '\\\\') - const end = `(?:${comment.header.end}|${comment.body.end})`.replace('\\', '\\\\') - const md_regex = new RegExp(`${start}(?:.|\\n)*\\n${end}`, 'gmi') - - return to.markdown(this.file.contents.replace(md_regex, '')) - } -} - -/// @name @markup -/// @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 -/// escaped: 'string' // escaped code, aka `` turns to `<span>` -/// } -/// ``` -/// @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 -annotations.markup = { - alias: [ 'code', 'example', 'output', 'outputs' ], - parse() { - let escaped_characters = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - '\'': ''' - } - - let [ - id = null, - language = this.file.type, - settings = {}, - description - ] = regex('markup', this.annotation.line) - - let raw = this.annotation.contents - - let escaped = raw - .split('\n') - .map((line) => line - .replace(/[&<>'"]/g, (match) => - escaped_characters[match] - ) - ) - .join('\n') - - // @todo {10} update this use use the user defined options - const state_interpolation = /\s*\${@states?[^\}]*\}\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: markdown(description), - raw, - escaped, - raw_stateless, - escaped_stateless, - } - - Object.defineProperty(result, '__details', { __proto__: null, value: this }) - - return [ result ] - }, - resolve() { - return this.map((obj, i) => { - if (obj.id === null) { - obj.id = `${i}` - } - return obj - }) - } -} - -annotations['raw-code'] = { - parse() { - return this.code.contents - } -} - -/// @name @name -/// @alias @title, @heading, @header -/// @description Name of the documented item -/// @returns {string} -/// -/// @markup Usage -/// /// @name Name of the documented item -annotations.name = { - alias: [ 'title', 'heading', 'header' ] -} - -/// @name @note -/// @alias @notes -/// @description A note about the documented item -/// @returns {object} -/// -/// @markup Usage -/// /// @note description -/// -/// /// @note {importance} description -/// -/// /// @note {importance} -/// /// multi -/// /// line -/// /// description -annotations.note = { - alias: [ 'notes' ], - parse() { - let [ importance = '0', description ] = regex('note', this.annotation.line) - - return [ - { - importance, - description: markdown(description, this.annotation.contents) - } - ] - } -} - -/// @name @page -/// @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 -annotations.page = { - alias: [ 'group' ], - parse() { - return list(this.annotation.line) - }, - autofill() { - // autofill header comments - if (this.comment.type === 'header') { - return [ 'other' ] - } - // don't autofill body comments - return - } -} - -/// @name @readonly -/// @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 -annotations.readonly = { - parse() { - let bool = toBoolean(this.annotation) - - if (bool !== undefined) { - return bool - } - - return true - } -} - -/// @name @requires -/// @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 -annotations.requires = { - alias: [ 'require' ], - parse() { - let [ types, name = '', description ] = regex('requires', this.annotation.line) - - return [ - { - types: list(types), - name, - description: markdown(description, this.annotation.contents) - } - ] - } -} - -/// @name @returns -/// @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 -annotations.returns = { - alias: [ 'return' ], - parse() { - let [ types, description ] = regex('returns', this.annotation.line) - - if ( - types == null || - types === '' - ) { - types = 'undefined' - } - - return { - types: list(types), - description: markdown(description, this.annotation.contents) - } - } -} - -/// @name @since -/// @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 -annotations.since = { - parse() { - let [ version = 'undefined', description ] = regex('since', this.annotation.line) - - return { - version, - description: markdown(description, this.annotation.contents) - } - } -} - -/// @name @states -/// @alias @state -/// @page annotations -/// @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 -annotations.states = { - alias: [ 'state' ], - parse() { - let [ markup_id = null, state_line ] = regex('state_id', this.annotation.line) - let state = [ state_line, ...to.array(this.annotation.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: markdown(description) } - }) - }, {}) - - Object.defineProperty(state, '__details', { __proto__: null, value: this }) - - return [ { markup_id, state } ] - }, - resolve({ parsed, block, log }) { - return this.reduce((previous, { markup_id, state }) => { - let markup - let start_at = state.__details.annotation.start - - // throw an error because a state should always be accompanied by a `@markup` block - if (!parsed.markup) { - log.emit('error', "There's no instance of a '@markup' annotation") - } else if (is.falsy(markup_id)) { - markup = findMarkupAfter(parsed.markup, start_at) - markup_id = markup.id - - if (!markup) { - log.emit('error', to.normalize(` - There's no instance of a '@markup' annotation after line ${block.comment.start + start_at} - in ${block.file.path} - `)) - } - } else { - markup = findMarkupById(parsed.markup, markup_id) - if (!markup) { - log.emit('error', to.normalize(` - There's no instance of a '@markup' annotation with an id of ${markup_id} - in ${block.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) - to.extend(_state, _state[to.keys(_state)[0]]) - markup.raw = replaceStates(markup.raw, _state) - markup.escaped = replaceStates(markup.escaped, _state) - - return to.merge(previous, { - [markup_id]: [ { state, markup } ] - }) - }, {}) - - - function replaceStates(str, states) { - // @todo {5} - Update this to use language settings - // - annotation name and it's aliases - // - interpolation - // - annotation prefix - // const state_interpolation = new RegExp(`${settings.interpolation.start}${settings.annotation.prefix}etc....`, 'gi') - const state_interpolation = /\${@(?:state|states)[^\}]*\}/g - return str.replace(state_interpolation, (original_match) => { - let match = original_match.replace(/\${@(?:states|state)|}/g, '').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] - } - - return states[clean(match)] - }) - } - - 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 markup_block of markup) { - if (start_at < markup_block.__details.annotation.start) { - return markup_block - } - } - return - } - } -} - -/// @name @throws -/// @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 -annotations.throws = { - alias: [ 'throw', 'exception', 'error', 'catch' ], - parse() { - let [ types, description ] = regex('throws', this.annotation.line) - - return [ - { - types: list(types), - description: markdown(description, this.annotation.contents) - } - ] - } -} - -/// @name @todo -/// @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 -annotations.todo = { - parse() { - let [ - importance = '0', - assignees, - description - ] = regex('todo', this.annotation.line) - - return [ - { - importance, - assignees: list(assignees), - description: markdown(description, this.annotation.contents) - } - ] - } -} - -/// @name @type -/// @description Describes the type of a variable -/// @returns {object} -/// @markup Usage -/// /// @type {type} -/// -/// /// @type {type} description -/// -/// /// @type {type} - description -/// -/// /// @type {type} -/// /// multi -/// /// line -/// /// description -annotations.type = { - parse() { - let [ type, description ] = regex('type', this.annotation.line) - - 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: markdown(description, this.annotation.contents) - } - } -} - -/// @name @version -/// @description Describes the type of a variable -/// @returns {string} -/// @markup Usage -/// /// @version {version} -/// -/// /// @version {version} - description -/// -/// /// @version {version} description -/// -/// /// @version {version} -/// /// multi -/// /// line -/// /// description -annotations.version = { - parse() { - let [ version, description ] = regex('version', this.annotation.line) - - if (!version) { - this.log.emit( - 'warning', - `You didn't pass in a version to ${clor.bold('@version ')}`, - logAnnotationError(this, `@version {version}${description ? ' - ' + description : ''}`) - ) - version = 'undefined' - } - - return { - version, - description: markdown(description, this.annotation.contents) - } - } -} - -export default { ...annotations } diff --git a/app/annotations/access.js b/app/annotations/access.js new file mode 100644 index 0000000..501d2a8 --- /dev/null +++ b/app/annotations/access.js @@ -0,0 +1,27 @@ +/// @name @access +/// @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 header or body comment +export default { + autofill() { + return 'public' + }, + parse() { + const line = this.annotation.line + 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..16d0d79 --- /dev/null +++ b/app/annotations/alias.js @@ -0,0 +1,23 @@ +import { is } from '../utils' +import { list, logAnnotationError } from './annotation-utils' +/// @name @alias +/// @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.line) + 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..cfdc3b3 --- /dev/null +++ b/app/annotations/annotation-utils.js @@ -0,0 +1,167 @@ +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+)?(.*)?' + + regexes = { + arg: new RegExp(types + space + name + space + value + space + description, 'i'), + deprecated: new RegExp(types + space + description, 'i'), + markup: new RegExp(id + space + types + space + value + space + description, 'i'), + note: new RegExp(types + space + description, 'i'), + throws: new RegExp(types + space + description, 'i'), + requires: new RegExp(types + space + name + description, 'i'), + returns: new RegExp(types + space + description, 'i'), + since: new RegExp(types + space + description, 'i'), + state_id: new RegExp(`${id}${space}(.*)`, 'i'), + state: new RegExp(types + space + value + space + description, 'i'), + todo: new RegExp(types + space + value + space + description, 'i'), + type: new RegExp(types + space + description, 'i'), + version: new RegExp(types + space + description, 'i'), + } +} + +export function regex(name, str) { + return regexes[name].exec(str).slice(1) +} + +export function list(str) { + return to.array(str, ',').map((item) => item.trim()).filter(Boolean) +} + + +export function multiple(annotation) { + return to.flatten([ + ...(annotation.line.split(',')), + ...(annotation.contents.split('\n').map((item) => item.split(','))) + ]) + .map((author) => author.trim()) + .filter(Boolean) +} + +export function toBoolean(annotation) { + let line = annotation.line + + if (annotation.contents.length > 0) { + return undefined + } + + if (line === 'false') { + return false + } else if (line.length === 0 || line === 'true') { + return true + } + + return undefined +} + +export function markdown(...args) { + return to.markdown([ ...args ].filter(Boolean).join('\n')) +} + +export function logAnnotationError(obj, expected) { + expected = to.array(expected) + const { + annotation, + comment, + code, + file + } = 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 = comment.contents.split('\n') + code.contents = code.contents.split('\n') + + // 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 = file.comment[comment.type].line + // 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') +} diff --git a/app/annotations/arg.js b/app/annotations/arg.js new file mode 100644 index 0000000..6640cba --- /dev/null +++ b/app/annotations/arg.js @@ -0,0 +1,32 @@ +import { markdown, regex, list } from './annotation-utils' + +/// @name @arg +/// @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 [ + types = [], + name = '', + value = '', + description = '', + ] = regex('arg', this.annotation.line) + + return [ + { + types: list(types), + name, + value, + description: markdown(description, this.annotation.contents) + } + ] + } +} diff --git a/app/annotations/author.js b/app/annotations/author.js new file mode 100644 index 0000000..a0154b5 --- /dev/null +++ b/app/annotations/author.js @@ -0,0 +1,18 @@ +import { multiple } from './annotation-utils' +/// @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 +export default { + alias: [ 'authors' ], + parse() { + return multiple(this.annotation) + } +} diff --git a/app/annotations/blockinfo.js b/app/annotations/blockinfo.js new file mode 100644 index 0000000..af3e6f7 --- /dev/null +++ b/app/annotations/blockinfo.js @@ -0,0 +1,47 @@ +import { to } from '../utils' +import { logAnnotationError } from './annotation-utils' +/// @name blockinfo +/// @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 +/// } +/// } +/// ``` +export default { + autofill() { + let obj = to.clone(this) + let comment = obj.comment + let code = obj.code + let file = obj.file + delete comment.contents + delete code.contents + delete file.contents + delete file.name + delete file.type + delete file.comment + + 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..c7c6318 --- /dev/null +++ b/app/annotations/chainable.js @@ -0,0 +1,29 @@ +import { toBoolean, multiple } from './annotation-utils' + +/// @name @chainable +/// @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() { + let bool = toBoolean(this.annotation) + + if (bool !== undefined) { + return bool + } + + return multiple(this.annotation) + } +} diff --git a/app/annotations/deprecated.js b/app/annotations/deprecated.js new file mode 100644 index 0000000..e2a906f --- /dev/null +++ b/app/annotations/deprecated.js @@ -0,0 +1,28 @@ +import { markdown, regex } from './annotation-utils' + +/// @name @deprecated +/// @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 [ version = '0', description ] = regex('deprecated', this.annotation.line) + return { + version, + description: markdown(description, this.annotation.contents) + } + } +} diff --git a/app/annotations/description.js b/app/annotations/description.js new file mode 100644 index 0000000..03c663b --- /dev/null +++ b/app/annotations/description.js @@ -0,0 +1,22 @@ +import { markdown } from './annotation-utils' +/// @name @description +/// @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 markdown(this.annotation.line, this.annotation.contents) + } +} diff --git a/app/annotations/index.js b/app/annotations/index.js new file mode 100644 index 0000000..3dd2e75 --- /dev/null +++ b/app/annotations/index.js @@ -0,0 +1,51 @@ +// export default { +// access: require('./access.js'), +// alias: require('./alias.js'), +// arg: require('./arg.js'), +// author: require('./author.js'), +// blockinfo: require('./blockinfo.js'), +// chainable: require('./chainable.js'), +// deprecated: require('./deprecated.js'), +// description: require('./description.js'), +// markdown: require('./markdown.js'), +// markup: require('./markup.js'), +// name: require('./name.js'), +// note: require('./note.js'), +// page: require('./page.js'), +// 'raw-code': require('./raw-code.js'), +// readonly: require('./readonly.js'), +// requires: require('./requires.js'), +// returns: require('./returns.js'), +// since: require('./since.js'), +// states: require('./states.js'), +// throws: require('./throws.js'), +// todo: require('./todo.js'), +// type: require('./type.js'), +// version: require('./version.js'), +// } + + + +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 type from './type' +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' +export version from './version' diff --git a/app/annotations/markdown.js b/app/annotations/markdown.js new file mode 100644 index 0000000..d4fa6d8 --- /dev/null +++ b/app/annotations/markdown.js @@ -0,0 +1,34 @@ +import { to } from '../utils' + +/// @name @markdown +/// @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 comment = this.file.comment + const start = `(?:${comment.header.start}|${comment.body.start})`.replace('\\', '\\\\') + const end = `(?:${comment.header.end}|${comment.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..dea52fd --- /dev/null +++ b/app/annotations/markup.js @@ -0,0 +1,109 @@ +import { is, to } from '../utils' +import { regex, list, markdown } from './annotation-utils' + +/// @name @markup +/// @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 +/// escaped: 'string' // escaped code, aka `` turns to `<span>` +/// } +/// ``` +/// @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 escaped_characters = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' + } + + let [ + id = null, + language = this.file.type, + settings = {}, + description + ] = regex('markup', this.annotation.line) + + let raw = this.annotation.contents + + let escaped = raw + .split('\n') + .map((line) => line + .replace(/[&<>'"]/g, (match) => + escaped_characters[match] + ) + ) + .join('\n') + + // @todo {10} update this use use the user defined options + const state_interpolation = /\s*\${@states?[^\}]*\}\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: markdown(description), + raw, + escaped, + raw_stateless, + escaped_stateless, + } + + Object.defineProperty(result, '__details', { __proto__: null, value: this }) + + return [ result ] + }, + resolve() { + return this.map((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..aa04ca2 --- /dev/null +++ b/app/annotations/name.js @@ -0,0 +1,10 @@ +/// @name @name +/// @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' ] +} diff --git a/app/annotations/note.js b/app/annotations/note.js new file mode 100644 index 0000000..b346184 --- /dev/null +++ b/app/annotations/note.js @@ -0,0 +1,29 @@ +import { regex, markdown } from './annotation-utils' + +/// @name @note +/// @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 [ importance = '0', description ] = regex('note', this.annotation.line) + + return [ + { + importance, + description: markdown(description, this.annotation.contents) + } + ] + } +} diff --git a/app/annotations/page.js b/app/annotations/page.js new file mode 100644 index 0000000..fa34643 --- /dev/null +++ b/app/annotations/page.js @@ -0,0 +1,53 @@ +import { list } from './annotation-utils' + +/// @name @page +/// @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 +export default { + alias: [ 'group' ], + parse() { + return list(this.annotation.line) + }, + autofill() { + // autofill header comments + if (this.comment.type === 'header') { + return [ 'other' ] + } + // don't autofill body comments + return + } +} diff --git a/app/annotations/raw-code.js b/app/annotations/raw-code.js new file mode 100644 index 0000000..0e5710c --- /dev/null +++ b/app/annotations/raw-code.js @@ -0,0 +1,5 @@ +export default { + parse() { + return this.code.contents + } +} diff --git a/app/annotations/readonly.js b/app/annotations/readonly.js new file mode 100644 index 0000000..1042243 --- /dev/null +++ b/app/annotations/readonly.js @@ -0,0 +1,26 @@ +import { toBoolean } from './annotation-utils' + +/// @name @readonly +/// @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) + + 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..1c95d93 --- /dev/null +++ b/app/annotations/requires.js @@ -0,0 +1,31 @@ +import { regex, list, markdown } from './annotation-utils' + +/// @name @requires +/// @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 [ types, name = '', description ] = regex('requires', this.annotation.line) + + return [ + { + types: list(types), + name, + description: markdown(description, this.annotation.contents) + } + ] + } +} diff --git a/app/annotations/returns.js b/app/annotations/returns.js new file mode 100644 index 0000000..b191684 --- /dev/null +++ b/app/annotations/returns.js @@ -0,0 +1,37 @@ +import { regex, list, markdown } from './annotation-utils' + +/// @name @returns +/// @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 [ types, description ] = regex('returns', this.annotation.line) + + if ( + types == null || + types === '' + ) { + types = 'undefined' + } + + return { + types: list(types), + description: markdown(description, this.annotation.contents) + } + } +} diff --git a/app/annotations/since.js b/app/annotations/since.js new file mode 100644 index 0000000..5572e8e --- /dev/null +++ b/app/annotations/since.js @@ -0,0 +1,26 @@ +import { regex, markdown } from './annotation-utils' + +/// @name @since +/// @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 [ version = 'undefined', description ] = regex('since', this.annotation.line) + + return { + version, + description: markdown(description, this.annotation.contents) + } + } +} diff --git a/app/annotations/states.js b/app/annotations/states.js new file mode 100644 index 0000000..3209cad --- /dev/null +++ b/app/annotations/states.js @@ -0,0 +1,150 @@ +import { is, to } from '../utils' +import { regex, markdown } from './annotation-utils' + +/// @name @states +/// @alias @state +/// @page annotations +/// @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 [ markup_id = null, state_line ] = regex('state_id', this.annotation.line) + let state = [ state_line, ...to.array(this.annotation.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: markdown(description) } + }) + }, {}) + + Object.defineProperty(state, '__details', { __proto__: null, value: this }) + + return [ { markup_id, state } ] + }, + resolve({ parsed, block, log }) { + return this.reduce((previous, { markup_id, state }) => { + let markup + let start_at = state.__details.annotation.start + + // throw an error because a state should always be accompanied by a `@markup` block + if (!parsed.markup) { + log.emit('error', "There's no instance of a '@markup' annotation") + } else if (is.falsy(markup_id)) { + markup = findMarkupAfter(parsed.markup, start_at) + markup_id = markup.id + + if (!markup) { + log.emit('error', to.normalize(` + There's no instance of a '@markup' annotation after line ${block.comment.start + start_at} + in ${block.file.path} + `)) + } + } else { + markup = findMarkupById(parsed.markup, markup_id) + if (!markup) { + log.emit('error', to.normalize(` + There's no instance of a '@markup' annotation with an id of ${markup_id} + in ${block.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) + to.extend(_state, _state[to.keys(_state)[0]]) + markup.raw = replaceStates(markup.raw, _state) + markup.escaped = replaceStates(markup.escaped, _state) + + return to.merge(previous, { + [markup_id]: [ { state, markup } ] + }) + }, {}) + } +} + + +function replaceStates(str, states) { + // @todo {5} - Update this to use language settings + // - annotation name and it's aliases + // - interpolation + // - annotation prefix + // const state_interpolation = new RegExp(`${settings.interpolation.start}${settings.annotation.prefix}etc....`, 'gi') + const state_interpolation = /\${@(?:state|states)[^\}]*\}/g + return str.replace(state_interpolation, (original_match) => { + let match = original_match.replace(/\${@(?:states|state)|}/g, '').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] + } + + return states[clean(match)] + }) +} + +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 markup_block of markup) { + if (start_at < markup_block.__details.annotation.start) { + return markup_block + } + } + return +} diff --git a/app/annotations/throws.js b/app/annotations/throws.js new file mode 100644 index 0000000..1f85248 --- /dev/null +++ b/app/annotations/throws.js @@ -0,0 +1,33 @@ +import { regex, list, markdown } from './annotation-utils' + +/// @name @throws +/// @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 [ types, description ] = regex('throws', this.annotation.line) + + return [ + { + types: list(types), + description: markdown(description, this.annotation.contents) + } + ] + } +} diff --git a/app/annotations/todo.js b/app/annotations/todo.js new file mode 100644 index 0000000..601ba6e --- /dev/null +++ b/app/annotations/todo.js @@ -0,0 +1,36 @@ +import { regex, list, markdown } from './annotation-utils' + +/// @name @todo +/// @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 [ + importance = '0', + assignees, + description + ] = regex('todo', this.annotation.line) + + return [ + { + importance, + assignees: list(assignees), + description: markdown(description, this.annotation.contents) + } + ] + } +} diff --git a/app/annotations/type.js b/app/annotations/type.js new file mode 100644 index 0000000..f370128 --- /dev/null +++ b/app/annotations/type.js @@ -0,0 +1,36 @@ +import { regex, markdown, logAnnotationError } from './annotation-utils' +import clor from 'clor' + +/// @name @type +/// @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 [ type, description ] = regex('type', this.annotation.line) + + 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: markdown(description, this.annotation.contents) + } + } +} diff --git a/app/annotations/version.js b/app/annotations/version.js new file mode 100644 index 0000000..70daf37 --- /dev/null +++ b/app/annotations/version.js @@ -0,0 +1,36 @@ +import { logAnnotationError, regex, markdown } from './annotation-utils' +import clor from 'clor' + +/// @name @version +/// @description Describes the type of a variable +/// @returns {string} +/// @markup Usage +/// /// @version {version} +/// +/// /// @version {version} - description +/// +/// /// @version {version} description +/// +/// /// @version {version} +/// /// multi +/// /// line +/// /// description +export default { + parse() { + let [ version, description ] = regex('version', this.annotation.line) + + if (!version) { + this.log.emit( + 'warning', + `You didn't pass in a version to ${clor.bold('@version ')}`, + logAnnotationError(this, `@version {version}${description ? ' - ' + description : ''}`) + ) + version = 'undefined' + } + + return { + version, + description: markdown(description, this.annotation.contents) + } + } +} diff --git a/app/config.js b/app/config.js index 9e7e685..48efbfd 100644 --- a/app/config.js +++ b/app/config.js @@ -1,7 +1,7 @@ /* eslint-disable guard-for-in */ import { info, fs, is, to, Logger } from './utils' import path from 'path' -import annotations from './annotations' +import * as annotations from './annotations' import AnnotationApi from './annotation-api' let log = new Logger() diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json index 9043a61..de35441 100644 --- a/tests/annotations/access/access.autofill.body.json +++ b/tests/annotations/access/access.autofill.body.json @@ -3,7 +3,6 @@ "body": [ { "name": "autofill access", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,8 @@ "start": 1, "end": 2 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json index 6e4b82d..cca80df 100644 --- a/tests/annotations/access/access.autofill.header.json +++ b/tests/annotations/access/access.autofill.header.json @@ -1,7 +1,6 @@ { "header": { "name": "autofill access", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 4 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json index 8667099..a8df25d 100644 --- a/tests/annotations/alias/alias.json +++ b/tests/annotations/alias/alias.json @@ -5,7 +5,6 @@ "alias": [ "foo" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,14 +20,14 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "alias": [ "foo", "bar" ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -44,14 +43,14 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "alias": [ "foo", "bar" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -67,7 +66,8 @@ "start": 1, "end": 6 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json index dbe1515..8594525 100644 --- a/tests/annotations/arg/arg.aliases.json +++ b/tests/annotations/arg/arg.aliases.json @@ -12,7 +12,6 @@ "description": "

argument alias

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -28,7 +27,8 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "arg": [ @@ -41,7 +41,6 @@ "description": "

param alias

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -57,7 +56,8 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "arg": [ @@ -70,7 +70,6 @@ "description": "

parameter alias

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -86,7 +85,8 @@ "start": 1, "end": 6 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json index 4a73d4a..73bfb11 100644 --- a/tests/annotations/arg/arg.json +++ b/tests/annotations/arg/arg.json @@ -10,7 +10,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,7 +25,8 @@ "start": 1, "end": 17 } - } + }, + "access": "public" }, { "arg": [ @@ -39,7 +39,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -55,7 +54,8 @@ "start": 1, "end": 17 } - } + }, + "access": "public" }, { "arg": [ @@ -69,7 +69,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -85,7 +84,8 @@ "start": 1, "end": 17 } - } + }, + "access": "public" }, { "arg": [ @@ -98,7 +98,6 @@ "description": "

description

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -114,7 +113,8 @@ "start": 1, "end": 17 } - } + }, + "access": "public" }, { "arg": [ @@ -127,7 +127,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -143,7 +142,8 @@ "start": 1, "end": 17 } - } + }, + "access": "public" }, { "arg": [ @@ -156,7 +156,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -172,7 +171,8 @@ "start": 1, "end": 17 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json index 5284ac7..673fe1d 100644 --- a/tests/annotations/author/author.alias.json +++ b/tests/annotations/author/author.alias.json @@ -7,7 +7,6 @@ "Author Two", "Author Three" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,7 +22,8 @@ "start": 1, "end": 2 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json index 8d21edf..f54e53f 100644 --- a/tests/annotations/author/author.body.json +++ b/tests/annotations/author/author.body.json @@ -5,7 +5,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,7 +20,8 @@ "start": 1, "end": 2 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json index 33e0ed3..75e9a9e 100644 --- a/tests/annotations/author/author.header.json +++ b/tests/annotations/author/author.header.json @@ -3,7 +3,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,6 +19,7 @@ "end": 4 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index fd71274..d98bbd0 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -4,7 +4,6 @@ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,6 +20,7 @@ "end": 14 } }, + "access": "public", "page": [ "other" ] @@ -31,7 +31,6 @@ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -47,14 +46,14 @@ "start": 1, "end": 14 } - } + }, + "access": "public" }, { "author": [ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 8, @@ -70,14 +69,14 @@ "start": 1, "end": 14 } - } + }, + "access": "public" }, { "author": [ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -93,7 +92,8 @@ "start": 1, "end": 14 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json index 55e602b..ba2aa81 100644 --- a/tests/annotations/chainable/chainable.json +++ b/tests/annotations/chainable/chainable.json @@ -3,7 +3,6 @@ "body": [ { "chainable": true, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,11 +18,11 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "chainable": true, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -39,11 +38,11 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "chainable": false, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -59,13 +58,13 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "chainable": [ "Object.prototype" ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -81,14 +80,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "chainable": [ "One", "Two" ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -104,14 +103,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "chainable": [ "One", "Two" ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -127,14 +126,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "chainable": [ "One", "Two" ], - "access": "public", "blockinfo": { "comment": { "start": 15, @@ -150,7 +149,8 @@ "start": 1, "end": 18 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json index 6be3310..9ef4503 100644 --- a/tests/annotations/depricated/depricated.body.json +++ b/tests/annotations/depricated/depricated.body.json @@ -6,7 +6,6 @@ "version": "0", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,14 @@ "start": 1, "end": 11 } - } + }, + "access": "public" }, { "deprecated": { "version": "0.0.1", "description": "

Lorem

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +44,14 @@ "start": 1, "end": 11 } - } + }, + "access": "public" }, { "deprecated": { "version": "0.0.1", "description": "

Lorem

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +67,14 @@ "start": 1, "end": 11 } - } + }, + "access": "public" }, { "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" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,7 +90,8 @@ "start": 1, "end": 11 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json index 6e716c4..62970eb 100644 --- a/tests/annotations/depricated/depricated.header.json +++ b/tests/annotations/depricated/depricated.header.json @@ -4,7 +4,6 @@ "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" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,6 +20,7 @@ "end": 7 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json index a67b42b..030edd2 100644 --- a/tests/annotations/description/description.alias.json +++ b/tests/annotations/description/description.alias.json @@ -4,7 +4,6 @@ { "name": "single-line `desc`", "description": "

Lorem ipsum

\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,12 +19,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "multi-line `desc`", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 4, @@ -41,12 +40,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "single-line `definition`", "description": "

Lorem ipsum

\n", - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -62,12 +61,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "multi-line `definition`", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 14, @@ -83,12 +82,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "single-line `explanation`", "description": "

Lorem ipsum

\n", - "access": "public", "blockinfo": { "comment": { "start": 21, @@ -104,12 +103,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "multi-line `explanation`", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 24, @@ -125,12 +124,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "single-line `writeup`", "description": "

Lorem ipsum

\n", - "access": "public", "blockinfo": { "comment": { "start": 31, @@ -146,12 +145,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "multi-line `writeup`", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -167,12 +166,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "single-line `summary`", "description": "

Lorem ipsum

\n", - "access": "public", "blockinfo": { "comment": { "start": 41, @@ -188,12 +187,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "multi-line `summary`", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 44, @@ -209,12 +208,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "single-line `summarization`", "description": "

Lorem ipsum

\n", - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -230,12 +229,12 @@ "start": 1, "end": 58 } - } + }, + "access": "public" }, { "name": "multi-line `summarization`", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 54, @@ -251,7 +250,8 @@ "start": 1, "end": 58 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json index 46af6e7..17775d5 100644 --- a/tests/annotations/description/description.body.json +++ b/tests/annotations/description/description.body.json @@ -3,7 +3,6 @@ "body": [ { "description": "

Lorem ipsum dolor sit amet

\n", - "access": "public", "blockinfo": { "comment": { "start": 2, @@ -19,11 +18,11 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "description": "

Line one\nOther\nlines\nbelow\nit

\n", - "access": "public", "blockinfo": { "comment": { "start": 4, @@ -39,11 +38,11 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "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", - "access": "public", "blockinfo": { "comment": { "start": 10, @@ -59,7 +58,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json index e7773a6..4ef4def 100644 --- a/tests/annotations/description/description.header.json +++ b/tests/annotations/description/description.header.json @@ -1,7 +1,6 @@ { "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", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 8 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index 14398b4..00c872a 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 3ef294b..63e8963 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index 3d43ba6..fd873ec 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index 65fe6bc..142c2c9 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index caad7ae..3bd2f59 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index 0600eee..96dee95 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index b3b6e92..5bd8fbf 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index 40d17f2..374b422 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index cdc6f54..b3ec690 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index 437425e..f77b483 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index a92bced..e7b299e 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

H1 Tag

\n
.foo {\n  .bar {\n    background: blue;\n  }\n}\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 13 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json index 1a71c97..49a420d 100644 --- a/tests/annotations/name/name.aliases.json +++ b/tests/annotations/name/name.aliases.json @@ -3,7 +3,6 @@ "body": [ { "name": "Title", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,11 +18,11 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "name": "Heading", - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -39,11 +38,11 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "name": "Header", - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -59,7 +58,8 @@ "start": 1, "end": 6 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json index d6737cb..7cec0e4 100644 --- a/tests/annotations/name/name.json +++ b/tests/annotations/name/name.json @@ -3,7 +3,6 @@ "body": [ { "name": "Foo", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,8 @@ "start": 1, "end": 2 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json index 38e77da..6c1b292 100644 --- a/tests/annotations/note/note.alias.json +++ b/tests/annotations/note/note.alias.json @@ -8,7 +8,6 @@ "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,8 @@ "start": 1, "end": 10 } - } + }, + "access": "public" }, { "note": [ @@ -33,7 +33,6 @@ "description": "
    \n
  • note 1
  • \n
  • note 2
  • \n
  • note 3
  • \n
\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -49,7 +48,8 @@ "start": 1, "end": 10 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json index f1da9bb..6fa19d7 100644 --- a/tests/annotations/note/note.json +++ b/tests/annotations/note/note.json @@ -8,7 +8,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,8 @@ "start": 1, "end": 20 } - } + }, + "access": "public" }, { "note": [ @@ -33,7 +33,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -49,7 +48,8 @@ "start": 1, "end": 20 } - } + }, + "access": "public" }, { "note": [ @@ -58,7 +58,6 @@ "description": "

Lorem ipsum dolor sit amet

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -74,7 +73,8 @@ "start": 1, "end": 20 } - } + }, + "access": "public" }, { "note": [ @@ -83,7 +83,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -99,7 +98,8 @@ "start": 1, "end": 20 } - } + }, + "access": "public" }, { "note": [ @@ -108,7 +108,6 @@ "description": "

Lorem ipsum dolor sit amet

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -124,7 +123,8 @@ "start": 1, "end": 20 } - } + }, + "access": "public" }, { "note": [ @@ -133,7 +133,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 15, @@ -149,7 +148,8 @@ "start": 1, "end": 20 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json index a037323..21035be 100644 --- a/tests/annotations/page/page.alias.json +++ b/tests/annotations/page/page.alias.json @@ -5,7 +5,6 @@ "page": [ "level 1" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,13 +20,13 @@ "start": 1, "end": 7 } - } + }, + "access": "public" }, { "page": [ "level 1/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -43,14 +42,14 @@ "start": 1, "end": 7 } - } + }, + "access": "public" }, { "page": [ "page 1/level 2", "page 2/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -66,7 +65,8 @@ "start": 1, "end": 7 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json index b5c4e75..8bbc01b 100644 --- a/tests/annotations/page/page.body.autofill.json +++ b/tests/annotations/page/page.body.autofill.json @@ -3,7 +3,6 @@ "body": [ { "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,8 @@ "start": 1, "end": 2 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json index 95783aa..f6a867c 100644 --- a/tests/annotations/page/page.body.json +++ b/tests/annotations/page/page.body.json @@ -5,7 +5,6 @@ "page": [ "level 1" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,13 +20,13 @@ "start": 1, "end": 7 } - } + }, + "access": "public" }, { "page": [ "level 1/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -43,14 +42,14 @@ "start": 1, "end": 7 } - } + }, + "access": "public" }, { "page": [ "page 1/level 2", "page 2/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -66,7 +65,8 @@ "start": 1, "end": 7 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json index 5efe48f..f2c7321 100644 --- a/tests/annotations/page/page.header.autofill.json +++ b/tests/annotations/page/page.header.autofill.json @@ -1,7 +1,6 @@ { "header": { "name": "page autofill test", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,6 +17,7 @@ "end": 4 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/page/page.header.json b/tests/annotations/page/page.header.json index 35bc7ce..49a5c27 100644 --- a/tests/annotations/page/page.header.json +++ b/tests/annotations/page/page.header.json @@ -3,7 +3,6 @@ "page": [ "level 1/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,8 @@ "start": 1, "end": 4 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json index b82a752..4430f95 100644 --- a/tests/annotations/readonly/readonly.json +++ b/tests/annotations/readonly/readonly.json @@ -3,7 +3,6 @@ "body": [ { "readonly": true, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,11 +18,11 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "readonly": true, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -39,11 +38,11 @@ "start": 1, "end": 6 } - } + }, + "access": "public" }, { "readonly": false, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -59,7 +58,8 @@ "start": 1, "end": 6 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json index 9ac627c..4d3bd3c 100644 --- a/tests/annotations/requires/requires.alias.json +++ b/tests/annotations/requires/requires.alias.json @@ -9,7 +9,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,7 +24,8 @@ "start": 1, "end": 2 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json index 67dffe4..5cae026 100644 --- a/tests/annotations/requires/requires.body.json +++ b/tests/annotations/requires/requires.body.json @@ -9,7 +9,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,7 +24,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "requires": [ @@ -37,7 +37,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -53,7 +52,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "requires": [ @@ -68,7 +68,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -84,7 +83,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "requires": [ @@ -94,7 +94,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -110,7 +109,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "requires": [ @@ -120,7 +120,6 @@ "description": "

the path function from node

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -136,7 +135,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "requires": [ @@ -148,7 +148,6 @@ "description": "

the path function from node

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -164,7 +163,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "requires": [ @@ -179,7 +179,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -195,7 +194,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json index 4ba7467..b8ccce6 100644 --- a/tests/annotations/requires/requires.header.json +++ b/tests/annotations/requires/requires.header.json @@ -9,7 +9,6 @@ "description": "

the path function from node

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,6 +25,7 @@ "end": 4 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json index ac9d2c8..894f6fc 100644 --- a/tests/annotations/returns/returns.alias.json +++ b/tests/annotations/returns/returns.alias.json @@ -8,7 +8,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -33,7 +33,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -49,7 +48,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -60,7 +60,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -76,7 +75,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -87,7 +87,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -103,7 +102,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -112,7 +112,6 @@ ], "description": "

Lorem ipsum dolor sit amet

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -128,7 +127,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -137,7 +137,6 @@ ], "description": "

Lorem ipsum dolor sit amet

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -153,7 +152,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -162,7 +162,6 @@ ], "description": "

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" }, - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -178,7 +177,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json index fe64497..980e140 100644 --- a/tests/annotations/returns/returns.json +++ b/tests/annotations/returns/returns.json @@ -8,7 +8,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -33,7 +33,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -49,7 +48,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -60,7 +60,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -76,7 +75,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -87,7 +87,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -103,7 +102,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -112,7 +112,6 @@ ], "description": "

Lorem ipsum dolor sit amet

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -128,7 +127,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -137,7 +137,6 @@ ], "description": "

Lorem ipsum dolor sit amet

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -153,7 +152,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" }, { "returns": { @@ -162,7 +162,6 @@ ], "description": "

This super awesome object

\n
{\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
\n" }, - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -178,7 +177,8 @@ "start": 1, "end": 23 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json index 2bbc5fc..652342e 100644 --- a/tests/annotations/since/since.body.json +++ b/tests/annotations/since/since.body.json @@ -6,7 +6,6 @@ "version": "undefined", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,14 @@ "start": 1, "end": 11 } - } + }, + "access": "public" }, { "since": { "version": "0.0.1", "description": "

Lorem

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +44,14 @@ "start": 1, "end": 11 } - } + }, + "access": "public" }, { "since": { "version": "0.0.1", "description": "

Lorem

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +67,14 @@ "start": 1, "end": 11 } - } + }, + "access": "public" }, { "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" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,7 +90,8 @@ "start": 1, "end": 11 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json index 06ccc72..c5c52bc 100644 --- a/tests/annotations/since/since.header.json +++ b/tests/annotations/since/since.header.json @@ -4,7 +4,6 @@ "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" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,6 +20,7 @@ "end": 7 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json index fc7fcd6..367e5d3 100644 --- a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json +++ b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json @@ -94,7 +94,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -110,7 +109,8 @@ "start": 1, "end": 27 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-multiple-markup-blocks.json b/tests/annotations/state/state-multiple-markup-blocks.json index cf14a4d..b729f35 100644 --- a/tests/annotations/state/state-multiple-markup-blocks.json +++ b/tests/annotations/state/state-multiple-markup-blocks.json @@ -60,7 +60,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -76,7 +75,8 @@ "start": 1, "end": 24 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-description.json b/tests/annotations/state/state-multiple-stupid-simple-with-description.json index c1e64e5..45e0c8a 100644 --- a/tests/annotations/state/state-multiple-stupid-simple-with-description.json +++ b/tests/annotations/state/state-multiple-stupid-simple-with-description.json @@ -66,7 +66,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -82,7 +81,8 @@ "start": 1, "end": 74 } - } + }, + "access": "public" }, { "states": { @@ -149,7 +149,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -165,7 +164,8 @@ "start": 1, "end": 74 } - } + }, + "access": "public" }, { "states": { @@ -232,7 +232,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -248,7 +247,8 @@ "start": 1, "end": 74 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-notations.json b/tests/annotations/state/state-multiple-stupid-simple-with-notations.json index d50e947..3bdfed4 100644 --- a/tests/annotations/state/state-multiple-stupid-simple-with-notations.json +++ b/tests/annotations/state/state-multiple-stupid-simple-with-notations.json @@ -66,7 +66,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -82,7 +81,8 @@ "start": 1, "end": 74 } - } + }, + "access": "public" }, { "states": { @@ -149,7 +149,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -165,7 +164,8 @@ "start": 1, "end": 74 } - } + }, + "access": "public" }, { "states": { @@ -232,7 +232,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -248,7 +247,8 @@ "start": 1, "end": 74 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-multiple-stupid-simple.json b/tests/annotations/state/state-multiple-stupid-simple.json index 2a149cf..4fb6a67 100644 --- a/tests/annotations/state/state-multiple-stupid-simple.json +++ b/tests/annotations/state/state-multiple-stupid-simple.json @@ -66,7 +66,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -82,7 +81,8 @@ "start": 1, "end": 24 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-stupid-simple-with-description.json b/tests/annotations/state/state-stupid-simple-with-description.json index 734b5e2..546770c 100644 --- a/tests/annotations/state/state-stupid-simple-with-description.json +++ b/tests/annotations/state/state-stupid-simple-with-description.json @@ -34,7 +34,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,7 +49,8 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, { "states": { @@ -85,7 +85,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -101,7 +100,8 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, { "states": { @@ -136,7 +136,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 30, @@ -152,7 +151,8 @@ "start": 1, "end": 43 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-stupid-simple-with-notations.json b/tests/annotations/state/state-stupid-simple-with-notations.json index 207d0d7..c7ee554 100644 --- a/tests/annotations/state/state-stupid-simple-with-notations.json +++ b/tests/annotations/state/state-stupid-simple-with-notations.json @@ -34,7 +34,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,7 +49,8 @@ "start": 1, "end": 44 } - } + }, + "access": "public" }, { "states": { @@ -85,7 +85,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -101,7 +100,8 @@ "start": 1, "end": 44 } - } + }, + "access": "public" }, { "states": { @@ -136,7 +136,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 31, @@ -152,7 +151,8 @@ "start": 1, "end": 44 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/state/state-stupid-simple.json b/tests/annotations/state/state-stupid-simple.json index aeed4c0..614d667 100644 --- a/tests/annotations/state/state-stupid-simple.json +++ b/tests/annotations/state/state-stupid-simple.json @@ -34,7 +34,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,7 +49,8 @@ "start": 1, "end": 14 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json index b6b7c66..73f3274 100644 --- a/tests/annotations/throws/throws.alias.json +++ b/tests/annotations/throws/throws.alias.json @@ -10,7 +10,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,7 +25,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" }, { "throws": [ @@ -37,7 +37,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -53,7 +52,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" }, { "throws": [ @@ -64,7 +64,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -80,7 +79,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" }, { "throws": [ @@ -91,7 +91,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -107,7 +106,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json index 5f305dd..ea2df0d 100644 --- a/tests/annotations/throws/throws.json +++ b/tests/annotations/throws/throws.json @@ -8,7 +8,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" }, { "throws": [ @@ -35,7 +35,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -51,7 +50,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" }, { "throws": [ @@ -62,7 +62,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -78,7 +77,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" }, { "throws": [ @@ -89,7 +89,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -105,7 +104,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" }, { "throws": [ @@ -116,7 +116,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -132,7 +131,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" }, { "throws": [ @@ -149,7 +149,6 @@ "description": "

when something goes wrong

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 14, @@ -165,7 +164,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json index 7c32a6f..8736ca4 100644 --- a/tests/annotations/todo/todo.body.json +++ b/tests/annotations/todo/todo.body.json @@ -9,7 +9,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,7 +24,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "todo": [ @@ -35,7 +35,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -51,7 +50,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "todo": [ @@ -61,7 +61,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -77,7 +76,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "todo": [ @@ -89,7 +89,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -105,7 +104,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "todo": [ @@ -118,7 +118,6 @@ "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -134,7 +133,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, { "todo": [ @@ -147,7 +147,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -163,7 +162,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json index 82381a2..2588d4b 100644 --- a/tests/annotations/todo/todo.header.json +++ b/tests/annotations/todo/todo.header.json @@ -10,7 +10,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -27,6 +26,7 @@ "end": 7 } }, + "access": "public", "page": [ "other" ] diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json index 1663a2d..580475c 100644 --- a/tests/annotations/type/type.json +++ b/tests/annotations/type/type.json @@ -6,7 +6,6 @@ "type": "undefined", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "type": { "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +44,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "type": { "type": "undefined", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +67,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "type": { "type": "undefined", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,14 +90,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "type": { "type": "array", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -114,14 +113,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "type": { "type": "array", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -137,14 +136,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public" }, { "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" }, - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -160,7 +159,8 @@ "start": 1, "end": 18 } - } + }, + "access": "public" } ] } diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json index e10459d..2d9ef8b 100644 --- a/tests/annotations/version/version.json +++ b/tests/annotations/version/version.json @@ -6,7 +6,6 @@ "version": "undefined", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,14 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, { "version": { "version": "0.0.1", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +44,14 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, { "version": { "version": "^0.0.1", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +67,14 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, { "version": { "version": "^0.0.1", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,14 +90,14 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, { "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" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -114,7 +113,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/4-blank-lines-between-code-blocks.json b/tests/cases/4-blank-lines-between-code-blocks.json index 2505335..857ef21 100644 --- a/tests/cases/4-blank-lines-between-code-blocks.json +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -14,7 +14,6 @@ "body": [ { "raw-code": "@mixin moz-only() {\n $selector: &;\n @at-root {\n @-moz-document url-prefix() {\n #{$selector} {\n @content;\n }\n }\n }\n}", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -30,7 +29,8 @@ "start": 1, "end": 33 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json index c0018d3..4743995 100644 --- a/tests/cases/header-comment-only.json +++ b/tests/cases/header-comment-only.json @@ -16,7 +16,6 @@ "Tyler Benton" ], "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -32,7 +31,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index 5fd5f66..eedac16 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -19,7 +19,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -35,7 +34,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" }, "body": [ { @@ -55,7 +55,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -71,7 +70,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index 51126bf..f72e47c 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -29,7 +29,6 @@ "Tyler Benton" ], "description": "

Your standard form button.

\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -45,7 +44,8 @@ "start": 1, "end": 19 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json index 5792b59..010e1a2 100644 --- a/tests/cases/only-comments.json +++ b/tests/cases/only-comments.json @@ -23,7 +23,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -39,7 +38,8 @@ "start": 1, "end": 27 } - } + }, + "access": "public" }, "body": [ { @@ -62,7 +62,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -78,12 +77,12 @@ "start": 1, "end": 27 } - } + }, + "access": "public" }, { "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", - "access": "public", "blockinfo": { "comment": { "start": 21, @@ -99,7 +98,8 @@ "start": 1, "end": 27 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/preserves-blank-lines.json b/tests/cases/preserves-blank-lines.json index be9d9ba..5de3a8e 100644 --- a/tests/cases/preserves-blank-lines.json +++ b/tests/cases/preserves-blank-lines.json @@ -31,7 +31,6 @@ "escaped_stateless": "<a href="#" class="c-btn @state">Button (a.button)</a>\n<button class="c-btn @state">Button (button)</button>\n<input class="c-btn @state" type="button" value="Button (input.button)">" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,7 +46,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/single-body-comment-no-code.json b/tests/cases/single-body-comment-no-code.json index 3fccf7d..c721897 100644 --- a/tests/cases/single-body-comment-no-code.json +++ b/tests/cases/single-body-comment-no-code.json @@ -20,7 +20,6 @@ { "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", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -36,7 +35,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/single-body-comment.json b/tests/cases/single-body-comment.json index 408e382..bf49fc2 100644 --- a/tests/cases/single-body-comment.json +++ b/tests/cases/single-body-comment.json @@ -37,7 +37,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -53,7 +52,8 @@ "start": 1, "end": 27 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/space-between-comment-and-code.json b/tests/cases/space-between-comment-and-code.json index f6c91d1..ff95335 100644 --- a/tests/cases/space-between-comment-and-code.json +++ b/tests/cases/space-between-comment-and-code.json @@ -40,7 +40,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -56,7 +55,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" } ] } diff --git a/tests/cases/starts-and-ends-with-spaces.json b/tests/cases/starts-and-ends-with-spaces.json index bfabfe9..8f100eb 100644 --- a/tests/cases/starts-and-ends-with-spaces.json +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -37,7 +37,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -53,7 +52,8 @@ "start": 1, "end": 38 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/c++/test.json b/tests/file-types/c++/test.json index 48a4889..fe54062 100644 --- a/tests/file-types/c++/test.json +++ b/tests/file-types/c++/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 93 } - } + }, + "access": "public" }, "body": [ { "name": "one", "description": "

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 93 } - } + }, + "access": "public" }, { "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", - "access": "public", "blockinfo": { "comment": { "start": 35, @@ -98,12 +97,12 @@ "start": 1, "end": 93 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 68, @@ -119,7 +118,8 @@ "start": 1, "end": 93 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/c/test.json b/tests/file-types/c/test.json index 5730b64..01e2902 100644 --- a/tests/file-types/c/test.json +++ b/tests/file-types/c/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 89 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 89 } - } + }, + "access": "public" }, { "name": "Two", "description": "

This is a normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -98,12 +97,12 @@ "start": 1, "end": 89 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 64, @@ -119,7 +118,8 @@ "start": 1, "end": 89 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/coffeescript/test.json b/tests/file-types/coffeescript/test.json index 49b8037..37ef0a4 100644 --- a/tests/file-types/coffeescript/test.json +++ b/tests/file-types/coffeescript/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 40 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -77,12 +76,12 @@ "start": 1, "end": 40 } - } + }, + "access": "public" }, { "name": "Two", "description": "

This is a normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 17, @@ -98,12 +97,12 @@ "start": 1, "end": 40 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normla multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 31, @@ -119,7 +118,8 @@ "start": 1, "end": 40 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/coldfusion/test.json b/tests/file-types/coldfusion/test.json index 7a2007f..d64c78a 100644 --- a/tests/file-types/coldfusion/test.json +++ b/tests/file-types/coldfusion/test.json @@ -43,7 +43,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -59,13 +58,13 @@ "start": 1, "end": 61 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -81,12 +80,12 @@ "start": 1, "end": 61 } - } + }, + "access": "public" }, { "name": "Two", "description": "

This is a normal multi-line coldfusion comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 18, @@ -102,12 +101,12 @@ "start": 1, "end": 61 } - } + }, + "access": "public" }, { "name": "Three", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -123,12 +122,12 @@ "start": 1, "end": 61 } - } + }, + "access": "public" }, { "name": "Four", "description": "

This is another normal multi-line coldfusion comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -144,7 +143,8 @@ "start": 1, "end": 61 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/cs/test.json b/tests/file-types/cs/test.json index a68bcb9..02efd95 100644 --- a/tests/file-types/cs/test.json +++ b/tests/file-types/cs/test.json @@ -40,7 +40,6 @@ "Tyler Benton" ], "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -56,13 +55,13 @@ "start": 1, "end": 95 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 10, @@ -78,12 +77,12 @@ "start": 1, "end": 95 } - } + }, + "access": "public" }, { "name": "Two", "description": "

This is a normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 40, @@ -99,12 +98,12 @@ "start": 1, "end": 95 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 70, @@ -120,7 +119,8 @@ "start": 1, "end": 95 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/css/test.json b/tests/file-types/css/test.json index 8cc7559..7b48421 100644 --- a/tests/file-types/css/test.json +++ b/tests/file-types/css/test.json @@ -35,7 +35,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -51,13 +50,13 @@ "start": 1, "end": 31 } - } + }, + "access": "public" }, "body": [ { "name": "Base Styles", "description": "
    \n
  1. Set default font family to sans-serif.
  2. \n
  3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
  4. \n
\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -73,12 +72,12 @@ "start": 1, "end": 31 } - } + }, + "access": "public" }, { "name": "Input", "description": "
    \n
  1. Address appearance set to searchfield in Safari 5 and Chrome.
  2. \n
  3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
  4. \n
\n", - "access": "public", "blockinfo": { "comment": { "start": 20, @@ -94,7 +93,8 @@ "start": 1, "end": 31 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/html/test.json b/tests/file-types/html/test.json index 2d8d7b2..602eea3 100644 --- a/tests/file-types/html/test.json +++ b/tests/file-types/html/test.json @@ -36,7 +36,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -52,13 +51,13 @@ "start": 1, "end": 36 } - } + }, + "access": "public" }, "body": [ { "name": "Body Block 1", "description": "

This is the main header of the site

\n", - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -74,12 +73,12 @@ "start": 1, "end": 36 } - } + }, + "access": "public" }, { "name": "Body Block 2", "description": "

This is the main footer of the site

\n", - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -95,7 +94,8 @@ "start": 1, "end": 36 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/jade/test.json b/tests/file-types/jade/test.json index e93b94f..f5f70e0 100644 --- a/tests/file-types/jade/test.json +++ b/tests/file-types/jade/test.json @@ -31,7 +31,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,13 +46,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -69,7 +68,8 @@ "start": 1, "end": 16 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/java/test.json b/tests/file-types/java/test.json index 7b78beb..98daac6 100644 --- a/tests/file-types/java/test.json +++ b/tests/file-types/java/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 34 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

A very simple class to print out Hello World

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 34 } - } + }, + "access": "public" }, { "name": "Two", "description": "

This is a normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 17, @@ -98,12 +97,12 @@ "start": 1, "end": 34 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -119,7 +118,8 @@ "start": 1, "end": 34 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/js/test.json b/tests/file-types/js/test.json index e18e8f6..3c29ae2 100644 --- a/tests/file-types/js/test.json +++ b/tests/file-types/js/test.json @@ -31,7 +31,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,7 +46,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" }, "body": [ { @@ -74,7 +74,6 @@ "escaped_stateless": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two" } ], - "access": "public", "blockinfo": { "comment": { "start": 8, @@ -90,7 +89,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json index 4830131..1369cad 100644 --- a/tests/file-types/less/test.json +++ b/tests/file-types/less/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,7 +54,8 @@ "start": 1, "end": 59 } - } + }, + "access": "public" }, "body": [ { @@ -76,7 +76,6 @@ "escaped_stateless": "\\@name" } ], - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -92,7 +91,8 @@ "start": 1, "end": 59 } - } + }, + "access": "public" }, { "name": "Two", @@ -109,7 +109,6 @@ "escaped_stateless": "<nav>\n <a href="">One</a>\n <a href="">Two</a>\n <a href="">Three</a>\n</nav>" } ], - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -125,7 +124,8 @@ "start": 1, "end": 59 } - } + }, + "access": "public" }, { "name": "Three", @@ -152,7 +152,6 @@ "escaped_stateless": ".foo {\n .opacity(.3);\n}" } ], - "access": "public", "blockinfo": { "comment": { "start": 43, @@ -168,7 +167,8 @@ "start": 1, "end": 59 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/markdown/mark.json b/tests/file-types/markdown/mark.json index 71748d5..70b5ed6 100644 --- a/tests/file-types/markdown/mark.json +++ b/tests/file-types/markdown/mark.json @@ -25,7 +25,6 @@ "header": { "name": "mark", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/markdown.json b/tests/file-types/markdown/markdown.json index 25790f0..399e9c3 100644 --- a/tests/file-types/markdown/markdown.json +++ b/tests/file-types/markdown/markdown.json @@ -25,7 +25,6 @@ "header": { "name": "markdown", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/md.json b/tests/file-types/markdown/md.json index 82b47e3..94c435c 100644 --- a/tests/file-types/markdown/md.json +++ b/tests/file-types/markdown/md.json @@ -25,7 +25,6 @@ "header": { "name": "md", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdml.json b/tests/file-types/markdown/mdml.json index b54f037..801a40c 100644 --- a/tests/file-types/markdown/mdml.json +++ b/tests/file-types/markdown/mdml.json @@ -25,7 +25,6 @@ "header": { "name": "mdml", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdown.json b/tests/file-types/markdown/mdown.json index 7b7b904..79a6be8 100644 --- a/tests/file-types/markdown/mdown.json +++ b/tests/file-types/markdown/mdown.json @@ -25,7 +25,6 @@ "header": { "name": "mdown", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdtext.json b/tests/file-types/markdown/mdtext.json index 7b43fb0..ba3d4fd 100644 --- a/tests/file-types/markdown/mdtext.json +++ b/tests/file-types/markdown/mdtext.json @@ -25,7 +25,6 @@ "header": { "name": "mdtext", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdtxt.json b/tests/file-types/markdown/mdtxt.json index 2d18726..c41d58b 100644 --- a/tests/file-types/markdown/mdtxt.json +++ b/tests/file-types/markdown/mdtxt.json @@ -25,7 +25,6 @@ "header": { "name": "mdtxt", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdwn.json b/tests/file-types/markdown/mdwn.json index 601b9a4..253f621 100644 --- a/tests/file-types/markdown/mdwn.json +++ b/tests/file-types/markdown/mdwn.json @@ -25,7 +25,6 @@ "header": { "name": "mdwn", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mkd.json b/tests/file-types/markdown/mkd.json index 2519cac..86f2c79 100644 --- a/tests/file-types/markdown/mkd.json +++ b/tests/file-types/markdown/mkd.json @@ -25,7 +25,6 @@ "header": { "name": "mkd", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mkdn.json b/tests/file-types/markdown/mkdn.json index 59303da..76d77d4 100644 --- a/tests/file-types/markdown/mkdn.json +++ b/tests/file-types/markdown/mkdn.json @@ -25,7 +25,6 @@ "header": { "name": "mkdn", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/text.json b/tests/file-types/markdown/text.json index cd58ead..092e484 100644 --- a/tests/file-types/markdown/text.json +++ b/tests/file-types/markdown/text.json @@ -25,7 +25,6 @@ "header": { "name": "text", "markdown": "

Default Annotations

\n

@name

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeValue
DescriptionName of the documented item
Multiplefalse
Default-
Aliases-
Autofilled-
\n
Example
\n
/// @name Name\n
\n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/php/test.json b/tests/file-types/php/test.json index c5bcec7..4eb1e54 100644 --- a/tests/file-types/php/test.json +++ b/tests/file-types/php/test.json @@ -40,7 +40,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 2, @@ -56,13 +55,13 @@ "start": 1, "end": 37 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -78,12 +77,12 @@ "start": 1, "end": 37 } - } + }, + "access": "public" }, { "name": "Two", "description": "

This is a normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 14, @@ -99,12 +98,12 @@ "start": 1, "end": 37 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 27, @@ -120,7 +119,8 @@ "start": 1, "end": 37 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/python/test.json b/tests/file-types/python/test.json index b9509d8..fcad486 100644 --- a/tests/file-types/python/test.json +++ b/tests/file-types/python/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, "body": [ { "name": "main", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, { "name": "something", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 23, @@ -98,12 +97,12 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, { "name": "something else", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 32, @@ -119,7 +118,8 @@ "start": 1, "end": 43 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/ruby/test.json b/tests/file-types/ruby/test.json index fa94902..077e874 100644 --- a/tests/file-types/ruby/test.json +++ b/tests/file-types/ruby/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, { "name": "Two", "description": "

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

\n", - "access": "public", "blockinfo": { "comment": { "start": 15, @@ -98,12 +97,12 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, { "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", - "access": "public", "blockinfo": { "comment": { "start": 24, @@ -119,7 +118,8 @@ "start": 1, "end": 43 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/scss/test.json b/tests/file-types/scss/test.json index c9e20a6..4d69883 100644 --- a/tests/file-types/scss/test.json +++ b/tests/file-types/scss/test.json @@ -35,7 +35,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -51,7 +50,8 @@ "start": 1, "end": 39 } - } + }, + "access": "public" }, "body": [ { @@ -60,7 +60,6 @@ "type": "color", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -76,7 +75,8 @@ "start": 1, "end": 39 } - } + }, + "access": "public" }, { "name": "moz-only", @@ -117,7 +117,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 12, @@ -133,7 +132,8 @@ "start": 1, "end": 39 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/stylus/test.json b/tests/file-types/stylus/test.json index c249d27..19f54fc 100644 --- a/tests/file-types/stylus/test.json +++ b/tests/file-types/stylus/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 37 } - } + }, + "access": "public" }, { "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", - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -98,12 +97,12 @@ "start": 1, "end": 37 } - } + }, + "access": "public" }, { "name": "Three", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 27, @@ -119,7 +118,8 @@ "start": 1, "end": 37 } - } + }, + "access": "public" } ] } diff --git a/tests/file-types/swift/test.json b/tests/file-types/swift/test.json index cd3cf35..1414c66 100644 --- a/tests/file-types/swift/test.json +++ b/tests/file-types/swift/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 49 } - } + }, + "access": "public" }, "body": [ { "name": "main", "description": "

main method

\n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,12 @@ "start": 1, "end": 49 } - } + }, + "access": "public" }, { "name": "Something", "description": "

This is a normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 23, @@ -98,12 +97,12 @@ "start": 1, "end": 49 } - } + }, + "access": "public" }, { "name": "Something else", "description": "

This is another normal multi-line comment.

\n", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -119,7 +118,8 @@ "start": 1, "end": 49 } - } + }, + "access": "public" } ] } From 0c22f5d976526ef0c552fd7a8dd1edb10def06f4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 4 Mar 2016 15:53:34 -0500 Subject: [PATCH 229/273] removed a missed comment --- app/annotations/index.js | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/app/annotations/index.js b/app/annotations/index.js index 3dd2e75..0ebdb16 100644 --- a/app/annotations/index.js +++ b/app/annotations/index.js @@ -1,31 +1,3 @@ -// export default { -// access: require('./access.js'), -// alias: require('./alias.js'), -// arg: require('./arg.js'), -// author: require('./author.js'), -// blockinfo: require('./blockinfo.js'), -// chainable: require('./chainable.js'), -// deprecated: require('./deprecated.js'), -// description: require('./description.js'), -// markdown: require('./markdown.js'), -// markup: require('./markup.js'), -// name: require('./name.js'), -// note: require('./note.js'), -// page: require('./page.js'), -// 'raw-code': require('./raw-code.js'), -// readonly: require('./readonly.js'), -// requires: require('./requires.js'), -// returns: require('./returns.js'), -// since: require('./since.js'), -// states: require('./states.js'), -// throws: require('./throws.js'), -// todo: require('./todo.js'), -// type: require('./type.js'), -// version: require('./version.js'), -// } - - - export access from './access' export alias from './alias' export arg from './arg' From 11875af2949ef1116075d05875c968ab90908737 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 4 Mar 2016 15:58:21 -0500 Subject: [PATCH 230/273] fixed a bug with annotation exports --- app/annotations/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/annotations/index.js b/app/annotations/index.js index 0ebdb16..c66c0b1 100644 --- a/app/annotations/index.js +++ b/app/annotations/index.js @@ -11,7 +11,7 @@ export markup from './markup' export name from './name' export note from './note' export page from './page' -export type from './type' +module.exports.type = require('./type') module.exports['raw-code'] = require('./raw-code.js') export readonly from './readonly' export requires from './requires' From facd5c39b6dad6a5c1afc35eb17ab7c1169f6710 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 4 Mar 2016 16:12:05 -0500 Subject: [PATCH 231/273] added `@page` annotation to all the annotation files --- app/annotations/access.js | 1 + app/annotations/alias.js | 2 ++ app/annotations/annotation-utils.js | 18 ++++++++++++++ app/annotations/arg.js | 1 + app/annotations/author.js | 1 + app/annotations/blockinfo.js | 1 + app/annotations/chainable.js | 1 + app/annotations/deprecated.js | 1 + app/annotations/description.js | 2 ++ app/annotations/markdown.js | 1 + app/annotations/markup.js | 24 +++++-------------- app/annotations/name.js | 1 + app/annotations/note.js | 1 + app/annotations/page.js | 1 + app/annotations/raw-code.js | 12 +++++++++- app/annotations/readonly.js | 1 + app/annotations/requires.js | 1 + app/annotations/returns.js | 1 + app/annotations/since.js | 1 + app/annotations/states.js | 2 +- app/annotations/throws.js | 1 + app/annotations/todo.js | 1 + app/annotations/type.js | 1 + app/annotations/version.js | 3 ++- .../4-blank-lines-between-code-blocks.json | 5 +++- 25 files changed, 63 insertions(+), 22 deletions(-) diff --git a/app/annotations/access.js b/app/annotations/access.js index 501d2a8..b28f7b8 100644 --- a/app/annotations/access.js +++ b/app/annotations/access.js @@ -1,4 +1,5 @@ /// @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. diff --git a/app/annotations/alias.js b/app/annotations/alias.js index 16d0d79..c61aac6 100644 --- a/app/annotations/alias.js +++ b/app/annotations/alias.js @@ -1,6 +1,8 @@ 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} diff --git a/app/annotations/annotation-utils.js b/app/annotations/annotation-utils.js index cfdc3b3..656ab3f 100644 --- a/app/annotations/annotation-utils.js +++ b/app/annotations/annotation-utils.js @@ -165,3 +165,21 @@ export function logAnnotationError(obj, expected) { return contents.join('\n') } + + +export function escape(str) { + return str + .split('\n') + .map((line) => { + return line.replace(/[&<>'"]/g, (match) => { + return { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' + }[match] + }) + }) + .join('\n') +} diff --git a/app/annotations/arg.js b/app/annotations/arg.js index 6640cba..d42f30d 100644 --- a/app/annotations/arg.js +++ b/app/annotations/arg.js @@ -1,6 +1,7 @@ import { markdown, regex, list } from './annotation-utils' /// @name @arg +/// @page annotations /// @description Parameters from the documented function/mixin /// @note Description runs through markdown /// @returns {object} diff --git a/app/annotations/author.js b/app/annotations/author.js index a0154b5..30083e1 100644 --- a/app/annotations/author.js +++ b/app/annotations/author.js @@ -1,5 +1,6 @@ import { multiple } from './annotation-utils' /// @name @author +/// @page annotations /// @alias @authors /// @description Author of the documented item /// @returns {string} diff --git a/app/annotations/blockinfo.js b/app/annotations/blockinfo.js index af3e6f7..b9dcbbb 100644 --- a/app/annotations/blockinfo.js +++ b/app/annotations/blockinfo.js @@ -1,6 +1,7 @@ import { to } from '../utils' import { logAnnotationError } from './annotation-utils' /// @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 diff --git a/app/annotations/chainable.js b/app/annotations/chainable.js index c7c6318..7021365 100644 --- a/app/annotations/chainable.js +++ b/app/annotations/chainable.js @@ -1,6 +1,7 @@ import { toBoolean, multiple } from './annotation-utils' /// @name @chainable +/// @page annotations /// @alias @chain /// @description Used to notate that a function is chainable /// @returns {boolean, array} diff --git a/app/annotations/deprecated.js b/app/annotations/deprecated.js index e2a906f..b619fa8 100644 --- a/app/annotations/deprecated.js +++ b/app/annotations/deprecated.js @@ -1,6 +1,7 @@ import { markdown, regex } from './annotation-utils' /// @name @deprecated +/// @page annotations /// @description Lets you know that a mixin/function has been depricated /// @returns {object} /// @markup Usage diff --git a/app/annotations/description.js b/app/annotations/description.js index 03c663b..e15983d 100644 --- a/app/annotations/description.js +++ b/app/annotations/description.js @@ -1,5 +1,7 @@ import { markdown } from './annotation-utils' + /// @name @description +/// @page annotations /// @alias @desc, @definition, @explanation, @writeup, @summary, @summarization /// @description Description of the documented item /// @note Runs through markdown diff --git a/app/annotations/markdown.js b/app/annotations/markdown.js index d4fa6d8..6bd48d3 100644 --- a/app/annotations/markdown.js +++ b/app/annotations/markdown.js @@ -1,6 +1,7 @@ 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. diff --git a/app/annotations/markup.js b/app/annotations/markup.js index dea52fd..3fa5549 100644 --- a/app/annotations/markup.js +++ b/app/annotations/markup.js @@ -1,7 +1,8 @@ import { is, to } from '../utils' -import { regex, list, markdown } from './annotation-utils' +import { regex, list, markdown, escape } from './annotation-utils' /// @name @markup +/// @page annotations /// @alias @code, @example, @output, @outputs /// @description /// Example code on how to use the documented block. @@ -20,7 +21,9 @@ import { regex, list, markdown } from './annotation-utils' /// settings: {}, // settings for the code block /// description: 'string', /// raw: 'string', // raw string of code -/// escaped: 'string' // escaped code, aka `` turns to `<span>` +/// 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 @@ -47,14 +50,6 @@ import { regex, list, markdown } from './annotation-utils' export default { alias: [ 'code', 'example', 'output', 'outputs' ], parse() { - let escaped_characters = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - '\'': ''' - } - let [ id = null, language = this.file.type, @@ -64,14 +59,7 @@ export default { let raw = this.annotation.contents - let escaped = raw - .split('\n') - .map((line) => line - .replace(/[&<>'"]/g, (match) => - escaped_characters[match] - ) - ) - .join('\n') + let escaped = escape(raw) // @todo {10} update this use use the user defined options const state_interpolation = /\s*\${@states?[^\}]*\}\s*/gi diff --git a/app/annotations/name.js b/app/annotations/name.js index aa04ca2..6ea4c2a 100644 --- a/app/annotations/name.js +++ b/app/annotations/name.js @@ -1,4 +1,5 @@ /// @name @name +/// @page annotations /// @alias @title, @heading, @header /// @description Name of the documented item /// @returns {string} diff --git a/app/annotations/note.js b/app/annotations/note.js index b346184..860956f 100644 --- a/app/annotations/note.js +++ b/app/annotations/note.js @@ -1,6 +1,7 @@ import { regex, markdown } from './annotation-utils' /// @name @note +/// @page annotations /// @alias @notes /// @description A note about the documented item /// @returns {object} diff --git a/app/annotations/page.js b/app/annotations/page.js index fa34643..cc08a56 100644 --- a/app/annotations/page.js +++ b/app/annotations/page.js @@ -1,6 +1,7 @@ import { list } from './annotation-utils' /// @name @page +/// @page annotations /// @alias @group /// @description The page you want the documented item to be on /// @note {5} diff --git a/app/annotations/raw-code.js b/app/annotations/raw-code.js index 0e5710c..89e3a28 100644 --- a/app/annotations/raw-code.js +++ b/app/annotations/raw-code.js @@ -1,5 +1,15 @@ +import { escape } from './annotation-utils' + +/// @name @raw-code +/// @page annotations +/// @description +/// This will output the raw code below the comment block +/// @returns {object} export default { parse() { - return this.code.contents + return { + raw: this.code.contents, + escaped: escape(this.code.contents) + } } } diff --git a/app/annotations/readonly.js b/app/annotations/readonly.js index 1042243..ec44f31 100644 --- a/app/annotations/readonly.js +++ b/app/annotations/readonly.js @@ -1,6 +1,7 @@ import { toBoolean } from './annotation-utils' /// @name @readonly +/// @page annotations /// @description /// To note that a property is readonly. /// @returns {boolean} diff --git a/app/annotations/requires.js b/app/annotations/requires.js index 1c95d93..a1b37f8 100644 --- a/app/annotations/requires.js +++ b/app/annotations/requires.js @@ -1,6 +1,7 @@ import { regex, list, markdown } from './annotation-utils' /// @name @requires +/// @page annotations /// @alias @require /// @description Requirements from the documented item /// @returns {object} diff --git a/app/annotations/returns.js b/app/annotations/returns.js index b191684..be07dc3 100644 --- a/app/annotations/returns.js +++ b/app/annotations/returns.js @@ -1,6 +1,7 @@ import { regex, list, markdown } from './annotation-utils' /// @name @returns +/// @page annotations /// @alias @return /// @description Return from the documented function /// @returns {string} diff --git a/app/annotations/since.js b/app/annotations/since.js index 5572e8e..35f1c41 100644 --- a/app/annotations/since.js +++ b/app/annotations/since.js @@ -1,6 +1,7 @@ import { regex, markdown } from './annotation-utils' /// @name @since +/// @page annotations /// @description Let's you know what version of the project a something was added /// @returns {string} /// @markup Usage diff --git a/app/annotations/states.js b/app/annotations/states.js index 3209cad..b49e93c 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -2,8 +2,8 @@ import { is, to } from '../utils' import { regex, markdown } from './annotation-utils' /// @name @states -/// @alias @state /// @page annotations +/// @alias @state /// @description A state of a the documented item /// @returns {hashmap} /// @note {10} This annotation must be used with @markup diff --git a/app/annotations/throws.js b/app/annotations/throws.js index 1f85248..aeac9a3 100644 --- a/app/annotations/throws.js +++ b/app/annotations/throws.js @@ -1,6 +1,7 @@ import { regex, list, markdown } from './annotation-utils' /// @name @throws +/// @page annotations /// @alias @throw, @exception, @error, @catch /// @description /// The error that happends if something goes wrong diff --git a/app/annotations/todo.js b/app/annotations/todo.js index 601ba6e..34f82bf 100644 --- a/app/annotations/todo.js +++ b/app/annotations/todo.js @@ -1,6 +1,7 @@ import { regex, list, markdown } from './annotation-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 diff --git a/app/annotations/type.js b/app/annotations/type.js index f370128..9faf1c5 100644 --- a/app/annotations/type.js +++ b/app/annotations/type.js @@ -2,6 +2,7 @@ import { regex, markdown, logAnnotationError } from './annotation-utils' import clor from 'clor' /// @name @type +/// @page annotations /// @description Describes the type of a variable /// @returns {object} /// @markup Usage diff --git a/app/annotations/version.js b/app/annotations/version.js index 70daf37..c0ba4b5 100644 --- a/app/annotations/version.js +++ b/app/annotations/version.js @@ -2,8 +2,9 @@ import { logAnnotationError, regex, markdown } from './annotation-utils' import clor from 'clor' /// @name @version +/// @page annotations /// @description Describes the type of a variable -/// @returns {string} +/// @returns {object} /// @markup Usage /// /// @version {version} /// diff --git a/tests/cases/4-blank-lines-between-code-blocks.json b/tests/cases/4-blank-lines-between-code-blocks.json index 857ef21..4d859f6 100644 --- a/tests/cases/4-blank-lines-between-code-blocks.json +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -13,7 +13,10 @@ "header": {}, "body": [ { - "raw-code": "@mixin moz-only() {\n $selector: &;\n @at-root {\n @-moz-document url-prefix() {\n #{$selector} {\n @content;\n }\n }\n }\n}", + "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, From 02c9abf6b6998c481df0e37ba0fb61a73252d31f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 4 Mar 2016 16:49:56 -0500 Subject: [PATCH 232/273] Updated markup and state to use file specific options for their regexes --- app/annotation-api.js | 2 ++ app/annotations/markup.js | 6 +++--- app/annotations/states.js | 19 +++++++++---------- app/config.js | 2 +- app/parser/parse-blocks.js | 4 ++++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/annotation-api.js b/app/annotation-api.js index 1f67c85..c52ae89 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -202,6 +202,7 @@ export default class AnnotationApi { let { annotation, annotations_list, + annotations_alias_list, block = {}, file, log @@ -217,6 +218,7 @@ export default class AnnotationApi { return this.run({ annotation: { name, + alias: is.in(annotations_alias_list, name) ? annotations_alias_list[name] : [], line: to.normalize(contents[0]), contents, start: null, diff --git a/app/annotations/markup.js b/app/annotations/markup.js index 3fa5549..042949a 100644 --- a/app/annotations/markup.js +++ b/app/annotations/markup.js @@ -58,11 +58,11 @@ export default { ] = regex('markup', this.annotation.line) let raw = this.annotation.contents - + let { interpolation, prefix, header, body } = this.file.comment let escaped = escape(raw) - // @todo {10} update this use use the user defined options - const state_interpolation = /\s*\${@states?[^\}]*\}\s*/gi + let state_interpolation = `${interpolation.start}${prefix}states?[^${interpolation.end}]*${interpolation.end}` + state_interpolation = new RegExp(`\\s*${state_interpolation}\\s*`, 'gi') let raw_stateless = raw.replace(state_interpolation, '') let escaped_stateless = escaped.replace(state_interpolation, '') diff --git a/app/annotations/states.js b/app/annotations/states.js index b49e93c..45441f6 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -88,8 +88,8 @@ export default { // without affecting the actual state output let _state = to.clone(state) to.extend(_state, _state[to.keys(_state)[0]]) - markup.raw = replaceStates(markup.raw, _state) - markup.escaped = replaceStates(markup.escaped, _state) + markup.raw = replaceStates(markup.raw, _state, state.__details) + markup.escaped = replaceStates(markup.escaped, _state, state.__details) return to.merge(previous, { [markup_id]: [ { state, markup } ] @@ -99,15 +99,14 @@ export default { } -function replaceStates(str, states) { - // @todo {5} - Update this to use language settings - // - annotation name and it's aliases - // - interpolation - // - annotation prefix - // const state_interpolation = new RegExp(`${settings.interpolation.start}${settings.annotation.prefix}etc....`, 'gi') - const state_interpolation = /\${@(?:state|states)[^\}]*\}/g +function replaceStates(str, states, options) { + let names = [ options.annotation.name, ...options.annotation.alias ].join('|') + let { interpolation, prefix } = options.file.comment + + const state_interpolation = new RegExp(`${interpolation.start}${prefix}(?:${names})[^${interpolation.end}]*${interpolation.end}`, 'g') + const replacement = new RegExp(`${interpolation.start}${prefix}(?:${names})|${interpolation.end}`, 'g') return str.replace(state_interpolation, (original_match) => { - let match = original_match.replace(/\${@(?:states|state)|}/g, '').slice(1) + let match = original_match.replace(replacement, '').slice(1) if (!match) { return states.state diff --git a/app/config.js b/app/config.js index 48efbfd..08305f8 100644 --- a/app/config.js +++ b/app/config.js @@ -64,7 +64,7 @@ export const default_comment = { // I'm making it a setting. // @note {10} This setting is used to create a RegExp so certain characters need to be escaped interpolation: { - start: '\${', + start: '\\${', end: '}' }, } diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index 03cf8a3..18a4ad0 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -74,6 +74,7 @@ function parseBlock(options = {}) { // gets the annotations to use on this file let annotations_list = annotations.list(file.type) + let annotations_alias_list = annotations.list(file.type, 'alias') let keys = to.keys(annotations_list) let contents = to.array(block.comment.contents) @@ -113,6 +114,7 @@ function parseBlock(options = {}) { [annotation.name]: annotations.run({ annotation, annotations_list, + annotations_alias_list, block, file, log @@ -124,6 +126,7 @@ function parseBlock(options = {}) { annotation = { name, // sets the current annotation name line: line.slice(prefix_index + 1 + name.length), // removes the current annotation name and it's prefix from the first line + alias: is.in(annotations_alias_list, name) ? annotations_alias_list[name] : [], contents: [], start: i, // sets the starting line of the annotation end: 0 @@ -145,6 +148,7 @@ function parseBlock(options = {}) { [annotation.name]: annotations.run({ annotation, annotations_list, + annotations_alias_list, block, file, log From 90e57f869dcfc827a9d48aded4200731a90cbd84 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 7 Mar 2016 08:26:10 -0500 Subject: [PATCH 233/273] added more test cases for @state --- app/annotations/states.js | 8 +- ...ltiple-markup-by-id-with-custom-props.json | 172 ++++++++++++++++++ ...ltiple-markup-by-id-with-custom-props.scss | 59 ++++++ ...multiple-states-multiple-markup-by-id.json | 172 ++++++++++++++++++ ...multiple-states-multiple-markup-by-id.scss | 59 ++++++ ...tes-multiple-markup-with-custom-props.json | 172 ++++++++++++++++++ ...tes-multiple-markup-with-custom-props.scss | 59 ++++++ ...mplex-multiple-states-multiple-markup.json | 172 ++++++++++++++++++ ...mplex-multiple-states-multiple-markup.scss | 59 ++++++ ...lex-multiple-states-with-custom-props.json | 100 ++++++++++ ...lex-multiple-states-with-custom-props.scss | 38 ++++ .../state/state-complex-multiple-states.json | 100 ++++++++++ .../state/state-complex-multiple-states.scss | 38 ++++ .../state/state-complex-single-markup.json | 60 ++++++ .../state/state-complex-single-markup.scss | 30 +++ ...e-markup-blocks-with-different-states.json | 36 ++-- ...e-markup-blocks-with-different-states.scss | 14 +- 17 files changed, 1322 insertions(+), 26 deletions(-) create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.json create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.scss create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.json create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.scss create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.json create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.scss create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup.json create mode 100644 tests/annotations/state/state-complex-multiple-states-multiple-markup.scss create mode 100644 tests/annotations/state/state-complex-multiple-states-with-custom-props.json create mode 100644 tests/annotations/state/state-complex-multiple-states-with-custom-props.scss create mode 100644 tests/annotations/state/state-complex-multiple-states.json create mode 100644 tests/annotations/state/state-complex-multiple-states.scss create mode 100644 tests/annotations/state/state-complex-single-markup.json create mode 100644 tests/annotations/state/state-complex-single-markup.scss diff --git a/app/annotations/states.js b/app/annotations/states.js index 45441f6..e713375 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -122,7 +122,13 @@ function replaceStates(str, states, options) { return (states[key] || {})[item] } - return states[clean(match)] + let result = states[clean(match)] + + if (is.plainObject(result)) { + return result.state + } + + return result }) } diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.json b/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.json new file mode 100644 index 0000000..cfddee8 --- /dev/null +++ b/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.json @@ -0,0 +1,172 @@ +{ + "header": {}, + "body": [ + { + "states": { + "foo": [ + { + "state": { + "1": { + "state": ":hover", + "description": "

Hover state for example 1, state 1

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

Modifier state for example 1, state 1

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

Example 1

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

Modifier state for example 1, state 1

\n

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

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Focus state for example 1, state 2

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

Modifier state for example 1, state 2

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

Example 1

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

Modifier state for example 1, state 2

\n

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

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Active state for example 1, state 3

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

Modifier state for example 1, state 3

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

Example 1

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

Modifier state for example 1, state 3

\n

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

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Hover state for example 2, state 1

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

Modifier state for example 2, state 1

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

Example 2

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

Example 2

Modifier state for example 2, state 1

\n

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

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

Modifier state for example 2, state 1

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

Hover state for example 2, state 1

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

Focus state for example 2, state 2

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

Modifier state for example 2, state 2

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

Example 2

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

Example 2

Modifier state for example 2, state 2

\n

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

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

Modifier state for example 2, state 2

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

Focus state for example 2, state 2

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

Active state for example 2, state 3

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

Modifier state for example 2, state 3

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

Example 2

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

Example 2

Modifier state for example 2, state 3

\n

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

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

Modifier state for example 2, state 3

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

Active state for example 2, state 3

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

Example 1

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

${@state.modifier.description}

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

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

Example 2

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

Example 2 ${@state.modifier.description}

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

Example 2

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

${@state.modifier.description}

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

Example 2 ${@state.modifier.description}

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Example 1

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

Modifier state for example 1, state 1

\n

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

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Example 1

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

Modifier state for example 1, state 2

\n

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

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Example 1

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

Modifier state for example 1, state 3

\n

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

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Modifier state for example 2, state 1

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

Hover state for example 2, state 1

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

Example 2

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

Example 2

Modifier state for example 2, state 1

\n

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

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

Modifier state for example 2, state 1

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

Hover state for example 2, state 1

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

Modifier state for example 2, state 2

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

Focus state for example 2, state 2

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

Example 2

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

Example 2

Modifier state for example 2, state 2

\n

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

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

Modifier state for example 2, state 2

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

Focus state for example 2, state 2

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

Modifier state for example 2, state 3

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

Active state for example 2, state 3

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

Example 2

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

Example 2

Modifier state for example 2, state 3

\n

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

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

Modifier state for example 2, state 3

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

Active state for example 2, state 3

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

Example 1

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

${@state[0].description}

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

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

Example 2

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

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

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

Example 2

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

${@state[0].description}

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

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

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

Hover state for example 1, state 1

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

Modifier state for example 1, state 1

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

Example 1

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

Modifier state for example 1, state 1

\n

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

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Focus state for example 1, state 2

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

Modifier state for example 1, state 2

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

Example 1

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

Modifier state for example 1, state 2

\n

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

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Active state for example 1, state 3

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

Modifier state for example 1, state 3

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

Example 1

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

Modifier state for example 1, state 3

\n

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

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Hover state for example 2, state 1

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

Modifier state for example 2, state 1

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

Example 2

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

Example 2

Modifier state for example 2, state 1

\n

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

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

Modifier state for example 2, state 1

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

Hover state for example 2, state 1

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

Focus state for example 2, state 2

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

Modifier state for example 2, state 2

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

Example 2

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

Example 2

Modifier state for example 2, state 2

\n

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

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

Modifier state for example 2, state 2

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

Focus state for example 2, state 2

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

Active state for example 2, state 3

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

Modifier state for example 2, state 3

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

Example 2

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

Example 2

Modifier state for example 2, state 3

\n

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

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

Modifier state for example 2, state 3

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

Active state for example 2, state 3

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

Example 1

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

${@state.modifier.description}

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

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

Example 2

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

Example 2 ${@state.modifier.description}

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

Example 2

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

${@state.modifier.description}

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

Example 2 ${@state.modifier.description}

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Example 1

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

Modifier state for example 1, state 1

\n

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

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Example 1

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

Modifier state for example 1, state 2

\n

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

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Example 1

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

Modifier state for example 1, state 3

\n

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

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Modifier state for example 2, state 1

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

Hover state for example 2, state 1

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

Example 2

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

Example 2

Modifier state for example 2, state 1

\n

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

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

Modifier state for example 2, state 1

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

Hover state for example 2, state 1

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

Modifier state for example 2, state 2

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

Focus state for example 2, state 2

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

Example 2

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

Example 2

Modifier state for example 2, state 2

\n

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

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

Modifier state for example 2, state 2

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

Focus state for example 2, state 2

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

Modifier state for example 2, state 3

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

Active state for example 2, state 3

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

Example 2

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

Example 2

Modifier state for example 2, state 3

\n

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

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

Modifier state for example 2, state 3

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

Active state for example 2, state 3

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

Example 1

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

${@state[0].description}

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

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

Example 2

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

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

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

Example 2

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

${@state[0].description}

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

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

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

Hover state for example 1, state 1

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

Modifier state for example 1, state 1

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

Example 1

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

Modifier state for example 1, state 1

\n

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

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

Modifier state for example 1, state 1

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

Hover state for example 1, state 1

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

Focus state for example 1, state 2

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

Modifier state for example 1, state 2

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

Example 1

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

Modifier state for example 1, state 2

\n

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

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

Modifier state for example 1, state 2

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

Focus state for example 1, state 2

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

Active state for example 1, state 3

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

Modifier state for example 1, state 3

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

Example 1

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

Modifier state for example 1, state 3

\n

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

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

Modifier state for example 1, state 3

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

Active state for example 1, state 3

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

Example 1

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

${@state.modifier.description}

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

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

${@state.modifier.description}

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

Modifier state

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

Hover state for .something-super-awesome__item

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

Example 1

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

Modifier state

\n

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

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

Modifier state

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

Hover state for .something-super-awesome__item

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

Modifier state

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

Focus state for .something-super-awesome__item

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

Example 1

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

Modifier state

\n

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

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

Modifier state

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

Focus state for .something-super-awesome__item

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

Modifier state

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

Active state for .something-super-awesome__item

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

Example 1

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

Modifier state

\n

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

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

Modifier state

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

Active state for .something-super-awesome__item

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

Example 1

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

${@state[0].description}

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

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

${@state[0].description}

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

Modifier state

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

Hover state for .something-super-awesome__item

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

Example 1

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

Modifier state

\n

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

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

Modifier state

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

Hover state for .something-super-awesome__item

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

Example 1

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

${@state[0].description}

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

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

${@state[0].description}

+///
    +///
  • ${@state[1].description}
  • +///
+///
+.something-super-awesome { + background: black; + + &:hover { + background: gray; + } + + &--modifier { + &:hover { + background: blue; + } + } + + &__item { + &:hover { + background: orange; + } + } +} diff --git a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json index 367e5d3..d582671 100644 --- a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json +++ b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json @@ -16,8 +16,8 @@ "language": "html", "settings": {}, "description": "

Example 1

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

Hover state for example 1

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

Hover state for example 1

\n\n</div>" } }, { @@ -32,8 +32,8 @@ "language": "html", "settings": {}, "description": "

Example 1

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

Focus state for example 1

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

Focus state for example 1

\n\n</div>" } } ], @@ -50,8 +50,8 @@ "language": "html", "settings": {}, "description": "

Example 2

\n", - "raw": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", - "escaped": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" + "raw": "
\n

Hover state for example 2

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

Hover state for example 2

\n\n</div>" } }, { @@ -66,8 +66,8 @@ "language": "html", "settings": {}, "description": "

Example 2

\n", - "raw": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", - "escaped": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" + "raw": "
\n

Focus state for example 2

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

Focus state for example 2

\n\n</div>" } } ] @@ -78,30 +78,30 @@ "language": "html", "settings": {}, "description": "

Example 1

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

Example 2

\n", - "raw": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", - "escaped": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>", - "raw_stateless": "
\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n
", - "escaped_stateless": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" + "raw": "
\n ${@state.description}\n
", + "escaped": "<div class="something-super-awesome ${@state}">\n ${@state.description}\n</div>", + "raw_stateless": "
", + "escaped_stateless": "<div class="something-super-awesome"></div>" } ], "blockinfo": { "comment": { "start": 1, - "end": 19, + "end": 15, "type": "body" }, "code": { - "start": 20, + "start": 16, "end": 27 }, "file": { diff --git a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss index 748b2b3..fb6cf50 100644 --- a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss +++ b/tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss @@ -3,19 +3,15 @@ /// /// @markup {html} Example 1 ///
-/// This is the only block that will get states applied to it. +/// ${@state.description} ///
/// /// @state {:hover} Hover state for example 2 /// @state {:focus} - Focus state for example 2 /// /// @markup (something) {html} Example 2 -///
-/// There are no states created with this markup because it is the -/// second markup annotation in the comment block and there was no -/// id set so the id is 1 by default. If you are looking for an example -/// of multiple markup blocks with seperate states see -/// `state-multiple-markup-blocks-with-different-states.scss` +///
+/// ${@state.description} ///
.something-super-awesome { background: black; @@ -23,4 +19,8 @@ &:hover { background: gray; } + + &:focus { + background: blue; + } } From 98a9b5e58597e5a9a1eabc4a517e3522e2bda548 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 7 Mar 2016 10:34:05 -0500 Subject: [PATCH 234/273] Update the way options are passed to the parser --- app/docs.js | 9 +++++---- app/parser/index.js | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/docs.js b/app/docs.js index ef7858d..5d8a3e4 100644 --- a/app/docs.js +++ b/app/docs.js @@ -10,7 +10,7 @@ import { } from './utils' import parser from './parser' import sorter from './sorter' -import get_config from './config' +import getConfig from './config' import { map } from 'async-array-methods' //// @@ -21,7 +21,7 @@ import { map } from 'async-array-methods' /// documentation for it and returns an `{}` of the document data //// export default async function docs(options = {}) { - options = await get_config(options) + options = await getConfig(options) /* eslint-disable no-unused-vars */ // these are all the options that can be used let { @@ -39,8 +39,9 @@ export default async function docs(options = {}) { comments, } = options /* eslint-enable no-unused-vars */ + let log - let log = new Logger({ debug, warning, timestamps }) + options.log = log = new Logger({ debug, warning, timestamps }) log.emit('start', 'total') @@ -53,7 +54,7 @@ export default async function docs(options = {}) { log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${s} to parse`) log.emit('start', 'parser') - files = await map(files, (file_path) => parser({ file_path, ...options, log })) + files = await map(files, (file_path) => parser(file_path, options)) log.emit('complete', 'parser') // converts json to a readable JS object diff --git a/app/parser/index.js b/app/parser/index.js index 5cba45c..9b16000 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -4,26 +4,26 @@ import getBlocks from './get-blocks' import parseBlocks from './parse-blocks' import replaceAliases from './replace-aliases' -export default async function parser({ - file_path, +export default async function parser(file_path, { comments, + languages, annotations, blank_lines, sort, log }) { // the filetype of the current file - let type = path.extname(file_path).replace('.', '') + const type = path.extname(file_path).replace('.', '') // gets the comments to use on this file - let comment = comments[type] ? comments[type] : comments._ + const comment = comments[type] ? comments[type] : comments._ - let contents = '\n' + to.normalString(await fs.readFile(file_path)) + const contents = '\n' + to.normalString(await fs.readFile(file_path)) let file = { contents, // all of the contents of the file path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, '.' + type), // name of the file + name: path.basename(file_path, `.${type}`), // name of the file type, // filetype of the file comment, start: 1, // starting point of the file From 2f6f5da465bbf63352e099ed974bcf9dd442b390 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 7 Mar 2016 12:27:48 -0500 Subject: [PATCH 235/273] updated to use `languages` instead of `comments` in the config This was because they're language specific settings not necessarily comments --- app/annotation-api.js | 17 ++- app/annotations/annotation-utils.js | 2 +- app/annotations/blockinfo.js | 23 ++-- app/annotations/markdown.js | 6 +- app/annotations/markup.js | 2 +- app/annotations/states.js | 2 +- app/cli.js | 20 ++-- app/config.js | 161 +++++++++++++++------------- app/docs.js | 2 +- app/parser/autofill.js | 6 +- app/parser/index.js | 24 ++--- app/parser/parse-blocks.js | 36 +++---- app/parser/replace-aliases.js | 10 +- app/parser/resolve.js | 6 +- tests/unit/config.test.js | 15 ++- 15 files changed, 167 insertions(+), 165 deletions(-) diff --git a/app/annotation-api.js b/app/annotation-api.js index c52ae89..b504be1 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -195,14 +195,21 @@ export default class AnnotationApi { }) } + lists(filetype) { + return to.reduce([ 'alias', 'autofill', 'resolve' ], (previous, current) => { + return to.extend(previous, { + [current]: this.list(filetype, current) + }) + }, { main: this.list(filetype) }) + } + /// @name run_annotation /// @access private /// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) run(options) { let { annotation, - annotations_list, - annotations_alias_list, + annotation_types, block = {}, file, log @@ -218,13 +225,13 @@ export default class AnnotationApi { return this.run({ annotation: { name, - alias: is.in(annotations_alias_list, name) ? annotations_alias_list[name] : [], + alias: is.in(annotation_types.alias, name) ? annotation_types.alias[name] : [], line: to.normalize(contents[0]), contents, start: null, end: null }, - annotations_list, + annotation_types, ...block, log }) @@ -258,7 +265,7 @@ export default class AnnotationApi { result.default = this.file_list.default[annotation.name].parse.call(result) } - return annotations_list[annotation.name].parse.call(result) + return annotation_types.main[annotation.name].parse.call(result) } /// @name file_list diff --git a/app/annotations/annotation-utils.js b/app/annotations/annotation-utils.js index 656ab3f..b2a383d 100644 --- a/app/annotations/annotation-utils.js +++ b/app/annotations/annotation-utils.js @@ -91,7 +91,7 @@ export function logAnnotationError(obj, expected) { // 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 = file.comment[comment.type].line + let comment_style = file.options[comment.type].line // 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 diff --git a/app/annotations/blockinfo.js b/app/annotations/blockinfo.js index b9dcbbb..b83ae57 100644 --- a/app/annotations/blockinfo.js +++ b/app/annotations/blockinfo.js @@ -1,4 +1,4 @@ -import { to } from '../utils' +import { to, is } from '../utils' import { logAnnotationError } from './annotation-utils' /// @name blockinfo /// @page annotations @@ -30,16 +30,25 @@ export default { autofill() { let obj = to.clone(this) let comment = obj.comment - let code = obj.code - let file = obj.file delete comment.contents + + let code = obj.code delete code.contents - delete file.contents - delete file.name - delete file.type - delete file.comment + + const file_filter = [ 'contents', 'name', 'type', 'comment', 'options' ] + let file = to.filter(obj.file, ({ key }) => !is.in(file_filter, key)) return { comment, code, file } + + // @todo {5} decide if `comment` needs the `type` key. If it doesn't need + // it then just use the code below because it removes all the things that + // aren't needed from each of the values in `this` + // const filter = [ 'contents', 'name', 'type', 'comment', 'options' ] + // return to.map(this, (obj) => { + // return { + // [obj.key]: to.filter(obj.value, ({ key }) => !is.in(filter, key)) + // } + // }) }, parse() { this.log.emit('warning', "Passed @blockinfo, it's only supposed to be an autofilled annotation", logAnnotationError(this, '')) diff --git a/app/annotations/markdown.js b/app/annotations/markdown.js index 6bd48d3..ffcea2c 100644 --- a/app/annotations/markdown.js +++ b/app/annotations/markdown.js @@ -25,9 +25,9 @@ export default { 'text', 'md' ], parse() { - const comment = this.file.comment - const start = `(?:${comment.header.start}|${comment.body.start})`.replace('\\', '\\\\') - const end = `(?:${comment.header.end}|${comment.body.end})`.replace('\\', '\\\\') + const options = this.file.options + const start = `(?:${options.header.start}|${options.body.start})`.replace('\\', '\\\\') + const end = `(?:${options.header.end}|${options.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 index 042949a..86937de 100644 --- a/app/annotations/markup.js +++ b/app/annotations/markup.js @@ -58,7 +58,7 @@ export default { ] = regex('markup', this.annotation.line) let raw = this.annotation.contents - let { interpolation, prefix, header, body } = this.file.comment + let { interpolation, prefix } = this.file.options let escaped = escape(raw) let state_interpolation = `${interpolation.start}${prefix}states?[^${interpolation.end}]*${interpolation.end}` diff --git a/app/annotations/states.js b/app/annotations/states.js index e713375..bb7b562 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -101,7 +101,7 @@ export default { function replaceStates(str, states, options) { let names = [ options.annotation.name, ...options.annotation.alias ].join('|') - let { interpolation, prefix } = options.file.comment + let { interpolation, prefix } = options.file.options const state_interpolation = new RegExp(`${interpolation.start}${prefix}(?:${names})[^${interpolation.end}]*${interpolation.end}`, 'g') const replacement = new RegExp(`${interpolation.start}${prefix}(?:${names})|${interpolation.end}`, 'g') diff --git a/app/cli.js b/app/cli.js index 4ccb3a9..3a9dcad 100644 --- a/app/cli.js +++ b/app/cli.js @@ -3,7 +3,7 @@ import pkg from '../package.json' import { info, fs, to } from './utils' import program from 'commander' import docs from './docs' -import { base_config } from './config' +import { default_options } from './config' export default function cli() { // helper functions to parse passed options @@ -21,14 +21,14 @@ export default function cli() { Note: Put globs quotes \`'.*, app/**/*'\` to avoid issues `) .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) - .option('-c, --config [path]', 'Path to configuration file', base_config.config) - .option('-i, --ignore ', 'Paths to ignore', to_list, base_config.ignore) - .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', base_config.gitignore) - .option('-x, --no-debug', 'Output debugging information', to_boolean, base_config.debug) - .option('-w, --no-warning', 'Output warning messages', to_boolean, base_config.warning) - .option('-m, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, base_config.timestamps) - .option('-a, --no-changed', 'Parse changed files', to_boolean, base_config.changed) - .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, base_config.blank_lines) + .option('-c, --config [path]', 'Path to configuration file', default_options.config) + .option('-i, --ignore ', 'Paths to ignore', to_list, default_options.ignore) + .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', default_options.gitignore) + .option('-x, --no-debug', 'Output debugging information', to_boolean, default_options.debug) + .option('-w, --no-warning', 'Output warning messages', to_boolean, default_options.warning) + .option('-m, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, default_options.timestamps) + .option('-a, --no-changed', 'Parse changed files', to_boolean, default_options.changed) + .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, default_options.blank_lines) .option('-p, --print', 'This will only print the results instead of outputting them', false) .option('-r, --raw', 'This prevents the data from each file from being sorted', false) .option('-t, --dry-run', 'This will run everything without outputting anything', false) @@ -53,7 +53,7 @@ export default function cli() { let files = to.flatten(args.map((arg) => to_list(arg))) if (!files.length) { - files = base_config.files + files = default_options.files } return docs({ diff --git a/app/config.js b/app/config.js index 08305f8..4d97abd 100644 --- a/app/config.js +++ b/app/config.js @@ -20,6 +20,7 @@ export const default_options = { 'dist/', 'build/', 'docs/', // normal folders 'tests/', 'coverage/' // unit tests and coverage results ], + page_fallback: 'general', // used if `@page` isn't defined // add gitignore files to the ignore list. Depending on ignored files it @@ -48,60 +49,59 @@ export const default_options = { return a.localeCompare(b) // same as the default sort function }, - // default annotation list - annotations, -} - -export const default_comment = { - prefix: '@', // annotation identifier(this should probably never be changed) - inline_prefix: '#', // @todo add support for this single line prefix for comments inside of the code below the comment block - // file level comment block identifier - header: { start: '////', line: '///', end: '////', type: 'header' }, - // block level comment block identifier - body: { start: '', line: '///', end: '', type: 'body' }, - // this is used for any interpolations that might occur in - // annotations. I don't see this needing to change but just incase - // I'm making it a setting. - // @note {10} This setting is used to create a RegExp so certain characters need to be escaped - interpolation: { - start: '\\${', - end: '}' + languages: { + default: { + // annotation identifier that can be change on a file specific basis if needed. + // While this is a setting, it probably should probably never be changed. If it does + // need to be changed it should be changed to be a special character. + prefix: '@', + + // @todo add support for this single line prefix for comments inside of the code below the comment block + inline_prefix: '#', + + // header comment style + // @note {10} only 1 of these can be used per file + header: { start: '////', line: '///', end: '////', type: 'header' }, + + // body comment style + body: { start: '', line: '///', end: '', type: 'body' }, + + // this is used for any interpolations that might occur in annotations. + // I don't see this needing to change but just incase I'm making it a setting. + // @note {10} This setting is used to create a RegExp so certain characters need to be escaped + interpolation: { + start: '\\${', + end: '}' + }, + }, + css: { + header: { start: '/***', line: '*', end: '***/' }, + body: { start: '/**', line: '*', end: '**/' } + }, + 'rb, py, coffee, sh, bash, pl': { + header: { start: '###', line: '##', end: '###' }, + body: { line: '##' } + }, + 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { + header: { start: '' }, + body: { start: '' } + }, + jade: { + header: { start: '//-//', line: '//-/', end: '//-//' }, + body: { line: '//-/' } + }, + cfm: { + header: { start: '' }, + body: { start: '' } + } }, -} -// some defaults for common languages -export const comments = { - _: default_comment, - css: { - header: { start: '/***', line: '*', end: '***/' }, - body: { start: '/**', line: '*', end: '**/' } - }, - 'rb, py, coffee, sh, bash, pl': { - header: { start: '###', line: '##', end: '###' }, - body: { line: '##' } - }, - 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { - header: { start: '' }, - body: { start: '' } - }, - jade: { - header: { start: '//-//', line: '//-/', end: '//-//' }, - body: { line: '//-/' } - }, - cfm: { - header: { start: '' }, - body: { start: '' } - } -} - - -export const base_config = { - ...default_options, - comments + // default annotation list + annotations, } export default async function config(options = {}) { - let config_file = (options.config ? options : base_config).config + let config_file = (options.config ? options : default_options).config // try to get the `docsfile.js` so the user config can be merged try { @@ -112,7 +112,11 @@ export default async function config(options = {}) { } // merge the config file with passed options - options = to.extend(ensureValidConfig(config_file), options) + options = to.extend(config_file, options) + // Not sure this valid config should be a thing because what if a user + // want's to pass in options here for their annotations. + // Should It be a option that determins if this runs? like `strict_config` + // options = to.extend(ensureValidConfig(config_file), options) // ensures `files`, `ignore` is always an array this way no // more checks have to happen for it @@ -120,8 +124,8 @@ export default async function config(options = {}) { if (options.ignore) options.ignore = to.array(options.ignore) - // merge options with base_config so there's a complete list of settings - options = to.extend(to.extend({}, base_config), options) + // merge options with default_options so there's a complete list of settings + options = to.extend(to.clone(default_options), options) if (options.gitignore) { try { @@ -140,56 +144,58 @@ export default async function config(options = {}) { // ensures blank_lines is a number to avoid errors options.blank_lines = to.number(options.blank_lines) - options.comments = parseComments(options.comments) + options.languages = parseLanguages(options.languages) options.annotations = new AnnotationApi(options.annotations) + return options } -let valid_options = to.keys(default_options) -let valid_comment_options = to.keys(default_comment) - - -export function parseComments(comments) { - let parsed_comments = {} +export function parseLanguages(languages) { + let parsed = {} // ensures comments are a normal structure (aka not `'rb, py': {...}`) - for (let [ option, value ] of to.entries(comments)) { + for (let [ option, value ] of to.entries(languages)) { // converts option into an array so multiple languages can be declared at the same time option = option.replace(/\s/g, '').split(',') - for (let lang in option) parsed_comments[option[lang]] = value + for (let lang in option) parsed[option[lang]] = value } - // ensures each comment as all the required comment settings + // ensures each comment has all the required comment settings // this makes it easier later on when parsing - for (let [ lang, value ] of to.entries(parsed_comments)) { + for (let [ lang, value ] of to.entries(parsed)) { if (lang !== '_') { - parsed_comments[lang] = to.extend(to.clone(default_comment), value) + parsed[lang] = to.extend(to.clone(default_options.languages.default), value) } } // extend any languages that have the extend option - for (let [ lang, value ] of to.entries(parsed_comments)) { + for (let [ lang, value ] of to.entries(parsed)) { if ( lang !== '_' && value.extend ) { - if (!parsed_comments[value.extend]) { + if (!parsed[value.extend]) { throw new Error(`${value.extend} comment style doesn't exist`) } else if (!is.string(value.extend)) { throw new Error(`the value of extend must be a string you passed ${value.extend}`) } else { - parsed_comments[lang] = to.extend(value, to.clone(parsed_comments[value.extend])) + parsed[lang] = to.extend(value, to.clone(parsed[value.extend])) } } - delete parsed_comments[lang].extend + delete parsed[lang].extend } - return parsed_comments + // console.log(parsed) + + return parsed } +let valid_options = to.keys(default_options) +let valid_language_options = to.keys(default_options.languages.default) + /// @name ensureValidConfig /// @description /// Ensures that the user set's a valid config @@ -202,15 +208,18 @@ function ensureValidConfig(user_config) { } // ensures the newly added language has the correct comment format - if (user_config.comments) { - for (let lang in user_config.comments) { - for (let type in lang) { - if (!is.in(valid_comment_options, type)) { - log.emit('warning', `'${type}' is not a valid comment option in '${lang}', must be 'header', or 'body'`) + if (user_config.languages) { + for (let [ lang, options ] of to.entries(user_config.languages)) { + // console.log('type', type) + for (let [ key ] of to.entries(options)) { + if (!is.in(valid_language_options, key)) { + log.emit( + 'warning', + `'${key}' is not a valid comment option in '${lang}'. Here's the default language config`, + default_options.languages.default + ) } } } } - - return user_config } diff --git a/app/docs.js b/app/docs.js index 5d8a3e4..bf5b44c 100644 --- a/app/docs.js +++ b/app/docs.js @@ -36,7 +36,7 @@ export default async function docs(options = {}) { raw, sort, annotations, - comments, + languages, } = options /* eslint-enable no-unused-vars */ let log diff --git a/app/parser/autofill.js b/app/parser/autofill.js index dc431d7..49e5b19 100644 --- a/app/parser/autofill.js +++ b/app/parser/autofill.js @@ -4,12 +4,10 @@ import { is, to } from '../utils' // @access private // @description // This function is used to run the all the functions that autofill if not defined. -export default function autofill(options) { - let { autofill_list, parsed, block/* , log */ } = options - +export default function autofill({ list, parsed, block/* , log */ }) { let parsed_keys = to.keys(parsed) - for (let [ annotation, annotation_autofill ] of to.entries(autofill_list)) { + for (let [ annotation, annotation_autofill ] of to.entries(list)) { if (!is.in(parsed_keys, annotation)) { const result = is.fn(annotation_autofill) ? annotation_autofill.call(block) : annotation_autofill if (result != null) { diff --git a/app/parser/index.js b/app/parser/index.js index 9b16000..482923c 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -5,7 +5,6 @@ import parseBlocks from './parse-blocks' import replaceAliases from './replace-aliases' export default async function parser(file_path, { - comments, languages, annotations, blank_lines, @@ -16,7 +15,7 @@ export default async function parser(file_path, { const type = path.extname(file_path).replace('.', '') // gets the comments to use on this file - const comment = comments[type] ? comments[type] : comments._ + const options = languages[type] ? languages[type] : languages.default const contents = '\n' + to.normalString(await fs.readFile(file_path)) @@ -25,26 +24,19 @@ export default async function parser(file_path, { path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file name: path.basename(file_path, `.${type}`), // name of the file type, // filetype of the file - comment, + options, start: 1, // starting point of the file end: to.array(contents).length - 1 // ending point of the file } - file.contents = replaceAliases({ - file, - annotations, - comment, - log - }) - - + file.contents = replaceAliases({ file, annotations }) // a) The file doesn't contain any header level comments, or body level comments if ( !is.any.in( file.contents, - ...to.values(comment.header).slice(0, -1), - ...to.values(comment.body).slice(0, -1) + ...to.values(file.options.header).slice(0, -1), + ...to.values(file.options.body).slice(0, -1) ) ) { console.log(`Well shitfire, '${file.path}' doesn't contain any sweet documentation`) @@ -54,13 +46,13 @@ export default async function parser(file_path, { let header = getBlocks({ file, blank_lines, - comment: comment.header + comment: file.options.header }) let body = getBlocks({ file, blank_lines, - comment: comment.body, + comment: file.options.body, restrict: false, start_at: !is.empty(header) ? header[0].comment.end + 1 : 0 }) @@ -69,7 +61,6 @@ export default async function parser(file_path, { file, blocks: header, annotations, - comment, sort, log })[0] || {} @@ -78,7 +69,6 @@ export default async function parser(file_path, { file, blocks: body, annotations, - comment, sort, log }) diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js index 18a4ad0..4601b85 100644 --- a/app/parser/parse-blocks.js +++ b/app/parser/parse-blocks.js @@ -12,7 +12,6 @@ export default function parseBlocks({ file, blocks, annotations, - comment, sort, log }) { @@ -22,11 +21,11 @@ export default function parseBlocks({ let parsed_blocks = [] - let autofill_list = annotations.list(file.type, 'autofill') - let resolve_list = annotations.list(file.type, 'resolve') + let annotation_types = annotations.lists(file.type) + // sort the parsed object before the annotations are resolved if (is.fn(sort)) { - resolve_list = to.sort(resolve_list, sort) + annotation_types.resolve = to.sort(annotation_types.resolve, sort) } // loop over each block @@ -36,18 +35,18 @@ export default function parseBlocks({ let parsed = parseBlock({ annotations, + annotation_types, block, - comment, file, log }) // run the autofill functions for all the annotations that have a autofill function - parsed = autofill({ autofill_list, parsed, block, log }) + parsed = autofill({ list: annotation_types.autofill, parsed, block, log }) if (!is.empty(parsed)) { // run the resolve function for all the annotations that have a resolve function - parsed = resolve({ resolve_list, parsed, block, log }) + parsed = resolve({ list: annotation_types.resolve, parsed, block, log }) parsed_blocks.push(parsed) } } // end blocks loop @@ -66,16 +65,13 @@ export default function parseBlocks({ function parseBlock(options = {}) { let { annotations, + annotation_types, block, - comment, file, log } = options - // gets the annotations to use on this file - let annotations_list = annotations.list(file.type) - let annotations_alias_list = annotations.list(file.type, 'alias') - let keys = to.keys(annotations_list) + let keys = to.keys(annotation_types.main) let contents = to.array(block.comment.contents) let block_annotations = {} @@ -89,12 +85,12 @@ function parseBlock(options = {}) { if ( !is.any.in( line, - `${comment.header.line} ${comment.prefix}`, - `${comment.body.line} ${comment.prefix}`, - `\\${comment.prefix}` + `${file.options.header.line} ${file.options.prefix}`, + `${file.options.body.line} ${file.options.prefix}`, + `\\${file.options.prefix}` ) ) { - prefix_index = line.indexOf(comment.prefix) + prefix_index = line.indexOf(file.options.prefix) } @@ -113,8 +109,7 @@ function parseBlock(options = {}) { to.merge(block_annotations, { [annotation.name]: annotations.run({ annotation, - annotations_list, - annotations_alias_list, + annotation_types, block, file, log @@ -126,7 +121,7 @@ function parseBlock(options = {}) { annotation = { name, // sets the current annotation name line: line.slice(prefix_index + 1 + name.length), // removes the current annotation name and it's prefix from the first line - alias: is.in(annotations_alias_list, name) ? annotations_alias_list[name] : [], + alias: is.in(annotation_types.alias, name) ? annotation_types.alias[name] : [], contents: [], start: i, // sets the starting line of the annotation end: 0 @@ -147,8 +142,7 @@ function parseBlock(options = {}) { to.merge(block_annotations, { [annotation.name]: annotations.run({ annotation, - annotations_list, - annotations_alias_list, + annotation_types, block, file, log diff --git a/app/parser/replace-aliases.js b/app/parser/replace-aliases.js index 4644a33..a7f6845 100644 --- a/app/parser/replace-aliases.js +++ b/app/parser/replace-aliases.js @@ -6,13 +6,13 @@ import { is, to } from '../utils' /// This function is used to replace all instances of aliases in a file /// @returns {string} - The file with the instances of aliases removed export default function aliases(options = {}) { - let { file, annotations, comment } = options /* , log */ + let { file, annotations } = options /* , log */ let main_annotation_list = to.keys(annotations.list(file.type)) let comment_types = [ - to.values(comment.header, '!type', '!end'), - to.values(comment.body, '!type', '!end') + to.values(file.options.header, '!type', '!end'), + to.values(file.options.body, '!type', '!end') ] comment_types = to.flatten(comment_types) @@ -20,8 +20,8 @@ export default function aliases(options = {}) { .map((comment_type) => '\\' + comment_type.split('').join('\\')) comment_types = `(?:${comment_types.join('|')})` let block_comment = `(?:^(?:\\s*${comment_types})?\\s*)` - let inline_comment = `(?:${comment_types}?${comment.inline_prefix}\\s+)` - let comment_regex = `((?:${block_comment}|${inline_comment})${comment.prefix})` + let inline_comment = `(?:${comment_types}?${file.options.inline_prefix}\\s+)` + let comment_regex = `((?:${block_comment}|${inline_comment})${file.options.prefix})` let alias_obj = to.reduce(annotations.list(file.type, 'alias'), (previous, { key, value }) => { value = value diff --git a/app/parser/resolve.js b/app/parser/resolve.js index ba92662..b782794 100644 --- a/app/parser/resolve.js +++ b/app/parser/resolve.js @@ -4,12 +4,10 @@ import { is, to } from '../utils' // @access private // @description // This function is used to run the all the functions that autofill if not defined. -export default function resolve(options) { - let { resolve_list, parsed, block, log } = options - +export default function resolve({ list, parsed, block, log }) { let parsed_keys = to.keys(parsed) - for (let [ annotation, annotation_resolve ] of to.entries(resolve_list)) { + for (let [ annotation, annotation_resolve ] of to.entries(list)) { if (is.in(parsed_keys, annotation)) { let result = annotation_resolve if (is.fn(annotation_resolve)) { diff --git a/tests/unit/config.test.js b/tests/unit/config.test.js index 1f10f58..d9958a4 100644 --- a/tests/unit/config.test.js +++ b/tests/unit/config.test.js @@ -2,26 +2,23 @@ import assert from 'core-assert' import asyncSuite from '../../tools/async-suite.js' import getConfig, { - parseComments, + parseLanguages, default_options, - default_comment, - comments, - base_config } from '../../app/config' asyncSuite('config', () => { return () => { - test('parseComments empty', () => { + test('parseLanguages empty', () => { assert.deepStrictEqual( - parseComments({ + parseLanguages({ test: {} }).test, - default_comment + default_options.languages.default ) }) - test('parseComments extend', () => { - let test = parseComments({ + test('parseLanguages extend', () => { + let test = parseLanguages({ rb: { header: { start: '###', line: '##', end: '###' }, body: { line: '#' } From abe83d8d818571a137d72aab03c90ceaa387df90 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 7 Mar 2016 17:26:08 -0500 Subject: [PATCH 236/273] Updated logger to be a little better --- app/parser/index.js | 3 +- app/sorter/pages.js | 14 ++++---- app/utils/logger.js | 86 +++++++++++++++++++++++++++------------------ 3 files changed, 62 insertions(+), 41 deletions(-) diff --git a/app/parser/index.js b/app/parser/index.js index 482923c..803b2f5 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -3,6 +3,7 @@ import path from 'path' import getBlocks from './get-blocks' import parseBlocks from './parse-blocks' import replaceAliases from './replace-aliases' +import clor from 'clor' export default async function parser(file_path, { languages, @@ -39,7 +40,7 @@ export default async function parser(file_path, { ...to.values(file.options.body).slice(0, -1) ) ) { - console.log(`Well shitfire, '${file.path}' doesn't contain any sweet documentation`) + log.emit('warning', `Well shitfire, ${clor.bold(file.path)} doesn't contain any sweet documentation`) return [] } diff --git a/app/sorter/pages.js b/app/sorter/pages.js index c5d9f9c..287c694 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -1,6 +1,6 @@ /* eslint-disable complexity, max-depth */ import { is, to } from '../utils' - +import clor from 'clor' /// @name pages /// @description @@ -19,7 +19,7 @@ export default function pages(options = {}) { header.page = [ page_fallback ] } else { log.emit('warning', ` - Header comment ${header.name && '(' + header.name + ')'} doesn't have a \`@page\` defined in + Header comment ${header.name && '(' + header.name + ')'} doesn't have a ${clor.bold('@page')} defined in ${path} `) } @@ -27,10 +27,12 @@ export default function pages(options = {}) { // a) Set the name in the header to be the name of the file if (is.falsy(header.name)) { - log.emit('warning', ` - The hardest thing in development is naming but you gotta try, add a '@name' to the header comment in - ${path} - `) + log.emit('warning', '' + + 'The hardest thing in development is naming but you gotta try, add a ' + + clor.bold('@name') + + ' to the header comment in ' + + clor.bold(path) + ) } // set the header for the file diff --git a/app/utils/logger.js b/app/utils/logger.js index 71b2766..ec81de5 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -1,6 +1,6 @@ import Purdy from './purdy' import clor from 'clor' - +import to from './to' let icon = { chevron: '\xBB ', @@ -10,7 +10,7 @@ let icon = { } const messaging = { - warning: clor.yellow.bold(`${icon.warning} [WARNING]`), + 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]`) @@ -24,7 +24,6 @@ export default class Logger { this.times = {} this.options = options - this.report() } @@ -45,11 +44,32 @@ export default class Logger { 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': + return arg.toString() + case 'string': + return to.normalize(arg) + default: + return arg + } + }) + } + print(...args) { - purdy.print(...args) + console.log(...this.format(...args)) return this } + space() { + console.log('') + } + report() { let { debug = true, @@ -69,30 +89,28 @@ export default class Logger { if (debug) { this - .on('debug', (...args) => this.debug(...args)) - .on('file', (...args) => this.file(...args)) + .on('debug', this.debug) + .on('file', this.file) } - if (warning) this.on('warning', (...args) => this.warn(...args)) + if (warning) this.on('warning', this.warn) + + this.on('success', this.success) } warn(...args) { - console.log( - '\n\n', - messaging.warning, - '\n', - ...purdy.format(...args) - ) + console.log('') + this.print(`${messaging.warning}`) + this.print(...args) + console.log('') return this } - error(arg) { - console.log( - '\n\n', - messaging.error, - '\n', - ...purdy.format(arg) - ) + error(...args) { + console.log('') + this.print(`${messaging.error}`) + this.print(...args) + console.log('') return this } @@ -110,7 +128,7 @@ export default class Logger { let duration = Date.now() - time console.log( - `${clor.green(icon.check)} ${format}`, + `${clor.green(icon.check)}${format}`, label, duration ) @@ -118,22 +136,22 @@ export default class Logger { } debug(...args) { - console.log( - '\n\n', - messaging.debug, - '\n', - ...purdy.format(...args) - ) + console.log('') + this.print(`${messaging.debug}`) + this.print(...args) + console.log('') return this } - file(file) { - console.log( - '\n\n', - messaging.file, - file, - '' - ) + success(...args) { + this.print(`${clor.green(icon.check)}`, ...args) + } + + file(file, ...args) { + console.log('') + this.print(`${messaging.file} ${file}`) + this.print(...args) + console.log('') return this } } From 94d0140c3d34251e256dcc86f7ec736d805250be Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 7 Mar 2016 17:27:52 -0500 Subject: [PATCH 237/273] Updated to support watching of files This update allows you to watch for file changes. It removes the `changed` option which allowed me to remove several functions around that functionality --- app/cli.js | 8 +-- app/config.js | 12 +++- app/docs.js | 135 +++++++++++++++++++---------------------- app/utils/fs.js | 17 ------ app/utils/info.js | 5 -- app/utils/logger.js | 4 -- package.json | 1 + tests/run.test.js | 1 - tools/generate-test.js | 2 - 9 files changed, 77 insertions(+), 108 deletions(-) diff --git a/app/cli.js b/app/cli.js index 3a9dcad..510216c 100644 --- a/app/cli.js +++ b/app/cli.js @@ -23,11 +23,11 @@ export default function cli() { .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) .option('-c, --config [path]', 'Path to configuration file', default_options.config) .option('-i, --ignore ', 'Paths to ignore', to_list, default_options.ignore) + .option('-w, --watch', 'Recompile docs on changes', true, default_options.watch) .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', default_options.gitignore) .option('-x, --no-debug', 'Output debugging information', to_boolean, default_options.debug) - .option('-w, --no-warning', 'Output warning messages', to_boolean, default_options.warning) + .option('-n, --no-warning', 'Output warning messages', to_boolean, default_options.warning) .option('-m, --no-timestamps', 'Output timestamps of how long it takes to parse the files', to_boolean, default_options.timestamps) - .option('-a, --no-changed', 'Parse changed files', to_boolean, default_options.changed) .option('-b, --blank-lines ', 'Stops parsing lines after consecutive blank lines', to_number, default_options.blank_lines) .option('-p, --print', 'This will only print the results instead of outputting them', false) .option('-r, --raw', 'This prevents the data from each file from being sorted', false) @@ -40,11 +40,11 @@ export default function cli() { dryRun: dry_run, print, ignore, + watch, gitignore, debug, warning, timestamps, - changed, raw, dest, args @@ -63,9 +63,9 @@ export default function cli() { debug, warning, timestamps, - changed, raw, blank_lines, + watch, }) .then((parsed) => { if (print) { diff --git a/app/config.js b/app/config.js index 4d97abd..c97305f 100644 --- a/app/config.js +++ b/app/config.js @@ -21,15 +21,15 @@ export const default_options = { 'tests/', 'coverage/' // unit tests and coverage results ], + // when true it will watch files for changes + watch: false, + page_fallback: 'general', // used if `@page` isn't defined // add gitignore files to the ignore list. Depending on ignored files it // could cause things to ge parsed slower, that's why it's defaulted to `false` gitignore: false, - // determins if only changed files should be parsed or not - changed: true, - // this stops the current block from adding lines if there're `n` // blank line lines between code, and starts a new block. blank_lines: 4, @@ -148,6 +148,12 @@ export default async function config(options = {}) { options.annotations = new AnnotationApi(options.annotations) + options.log = new Logger({ + debug: options.debug, + warning: options.warning, + timestamps: options.timestamps + }) + return options } diff --git a/app/docs.js b/app/docs.js index bf5b44c..87680bc 100644 --- a/app/docs.js +++ b/app/docs.js @@ -6,12 +6,13 @@ import { to, fs, glob, - Logger } from './utils' import parser from './parser' import sorter from './sorter' import getConfig from './config' import { map } from 'async-array-methods' +import chokidar from 'chokidar' +import clor from 'clor' //// /// @name docs.js @@ -25,9 +26,8 @@ export default async function docs(options = {}) { /* eslint-disable no-unused-vars */ // these are all the options that can be used let { - files, + files: initial_files, ignore, - changed, blank_lines, page_fallback, debug, @@ -36,89 +36,80 @@ export default async function docs(options = {}) { raw, sort, annotations, + watch, languages, + log, } = options /* eslint-enable no-unused-vars */ - let log - options.log = log = new Logger({ debug, warning, timestamps }) + let json = {} + let ignored - log.emit('start', 'total') + let walk = async (files) => { + files = to.array(files) - try { - await fs.ensureFile(info.temp.file) - let json = fs.readFile(info.temp.file) - log.emit('start', 'paths') - files = await glob(files, ignore, changed ? hasFileChanged : false) - let s = files.length > 1 ? 's' : '' // eslint-disable-line - log.emit('complete', 'paths', `%s completed after %dms with ${files.length} file${s} to parse`) + log.emit('start', 'total') + try { + log.emit('start', 'paths') + ignored = await glob(ignore) + files = await glob(files, ignored) - log.emit('start', 'parser') - files = await map(files, (file_path) => parser(file_path, options)) - log.emit('complete', 'parser') + let paths_message = `%s completed ${to.map(files, (file) => clor.bold(path.join(info.dir, file))).join(', ')} after %dms` + if (files.length > 3) { + let s = files.length > 1 ? 's' : '' // eslint-disable-line + paths_message = `%s completed after %dms with ${files.length} file${s} to parse` + } + log.emit('complete', 'paths', paths_message) - // converts json to a readable JS object - json = changed ? to.string(await json) : false - json = !!json ? to.object(json) : {} + log.emit('start', 'parser') + files = await map(files, (file_path) => parser(file_path, options)) - // Loop through the parsed files and update the - // json data that was stored. - for (let file of files) { - to.extend(json, file) - } - // Update the temp json data. Even though this returns a promise - // it's not returned below because there's no need to wait for it - // to finish writing out the json file before moving on. Because the - // `json` object has already been updated. - fs.outputJson(info.temp.file, (changed ? json : {}), { spaces: 2 }) - .catch((err) => log.error(err.stack)) - - if (!raw) { - log.emit('start', 'sorter') - json = sorter({ json, page_fallback, log }) - log.emit('complete', 'sorter') - } + log.emit('complete', 'parser') - log.emit('complete', 'total') - return json - } catch (err) { - log.error(err.stack) - } -} + // Loop through the parsed files and update the + // json data that was stored. + for (let file of files) { + to.extend(json, file) + } + + let result = json + + if (!raw) { + log.emit('start', 'sorter') + result = sorter({ json, page_fallback, log }) + log.emit('complete', 'sorter') + } + + log.emit('complete', 'total') + timestamps && log.space() -// @name hasFileChanged -// @access private -// @description -// checks the status of the file to see if it has changed or not. -// @arg {string} - path to file -// @async -// @returns {boolean} -async function hasFileChanged(file) { - let source = path.join(info.root, file) - let target = path.join(info.temp.folder, file) - - try { - let stats = await map([ source, target ], (_path) => fs.stat(_path)) - - // copies new files over because it's changed - if (stats[0].mtime > stats[1].mtime) { - fs.fakeCopy(source, target) - return true + return result + } catch (err) { + log.error(err.stack) } + } + + let result = await walk(initial_files) - return false - } catch (err) { - // copies new files over because it doesn't exist in the temp target directory - fs.fakeCopy(source, target) - return true + if (!watch) { + return result } -} + let watcher = chokidar.watch(initial_files, { ignored, persistent: true, ignoreInitial: true }) -// let logger = new Logger() -// process.on('uncaughtException', (err) => { -// logger.error('An uncaughtException was found:', err) -// console.trace(err) -// process.exit(1) -// }) + log.space() + log.print('Watching', to.map(initial_files, (file) => clor.bold(file)).join(', ')) + log.print('Excluding', to.map(ignore, (file) => clor.bold(file)).join(', ')) + log.space() + + watcher.on('all', async (type, file) => { + if (type === 'add' || type === 'changed') { + try { + await walk(file) + } catch (err) { + log.emit('error', file, 'was not updated', err) + } + } + }) +} diff --git a/app/utils/fs.js b/app/utils/fs.js index 4db60bd..cd1f008 100644 --- a/app/utils/fs.js +++ b/app/utils/fs.js @@ -1,23 +1,7 @@ // File System -import path from 'path' import fs from 'fs-extra' import promisify from 'es6-promisify' -// @name fs.fakeCopy -// @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.fakeCopy = (source, target, callback) => { - 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 = promisify(fs.readJson) fs.outputJson = promisify(fs.outputJson) @@ -26,4 +10,3 @@ fs.readFile = promisify(fs.readFile) fs.ensureFile = promisify(fs.ensureFile) export default fs -// export default promisify(fs) diff --git a/app/utils/info.js b/app/utils/info.js index 67060c4..e76c239 100644 --- a/app/utils/info.js +++ b/app/utils/info.js @@ -7,9 +7,4 @@ 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 = {} -// @todo {8} - come back and change the `.tmp` directory to be inside of `/node_modules/docs/.temp` -info.temp.folder = path.join(info.root, '.tmp') -info.temp.file = path.join(info.temp.folder, 'data.json') - export default info diff --git a/app/utils/logger.js b/app/utils/logger.js index ec81de5..ff8c5cf 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -102,7 +102,6 @@ export default class Logger { console.log('') this.print(`${messaging.warning}`) this.print(...args) - console.log('') return this } @@ -110,7 +109,6 @@ export default class Logger { console.log('') this.print(`${messaging.error}`) this.print(...args) - console.log('') return this } @@ -139,7 +137,6 @@ export default class Logger { console.log('') this.print(`${messaging.debug}`) this.print(...args) - console.log('') return this } @@ -151,7 +148,6 @@ export default class Logger { console.log('') this.print(`${messaging.file} ${file}`) this.print(...args) - console.log('') return this } } diff --git a/package.json b/package.json index 6040610..9535865 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "async-array-methods": "^2.1.0", "babel-runtime": "^6.6.1", "change-case": "^2.3.1", + "chokidar": "^1.4.3", "clone": "^1.0.2", "clor": "^2.0.2", "commander": "^2.9.0", diff --git a/tests/run.test.js b/tests/run.test.js index fca8ba4..507cef3 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -10,7 +10,6 @@ const test_defaults = { debug: false, timestamps: false, warning: false, - changed: false, ignore: '.*' } diff --git a/tools/generate-test.js b/tools/generate-test.js index 22525ec..d9ee582 100755 --- a/tools/generate-test.js +++ b/tools/generate-test.js @@ -46,7 +46,6 @@ function annotationTest(file) { return new Promise(function(resolve) { docs({ files: file, - changed: false, warning: false, debug: false, timestamps: false, @@ -75,7 +74,6 @@ function caseTest(file) { return new Promise(function(resolve) { docs({ files: file, - changed: false, warning: false, debug: false, timestamps: false, From 60b09d3b21277cfe23eed3be0cca22bc01276def Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 8 Mar 2016 16:31:29 -0500 Subject: [PATCH 238/273] Updated parser to normalize the annotations comment and code contents --- app/parser/get-blocks.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js index 0f36285..8e7bfc0 100644 --- a/app/parser/get-blocks.js +++ b/app/parser/get-blocks.js @@ -50,6 +50,13 @@ export default function getBlocks({ return debug_file } + + function pushBlock(block_to_push) { + block_to_push.comment.contents = to.normalize(block_to_push.comment.contents) + block_to_push.code.contents = to.normalize(block_to_push.code.contents) + parsed.push(block_to_push) + } + for (let i = start_at, l = lines.length; i < l; i++) { // If you're trying to debug something between specific lines you // can use this to narrow down the longs to the lines you're wanting debug @@ -86,7 +93,7 @@ export default function getBlocks({ // a) There was block that has already been processed if (!is.undefined(block)) { // holds the current block information block.code.end = i - 1 - parsed.push(block) + pushBlock(block) // Stops the loop after the first comment block // has been parsed. This is for file header comments @@ -138,7 +145,7 @@ export default function getBlocks({ if (in_comment && (style === 'multi' && index.end !== false ? i === l : i === l - 1)) { debug('the last line in the file is a comment') block.comment.end = style === 'multi' ? i - 1 : i - parsed.push(block) + pushBlock(block) break // ensures that the loop stops because it's the last line in the file } @@ -156,7 +163,7 @@ export default function getBlocks({ // Stops the loop after the first comment block // has been parsed. This is for file header comments if (restrict) { - parsed.push(block) + pushBlock(block) break } // a) The previous line was a comment @@ -171,7 +178,7 @@ export default function getBlocks({ // a) pushes the last block onto the body if (i === l - 1) { block.code.end = i - parsed.push(block) + pushBlock(block) } } } else if ( @@ -181,7 +188,7 @@ export default function getBlocks({ ) ) { block[block.comment.end > -1 ? 'code' : 'comment'].end = i - parsed.push(block) + pushBlock(block) block = undefined } } // end loop From d1bef19d245be3b5f98b8a4c6f8d1ff7944d7482 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 9 Mar 2016 13:32:26 -0500 Subject: [PATCH 239/273] added `to.random` function --- app/utils/to.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app/utils/to.js b/app/utils/to.js index 9500644..9075c37 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -46,6 +46,58 @@ let to = { 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': + 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 From 65f15b3f8978963adc6ed3b551b60eea743d291f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 10 Mar 2016 11:14:54 -0500 Subject: [PATCH 240/273] updated lots of shit --- app/new-annotation-api.js | 333 +++++++++++++++ app/new-parser/index.js | 104 +++++ app/new-parser/tokenizer.js | 780 ++++++++++++++++++++++++++++++++++++ app/utils/debug.js | 170 ++++++++ app/utils/index.js | 1 + app/utils/purdy.js | 3 +- package.json | 13 +- 7 files changed, 1397 insertions(+), 7 deletions(-) create mode 100644 app/new-annotation-api.js create mode 100644 app/new-parser/index.js create mode 100644 app/new-parser/tokenizer.js create mode 100644 app/utils/debug.js diff --git a/app/new-annotation-api.js b/app/new-annotation-api.js new file mode 100644 index 0000000..0abe1a1 --- /dev/null +++ b/app/new-annotation-api.js @@ -0,0 +1,333 @@ +'use strict' + +import { is, to } from './utils' + +const 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.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 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 +} + + +export default class AnnotationApi { + constructor({ annotations, file }) { + // 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 + + + // 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.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 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) + }) + }, { main: 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 + /// annoationsApi.add("name", function(){ + /// return this.annotation.line + /// }) + /// + /// @markup {js} **Example:** Declaring a annotation with more options + /// annoationsApi.add("name", { + /// alias: ['title', 'heading'], + /// parse(){ + /// return this.annotation.line + /// }, + /// autofill: false, + /// resolve: false + /// }) + /// + /// @markup {js} **Example** Specifing a file specific annotation + /// annoationsApi.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 + }) + } + + /// @name run_annotation + /// @access private + /// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) + run(options) { + let { + annotation, + annotation_types, + block = {}, + file, + log + } = 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(annotation_types.alias, name) ? annotation_types.alias[name] : [], + line: to.normalize(contents[0]), + contents, + start: null, + end: null + }, + annotation_types, + ...block, + log + }) + } + + // removes the first line because it's the `line` of the annotation + annotation.contents.shift() + + // normalizes the current annotation contents + annotation.contents = to.normalize(annotation.contents) + + // normalizes the current annotation line + annotation.line = to.normalize(annotation.line) + + // Merges the data together so it can be used to run all the annotations + let result = { + // sets the annotation block information to be in it's own namespace of `annotation` + annotation, + + // adds the comment, code, and file information + ...block, + + add, + + // adds the ability to add logging information + log + } + + // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed + if (is.all.truthy((this.annotations_list[file.type] || {})[annotation.name], ((this.annotations_list.default || {})[annotation.name]) || {}).parse) { + result.default = this.annotations_list.default[annotation.name].parse.call(result) + } + + return annotation_types.main[annotation.name].parse.call(result) + } + + + _run({ list, parsed, block }) { + let parsed_keys = to.keys(parsed) + + for (let [ annotation, fn ] of to.entries(list)) { + if (!is.in(parsed_keys, annotation)) { + const result = is.fn(fn) ? fn.call(block) : fn + if (result != null) { + parsed[annotation] = result + } + } + } + + return parsed + } + + 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/new-parser/index.js b/app/new-parser/index.js new file mode 100644 index 0000000..40f5782 --- /dev/null +++ b/app/new-parser/index.js @@ -0,0 +1,104 @@ +import { info, fs, is, to } from '../utils' +import AnnotationApi from '../new-annotation-api' +import * as annotations from '../annotations' +import path from 'path' +// import getBlocks from '../../get-blocks' +// import parseBlocks from '../parser/parse-blocks' +import getConfig from '../config' +import tokenizer from './tokenizer' +import clor from 'clor' + +export default async function parser(file_path, settings = {}) { + if (is.empty(settings)) { + settings = await getConfig() + } + // { + // languages, + // annotations, + // blank_lines, + // sort, + // log + // } + + const contents = to.normalString(await fs.readFile(file_path)) + + // { + // file_path, + // comments, + // languages, + // annotations, + // blank_lines, + // sort, + // log + // } + return new Parser({ path: file_path, contents }, settings) +} + +// parser.prototype.fn = Parser.prototype + +class Parser extends AnnotationApi { + constructor(file, settings) { + // the filetype of the current file + const type = path.extname(file.path).replace('.', '') + + // file.contents = replaceAliases() + const language = settings.languages[type] ? settings.languages[type] : settings.languages.default + + to.extend(file, { + path: path.join(info.dir, path.relative(info.root, file.path)) || file.path, // path of the file + name: path.basename(file.path, `.${type}`), // name of the file + type, // filetype of the file + options: language, // @todo remove this + settings: language, + start: 1, // starting point of the file + end: to.array(file.contents).length - 1 // ending point of the file + }) + + super({ annotations, file }) + + this.language = language + + to.extend(this, to.filter(settings, ({ key }) => { + return is.in([ 'blank_lines', 'sort', 'log' ], key) + })) + + // removes aliases from the file contents + this.replaceAliases() + + // a) The file doesn't contain any header level comments, or body level comments + if (!is.any.in(file.contents, ...to.values(file.options.header, '!type'), ...to.values(file.options.body, '!type'))) { + this.log.emit('warning', `Well shitfire, ${clor.bold(file.path)} doesn't contain any sweet documentation`) + return [] + } + + return this.parse() + } + + parse() { + let tokens = tokenizer(this) + } + + replaceAliases() { + let comment_types = to.flatten([ + ...to.values(this.language.header, '!type', '!end'), + ...to.values(this.language.body, '!type', '!end') + ]) + .filter(Boolean) + .map((comment_type) => '\\' + comment_type.split('').join('\\')) // this escapes every character (aka `/**` ==> `\\/\\*\\*`) + comment_types = `(?:${comment_types.join('|')})` + let block_comment = `(?:^(?:\\s*${comment_types})?\\s*)` + let inline_comment = `(?:${comment_types}?${this.language.inline_prefix}\\s+)` + let comment_regex = `((?:${block_comment}|${inline_comment})${this.language.prefix})` + + let alias_obj = to.reduce(this.annotations.alias, (previous, { key, value }) => { + value = value + .filter((alias) => !is.in(this.annotations.main, alias)) + .reduce((a, b) => to.extend(a, { [b]: key }), {}) + return to.extend(previous, value) + }, {}) + + const alias_list_regex = new RegExp(`${comment_regex}(${to.keys(alias_obj).join('|')})\\b`, 'gm') + + this.file.contents.replace(alias_list_regex, (match, comment_match, alias) => comment_match + alias_obj[alias]) + } +} diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js new file mode 100644 index 0000000..eb43846 --- /dev/null +++ b/app/new-parser/tokenizer.js @@ -0,0 +1,780 @@ +/* eslint-disable complexity, max-statements, max-depth */ +import { is, to, Logger, debug } from '../utils' +import { default_options } from '../config' +import clor from 'clor' + + +/// @name tokenizer +/// @access private +/// @description Parses the file and returns the comment blocks in an array +/// @returns {array} of the comment blocks +/// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. +export default function tokenizer(settings) { + // filters out the settings that aren't needed to prevent cluter + settings = to.filter(settings, ({ key }) => is.in([ 'file', 'blank_lines', 'sort', 'log', 'language' ], key)) + + let { + file, + language, + sort, // @todo figure out if this is needed + ...options + } = settings + + // let header = new Tokenizer({ comment: settings.file.settings.header, ...settings, restrict: true }) + let body = new Tokenizer( // eslint-disable-line + settings.file.contents, + { + comment: settings.file.settings.body, + should_debug: true, + ...options, + } + // settings.file.settings.body, + // { ...settings, should_debug: true } + ) + // console.log('new parser:', to.json(header)) + // console.log('new parser:', to.json(body)) + return '' +} + +@debug('Tokenizer') +class Tokenizer { + constructor(str, options = {}) { + if (arguments.length === 1) { + options = arguments[0] + str = options.str || options.content || options.source + } + + // forces the string to become 1 based instead of 0 and it normalizes it #windows sucks + str = '\n' + to.normalString(str) + + options = to.extend({ + comment: { start: '', line: '///', end: '' }, // the default comment style to look for + blank_lines: default_options.blank_lines, + strip: false, // determins if the comment should be stripped from the line + retrict: false, + }, options) + + to.extend(this, options) + + this.content = str // the contents to parse + this.lines = to.array(this.content) + this.lineno = to.number(this.start_at || this.lineno, this.i || this.index || 0) + this.is_multi = is.all.truthy(this.comment.start, this.comment.end) + + // this ensures there aren't any errors looking comment lines + // because `''` will always have an index of `0` + if (this.comment.line === '') { + this.comment.line = undefined + } + + // The base of what each token looks like + this.token_base = { + comment: { contents: [], start: -1, end: -1, type: this.comment.type || 'NA' }, + subcomments: [], + code: { contents: [], start: -1, end: -1 } + } + this.tokens = [] // placeholder for all the parsed tokens + this.blank_line_count = 0 // stores the current count of blank lines + this.token = undefined // stores the current token + this.in_comment = false // used to determin that you are in a comment + this.in_code = false // used to determin if you are in the code after the comment block + + // checks to see if the file has any comments + if (!(this.is_multi ? is.any.in(this.content, this.comment.start, this.comment.end) : is.in(this.content, this.comment.line))) { + return [] + } + + // debuggers + this.debugLine = this.debugSet('line') + this.tokenize() + return this.tokens + } + + tokenize() { + for (; this.lineno < this.lines.length; this.lineno++) { + this.update(false) + // const l = this.lines.length - 1 + // while (this.update() || this.lineno < this.lines.length) { + // if `this.break` is set at any point it will stop loop + // and return the tokens that exist + if (this.break) { + break + this.pushToken() + return this.tokens + } + this.visit() + this.debugLine.runDebug() + } + } + + pushToken() { + this.token.comment.contents = to.normalize(this.token.comment.contents).split('\n') + this.token.code.contents = to.normalize(this.token.code.contents).split('\n') + this.tokens.push(this.token) + this.token = undefined + } + + update(update_index = true) { + const dl = this.debugLine + if (update_index) { + this.lineno++ + } + this.line = this.lines[this.lineno] + dl.debug(`line ${this.lineno}:`) + dl.debug(`${clor.bgBlue(this.line)}`) + + // If you're trying to debug something between specific lines you + // can use this to narrow down the longs to the lines you're wanting debug + // just pass in the starting line number and end line number both should be 1 + // less that what you're looking for since this is zero based. + // debug = is.between(i, [start line], [end line]) + // this.should_debug = is.between(this.lineno, 0, 8) + // const escape = (str) => '\\' + str.split('').join('\\') + + this.index = { start: false, line: false, end: false } + const test_comment = (comment) => { + if (is.falsy(comment)) { + return false + } + // store the index of the comment + let index = this.line.indexOf(comment) + // check to see if the comment exisits + if (index > -1) { + // check to see if the required space after the comment exisits + if (is.in(this.line, `${comment} `)) { + return index + } + + // check to see if the comment is the only thing on the line + if (this.line.length === index + comment.length) { + return index + } + } + + return false + } + + // const test_comment = (comment) => { + // if (!comment) { + // return false + // } + // const escape = (str) => '\\' + str.split('').join('\\') + // const regex = new RegExp(escape(comment) + '\s*') + // const result = this.line.match(regex) + // console.log('regex:', regex) + // console.log('result:', result) + // return result !== false && this.line.indexOf(this.line) + // } + // console.log('line:', `${clor.bold.magenta(this.lineno)}`, `${clor.bgBlue(this.line)}`) + this.index = to.reduce([ 'start', 'line', 'end' ], (prev, next) => { + prev[next] = test_comment(this.comment[next]) + return prev + }, {}) + + this.index = { + start: test_comment(this.comment.start), + line: test_comment(this.comment.line), + end: test_comment(this.comment.end) + } + // console.log('{') + // to.map(this.index, ({ key, value }) => { + // console.log(` ${key}: ${clor[value !== false ? 'green' : 'red'](value)}`) + // return {} + // }) + // console.log('}') + + // this.index = { + // start: this.is_multi && is.in(this.line, this.comment.start) ? this.line.indexOf(this.comment.start) : false, + // line: is.in(this.line, this.comment.line) ? this.line.indexOf(this.comment.line) : false, + // end: this.is_multi && is.in(this.line, this.comment.end) ? this.line.indexOf(this.comment.end) : false + // } + + // console.log('') + // console.log('') + // console.log('') + // console.log('') + dl.debug('index:', this.index) + dl.debug('') + } + + visit() { + if (!is.empty(this.line)) { + // reset the current blank line count back to 0 because this line wasn't empty + this.blank_line_count = 0 + + // // there's instance of comment + if (this.isComment()) { + this.walkComment() + if (this.restrict) { + this.debugLine.debug('is restricted') + return this.token + } + } + + if (this.isCode()) { + // this.debug('is code') + // // Stops the loop after the first comment block + // // has been parsed. This is for file header comments + // if (this.restrict) { + // this.pushToken() + // break + // } + // + this.walkCode() + } + } else if (this.shouldStop()) { + this.handleShouldStop() + } + } + + isLastLine() { + // checks to see if the current line is the last line in the file + const length = this.is_multi && this.index.end !== false ? this.lines.length : this.lines.length - 1 + return this.debugLine.debugIfTrue(this.lineno === length, `${clor.red('is the last line')}`) + } + + shouldStop() { + const dl = this.debugLine + if ( + !is.undefined(this.token) && ( + // checks to see if there were 4 consecutive blank lines + dl.debugIfTrue(++this.blank_line_count === this.blank_lines, 'hit the max blank lines') || + // checks to see if it was the last line in the file + this.isLastLine() + ) + ) { + this.debugLine.debug('is stopping') + return true + } + + return false + } + handleShouldStop() { + this.token[this.token.comment.end > -1 ? 'code' : 'comment'].end = this.lineno + this.pushToken() + } + + + isComment() { + const dl = this.debugLine + // checks for the start and end style or there was an instance of a comment line + if ( + this.is_multi && ( + dl.debugIfTrue(this.index.start !== false, 'is the start of a multi line comment') || + dl.debugIfTrue(this.in_comment, 'is in a multi line comment') + ) || + dl.debugIfTrue(this.index.line !== false, 'is single line comment') + ) { + return true + } + return false + } + + walkComment() { + const dl = this.debugLine + + const isNewToken = this.index.start !== false || (!this.is_multi && !this.in_comment) + // check for the start of a new token block + if (isNewToken) { + dl.debug('is new token') + this.in_code = false + this.in_comment = true + + // There was a token that has already been processed + if (!is.undefined(this.token)) { // holds the current token information + dl.debug('this.token', this.token) + this.token.code.end = this.lineno - 1 // sets the line number to be the previous line + this.pushToken() + + // Stops the loop after the first comment token + // has been parsed. This is for file header comments + if (this.restrict) { + this.token.comment.end = this.lineno + this.token.code.end = -1 + return this.tokens + } + } + + // reset the `token` to use on the new token + this.token = to.clone(this.token_base) + this.token.comment.start = this.lineno + + this.in_comment = true + } + + // check for the end comment + const isEndComment = !is.undefined(this.token) && this.is_multi && this.token.comment.start !== this.lineno && this.index.end !== false + if (isEndComment) { + dl.debug('is end comment') + this.in_comment = false + this.token.comment.end = this.lineno // sets the end line in the comment token + + // @todo try to use `this.update()` instead of the following lines + this.lineno++ // skips end comment line + this.line = this.lines[this.lineno] // updates to be the next line + this.index.end = (this.line && is.in(this.line, this.comment.end)) ? this.line.indexOf(this.comment.end) : false + } + + // adds this line to token comment contents + const shouldPushLine = this.in_comment && (this.index.start === false || this.index.end === false) + if (shouldPushLine) { + if (this.index.line !== false) { + // removes the `comment.line` from the line. + this.line = this.line.slice(this.index.line + this.comment.line.length) + } else if (this.index.start !== false) { + // removes the `comment.start` from the line. + this.line = this.line.slice(this.index.start + this.comment.start.length) + } + + if (!is.empty(this.line)) { + dl.debug('line was pushed') + this.token.comment.contents.push(this.line) + } + } + + + // The last line in the file is a commment + if (this.in_comment && this.isLastLine()) { + dl.debug('the last line in the file is a comment') + this.token.comment.end = this.is_multi ? this.lineno - 1 : this.lineno + this.pushToken() + } + + // check the next line for an instance of the a line comment + if ( + !this.is_multi && + !is.in(this.lines[this.lineno + 1], this.comment.line) + ) { + dl.debug('next line is not a comment') + this.in_comment = false + this.token.comment.end = this.lineno // sets the end line in the comment token + this.update() // updates to be the next line + } + } + + isCode() { + if ( + !is.undefined(this.token) && + !this.in_comment && + this.index.end === false + ) { + this.debugLine.debug(`${clor.green('is code')}`) + this.in_comment = false + this.in_code = true + return true + } + return false + } + + walkCode() { + // The previous line was a comment + if (this.token.code.start === -1) { + this.token.code.start = this.lineno + } + + // adds this line to token code contents + this.token.code.contents.push(this.line) + + // pushes the last token onto the body + if (this.isLastLine()) { + this.token.code.end = this.lineno + this.pushToken() + } + } +} +/* eslint-disable */ + + + + +// class Line { +// constructor(line, info = {}) { +// this.str = line +// to.extend(this, info) +// } +// get line() { +// return this.str +// } +// } +// +// Object.defineProperty(Line.prototype, 'toString', { +// value() { return this.line } +// }) + + +class Line { + constructor(line, { + lineno = 'NA', + column = 'NA', + type = undefined, // expect one of `'start'`, `'line'`, `'end'`, `'code'` + index = undefined + } = {}) { + this.line = line + + to.extend(this, { + lineno, + column, + type, + index + }) + + return this.line + } +} + +Object.defineProperty(Line.prototype, 'toString', { + value() { return this.line } +}) + + + + + + + + + + + + + + + + + + + +/* eslint-enable */ +@debug('Tokenizer') +class _Tokenizer { // eslint-disable-line + constructor(settings) { + to.extend(this, settings) + + this.i = to.number(this.start_at || this.i || this.index || 0) + + this.is_multi = is.all.truthy(this.comment.start, this.comment.end) + + // this ensures there aren't any errors looking comment lines + // because `''` will always have an index of `0` + if (this.comment.line === '') { + this.comment.line = undefined + } + + this.token_base = { + comment: { contents: [], start: -1, end: -1, type: this.comment.type }, + code: { contents: [], start: -1, end: -1 }, + file: this.file + } + + this.lines = to.array(this.file.contents) // lines of the file + this.tokens = [] // placeholder for all the parsed tokens + this.blank_line_count = 0 // stores the current count of blank lines + this.token = undefined // stores the current block + this.in_comment = false // used to determin that you are in a comment + this.in_code = false // used to determin if you are in the code after the comment block + + this.debug_file = !is.undefined(this.debug_file) ? this.debug_file : false + this.debug_list = [] + + if (!(this.is_multi ? is.any.in(this.file.contents, this.comment.start, this.comment.end) : is.in(this.file.contents, this.comment.line))) { + return [] + } + + return this.tokenize() + } + + update() { + this.line = this.lines[this.i] + + // If you're trying to debug something between specific lines you + // can use this to narrow down the longs to the lines you're wanting debug + // just pass in the starting line number and end line number both should be 1 + // less that what you're looking for since this is zero based. + // debug = is.between(i, [start line], [end line]) + // this.debug_file = is.between(this.i, 0, 8) + this.index = { + start: this.is_multi && is.in(this.line, this.comment.start) ? this.line.indexOf(this.comment.start) : false, + line: is.in(this.line, this.comment.line) ? this.line.indexOf(this.comment.line) : false, + end: this.is_multi && is.in(this.line, this.comment.end) ? this.line.indexOf(this.comment.end) : false + } + } + + tokenize() { + for (; this.i < this.lines.length; this.i++) { + this.update() + this.debug(`line ${this.i}:`) + this.debug(this.line) + this.debug('index:', this.index) + + if (!is.empty(this.line)) { + // reset the current blank line count back to 0 because this line wasn't empty + this.blank_line_count = 0 + + // there's instance of comment + if (this.isComment()) { + this.debug('is a comment') + this.walkComment() + + if (this.restrict) { + this.debug('is restricted') + return this.token + } + } + + if (this.isCode()) { + this.debug('is code') + // Stops the loop after the first comment block + // has been parsed. This is for file header comments + if (this.restrict) { + this.pushToken() + break + } + + this.walkCode() + } + } else if (this.isStopWorthy()) { + this.handleStopWorthy() + } + + + + this.runDebug() + } + + return this.tokens + } + + + isCode() { + if (this.hasExistingToken() && !this.in_comment && this.index.end === false) { + this.in_comment = false + this.in_code = true + return true + } + return false + } + + + isComment() { + // checks for the start and end style or there was an instance of a comment line + return this.is_multi && (this.index.start !== false || this.in_comment) || this.index.line !== false + } + + isLastLine() { + // checks to see if the current line is the last line in the file + if (this.i === this.lines.length - 1 && is.truthy(this.token) && this.hasExistingToken()) { + this.debug('is the last line') + return true + } + return false + } + + hasExistingToken() { + return !is.undefined(this.token) + } + + + isStopWorthy() { + return this.hasExistingToken() && ( + // checks to see if there were 4 consecutive blank lines + ++this.blank_line_count === this.blank_lines || + this.isLastLine() + ) + } + + handleStopWorthy() { + this.token[this.token.comment.end > -1 ? 'code' : 'comment'].end = this.i + this.pushToken() + this.token = undefined + } + + + walkComment() { + // check for the start of a new token block + if (this.isNewToken()) { + this.handleNewToken() + } + + // check for the end comment + if (this.isEndComment()) { + this.handleEndComment() + } + + // adds this line to token comment contents + if (this.isWorthy()) { + this.handleWorthy() + } + + // The last line in the file is a commment + if (this.isLastLineComment()) { + this.handleLastLineComment() + } + + // check the next line for an instance of the a line comment + if (this.isNextLineComment()) { + this.handleNextLineComment() + } + } + + + isWorthy() { + return this.hasExistingToken() && this.in_comment && (this.index.start === false || this.index.end === false) + } + + handleWorthy() { + this.debug('is worthy') + if (this.index.line !== false) { + // removes the `comment.line` from the line. + this.line = this.line.slice(this.index.line + this.comment.line.length) + } else if (this.index.start !== false) { + // removes the `comment.start` from the line. + this.line = this.line.slice(this.index.start + this.comment.start.length) + } + + if (!is.empty(this.line)) { + this.debug('line was pushed') + this.token.comment.contents.push(this.line) + } + } + + + isNewToken() { + if ( + this.index.start !== false || ( + !this.is_multi && + !this.in_comment + ) + ) { + this.debug('is new token') + this.in_code = false + this.in_comment = true + return true + } + return false + } + + handleNewToken() { + // There was a token that has already been processed + if (this.hasExistingToken()) { // holds the current token information + this.debug('this.token', this.token) + this.token.code.end = this.i - 1 + this.pushToken() + + // Stops the loop after the first comment token + // has been parsed. This is for file header comments + if (this.restrict) { + this.token.comment.end = this.i + this.token.code.end = -1 + return this.tokens + } + } + + // reset the `token` to use on the new token + this.token = to.clone(this.token_base) + this.token.comment.start = this.i + + this.in_comment = true + } + + + isEndComment() { + if ( + this.token && + this.is_multi && + this.token.comment.start !== this.i && + this.index.end !== false + ) { + this.debug('is end comment') + return true + } + + return false + } + + handleEndComment() { + this.debug('handled end comment') + this.in_comment = false + this.token.comment.end = this.i // sets the end line in the comment token + this.i++ // skips end comment line + this.line = this.lines[this.i] // updates to be the next line + this.index.end = (this.line && is.in(this.line, this.comment.end)) ? this.line.indexOf(this.comment.end) : false + } + + + isLastLineComment() { + let length = this.file.end + + if (!(this.is_multi && this.index.end !== false)) { + length-- + } + + if (this.in_comment && (this.i === length)) { + return true + } + + return false + } + + handleLastLineComment() { + this.debug('the last line in the file is a comment') + this.token.comment.end = this.is_multi ? this.i - 1 : this.i + this.pushToken() + } + + isNextLineComment() { + return !this.is_multi && !is.in(this.lines[this.i + 1], this.comment.line) + } + + handleNextLineComment() { + this.debug('next line is a comment') + this.in_comment = false + this.token.comment.end = this.i // sets the end line in the comment token + this.i = this.i + 1 // skips end comment line + this.line = this.lines[this.i] // updates to be the next line + } + + + walkCode() { + // The previous line was a comment + if (!this.in_code) { + this.in_code = true + this.token.code.start = this.i + } + + // adds this line to token code contents + this.token.code.contents.push(this.line) + + // pushes the last token onto the body + if (this.isLastLine()) { + this.token.code.end = this.i + this.pushToken() + } + } + + + pushToken() { + this.token.comment.contents = to.normalize(this.token.comment.contents) + this.token.code.contents = to.normalize(this.token.code.contents) + this.tokens.push(this.token) + } + + + + // This is used for debuging files. to debug a file just set `this.debug_file = true` and this will debug files + // @note THIS SHOULD NEVER BE COMMITTED AS `TRUE` + debug(...args) { + this.debug_list.push(...args) + return this.debug_file + } + + runDebug() { + if (this.debug_file && this.debug_list.length > 0) { + this.debug_list.slice(0, 1).forEach((obj) => { + console.log('') + this.log.debug(obj) + }) + this.debug_list.slice(1).forEach((obj) => this.log.print(obj)) + this.debug_list = [] + } + } +} diff --git a/app/utils/debug.js b/app/utils/debug.js new file mode 100644 index 0000000..25549b5 --- /dev/null +++ b/app/utils/debug.js @@ -0,0 +1,170 @@ +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', value = false, default_color = 'magenta') { + const color_list = [ 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray' ].filter((color) => color !== default_color) + const icon_chevron = '\xBB ' + const base = clor[default_color].bold(`${icon_chevron}[${default_name}]:`) + + return function debugDecorator(target) { + let log = target.log || new Logger() + /// @name define + /// This function helps define properties on an object + /// @description + /// @private + function define(obj, name, val, options = {}) { + Object.defineProperty(obj, name, { + configurable: true, + writable: true, + enumerable: false, + value: val, + ...options + }) + } + + class Debugger { + constructor(name = '', val, color = default_color, context) { + this.should_debug = val + this.__debug_list = [] + this.__color = color + this.__name = name + let self = this + return function boundDebugger() { + this.should_debug = self.should_debug + define(this, '__default_name', self.__name) + define(this, '__name', self.__name) + define(this, '__color', self.__color) + // this ensures the __debug_list won't show up as enumerable in + // the object it's applied to called object + define(this, '__debug_list', self.__debug_list) + }.bind(context || this)() + } + + debug(...args) { + this.__debug_list.push(...args) + return this.should_debug + } + + debugIfTrue(arg, ...args) { + if (is.truthy(arg)) { + this.__debug_list.push(...args) + } + return arg + } + + debugIfFalse(arg, ...args) { + if (is.false(arg)) { + this.__debug_list.push(...args) + } + return arg + } + + debugWrap(arg, cb, ...args) { + if (is.function(cb)) { + console.log('debugWrap must use have a callback') + if (cb(arg)) { + this.__debug_list.push(...args) + } + } + return arg + } + + runDebug() { + if (this.should_debug && this.__debug_list.length > 0) { + console.log('') + console.log('') + console.log(`${base} ${clor[this.__color].bold(this.__name)}`) + 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 + define(this, '__debug_list', []) + } + } + } + + const default_debugger = new Debugger('', value, default_color, target.prototype) + target.prototype.debug = default_debugger.debug + target.prototype.runDebug = default_debugger.runDebug + target.prototype.debugIfTrue = default_debugger.debugIfTrue + target.prototype.debugIfFalse = default_debugger.debugIfFalse + target.prototype.debugSet = function debugSet(name = '', val = value, color = to.random(color_list)) { + return new Debugger(name, val, color) + } + + return target + } +} diff --git a/app/utils/index.js b/app/utils/index.js index d8f0176..1245f06 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -5,3 +5,4 @@ export glob from './glob' export info from './info' export is from './is' export to from './to' +export debug from './debug' diff --git a/app/utils/purdy.js b/app/utils/purdy.js index 9bd57a6..bfbc6b0 100644 --- a/app/utils/purdy.js +++ b/app/utils/purdy.js @@ -220,7 +220,8 @@ export default class Purdy { } _string(str) { - str = to.normalize(str, false).split('\n') + // str = to.normalize(str, false).split('\n') + str = to.array(str) let quote = str.length > 1 ? '`' : "'" let l = str.length diff --git a/package.json b/package.json index 9535865..aabd7f0 100644 --- a/package.json +++ b/package.json @@ -60,21 +60,22 @@ "marked": "^0.3.5" }, "devDependencies": { - "babel-cli": "^6.6.4", + "babel-cli": "^6.6.5", "babel-eslint": "^5.0.0", "babel-plugin-syntax-async-functions": "^6.5.0", - "babel-plugin-transform-async-to-generator": "^6.5.0", - "babel-plugin-transform-regenerator": "^6.6.0", + "babel-plugin-transform-async-to-generator": "^6.7.0", + "babel-plugin-transform-decorators-legacy": "^1.3.4", + "babel-plugin-transform-regenerator": "^6.6.5", "babel-plugin-transform-runtime": "^6.6.0", "babel-preset-es2015": "^6.6.0", "babel-preset-stage-0": "^6.5.0", - "babel-register": "^6.6.0", + "babel-register": "^6.6.5", "core-assert": "^0.1.3", "coveralls": "^2.11.8", - "eslint": "^2.1.0", + "eslint": "^2.3.0", "eslint-plugin-babel": "^3.1.0", "mocha": "^2.4.5", - "nyc": "^5.6.0", + "nyc": "^6.0.0", "plato": "deedubs/es6-plato", "proxyquire": "^1.7.4", "sinon": "^1.17.3" From 75a97be3c6119063c57f75c05266793b632f7bb5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 11 Mar 2016 11:24:42 -0500 Subject: [PATCH 241/273] Updated debug function --- app/utils/debug.js | 134 ++++++++++++++++++++++++--------------------- 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/app/utils/debug.js b/app/utils/debug.js index 25549b5..232a2d1 100644 --- a/app/utils/debug.js +++ b/app/utils/debug.js @@ -75,96 +75,108 @@ import clor from 'clor' /// } /// } /// -export default function debug(default_name = 'DEBUG', value = false, default_color = 'magenta') { - const color_list = [ 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray' ].filter((color) => color !== default_color) - const icon_chevron = '\xBB ' - const base = clor[default_color].bold(`${icon_chevron}[${default_name}]:`) - - return function debugDecorator(target) { - let log = target.log || new Logger() - /// @name define - /// This function helps define properties on an object - /// @description - /// @private - function define(obj, name, val, options = {}) { - Object.defineProperty(obj, name, { - configurable: true, - writable: true, - enumerable: false, - value: val, - ...options - }) - } +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({ seperator: 2, 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}]:`) class Debugger { - constructor(name = '', val, color = default_color, context) { - this.should_debug = val - this.__debug_list = [] - this.__color = color - this.__name = name - let self = this - return function boundDebugger() { - this.should_debug = self.should_debug - define(this, '__default_name', self.__name) - define(this, '__name', self.__name) - define(this, '__color', self.__color) - // this ensures the __debug_list won't show up as enumerable in - // the object it's applied to called object - define(this, '__debug_list', self.__debug_list) - }.bind(context || this)() + constructor(name = 'Define a Name', should_debug, options = {}) { + if (is.plainObject(should_debug)) { + options = should_debug + should_debug = options.should_debug || default_should_debug + } + this.should_debug = should_debug + this.debug_list = [] + this.name = name + this.color = options.color + this.seperator = options.seperator } debug(...args) { - this.__debug_list.push(...args) + this.debug_list.push(...args) return this.should_debug } + push(...args) { + return this.debug(...args) + } + + add(...args) { + return this.debug(...args) + } + debugIfTrue(arg, ...args) { if (is.truthy(arg)) { - this.__debug_list.push(...args) + this.debug_list.push(...args) } return arg } debugIfFalse(arg, ...args) { if (is.false(arg)) { - this.__debug_list.push(...args) + this.debug_list.push(...args) } return arg } debugWrap(arg, cb, ...args) { - if (is.function(cb)) { - console.log('debugWrap must use have a callback') - if (cb(arg)) { - this.__debug_list.push(...args) - } + if (!is.function(cb)) { + console.log('debugWrap must use a callback') + } + if (cb(arg)) { + this.debug_list.push(...args) } return arg } - runDebug() { - if (this.should_debug && this.__debug_list.length > 0) { - console.log('') - console.log('') - console.log(`${base} ${clor[this.__color].bold(this.__name)}`) - 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 - define(this, '__debug_list', []) + run() { + try { + if (this.should_debug && this.debug_list.length > 0) { + for (let i = this.seperator; i; i--) console.log('') + console.log(this.name) + 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) } } - } - const default_debugger = new Debugger('', value, default_color, target.prototype) - target.prototype.debug = default_debugger.debug - target.prototype.runDebug = default_debugger.runDebug - target.prototype.debugIfTrue = default_debugger.debugIfTrue - target.prototype.debugIfFalse = default_debugger.debugIfFalse - target.prototype.debugSet = function debugSet(name = '', val = value, color = to.random(color_list)) { - return new Debugger(name, val, color) + debugSet(name = 'define a name silly', should_debug, options = {}) { + if (!should_debug) { + should_debug = this.should_debug ? this.should_debug : default_should_debug + } + + if (!options.seperator) { + options.seperator = this.seperator ? this.seperator : default_options.seperator + } + + if (!options.color) { + options.color = to.random(color_list) + } + + if (this.name) { + name = `${this.name} > ${clor[options.color].bold(name)}` + } else { + name = `${default_name} ${clor[options.color].bold(name)}` + } + + return new Debugger(name, should_debug, options) + } } - return target + return function debugDecorator(target) { + target.prototype.debugSet = Debugger.prototype.debugSet + return target + } + } catch (err) { + console.trace(err) } } From 7e61493b58da1f6dfbd14f372d4620a9fb284d16 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 14 Mar 2016 09:26:37 -0400 Subject: [PATCH 242/273] Updated the debugger to be more helpful and extendable --- .babelrc | 1 + app/utils/debug.js | 172 +++++++++++++++++++++++++++------------------ 2 files changed, 106 insertions(+), 67 deletions(-) diff --git a/.babelrc b/.babelrc index 978074c..a818e4e 100644 --- a/.babelrc +++ b/.babelrc @@ -6,6 +6,7 @@ "plugins": [ "syntax-async-functions", "transform-async-to-generator", + "transform-decorators-legacy", "transform-regenerator", "transform-runtime" ] diff --git a/app/utils/debug.js b/app/utils/debug.js index 232a2d1..574da3e 100644 --- a/app/utils/debug.js +++ b/app/utils/debug.js @@ -78,100 +78,138 @@ import clor from 'clor' 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({ seperator: 2, color: to.random(color_list) }, default_options) + + 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}]:`) - class Debugger { - constructor(name = 'Define a Name', should_debug, options = {}) { - if (is.plainObject(should_debug)) { - options = should_debug - should_debug = options.should_debug || default_should_debug - } - this.should_debug = should_debug - this.debug_list = [] - this.name = name - this.color = options.color - this.seperator = options.seperator - } + default_name = clor[default_options.color].bold(`${icon_chevron}[${default_name}]: `) - debug(...args) { - this.debug_list.push(...args) - return this.should_debug - } - push(...args) { - return this.debug(...args) + function Debugger(name = 'Define a Name', should_debug, options = {}) { + if (is.plainObject(should_debug)) { + options = should_debug + should_debug = options.should_debug || default_should_debug } + this.should_debug = should_debug + this.debug_list = [] + this.name = name + this.color = options.color + this.spaces = options.spaces + } - add(...args) { - return this.debug(...args) - } + const dp = Debugger.prototype - debugIfTrue(arg, ...args) { - if (is.truthy(arg)) { - this.debug_list.push(...args) - } - return arg + dp.push = dp.debug = dp.add = function push(...args) { + this.debug_list.push(...args) + return this.should_debug + } + + dp.debugIfTrue = dp.ifTrue = function debugIfTrue(arg, ...args) { + if (is.truthy(arg)) { + this.debug_list.push(...args) } + return arg + } - debugIfFalse(arg, ...args) { - if (is.false(arg)) { - this.debug_list.push(...args) - } - return arg + + dp.debugIfFalse = dp.ifFalse = function debugIfFalse(arg, ...args) { + if (is.false(arg)) { + this.debug_list.push(...args) } + return arg + } - debugWrap(arg, cb, ...args) { - if (!is.function(cb)) { - console.log('debugWrap must use a callback') - } - if (cb(arg)) { - this.debug_list.push(...args) - } - return arg + dp.debugWrap = dp.wrap = function debugWrap(arg, cb, ...args) { + if (!is.function(cb)) { + console.log('debugWrap must use a callback') + } + if (cb(arg)) { + this.debug_list.push(...args) } + return arg + } - run() { - try { - if (this.should_debug && this.debug_list.length > 0) { - for (let i = this.seperator; i; i--) console.log('') - console.log(this.name) + // dp.debugSet.prototype.run = dp.set.prototype.run = dp.debugWrap.prototype.run = dp.wrap.prototype.run = dp.debugIfFalse.prototype.run = dp.ifFalse.prototype.run = dp.debugIfTrue.prototype.run = dp.ifTrue.prototype.run = dp.push.prototype.run = dp.debug.prototype.run = dp.add.prototype.run = + 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) + // update the debug list to be empty + this.debug_list = [] } + } catch (e) { + console.trace(e) } + } - debugSet(name = 'define a name silly', should_debug, options = {}) { - if (!should_debug) { - should_debug = this.should_debug ? this.should_debug : default_should_debug - } + 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 (!options.seperator) { - options.seperator = this.seperator ? this.seperator : default_options.seperator - } + // 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 = this.should_debug ? this.should_debug : default_should_debug + } - if (!options.color) { - options.color = to.random(color_list) - } + if ( + options.color === 'inherit' || ( + this.color === 'inherit' && + is.undefined(options.color) + ) + ) { + options.color = this.color ? this.color : default_options.color + } - if (this.name) { - name = `${this.name} > ${clor[options.color].bold(name)}` - } else { - name = `${default_name} ${clor[options.color].bold(name)}` - } + 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) - return new Debugger(name, should_debug, 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) } + // let debugger_map = to.reduce(dp, (prev, { key, value }) => { + // prev[key] = { + // configurable: true, + // enumerable: true, + // writable: true, + // value, + // } + // return prev + // }, {}) + return function debugDecorator(target) { target.prototype.debugSet = Debugger.prototype.debugSet return target From 42444286f9e121a936020b304d124e3e4d6f0291 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 14 Mar 2016 09:28:27 -0400 Subject: [PATCH 243/273] added tests for the `to.random` function --- app/utils/to.js | 3 +++ tests/unit/utils/to.test.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/utils/to.js b/app/utils/to.js index 9075c37..8b6aa20 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -57,6 +57,9 @@ let to = { switch (to.type(min)) { case 'number': + if (min === max) { + return min + } return Math.floor(Math.random() * (max - min + 1)) + min break case 'array': diff --git a/tests/unit/utils/to.test.js b/tests/unit/utils/to.test.js index a2fe21c..8a839c9 100644 --- a/tests/unit/utils/to.test.js +++ b/tests/unit/utils/to.test.js @@ -30,6 +30,20 @@ asyncSuite.wrap('to', () => { '`boolean` should be converted to a typeof string') }) + test('to.random', () => { + let array_test = [ 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray' ] + + for (let i = 0; i < 1000; i++) { + let random_array_item = to.random(array_test) + assert.ok(array_test.indexOf(random_array_item) > -1) + } + + for (let i = -1000; i < 1000; i++) { + let random_number = to.random(i, 1000) + assert.ok(random_number >= i && random_number <= 1000) + } + }) + test('to.normalString', async () => { let result From ec38a2dc5768d4592bcfaeb5ee80f84c8eba3926 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 14 Mar 2016 09:40:12 -0400 Subject: [PATCH 244/273] Updated the way options can be passed to the tokenizer --- app/new-parser/tokenizer.js | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index eb43846..f78d48b 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -36,16 +36,16 @@ export default function tokenizer(settings) { return '' } -@debug('Tokenizer') -class Tokenizer { - constructor(str, options = {}) { - if (arguments.length === 1) { +@_debug('Tokenizer') +export class Tokenizer { + constructor(content, options = {}) { + if (arguments.length === 1 && is.plainObject(content)) { options = arguments[0] - str = options.str || options.content || options.source + content = options.str || options.content || options.source } // forces the string to become 1 based instead of 0 and it normalizes it #windows sucks - str = '\n' + to.normalString(str) + content = '\n' + to.normalString(content) options = to.extend({ comment: { start: '', line: '///', end: '' }, // the default comment style to look for @@ -56,8 +56,7 @@ class Tokenizer { to.extend(this, options) - this.content = str // the contents to parse - this.lines = to.array(this.content) + this.lines = to.array(content) this.lineno = to.number(this.start_at || this.lineno, this.i || this.index || 0) this.is_multi = is.all.truthy(this.comment.start, this.comment.end) @@ -69,10 +68,14 @@ class Tokenizer { // The base of what each token looks like this.token_base = { - comment: { contents: [], start: -1, end: -1, type: this.comment.type || 'NA' }, - subcomments: [], + comment: { contents: [], start: -1, end: -1 }, code: { contents: [], start: -1, end: -1 } } + // add the comment type if it was passed + if (this.comment.type) { + this.token_base.comment.type = this.comment.type + } + this.tokens = [] // placeholder for all the parsed tokens this.blank_line_count = 0 // stores the current count of blank lines this.token = undefined // stores the current token @@ -80,18 +83,29 @@ class Tokenizer { this.in_code = false // used to determin if you are in the code after the comment block // checks to see if the file has any comments - if (!(this.is_multi ? is.any.in(this.content, this.comment.start, this.comment.end) : is.in(this.content, this.comment.line))) { + if ( + this.is_multi && + !is.any.in(content, this.comment.start, this.comment.end) || // checks if the multi line comment style exists + !is.in(content, this.comment.line) // checks if the single line comment style exists + ) { return [] } // debuggers - this.debugLine = this.debugSet('line') + this.debugLine = this.debugSet('line', { spaces: 2 }) + this.debugUpdate = this.debugLine.debugSet('update', 0) + this.debugWalkComment = this.debugLine.debugSet('walkComment', 0) + this.debugIsCode = this.debugLine.set('isCode', { spaces: 0, color: 'green' }) + this.debugIsComment = this.debugLine.set('isComment', 0) + this.debugIsLastLine = this.debugLine.set('isLasLine', { spaces: 0, color: 'bgRed' }) + this.debugShouldStop = this.debugLine.set('shouldStop', 0) + this.debugPushToken = this.debugLine.debugSet('pushToken', 0) + this.tokenize() return this.tokens } tokenize() { - for (; this.lineno < this.lines.length; this.lineno++) { this.update(false) // const l = this.lines.length - 1 // while (this.update() || this.lineno < this.lines.length) { From 68cdd85f1f90252305431a5fb1d3009464a940d2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 14 Mar 2016 09:47:28 -0400 Subject: [PATCH 245/273] Updated the debugging information --- app/new-parser/tokenizer.js | 195 +++++++++++++++++++----------------- 1 file changed, 105 insertions(+), 90 deletions(-) diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index f78d48b..7bd940d 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -1,5 +1,5 @@ /* eslint-disable complexity, max-statements, max-depth */ -import { is, to, Logger, debug } from '../utils' +import { is, to, debug as _debug } from '../utils' import { default_options } from '../config' import clor from 'clor' @@ -106,9 +106,8 @@ export class Tokenizer { } tokenize() { - this.update(false) - // const l = this.lines.length - 1 - // while (this.update() || this.lineno < this.lines.length) { + this.lineno-- + while (this.update('updated from the loop')) { // if `this.break` is set at any point it will stop loop // and return the tokens that exist if (this.break) { @@ -117,25 +116,60 @@ export class Tokenizer { return this.tokens } this.visit() - this.debugLine.runDebug() + this.debugLine.run() } } - pushToken() { + ifToken() { + return !this.break && !is.undefined(this.token) + } + + pushToken(pushed_from = 'unknown unknown') { + const debug = this.debugPushToken + debug.push(`pushed from: ${pushed_from}`) + debug.run() + + // set the end point of the code or the comment + this.token[this.token.comment.end > -1 && this.token.code.start > -1 ? 'code' : 'comment'].end = this.lineno + + // normalize the comment contents by striping out empty lines from the start and end of comment block this.token.comment.contents = to.normalize(this.token.comment.contents).split('\n') - this.token.code.contents = to.normalize(this.token.code.contents).split('\n') + + let code = this.token.code + // normalize the code contents + code.contents = to.normalize(code.contents).split('\n') + // check to see if the code contents is just empty lines + if (is.empty(code.contents.filter((line) => !!line.trim()))) { + // set code start and end points to -1 because there really wasn't any code + code.start = -1 + code.end = -1 + code.contents = [] + } + + this.token.code = code + + // push the finished token to the tokens list this.tokens.push(this.token) + + // reset the token to be undefined because it's finished this.token = undefined } - update(update_index = true) { - const dl = this.debugLine - if (update_index) { - this.lineno++ + update(updated_from = 'wtf yo') { + const debug = this.debugUpdate + debug.push(`updated from: ${updated_from}`) + + if (!(++this.lineno < this.lines.length)) { + this.break = true + if (this.ifToken()) { + // lol I don't know why i put this here but it looks important + console.log(`${clor.red.bold.underline('FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK')}`) + } + return false } + this.line = this.lines[this.lineno] - dl.debug(`line ${this.lineno}:`) - dl.debug(`${clor.bgBlue(this.line)}`) + debug.push(`line ${this.lineno}: ${!this.line ? clor.bgRed('empty line') : clor.bgBlue(this.line)}`) // If you're trying to debug something between specific lines you // can use this to narrow down the longs to the lines you're wanting debug @@ -143,9 +177,9 @@ export class Tokenizer { // less that what you're looking for since this is zero based. // debug = is.between(i, [start line], [end line]) // this.should_debug = is.between(this.lineno, 0, 8) - // const escape = (str) => '\\' + str.split('').join('\\') - this.index = { start: false, line: false, end: false } + // this is a helper function that is used + // to test the existence of the comment const test_comment = (comment) => { if (is.falsy(comment)) { return false @@ -159,7 +193,8 @@ export class Tokenizer { return index } - // check to see if the comment is the only thing on the line + // check to see if the comment is the last thing on that line + // aka if (this.line.length === index + comment.length) { return index } @@ -168,47 +203,14 @@ export class Tokenizer { return false } - // const test_comment = (comment) => { - // if (!comment) { - // return false - // } - // const escape = (str) => '\\' + str.split('').join('\\') - // const regex = new RegExp(escape(comment) + '\s*') - // const result = this.line.match(regex) - // console.log('regex:', regex) - // console.log('result:', result) - // return result !== false && this.line.indexOf(this.line) - // } - // console.log('line:', `${clor.bold.magenta(this.lineno)}`, `${clor.bgBlue(this.line)}`) this.index = to.reduce([ 'start', 'line', 'end' ], (prev, next) => { prev[next] = test_comment(this.comment[next]) return prev }, {}) - this.index = { - start: test_comment(this.comment.start), - line: test_comment(this.comment.line), - end: test_comment(this.comment.end) - } - // console.log('{') - // to.map(this.index, ({ key, value }) => { - // console.log(` ${key}: ${clor[value !== false ? 'green' : 'red'](value)}`) - // return {} - // }) - // console.log('}') - - // this.index = { - // start: this.is_multi && is.in(this.line, this.comment.start) ? this.line.indexOf(this.comment.start) : false, - // line: is.in(this.line, this.comment.line) ? this.line.indexOf(this.comment.line) : false, - // end: this.is_multi && is.in(this.line, this.comment.end) ? this.line.indexOf(this.comment.end) : false - // } - - // console.log('') - // console.log('') - // console.log('') - // console.log('') - dl.debug('index:', this.index) - dl.debug('') + debug.push('index:', this.index) + debug.run() + return true } visit() { @@ -221,7 +223,7 @@ export class Tokenizer { this.walkComment() if (this.restrict) { this.debugLine.debug('is restricted') - return this.token + return this.tokens } } @@ -237,74 +239,89 @@ export class Tokenizer { this.walkCode() } } else if (this.shouldStop()) { - this.handleShouldStop() + this.token[this.token.comment.end > -1 ? 'code' : 'comment'].end = this.lineno + this.pushToken() } } isLastLine() { // checks to see if the current line is the last line in the file const length = this.is_multi && this.index.end !== false ? this.lines.length : this.lines.length - 1 - return this.debugLine.debugIfTrue(this.lineno === length, `${clor.red('is the last line')}`) + if (this.lineno === length) { + this.debugIsLastLine.run() + return true + } + return false } shouldStop() { - const dl = this.debugLine + const debug = this.debugShouldStop if ( - !is.undefined(this.token) && ( + this.ifToken() && ( // checks to see if there were 4 consecutive blank lines - dl.debugIfTrue(++this.blank_line_count === this.blank_lines, 'hit the max blank lines') || + debug.debugIfTrue(++this.blank_line_count === this.blank_lines, 'hit the max blank lines') || // checks to see if it was the last line in the file this.isLastLine() ) ) { - this.debugLine.debug('is stopping') + debug.push('is stopping') + debug.run() return true } return false } - handleShouldStop() { - this.token[this.token.comment.end > -1 ? 'code' : 'comment'].end = this.lineno - this.pushToken() - } isComment() { - const dl = this.debugLine + const debug = this.debugIsComment // checks for the start and end style or there was an instance of a comment line if ( this.is_multi && ( - dl.debugIfTrue(this.index.start !== false, 'is the start of a multi line comment') || - dl.debugIfTrue(this.in_comment, 'is in a multi line comment') + debug.debugIfTrue(this.index.start !== false, 'is the start of a multi line comment') || + debug.debugIfTrue(this.in_comment, 'is in a multi line comment') ) || - dl.debugIfTrue(this.index.line !== false, 'is single line comment') + debug.debugIfTrue(this.index.line !== false, 'is single line comment') ) { + debug.run() return true } return false } walkComment() { - const dl = this.debugLine + const debug = this.debugWalkComment + + // Handles situations where there's a start and end style comment that are identical + // such as { start: '////', line: '///', end: '////' }. If the comment styles + // are identical they can't be used like this `//// some comment //// some other comment` + // however `` is perfectly acceptable + if ( + this.is_multi && + this.comment.start === this.comment.end && + this.ifToken() && + this.token.comment.start !== -1 + ) { + this.comment.start = false + } - const isNewToken = this.index.start !== false || (!this.is_multi && !this.in_comment) // check for the start of a new token block + const isNewToken = this.index.start !== false || (!this.is_multi && !this.in_comment) if (isNewToken) { - dl.debug('is new token') + debug.push('is new token') this.in_code = false this.in_comment = true // There was a token that has already been processed - if (!is.undefined(this.token)) { // holds the current token information - dl.debug('this.token', this.token) + if (this.ifToken()) { this.token.code.end = this.lineno - 1 // sets the line number to be the previous line this.pushToken() // Stops the loop after the first comment token // has been parsed. This is for file header comments if (this.restrict) { - this.token.comment.end = this.lineno - this.token.code.end = -1 + this.tokens[0].comment.end = this.lineno + this.tokens[0].code.end = -1 return this.tokens } } @@ -317,9 +334,9 @@ export class Tokenizer { } // check for the end comment - const isEndComment = !is.undefined(this.token) && this.is_multi && this.token.comment.start !== this.lineno && this.index.end !== false - if (isEndComment) { - dl.debug('is end comment') + const isEndComment = this.is_multi && this.token.comment.start !== this.lineno && this.index.end !== false + if (this.ifToken() && isEndComment) { + debug.push('is end comment') this.in_comment = false this.token.comment.end = this.lineno // sets the end line in the comment token @@ -340,39 +357,37 @@ export class Tokenizer { this.line = this.line.slice(this.index.start + this.comment.start.length) } - if (!is.empty(this.line)) { - dl.debug('line was pushed') - this.token.comment.contents.push(this.line) - } + debug.push('line was pushed') + this.token.comment.contents.push(this.line) } // The last line in the file is a commment if (this.in_comment && this.isLastLine()) { - dl.debug('the last line in the file is a comment') + debug.push('the last line in the file is a comment') this.token.comment.end = this.is_multi ? this.lineno - 1 : this.lineno this.pushToken() - } - - // check the next line for an instance of the a line comment - if ( + this.break = true + } else if ( !this.is_multi && !is.in(this.lines[this.lineno + 1], this.comment.line) ) { - dl.debug('next line is not a comment') + debug.push('next line is not a comment') this.in_comment = false this.token.comment.end = this.lineno // sets the end line in the comment token - this.update() // updates to be the next line + this.update('checks the next line') // updates to be the next line } + + debug.run() } isCode() { if ( - !is.undefined(this.token) && + this.ifToken() && !this.in_comment && this.index.end === false ) { - this.debugLine.debug(`${clor.green('is code')}`) + this.debugIsCode.run() this.in_comment = false this.in_code = true return true From c9d383d239441bd0ab638a9672f5f161072c1b49 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 14 Mar 2016 09:48:21 -0400 Subject: [PATCH 246/273] Updated tokenizer with test cases --- app/new-parser/tokenizer.js | 1083 ++++++----------- app/utils/debug.js | 104 +- app/utils/logger.js | 4 +- app/utils/purdy.js | 6 +- tests/run.test.js | 25 + .../multiple-blocks-comments.json | 68 ++ .../multiple-blocks-comments.scss | 26 + .../multiple-blocks-with-trailing-line.json | 68 ++ .../multiple-blocks-with-trailing-line.scss | 26 + .../single-block-with-trailing-line.json | 22 + .../single-block-with-trailing-line.scss | 6 + .../single-block.json | 22 + .../single-block.scss | 6 + .../multiple-blocks-with-trailing-line.json | 56 + .../multiple-blocks-with-trailing-line.scss | 19 + .../single-block-with-trailing-line.json | 18 + .../single-block-with-trailing-line.scss | 3 + .../multi-single-line/single-block.json | 18 + .../multi-single-line/single-block.scss | 3 + ...single-line-comments-with-code-before.json | 50 + ...single-line-comments-with-code-before.scss | 5 + ...ngle-line-comments-with-trailing-line.json | 56 + ...ngle-line-comments-with-trailing-line.scss | 14 + .../multiple-single-line-comments.json | 56 + .../multiple-single-line-comments.scss | 14 + ...with-code-before-2-with-trailing-line.json | 18 + ...with-code-before-2-with-trailing-line.scss | 1 + .../single-line-with-code-before-2.json | 18 + .../single-line-with-code-before-2.scss | 1 + .../single-line-with-code-before.json | 18 + .../single-line-with-code-before.scss | 3 + .../single-line-with-trailing-line.json | 20 + .../single-line-with-trailing-line.scss | 4 + .../single-line-with-code/single-line.json | 20 + .../single-line-with-code/single-line.scss | 4 + ...ngle-line-comments-with-trailing-line.json | 44 + ...ngle-line-comments-with-trailing-line.scss | 5 + .../multiple-single-line-comments.json | 44 + .../multiple-single-line-comments.scss | 5 + .../single-line-with-trailing-line.json | 16 + .../single-line-with-trailing-line.scss | 1 + .../css-like/single-line/single-line.json | 16 + .../css-like/single-line/single-line.scss | 1 + ...fter-start-and-end-with-trailing-line.json | 23 + ...fter-start-and-end-with-trailing-line.scss | 7 + .../comments-after-start-and-end.json | 23 + .../comments-after-start-and-end.scss | 7 + ...multiple-blocks-with-no-space-between.json | 56 + ...multiple-blocks-with-no-space-between.scss | 18 + .../multiple-blocks-with-trailing-line.json | 59 + .../multiple-blocks-with-trailing-line.scss | 23 + .../start-end-with-code/multiple-blocks.json | 59 + .../start-end-with-code/multiple-blocks.scss | 23 + .../single-block-with-trailing-line.json | 23 + .../single-block-with-trailing-line.scss | 9 + .../start-end-with-code/single-block.json | 23 + .../start-end-with-code/single-block.scss | 9 + ...fter-start-and-end-with-trailing-line.json | 19 + ...fter-start-and-end-with-trailing-line.scss | 4 + .../comments-after-start-and-end.json | 19 + .../comments-after-start-and-end.scss | 4 + ...multiple-blocks-with-no-space-between.json | 44 + ...multiple-blocks-with-no-space-between.scss | 9 + .../multiple-blocks-with-trailing-line.json | 47 + .../multiple-blocks-with-trailing-line.scss | 14 + .../css-like/start-end/multiple-blocks.json | 47 + .../css-like/start-end/multiple-blocks.scss | 14 + .../single-block-with-trailing-line.json | 19 + .../single-block-with-trailing-line.scss | 6 + .../css-like/start-end/single-block.json | 19 + .../css-like/start-end/single-block.scss | 6 + ...single-line-comments-with-code-before.json | 50 + ...single-line-comments-with-code-before.scss | 5 + ...ngle-line-comments-with-trailing-line.json | 56 + ...ngle-line-comments-with-trailing-line.scss | 14 + .../multiple-single-line-comments.json | 56 + .../multiple-single-line-comments.scss | 14 + ...with-code-before-2-with-trailing-line.json | 18 + ...with-code-before-2-with-trailing-line.scss | 1 + .../single-line-with-code-before-2.json | 18 + .../single-line-with-code-before-2.scss | 1 + .../single-line-with-code-before.json | 18 + .../single-line-with-code-before.scss | 3 + .../single-line-with-trailing-line.json | 20 + .../single-line-with-trailing-line.scss | 4 + .../single-line-with-code/single-line.json | 20 + .../single-line-with-code/single-line.scss | 4 + ...ngle-line-comments-with-trailing-line.json | 44 + ...ngle-line-comments-with-trailing-line.scss | 5 + .../multiple-single-line-comments.json | 44 + .../multiple-single-line-comments.scss | 5 + .../single-line-with-trailing-line.json | 16 + .../single-line-with-trailing-line.scss | 1 + .../css/single-line/single-line.json | 16 + .../css/single-line/single-line.scss | 1 + ...fter-start-and-end-with-trailing-line.json | 23 + ...fter-start-and-end-with-trailing-line.scss | 7 + .../comments-after-start-and-end.json | 23 + .../comments-after-start-and-end.scss | 7 + ...multiple-blocks-with-no-space-between.json | 56 + ...multiple-blocks-with-no-space-between.scss | 18 + .../multiple-blocks-with-trailing-line.json | 59 + .../multiple-blocks-with-trailing-line.scss | 23 + .../start-end-with-code/multiple-blocks.json | 59 + .../start-end-with-code/multiple-blocks.scss | 23 + .../single-block-with-trailing-line.json | 23 + .../single-block-with-trailing-line.scss | 9 + .../css/start-end-with-code/single-block.json | 23 + .../css/start-end-with-code/single-block.scss | 9 + ...fter-start-and-end-with-trailing-line.json | 19 + ...fter-start-and-end-with-trailing-line.scss | 4 + .../comments-after-start-and-end.json | 19 + .../comments-after-start-and-end.scss | 4 + ...multiple-blocks-with-no-space-between.json | 44 + ...multiple-blocks-with-no-space-between.scss | 9 + .../multiple-blocks-with-trailing-line.json | 47 + .../multiple-blocks-with-trailing-line.scss | 14 + .../css/start-end/multiple-blocks.json | 47 + .../css/start-end/multiple-blocks.scss | 14 + .../single-block-with-trailing-line.json | 19 + .../single-block-with-trailing-line.scss | 6 + .../tokenizer/css/start-end/single-block.json | 19 + .../tokenizer/css/start-end/single-block.scss | 6 + .../multiple-blocks-comments.coffee | 32 + .../multiple-blocks-comments.json | 74 ++ .../multiple-blocks-with-trailing-line.coffee | 32 + .../multiple-blocks-with-trailing-line.json | 74 ++ .../single-block-with-trailing-line.coffee | 8 + .../single-block-with-trailing-line.json | 24 + .../single-block.coffee | 8 + .../single-block.json | 24 + .../multiple-blocks-with-trailing-line.coffee | 19 + .../multiple-blocks-with-trailing-line.json | 56 + .../single-block-with-trailing-line.coffee | 3 + .../single-block-with-trailing-line.json | 18 + .../multi-single-line/single-block.coffee | 3 + .../multi-single-line/single-block.json | 18 + ...ngle-line-comments-with-code-before.coffee | 5 + ...single-line-comments-with-code-before.json | 50 + ...le-line-comments-with-trailing-line.coffee | 20 + ...ngle-line-comments-with-trailing-line.json | 62 + .../multiple-single-line-comments.coffee | 20 + .../multiple-single-line-comments.json | 62 + ...th-code-before-2-with-trailing-line.coffee | 1 + ...with-code-before-2-with-trailing-line.json | 18 + .../single-line-with-code-before-2.coffee | 1 + .../single-line-with-code-before-2.json | 18 + .../single-line-with-code-before.coffee | 3 + .../single-line-with-code-before.json | 18 + .../single-line-with-trailing-line.coffee | 6 + .../single-line-with-trailing-line.json | 22 + .../single-line-with-code/single-line.coffee | 6 + .../single-line-with-code/single-line.json | 22 + ...le-line-comments-with-trailing-line.coffee | 5 + ...ngle-line-comments-with-trailing-line.json | 44 + .../multiple-single-line-comments.coffee | 5 + .../multiple-single-line-comments.json | 44 + .../single-line-with-trailing-line.coffee | 1 + .../single-line-with-trailing-line.json | 16 + .../hash-style/single-line/single-line.coffee | 1 + .../hash-style/single-line/single-line.json | 16 + ...er-start-and-end-with-trailing-line.coffee | 9 + ...fter-start-and-end-with-trailing-line.json | 25 + .../comments-after-start-and-end.coffee | 9 + .../comments-after-start-and-end.json | 25 + ...ltiple-blocks-with-no-space-between.coffee | 24 + ...multiple-blocks-with-no-space-between.json | 62 + .../multiple-blocks-with-trailing-line.coffee | 29 + .../multiple-blocks-with-trailing-line.json | 65 + .../multiple-blocks.coffee | 29 + .../start-end-with-code/multiple-blocks.json | 65 + .../single-block-with-trailing-line.coffee | 11 + .../single-block-with-trailing-line.json | 25 + .../start-end-with-code/single-block.coffee | 11 + .../start-end-with-code/single-block.json | 25 + ...er-start-and-end-with-trailing-line.coffee | 4 + ...fter-start-and-end-with-trailing-line.json | 19 + .../comments-after-start-and-end.coffee | 4 + .../comments-after-start-and-end.json | 19 + ...ltiple-blocks-with-no-space-between.coffee | 9 + ...multiple-blocks-with-no-space-between.json | 44 + .../multiple-blocks-with-trailing-line.coffee | 14 + .../multiple-blocks-with-trailing-line.json | 47 + .../start-end/multiple-blocks.coffee | 14 + .../hash-style/start-end/multiple-blocks.json | 47 + .../single-block-with-trailing-line.coffee | 6 + .../single-block-with-trailing-line.json | 19 + .../hash-style/start-end/single-block.coffee | 6 + .../hash-style/start-end/single-block.json | 19 + ...ne-with-code-before-with-space-before.html | 7 + ...ne-with-code-before-with-space-before.json | 50 + ...multiple-single-line-with-code-before.html | 5 + ...multiple-single-line-with-code-before.json | 50 + ...ltiple-single-line-with-trailing-line.html | 8 + ...ltiple-single-line-with-trailing-line.json | 50 + .../multiple-single-line.html | 8 + .../multiple-single-line.json | 50 + ...e-with-code-before-with-trailing-line.html | 3 + ...e-with-code-before-with-trailing-line.json | 20 + .../single-line-with-code-before.html | 3 + .../single-line-with-code-before.json | 20 + .../single-line-with-trailing-line.html | 4 + .../single-line-with-trailing-line.json | 20 + .../single-line-with-code/single-line.html | 4 + .../single-line-with-code/single-line.json | 20 + ...e-no-space-between-with-trailing-line.html | 3 + ...e-no-space-between-with-trailing-line.json | 44 + ...multiple-single-line-no-space-between.html | 3 + ...multiple-single-line-no-space-between.json | 44 + ...ltiple-single-line-with-trailing-line.html | 5 + ...ltiple-single-line-with-trailing-line.json | 44 + .../single-line/multiple-single-line.html | 5 + .../single-line/multiple-single-line.json | 44 + .../single-line-with-trailing-line.html | 1 + .../single-line-with-trailing-line.json | 16 + .../html/single-line/single-line.html | 1 + .../html/single-line/single-line.json | 16 + ...art-and-before-end-with-trailing-line.html | 10 + ...art-and-before-end-with-trailing-line.json | 26 + .../comments-after-start-and-before-end.html | 10 + .../comments-after-start-and-before-end.json | 26 + ...multiple-blocks-with-no-space-between.html | 27 + ...multiple-blocks-with-no-space-between.json | 65 + .../multiple-blocks-with-trailing-line.html | 32 + .../multiple-blocks-with-trailing-line.json | 68 ++ .../start-end-with-code/multiple-blocks.html | 32 + .../start-end-with-code/multiple-blocks.json | 68 ++ .../single-block-with-trailing-line.html | 12 + .../single-block-with-trailing-line.json | 26 + .../start-end-with-code/single-block.html | 12 + .../start-end-with-code/single-block.json | 26 + ...art-and-before-end-with-trailing-line.html | 4 + ...art-and-before-end-with-trailing-line.json | 19 + .../comments-after-start-and-before-end.html | 4 + .../comments-after-start-and-before-end.json | 19 + ...multiple-blocks-with-no-space-between.html | 9 + ...multiple-blocks-with-no-space-between.json | 44 + .../multiple-blocks-with-trailing-line.html | 14 + .../multiple-blocks-with-trailing-line.json | 47 + .../html/start-end/multiple-blocks.html | 14 + .../html/start-end/multiple-blocks.json | 47 + .../single-block-with-trailing-line.html | 6 + .../single-block-with-trailing-line.json | 19 + .../html/start-end/single-block.html | 6 + .../html/start-end/single-block.json | 19 + tools/generate-test.js | 52 +- tools/tokenizer-helper.js | 90 ++ 247 files changed, 5930 insertions(+), 732 deletions(-) create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/single-block.json create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss create mode 100644 tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/multi-single-line/single-block.json create mode 100644 tests/tokenizer/css-like/multi-single-line/single-block.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line.json create mode 100644 tests/tokenizer/css-like/single-line-with-code/single-line.scss create mode 100644 tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/single-line/multiple-single-line-comments.json create mode 100644 tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss create mode 100644 tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/single-line/single-line.json create mode 100644 tests/tokenizer/css-like/single-line/single-line.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/start-end-with-code/single-block.json create mode 100644 tests/tokenizer/css-like/start-end-with-code/single-block.scss create mode 100644 tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/start-end/comments-after-start-and-end.json create mode 100644 tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss create mode 100644 tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss create mode 100644 tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/start-end/multiple-blocks.json create mode 100644 tests/tokenizer/css-like/start-end/multiple-blocks.scss create mode 100644 tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss create mode 100644 tests/tokenizer/css-like/start-end/single-block.json create mode 100644 tests/tokenizer/css-like/start-end/single-block.scss create mode 100644 tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json create mode 100644 tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss create mode 100644 tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json create mode 100644 tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss create mode 100644 tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json create mode 100644 tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss create mode 100644 tests/tokenizer/css/single-line-with-code/single-line.json create mode 100644 tests/tokenizer/css/single-line-with-code/single-line.scss create mode 100644 tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json create mode 100644 tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss create mode 100644 tests/tokenizer/css/single-line/multiple-single-line-comments.json create mode 100644 tests/tokenizer/css/single-line/multiple-single-line-comments.scss create mode 100644 tests/tokenizer/css/single-line/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/css/single-line/single-line-with-trailing-line.scss create mode 100644 tests/tokenizer/css/single-line/single-line.json create mode 100644 tests/tokenizer/css/single-line/single-line.scss create mode 100644 tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json create mode 100644 tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss create mode 100644 tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json create mode 100644 tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss create mode 100644 tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss create mode 100644 tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss create mode 100644 tests/tokenizer/css/start-end-with-code/multiple-blocks.json create mode 100644 tests/tokenizer/css/start-end-with-code/multiple-blocks.scss create mode 100644 tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss create mode 100644 tests/tokenizer/css/start-end-with-code/single-block.json create mode 100644 tests/tokenizer/css/start-end-with-code/single-block.scss create mode 100644 tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json create mode 100644 tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss create mode 100644 tests/tokenizer/css/start-end/comments-after-start-and-end.json create mode 100644 tests/tokenizer/css/start-end/comments-after-start-and-end.scss create mode 100644 tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss create mode 100644 tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss create mode 100644 tests/tokenizer/css/start-end/multiple-blocks.json create mode 100644 tests/tokenizer/css/start-end/multiple-blocks.scss create mode 100644 tests/tokenizer/css/start-end/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/css/start-end/single-block-with-trailing-line.scss create mode 100644 tests/tokenizer/css/start-end/single-block.json create mode 100644 tests/tokenizer/css/start-end/single-block.scss create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json create mode 100644 tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/multi-single-line/single-block.coffee create mode 100644 tests/tokenizer/hash-style/multi-single-line/single-block.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line-with-code/single-line.json create mode 100644 tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee create mode 100644 tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json create mode 100644 tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/single-line/single-line.coffee create mode 100644 tests/tokenizer/hash-style/single-line/single-line.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/start-end-with-code/single-block.coffee create mode 100644 tests/tokenizer/hash-style/start-end-with-code/single-block.json create mode 100644 tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee create mode 100644 tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json create mode 100644 tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee create mode 100644 tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/start-end/multiple-blocks.coffee create mode 100644 tests/tokenizer/hash-style/start-end/multiple-blocks.json create mode 100644 tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee create mode 100644 tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/hash-style/start-end/single-block.coffee create mode 100644 tests/tokenizer/hash-style/start-end/single-block.json create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line.html create mode 100644 tests/tokenizer/html/single-line-with-code/multiple-single-line.json create mode 100644 tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html create mode 100644 tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json create mode 100644 tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html create mode 100644 tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json create mode 100644 tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html create mode 100644 tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/html/single-line-with-code/single-line.html create mode 100644 tests/tokenizer/html/single-line-with-code/single-line.json create mode 100644 tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html create mode 100644 tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json create mode 100644 tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html create mode 100644 tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json create mode 100644 tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html create mode 100644 tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json create mode 100644 tests/tokenizer/html/single-line/multiple-single-line.html create mode 100644 tests/tokenizer/html/single-line/multiple-single-line.json create mode 100644 tests/tokenizer/html/single-line/single-line-with-trailing-line.html create mode 100644 tests/tokenizer/html/single-line/single-line-with-trailing-line.json create mode 100644 tests/tokenizer/html/single-line/single-line.html create mode 100644 tests/tokenizer/html/single-line/single-line.json create mode 100644 tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html create mode 100644 tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json create mode 100644 tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html create mode 100644 tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json create mode 100644 tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html create mode 100644 tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html create mode 100644 tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/html/start-end-with-code/multiple-blocks.html create mode 100644 tests/tokenizer/html/start-end-with-code/multiple-blocks.json create mode 100644 tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html create mode 100644 tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/html/start-end-with-code/single-block.html create mode 100644 tests/tokenizer/html/start-end-with-code/single-block.json create mode 100644 tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html create mode 100644 tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json create mode 100644 tests/tokenizer/html/start-end/comments-after-start-and-before-end.html create mode 100644 tests/tokenizer/html/start-end/comments-after-start-and-before-end.json create mode 100644 tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html create mode 100644 tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json create mode 100644 tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html create mode 100644 tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json create mode 100644 tests/tokenizer/html/start-end/multiple-blocks.html create mode 100644 tests/tokenizer/html/start-end/multiple-blocks.json create mode 100644 tests/tokenizer/html/start-end/single-block-with-trailing-line.html create mode 100644 tests/tokenizer/html/start-end/single-block-with-trailing-line.json create mode 100644 tests/tokenizer/html/start-end/single-block.html create mode 100644 tests/tokenizer/html/start-end/single-block.json create mode 100644 tools/tokenizer-helper.js diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index 7bd940d..e6c216e 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -3,807 +3,526 @@ import { is, to, debug as _debug } from '../utils' import { default_options } from '../config' import clor from 'clor' - -/// @name tokenizer -/// @access private -/// @description Parses the file and returns the comment blocks in an array -/// @returns {array} of the comment blocks -/// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. -export default function tokenizer(settings) { - // filters out the settings that aren't needed to prevent cluter - settings = to.filter(settings, ({ key }) => is.in([ 'file', 'blank_lines', 'sort', 'log', 'language' ], key)) - - let { - file, - language, - sort, // @todo figure out if this is needed - ...options - } = settings - - // let header = new Tokenizer({ comment: settings.file.settings.header, ...settings, restrict: true }) - let body = new Tokenizer( // eslint-disable-line - settings.file.contents, - { - comment: settings.file.settings.body, - should_debug: true, - ...options, - } - // settings.file.settings.body, - // { ...settings, should_debug: true } - ) - // console.log('new parser:', to.json(header)) - // console.log('new parser:', to.json(body)) - return '' -} - +/* eslint-enable */ @_debug('Tokenizer') -export class Tokenizer { - constructor(content, options = {}) { - if (arguments.length === 1 && is.plainObject(content)) { - options = arguments[0] - content = options.str || options.content || options.source - } - - // forces the string to become 1 based instead of 0 and it normalizes it #windows sucks - content = '\n' + to.normalString(content) - - options = to.extend({ +export default class Tokenizer { + constructor(str, options = {}) { // eslint-disable-line + options = to.arguments({ + content: '', comment: { start: '', line: '///', end: '' }, // the default comment style to look for blank_lines: default_options.blank_lines, + verbose: false, // determins if all the extra line info will be returned or if it will just return strings strip: false, // determins if the comment should be stripped from the line - retrict: false, - }, options) - - to.extend(this, options) - - this.lines = to.array(content) - this.lineno = to.number(this.start_at || this.lineno, this.i || this.index || 0) - this.is_multi = is.all.truthy(this.comment.start, this.comment.end) - - // this ensures there aren't any errors looking comment lines - // because `''` will always have an index of `0` - if (this.comment.line === '') { - this.comment.line = undefined - } - - // The base of what each token looks like - this.token_base = { - comment: { contents: [], start: -1, end: -1 }, - code: { contents: [], start: -1, end: -1 } - } - // add the comment type if it was passed - if (this.comment.type) { - this.token_base.comment.type = this.comment.type - } - - this.tokens = [] // placeholder for all the parsed tokens - this.blank_line_count = 0 // stores the current count of blank lines - this.token = undefined // stores the current token - this.in_comment = false // used to determin that you are in a comment - this.in_code = false // used to determin if you are in the code after the comment block - - // checks to see if the file has any comments - if ( - this.is_multi && - !is.any.in(content, this.comment.start, this.comment.end) || // checks if the multi line comment style exists - !is.in(content, this.comment.line) // checks if the single line comment style exists - ) { - return [] - } - - // debuggers - this.debugLine = this.debugSet('line', { spaces: 2 }) - this.debugUpdate = this.debugLine.debugSet('update', 0) - this.debugWalkComment = this.debugLine.debugSet('walkComment', 0) - this.debugIsCode = this.debugLine.set('isCode', { spaces: 0, color: 'green' }) - this.debugIsComment = this.debugLine.set('isComment', 0) - this.debugIsLastLine = this.debugLine.set('isLasLine', { spaces: 0, color: 'bgRed' }) - this.debugShouldStop = this.debugLine.set('shouldStop', 0) - this.debugPushToken = this.debugLine.debugSet('pushToken', 0) - - this.tokenize() - return this.tokens - } - - tokenize() { - this.lineno-- - while (this.update('updated from the loop')) { - // if `this.break` is set at any point it will stop loop - // and return the tokens that exist - if (this.break) { - break - this.pushToken() - return this.tokens - } - this.visit() - this.debugLine.run() - } - } - - ifToken() { - return !this.break && !is.undefined(this.token) - } + restrict: false, + indent: true, + }, arguments) - pushToken(pushed_from = 'unknown unknown') { - const debug = this.debugPushToken - debug.push(`pushed from: ${pushed_from}`) - debug.run() - - // set the end point of the code or the comment - this.token[this.token.comment.end > -1 && this.token.code.start > -1 ? 'code' : 'comment'].end = this.lineno - - // normalize the comment contents by striping out empty lines from the start and end of comment block - this.token.comment.contents = to.normalize(this.token.comment.contents).split('\n') - - let code = this.token.code - // normalize the code contents - code.contents = to.normalize(code.contents).split('\n') - // check to see if the code contents is just empty lines - if (is.empty(code.contents.filter((line) => !!line.trim()))) { - // set code start and end points to -1 because there really wasn't any code - code.start = -1 - code.end = -1 - code.contents = [] + // Update the content + { + const { str: _str, string, source, code, content } = options + options.content = _str || string || source || code || content } - this.token.code = code - - // push the finished token to the tokens list - this.tokens.push(this.token) - - // reset the token to be undefined because it's finished - this.token = undefined - } - - update(updated_from = 'wtf yo') { - const debug = this.debugUpdate - debug.push(`updated from: ${updated_from}`) - if (!(++this.lineno < this.lines.length)) { - this.break = true - if (this.ifToken()) { - // lol I don't know why i put this here but it looks important - console.log(`${clor.red.bold.underline('FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK!!!FUCK')}`) - } - return false - } + // ensures that the comment style that was passed will work + { + let { start, line, single, end } = options.comment - this.line = this.lines[this.lineno] - debug.push(`line ${this.lineno}: ${!this.line ? clor.bgRed('empty line') : clor.bgBlue(this.line)}`) - - // If you're trying to debug something between specific lines you - // can use this to narrow down the longs to the lines you're wanting debug - // just pass in the starting line number and end line number both should be 1 - // less that what you're looking for since this is zero based. - // debug = is.between(i, [start line], [end line]) - // this.should_debug = is.between(this.lineno, 0, 8) - - // this is a helper function that is used - // to test the existence of the comment - const test_comment = (comment) => { - if (is.falsy(comment)) { - return false + single = single || line + // this ensures there aren't any errors while looking comment lines + // because `''` will always have an index of `0` + if (single === '') { + single = undefined } - // store the index of the comment - let index = this.line.indexOf(comment) - // check to see if the comment exisits - if (index > -1) { - // check to see if the required space after the comment exisits - if (is.in(this.line, `${comment} `)) { - return index - } - - // check to see if the comment is the last thing on that line - // aka - if (this.line.length === index + comment.length) { - return index - } - } - - return false - } - - this.index = to.reduce([ 'start', 'line', 'end' ], (prev, next) => { - prev[next] = test_comment(this.comment[next]) - return prev - }, {}) - - debug.push('index:', this.index) - debug.run() - return true - } - visit() { - if (!is.empty(this.line)) { - // reset the current blank line count back to 0 because this line wasn't empty - this.blank_line_count = 0 - - // // there's instance of comment - if (this.isComment()) { - this.walkComment() - if (this.restrict) { - this.debugLine.debug('is restricted') - return this.tokens - } + if (is.any.in([ single, '' ], start, end)) { + start = end = undefined } - if (this.isCode()) { - // this.debug('is code') - // // Stops the loop after the first comment block - // // has been parsed. This is for file header comments - // if (this.restrict) { - // this.pushToken() - // break - // } - // - this.walkCode() + if (!single && is.any.undefined(start, end)) { + throw new Error("You must set the start and end comment style if you don't specify a single comment") + } else if (!start && !end && !single) { + throw new Error('You must set the single comment or the start and end comment') + } else if (is.all.existy(single, start, end) && (start.length <= single.length || start.end <= single.length)) { + throw new Error('The start and end comments must be longer than the single comment') } - } else if (this.shouldStop()) { - this.token[this.token.comment.end > -1 ? 'code' : 'comment'].end = this.lineno - this.pushToken() - } - } - isLastLine() { - // checks to see if the current line is the last line in the file - const length = this.is_multi && this.index.end !== false ? this.lines.length : this.lines.length - 1 - if (this.lineno === length) { - this.debugIsLastLine.run() - return true - } - return false - } - - shouldStop() { - const debug = this.debugShouldStop - if ( - this.ifToken() && ( - // checks to see if there were 4 consecutive blank lines - debug.debugIfTrue(++this.blank_line_count === this.blank_lines, 'hit the max blank lines') || - // checks to see if it was the last line in the file - this.isLastLine() - ) - ) { - debug.push('is stopping') - debug.run() - return true - } - - return false - } - - - isComment() { - const debug = this.debugIsComment - // checks for the start and end style or there was an instance of a comment line - if ( - this.is_multi && ( - debug.debugIfTrue(this.index.start !== false, 'is the start of a multi line comment') || - debug.debugIfTrue(this.in_comment, 'is in a multi line comment') - ) || - debug.debugIfTrue(this.index.line !== false, 'is single line comment') - ) { - debug.run() - return true - } - return false - } - - walkComment() { - const debug = this.debugWalkComment - - // Handles situations where there's a start and end style comment that are identical - // such as { start: '////', line: '///', end: '////' }. If the comment styles - // are identical they can't be used like this `//// some comment //// some other comment` - // however `` is perfectly acceptable - if ( - this.is_multi && - this.comment.start === this.comment.end && - this.ifToken() && - this.token.comment.start !== -1 - ) { - this.comment.start = false + options.comment = { start, single, end } } - // check for the start of a new token block - const isNewToken = this.index.start !== false || (!this.is_multi && !this.in_comment) - if (isNewToken) { - debug.push('is new token') - this.in_code = false - this.in_comment = true - - // There was a token that has already been processed - if (this.ifToken()) { - this.token.code.end = this.lineno - 1 // sets the line number to be the previous line - this.pushToken() - - // Stops the loop after the first comment token - // has been parsed. This is for file header comments - if (this.restrict) { - this.tokens[0].comment.end = this.lineno - this.tokens[0].code.end = -1 - return this.tokens - } - } + const { content, ...rest } = options - // reset the `token` to use on the new token - this.token = to.clone(this.token_base) - this.token.comment.start = this.lineno + this.options = rest - this.in_comment = true - } + // holds the parsed tokens + this.tokens = [] - // check for the end comment - const isEndComment = this.is_multi && this.token.comment.start !== this.lineno && this.index.end !== false - if (this.ifToken() && isEndComment) { - debug.push('is end comment') - this.in_comment = false - this.token.comment.end = this.lineno // sets the end line in the comment token - - // @todo try to use `this.update()` instead of the following lines - this.lineno++ // skips end comment line - this.line = this.lines[this.lineno] // updates to be the next line - this.index.end = (this.line && is.in(this.line, this.comment.end)) ? this.line.indexOf(this.comment.end) : false - } - - // adds this line to token comment contents - const shouldPushLine = this.in_comment && (this.index.start === false || this.index.end === false) - if (shouldPushLine) { - if (this.index.line !== false) { - // removes the `comment.line` from the line. - this.line = this.line.slice(this.index.line + this.comment.line.length) - } else if (this.index.start !== false) { - // removes the `comment.start` from the line. - this.line = this.line.slice(this.index.start + this.comment.start.length) - } + this.is_multi = is.all.truthy(options.comment.start, options.comment.end) + this.is_same_multi = this.is_multi && options.comment.start === options.comment.end - debug.push('line was pushed') - this.token.comment.contents.push(this.line) - } + const debug = this.debugSet('options') + debug.push('this.options', this.options, '') - // The last line in the file is a commment - if (this.in_comment && this.isLastLine()) { - debug.push('the last line in the file is a comment') - this.token.comment.end = this.is_multi ? this.lineno - 1 : this.lineno - this.pushToken() - this.break = true - } else if ( - !this.is_multi && - !is.in(this.lines[this.lineno + 1], this.comment.line) - ) { - debug.push('next line is not a comment') - this.in_comment = false - this.token.comment.end = this.lineno // sets the end line in the comment token - this.update('checks the next line') // updates to be the next line + if (!!content) { + debug.push('has content in the options').run() + return this.parse(content) } - debug.run() + return + } + + /// @name hasNext + /// @description + /// Used to check if the next line exists + /// @returns {boolean} + hasNext() { + return this.debugHasNext.ifFalse(this.peak(), "doesn't have another element", true) + } + + /// @name next + /// @description + /// Used to progress forward to the next line + /// @returns {boolean} - If true it means the next line exists, else the next line doesn't exisit + next() { + const obj = this.iterator.next().value + if (!obj) return false + this.line = obj[1] + this.lineno = obj[0] + return true } - isCode() { - if ( - this.ifToken() && - !this.in_comment && - this.index.end === false - ) { - this.debugIsCode.run() - this.in_comment = false - this.in_code = true - return true - } - return false + /// @name peak + /// @description + /// This function is used to peak ahead or behind the current line + /// @arg {number} amount [1] - The amount to look ahead or before + /// @returns {object} - The line + peak(amount = 1) { + return this.stash[this.lineno + amount] } - walkCode() { - // The previous line was a comment - if (this.token.code.start === -1) { - this.token.code.start = this.lineno - } - - // adds this line to token code contents - this.token.code.contents.push(this.line) - - // pushes the last token onto the body - if (this.isLastLine()) { - this.token.code.end = this.lineno - this.pushToken() - } - } -} -/* eslint-disable */ + /// @name stash + /// @description + /// This updates the stash that's used for this parser + /// @arg {string} str [''] - The string to use for the stash + /// @returns {array} - The array of lines with the correct info + getStash(content = '') { + // add a starting line to the content to convert it to be 1 based instead of 0 based + // fixes stupid ass issues with windows + content = '\n' + to.normalString(content) + // if the content is empty return an empty string + if (this.isEmpty(content)) return [] + + // add a space to each line so the line index is 1 based instead of 0 based. If the line is empty, + // a space will not be added so that it's still easy to check if a line is empty or not. Doing this makes it + // much easier to determine if any of the indexes are actually falsy or not, and it makes tracking errors easier + let stash = to.map(to.array(content), (line, i) => { + line = new Line(!line ? line : ` ${line}`, i) + const str = `${line}` + line.index = to.reduce([ 'start', 'single', 'end' ], (prev, next) => { + prev[next] = this.commentExists(str, this.options.comment[next]) + return prev + }, {}) + + // This ensures that `line` can't be true if there's already a `start` or `end` style comment + if (this.is_multi && (line.index.start || line.index.end)) { + line.index.single = false + } + { + const { start, single, end } = this.options.comment + let code_exsists + // remove the comment and check to see if it has a line has code on it. + if (!this.is_multi && line.index.single) { + code_exsists = !this.isEmpty(this.getBefore(single, str)) + } else if (this.is_same_multi || line.index.start) { + code_exsists = !this.isEmpty(this.getBefore(start || end, str)) + } else { + code_exsists = !this.isEmpty(this.getAfter(end, str)) + } -// class Line { -// constructor(line, info = {}) { -// this.str = line -// to.extend(this, info) -// } -// get line() { -// return this.str -// } -// } -// -// Object.defineProperty(Line.prototype, 'toString', { -// value() { return this.line } -// }) + line.index.code = code_exsists && line.indent + } + line.has_comment = is.any.truthy(line.index.start, line.index.single, line.index.end) + line.has_code = is.truthy(line.index.code) -class Line { - constructor(line, { - lineno = 'NA', - column = 'NA', - type = undefined, // expect one of `'start'`, `'line'`, `'end'`, `'code'` - index = undefined - } = {}) { - this.line = line - - to.extend(this, { - lineno, - column, - type, - index + return line }) - return this.line + return stash } -} - -Object.defineProperty(Line.prototype, 'toString', { - value() { return this.line } -}) - - - - - - - - - + /// @name parse + /// @description + /// This will parse the passed content + /// @arg {string} content [''] - The content to parse + /// @arg {number} start_at [0] - The starting line to start parsing at + /// @arg {boolean} verbose [this.verbose] - The default is what was passed when creating the Tokenizer + /// @returns {array} - Of parsed tokens + /// @note {5} This function also accepts a object to be passed with named arguments + /// @markup Usage + parse(content = '', start_at = 0, verbose) { // eslint-disable-line + let options = to.arguments({ + content: '', + start_at: this.options.start_at || 0, + verbose: this.options.verbose, + }, arguments) + // update the verbose option incase it changed + this.verbose = options.verbose + // update the stash to use the passed content + this.stash = options.content = this.getStash(options.content) + // holds the current position in the stash to start from + this.lineno = options.i || options.index || options.lineno || options.start_at || 0 + // update the iterator to use + this.iterator = to.entries(this.stash, this.lineno) + // holds the parsed tokens + this.tokens = [] + this.setDebug() + const debug = this.debugParse + const result = this.getTokens() + debug.push('parsed:', result) + debug.run() + return result + } -/* eslint-enable */ -@debug('Tokenizer') -class _Tokenizer { // eslint-disable-line - constructor(settings) { - to.extend(this, settings) + /// @name isEmpty + /// @description checks to see if the passed string is empty(only contains spaces) + /// @returns {boolean} + isEmpty(str) { + return !str.replace(/\s+/gm, '') + } - this.i = to.number(this.start_at || this.i || this.index || 0) + /// @name getTokens + /// @description + /// This function will recursively get all the tokens in the file + getTokens() { + this.token = undefined + this.setDebug(true) + const debug = this.debugGetTokens + if (!this.hasNext()) { + return this.tokens + } - this.is_multi = is.all.truthy(this.comment.start, this.comment.end) + this.next() - // this ensures there aren't any errors looking comment lines - // because `''` will always have an index of `0` - if (this.comment.line === '') { - this.comment.line = undefined + if ( + debug.ifTrue(is.empty(`${this.line}`.trim()), "the line was empty, and isn't in a token already") || + debug.ifTrue(!this.line.has_comment, "The line doesn't have a comment, and isn't in a token already") + ) { + debug.push('', '', '', '').run() + return this.getTokens() } - this.token_base = { - comment: { contents: [], start: -1, end: -1, type: this.comment.type }, - code: { contents: [], start: -1, end: -1 }, - file: this.file - } + debug.push(`line [${this.lineno}]: ${clor.bgBlue(this.line)}`, this.line).run() - this.lines = to.array(this.file.contents) // lines of the file - this.tokens = [] // placeholder for all the parsed tokens - this.blank_line_count = 0 // stores the current count of blank lines - this.token = undefined // stores the current block - this.in_comment = false // used to determin that you are in a comment - this.in_code = false // used to determin if you are in the code after the comment block + if (this.line.has_comment) { + this.token = new Token() + debug.push('has comment').run() - this.debug_file = !is.undefined(this.debug_file) ? this.debug_file : false - this.debug_list = [] + if (this.is_same_multi && this.line.index.start === this.line.index.end) { + this.line.index.end = false + } - if (!(this.is_multi ? is.any.in(this.file.contents, this.comment.start, this.comment.end) : is.in(this.file.contents, this.comment.line))) { - return [] + if (!this.is_multi) { + this.getSingleComment() + } else { + this.getMultiComment() + } } - return this.tokenize() - } + if (this.line.has_code) { + this.getCode() + } - update() { - this.line = this.lines[this.i] - - // If you're trying to debug something between specific lines you - // can use this to narrow down the longs to the lines you're wanting debug - // just pass in the starting line number and end line number both should be 1 - // less that what you're looking for since this is zero based. - // debug = is.between(i, [start line], [end line]) - // this.debug_file = is.between(this.i, 0, 8) - this.index = { - start: this.is_multi && is.in(this.line, this.comment.start) ? this.line.indexOf(this.comment.start) : false, - line: is.in(this.line, this.comment.line) ? this.line.indexOf(this.comment.line) : false, - end: this.is_multi && is.in(this.line, this.comment.end) ? this.line.indexOf(this.comment.end) : false + if (is.truthy(this.token)) { + this.pushToken() } - } - tokenize() { - for (; this.i < this.lines.length; this.i++) { - this.update() - this.debug(`line ${this.i}:`) - this.debug(this.line) - this.debug('index:', this.index) - - if (!is.empty(this.line)) { - // reset the current blank line count back to 0 because this line wasn't empty - this.blank_line_count = 0 - - // there's instance of comment - if (this.isComment()) { - this.debug('is a comment') - this.walkComment() - - if (this.restrict) { - this.debug('is restricted') - return this.token - } - } + debug.push('', '', '', '').run() + + return this.getTokens() + } + + /// @name this.getBefore + /// @description + /// This function is used to get the content before a comment + /// @arg {string} comment - the comment to start after + /// @arg {string} str - the content to extract the content from + /// @returns {string} + getBefore(comment, str) { + if (!comment || !str) return str + return str.split(comment).shift() + } + + /// @name this.getAfter + /// @description + /// This function is used to get the content after a comment + /// @arg {string} comment - the comment to start after + /// @arg {string} str - the content to extract the content from + /// @returns {string} + getAfter(comment, str) { + if (!comment || !str) return str + return str.split(comment).pop() + } + + /// @name getCode + /// @description + /// Recursively pushes the code from each line onto the current token + getCode() { + const debug = this.debugGetCode + const { indent } = this.line + + const recursiveCode = () => { + let line = to.clone(this.line) + if ( + !this.is_same_multi && + !line.index.start && + line.index.end + ) { + line.line = `${line}`.slice(line.index.end + this.options.comment.end.length + 1) + } else { + line.line = `${line}`.slice(1, line.index.start || line.index.single || line.index.end || undefined) + } - if (this.isCode()) { - this.debug('is code') - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if (this.restrict) { - this.pushToken() - break - } - this.walkCode() - } - } else if (this.isStopWorthy()) { - this.handleStopWorthy() + // check to see if the current lines indent is less than the starting indent of the code + if (this.options.indent && !is.empty(line.toString()) && line.indent < indent) { + return } + // push the line onto the code contents + this.token.code.contents.push(line) - - this.runDebug() + if ( + this.hasNext() && + debug.ifTrue(!this.is_same_multi || !line.has_comment, `the current line(${line.lineno}) doesn't have a comment: ${clor.bgGreen(line)}`) + ) { + const next_line = this.peak() + const next_msg = `the next line(${next_line.lineno}) has a comment: ${clor.bgRed(next_line)}` + return debug.ifFalse(!next_line.has_comment, next_msg) && this.next() && recursiveCode() + } } - return this.tokens - } - - - isCode() { - if (this.hasExistingToken() && !this.in_comment && this.index.end === false) { - this.in_comment = false - this.in_code = true - return true - } - return false + recursiveCode() + debug.run() } + /// @name getSingleComment + /// @description + /// Recursively pushes the single comment lines from each line onto the + /// current token until the next instance of code + getSingleComment() { + const debug = this.debugGetSingleComment + const { comment } = this.options + let line = to.clone(this.line) + line.line = this.getAfter(comment.single, `${line}`) - isComment() { - // checks for the start and end style or there was an instance of a comment line - return this.is_multi && (this.index.start !== false || this.in_comment) || this.index.line !== false - } + this.token.comment.contents.push(line) + const current_msg = `the current line(${line.lineno}) doesn't have code: ${clor.bgGreen(line)}` + if (debug.ifTrue(!line.has_code, current_msg) && this.hasNext()) { + const next_line = this.peak() + const context = next_line.has_code ? 'has code' : 'is empty' + const next_msg = `the next line(${next_line.lineno}) ${context}: ${clor.bgRed(next_line)}` - isLastLine() { - // checks to see if the current line is the last line in the file - if (this.i === this.lines.length - 1 && is.truthy(this.token) && this.hasExistingToken()) { - this.debug('is the last line') - return true + this.next() + return debug.ifFalse(next_line.has_comment && !next_line.has_code, next_msg, true) && this.getSingleComment() } - return false - } - - hasExistingToken() { - return !is.undefined(this.token) - } - - - isStopWorthy() { - return this.hasExistingToken() && ( - // checks to see if there were 4 consecutive blank lines - ++this.blank_line_count === this.blank_lines || - this.isLastLine() - ) - } - - handleStopWorthy() { - this.token[this.token.comment.end > -1 ? 'code' : 'comment'].end = this.i - this.pushToken() - this.token = undefined + debug.run() } + /// @name getMultiComment + /// @description + /// Recursively pushes the multi line comment lines onto the + /// current token until the next instance of code + getMultiComment() { + const debug = this.debugGetMultiComment + const { comment } = this.options - walkComment() { - // check for the start of a new token block - if (this.isNewToken()) { - this.handleNewToken() - } + let line = to.clone(this.line) + let str = `${line}` - // check for the end comment - if (this.isEndComment()) { - this.handleEndComment() + if (line.index.start || line.index.single) { + str = this.getAfter(line.index.start ? comment.start : comment.single, str) } - // adds this line to token comment contents - if (this.isWorthy()) { - this.handleWorthy() - } + if (line.index.end) { + str = this[this.is_same_multi ? 'getAfter' : 'getBefore'](comment.end, str) - // The last line in the file is a commment - if (this.isLastLineComment()) { - this.handleLastLineComment() + // update the start index if the indexes are the same + if (this.is_same_multi && line.index.start === line.index.end) { + line.index.start = false + } } - // check the next line for an instance of the a line comment - if (this.isNextLineComment()) { - this.handleNextLineComment() + line.line = str + this.token.comment.contents.push(line) + debug.push(line) + if (this.hasNext()) { + if (debug.ifTrue(!line.index.end, `the current line(${line.lineno}) wasn't the last comment: ${clor.bgGreen(this.line)}`)) { + debug.run() + return this.next() && this.getMultiComment() + } + const next = this.peak() + if ( + debug.ifTrue(!line.index.code, `the current line(${line.lineno}) doesn't has code: ${clor.bgGreen(line)}`) && + debug.ifTrue(!next.has_comment, `the next line(${next.lineno}) doesn't have a comment: ${clor.bgGreen(next)}`) + ) { + debug.run() + return this.next() + } } - } - - isWorthy() { - return this.hasExistingToken() && this.in_comment && (this.index.start === false || this.index.end === false) + debug.run() + return } - handleWorthy() { - this.debug('is worthy') - if (this.index.line !== false) { - // removes the `comment.line` from the line. - this.line = this.line.slice(this.index.line + this.comment.line.length) - } else if (this.index.start !== false) { - // removes the `comment.start` from the line. - this.line = this.line.slice(this.index.start + this.comment.start.length) - } + /// @name pushToken + /// @description + /// This function is used to push the current token onto the parsed token list(`this.tokens`). + /// It will normalize all the content that's passed to the comment and code in the token, then + /// determin the starting and ending point for the comment and code. + pushToken() { + const debug = this.debugPushToken + let token = to.clone(this.token) + + const normalizeContent = (obj, set_start_end_before = false) => { + // normalize the contents of the obj + let { content, leading, trailing } = to.normalize(obj.contents.join('\n'), { info: true }) + let lines = to.array(content) + trailing += obj.contents.length + const points = () => { + obj.start = (obj.contents[0] || {}).lineno || -1 // get the starting line of the comment + obj.end = (obj.contents.slice(-1)[0] || {}).lineno || -1 // get the end line of the comment + } - if (!is.empty(this.line)) { - this.debug('line was pushed') - this.token.comment.contents.push(this.line) - } - } + if (set_start_end_before) points() + obj.contents = obj.contents + .filter((line, i) => i >= leading && i < trailing) // filter out the lines that were removed + .map((line, i) => { + line.line = lines[i] // update the lines content to be the normalized version + return line + }) - isNewToken() { - if ( - this.index.start !== false || ( - !this.is_multi && - !this.in_comment - ) - ) { - this.debug('is new token') - this.in_code = false - this.in_comment = true - return true - } - return false - } - - handleNewToken() { - // There was a token that has already been processed - if (this.hasExistingToken()) { // holds the current token information - this.debug('this.token', this.token) - this.token.code.end = this.i - 1 - this.pushToken() + if (!set_start_end_before) points() - // Stops the loop after the first comment token - // has been parsed. This is for file header comments - if (this.restrict) { - this.token.comment.end = this.i - this.token.code.end = -1 - return this.tokens + if (this.isEmpty(content)) { + obj = new Token().code + return obj } - } - - // reset the `token` to use on the new token - this.token = to.clone(this.token_base) - this.token.comment.start = this.i - this.in_comment = true - } + // obj.raw_contents = content.split('\n') + // @todo uncomment these lines after everything setup and working + if (!this.options.verbose) { + // obj.raw_contents = obj.contents + obj.contents = content.split('\n') + } - isEndComment() { - if ( - this.token && - this.is_multi && - this.token.comment.start !== this.i && - this.index.end !== false - ) { - this.debug('is end comment') - return true + return obj } - return false - } - - handleEndComment() { - this.debug('handled end comment') - this.in_comment = false - this.token.comment.end = this.i // sets the end line in the comment token - this.i++ // skips end comment line - this.line = this.lines[this.i] // updates to be the next line - this.index.end = (this.line && is.in(this.line, this.comment.end)) ? this.line.indexOf(this.comment.end) : false + token.comment = normalizeContent(token.comment, true) + token.code = normalizeContent(token.code) + debug.push(token).run() + this.tokens.push(token) + this.token = undefined } - - isLastLineComment() { - let length = this.file.end - - if (!(this.is_multi && this.index.end !== false)) { - length-- + /// @name commentExisits + /// @description + /// this is a helper function that is used to test the existence of the comment on a given line + commentExists(line, comment_type) { + // ensure that the line, and comment_type are truthy + if (is.any.falsy(line, comment_type)) { + return false } - if (this.in_comment && (this.i === length)) { - return true + // store the index of the comment_type + let index = line.indexOf(comment_type) + + // check to see if the comment_type exisits + if (index > -1) { + if ( + is.in(line, `${comment_type} `) || // check to see if the required space after the comment_type exisits + line.length === index + comment_type.length || // check to see if the comment_type is the last thing on that line (aka ) + !line.slice(0, index).trim() + ) { + return index + } } return false } - handleLastLineComment() { - this.debug('the last line in the file is a comment') - this.token.comment.end = this.is_multi ? this.i - 1 : this.i - this.pushToken() - } - - isNextLineComment() { - return !this.is_multi && !is.in(this.lines[this.i + 1], this.comment.line) - } + /// @name setDebug + /// @description + /// This function is used to turn the debug options on or off + /// @arg {boolean} condition + setDebug(condition) { + if (is.undefined(condition)) { + condition = this.should_debug + } - handleNextLineComment() { - this.debug('next line is a comment') - this.in_comment = false - this.token.comment.end = this.i // sets the end line in the comment token - this.i = this.i + 1 // skips end comment line - this.line = this.lines[this.i] // updates to be the next line + this.debugParse = this.debugSet('parse', condition, { spaces: 0 }) + this.debugGetTokens = this.debugSet('parse', condition, { spaces: 0 }) + this.debugGetSingleComment = this.debugGetTokens.set('getSingleComment', 0) + this.debugGetMultiComment = this.debugGetTokens.set('getMultiComment', 0) + this.debugGetCode = this.debugGetTokens.set('getCode', 0) + this.debugPushToken = this.debugGetTokens.set('pushToken', 0) + this.debugHasNext = this.debugGetTokens.set('hasNext', 0) } +} - walkCode() { - // The previous line was a comment - if (!this.in_code) { - this.in_code = true - this.token.code.start = this.i +class Token { + constructor() { + // The base of what each token looks like + this.token_base = { + comment: { contents: [], start: -1, end: -1 }, + code: { contents: [], start: -1, end: -1 } } - // adds this line to token code contents - this.token.code.contents.push(this.line) - - // pushes the last token onto the body - if (this.isLastLine()) { - this.token.code.end = this.i - this.pushToken() - } + return to.clone(this.token_base) } +} - pushToken() { - this.token.comment.contents = to.normalize(this.token.comment.contents) - this.token.code.contents = to.normalize(this.token.code.contents) - this.tokens.push(this.token) +class Line { + constructor(...args) { + args = to.arguments({ + line: '', + lineno: '' + }, ...args) + to.extend(this, args) + this.raw = this.line + this.indent = to.indentLevel(this.line) } + get length() { + return this.line.length + } + toString() { + return this.line + } - // This is used for debuging files. to debug a file just set `this.debug_file = true` and this will debug files - // @note THIS SHOULD NEVER BE COMMITTED AS `TRUE` - debug(...args) { - this.debug_list.push(...args) - return this.debug_file + get str() { + return this.line } - runDebug() { - if (this.debug_file && this.debug_list.length > 0) { - this.debug_list.slice(0, 1).forEach((obj) => { - console.log('') - this.log.debug(obj) - }) - this.debug_list.slice(1).forEach((obj) => this.log.print(obj)) - this.debug_list = [] - } + get string() { + return this.line } } diff --git a/app/utils/debug.js b/app/utils/debug.js index 574da3e..974081d 100644 --- a/app/utils/debug.js +++ b/app/utils/debug.js @@ -110,50 +110,63 @@ export default function debug(default_name = 'DEBUG', default_should_debug = fal dp.push = dp.debug = dp.add = function push(...args) { this.debug_list.push(...args) - return this.should_debug + 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.debug_list.push(...args) + this.shouldRun(...args) } + return arg } dp.debugIfFalse = dp.ifFalse = function debugIfFalse(arg, ...args) { - if (is.false(arg)) { - this.debug_list.push(...args) + if (arg === false) { + this.shouldRun(...args) } + return arg } dp.debugWrap = dp.wrap = function debugWrap(arg, cb, ...args) { - if (!is.function(cb)) { - console.log('debugWrap must use a callback') + if (is.undefined(cb)) { + cb = () => true } if (cb(arg)) { - this.debug_list.push(...args) + this.shouldRun(...args) } - return arg - } - // dp.debugSet.prototype.run = dp.set.prototype.run = dp.debugWrap.prototype.run = dp.wrap.prototype.run = dp.debugIfFalse.prototype.run = dp.ifFalse.prototype.run = dp.debugIfTrue.prototype.run = dp.ifTrue.prototype.run = dp.push.prototype.run = dp.debug.prototype.run = dp.add.prototype.run = - 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) - } + return arg } dp.debugSet = dp.set = function debugSet(name = 'define a name silly', should_debug, options = {}) { @@ -171,7 +184,7 @@ export default function debug(default_name = 'DEBUG', default_should_debug = fal // 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 = this.should_debug ? this.should_debug : default_should_debug + should_debug = !is.undefined(this.should_debug) ? this.should_debug : default_should_debug } if ( @@ -200,15 +213,38 @@ export default function debug(default_name = 'DEBUG', default_should_debug = fal return new Debugger(`${name}`, should_debug, options) } - // let debugger_map = to.reduce(dp, (prev, { key, value }) => { - // prev[key] = { - // configurable: true, - // enumerable: true, - // writable: true, - // value, + /* 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 prev - // }, {}) + // } return function debugDecorator(target) { target.prototype.debugSet = Debugger.prototype.debugSet diff --git a/app/utils/logger.js b/app/utils/logger.js index ff8c5cf..779fbd4 100644 --- a/app/utils/logger.js +++ b/app/utils/logger.js @@ -52,7 +52,9 @@ export default class Logger { case 'number': return purdy.format(arg).toString() case 'function': - return arg.toString() + let obj = to.array(arg.toString()) + const first = obj.shift() + return first + '\n' + to.normalize(obj) case 'string': return to.normalize(arg) default: diff --git a/app/utils/purdy.js b/app/utils/purdy.js index bfbc6b0..6a08eea 100644 --- a/app/utils/purdy.js +++ b/app/utils/purdy.js @@ -22,7 +22,7 @@ export default class Purdy { Null: 'red.bold', Number: 'blue.bold', RegExp: 'magenta', - String: undefined, // use the default color + String: 'green', // use the default color Undefined: 'red.inverse', path: 'grey' } @@ -226,8 +226,8 @@ export default class Purdy { let l = str.length // returns because it's a single line string - if (l === 1) { - return quote + str[0] + quote + if (l <= 1) { + return quote + to.string(str) + quote } // let has_newline_only = /(?:\s*?(\n)\s*?)(.*)/.exec(str[0]) diff --git a/tests/run.test.js b/tests/run.test.js index 507cef3..b161198 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -1,6 +1,7 @@ /* eslint-disable no-loop-func */ import path from 'path' import docs from '../dist/index.js' +import Tokenizer from '../dist/new-parser/tokenizer.js' import { fs, glob } from '../dist/utils' import assert from 'core-assert' import { map } from 'async-array-methods' @@ -61,6 +62,30 @@ addSuite('annotations', async ({ paths, expected }) => { }) +import tokenizerHelper from '../tools/tokenizer-helper.js' +addSuite('Tokenizer', async ({ paths, expected }) => { + const actual = await map(paths, async (file) => { + try { + const obj = await tokenizerHelper(file) + return new Tokenizer(obj.str, obj.comment) + } catch (e) { + console.trace(e) + } + }) + + return () => { + for (let i = 0; i < paths.length; i++) { + test(`${i}: ${paths[i]}`, () => { + assert.deepStrictEqual( + actual[i], + expected[i] + ) + }) + } + } +}) + + const mochaAsync = (fn) => { // eslint-disable-line return async (done) => { try { diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json new file mode 100644 index 0000000..d11050e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 6, + "end": 8 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 10, + "end": 14 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 15, + "end": 17 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 19, + "end": 23 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 24, + "end": 26 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss new file mode 100644 index 0000000..2e418b9 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-comments.scss @@ -0,0 +1,26 @@ +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..d11050e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 6, + "end": 8 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 10, + "end": 14 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 15, + "end": 17 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 19, + "end": 23 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 24, + "end": 26 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..bba75d6 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,26 @@ +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} + +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..acecfeb --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss new file mode 100644 index 0000000..1048da4 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block-with-trailing-line.scss @@ -0,0 +1,6 @@ +/// foo +/// bar +/// baz +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block.json b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.json new file mode 100644 index 0000000..acecfeb --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss new file mode 100644 index 0000000..3349402 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/single-block.scss @@ -0,0 +1,6 @@ +/// foo +/// bar +/// baz +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..efb6713 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 8, + "end": 12 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 15, + "end": 19 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..924da91 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,19 @@ +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. + + +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. + + +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +/// voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +/// molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +/// hic! Repellendus. diff --git a/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss new file mode 100644 index 0000000..dc2db2d --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block-with-trailing-line.scss @@ -0,0 +1,3 @@ +/// foo +/// bar +/// baz diff --git a/tests/tokenizer/css-like/multi-single-line/single-block.json b/tests/tokenizer/css-like/multi-single-line/single-block.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line/single-block.scss b/tests/tokenizer/css-like/multi-single-line/single-block.scss new file mode 100644 index 0000000..a87e3a7 --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line/single-block.scss @@ -0,0 +1,3 @@ +/// foo +/// bar +/// baz \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json new file mode 100644 index 0000000..71cfbf1 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'prop value 1'," + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "'baz': 'prop value 2'," + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "'qux': 'prop value 3'," + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss new file mode 100644 index 0000000..08b1307 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-code-before.scss @@ -0,0 +1,5 @@ +$foo: ( + 'bar': 'prop value 1', ///# one + 'baz': 'prop value 2', ///# two + 'qux': 'prop value 3', ///# three +); diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..19b63bd --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,14 @@ +///# one +.foo { + background: blue; +} + +///# two +.foo { + background: blue; +} + +///# three +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss new file mode 100644 index 0000000..215239f --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/multiple-single-line-comments.scss @@ -0,0 +1,14 @@ +///# one +.foo { + background: blue; +} + +///# two +.foo { + background: blue; +} + +///# three +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss new file mode 100644 index 0000000..ca5add6 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); ///# bock 1 diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss new file mode 100644 index 0000000..788870d --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before-2.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); ///# bock 1 \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..3774e72 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'baz'" + ], + "start": 2, + "end": 2 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss new file mode 100644 index 0000000..3427fbd --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-code-before.scss @@ -0,0 +1,3 @@ +$foo: ( + 'bar': 'baz' ///# bock 1 +); \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss new file mode 100644 index 0000000..a2a0c3b --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line-with-trailing-line.scss @@ -0,0 +1,4 @@ +///# @name single line slash +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line.json b/tests/tokenizer/css-like/single-line-with-code/single-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css-like/single-line-with-code/single-line.scss b/tests/tokenizer/css-like/single-line-with-code/single-line.scss new file mode 100644 index 0000000..e611f5a --- /dev/null +++ b/tests/tokenizer/css-like/single-line-with-code/single-line.scss @@ -0,0 +1,4 @@ +///# @name single line slash +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..d88595d --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,5 @@ +///# one + +///# two + +///# three diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments.json b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss new file mode 100644 index 0000000..2dc54b8 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/multiple-single-line-comments.scss @@ -0,0 +1,5 @@ +///# one + +///# two + +///# three \ No newline at end of file diff --git a/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss new file mode 100644 index 0000000..4dd5f2d --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line-with-trailing-line.scss @@ -0,0 +1 @@ +///# @name single line slash diff --git a/tests/tokenizer/css-like/single-line/single-line.json b/tests/tokenizer/css-like/single-line/single-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/single-line/single-line.scss b/tests/tokenizer/css-like/single-line/single-line.scss new file mode 100644 index 0000000..1cab960 --- /dev/null +++ b/tests/tokenizer/css-like/single-line/single-line.scss @@ -0,0 +1 @@ +///# @name single line slash \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..3e26412 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,7 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss new file mode 100644 index 0000000..08601d2 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/comments-after-start-and-end.scss @@ -0,0 +1,7 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..319fc47 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 10, + "end": 12 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 13, + "end": 15 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 16, + "end": 18 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..ee94771 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,18 @@ +//// +/// Block 1 +//// +.foo { + background: blue; +} +//// +/// Block 2 +//// +.foo { + background: blue; +} +//// +/// Block 3 +//// +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..10915b8 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,23 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss new file mode 100644 index 0000000..c8dde22 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/multiple-blocks.scss @@ -0,0 +1,23 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss new file mode 100644 index 0000000..fe4f0f6 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block-with-trailing-line.scss @@ -0,0 +1,9 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// +.foo { + background: blue; +} diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block.json b/tests/tokenizer/css-like/start-end-with-code/single-block.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css-like/start-end-with-code/single-block.scss b/tests/tokenizer/css-like/start-end-with-code/single-block.scss new file mode 100644 index 0000000..3951dc4 --- /dev/null +++ b/tests/tokenizer/css-like/start-end-with-code/single-block.scss @@ -0,0 +1,9 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..5c60db7 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,4 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end.json b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss new file mode 100644 index 0000000..61adfa5 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/comments-after-start-and-end.scss @@ -0,0 +1,4 @@ +//// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +//// obcaecati ullam. \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..35c23fe --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,9 @@ +//// +/// Block 1 +//// +//// +/// Block 2 +//// +//// +/// Block 3 +//// \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..11127c7 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,14 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks.json b/tests/tokenizer/css-like/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/multiple-blocks.scss b/tests/tokenizer/css-like/start-end/multiple-blocks.scss new file mode 100644 index 0000000..8691bd2 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/multiple-blocks.scss @@ -0,0 +1,14 @@ +//// +/// Block 1 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 2 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// + +//// +/// Block 3 +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. +//// \ No newline at end of file diff --git a/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss new file mode 100644 index 0000000..19e2ab2 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block-with-trailing-line.scss @@ -0,0 +1,6 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// diff --git a/tests/tokenizer/css-like/start-end/single-block.json b/tests/tokenizer/css-like/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css-like/start-end/single-block.scss b/tests/tokenizer/css-like/start-end/single-block.scss new file mode 100644 index 0000000..77bdd38 --- /dev/null +++ b/tests/tokenizer/css-like/start-end/single-block.scss @@ -0,0 +1,6 @@ +//// +/// Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +/// necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +/// qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +/// obcaecati ullam. +//// \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json new file mode 100644 index 0000000..71cfbf1 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'prop value 1'," + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "'baz': 'prop value 2'," + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "'qux': 'prop value 3'," + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss new file mode 100644 index 0000000..2dbd038 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-code-before.scss @@ -0,0 +1,5 @@ +$foo: ( + 'bar': 'prop value 1', /*# one */ + 'baz': 'prop value 2', /*# two */ + 'qux': 'prop value 3', /*# three */ +); diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..fe33023 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,14 @@ +/*# one */ +.foo { + background: blue; +} + +/*# two */ +.foo { + background: blue; +} + +/*# three */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json new file mode 100644 index 0000000..853c869 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 11, + "end": 11 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 12, + "end": 14 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss new file mode 100644 index 0000000..a4f5d4a --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/multiple-single-line-comments.scss @@ -0,0 +1,14 @@ +/*# one */ +.foo { + background: blue; +} + +/*# two */ +.foo { + background: blue; +} + +/*# three */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss new file mode 100644 index 0000000..7121080 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2-with-trailing-line.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); /*# bock 1 */ diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json new file mode 100644 index 0000000..2c0ba34 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo: ( 'bar': 'baz' );" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss new file mode 100644 index 0000000..bbcd7b4 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before-2.scss @@ -0,0 +1 @@ +$foo: ( 'bar': 'baz' ); /*# bock 1 */ \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..3774e72 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'baz'" + ], + "start": 2, + "end": 2 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss new file mode 100644 index 0000000..97eb705 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-code-before.scss @@ -0,0 +1,3 @@ +$foo: ( + 'bar': 'baz' /*# bock 1 */ +); \ No newline at end of file diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss new file mode 100644 index 0000000..17d713a --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line-with-trailing-line.scss @@ -0,0 +1,4 @@ +/*# @name single line slash */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/single-line-with-code/single-line.json b/tests/tokenizer/css/single-line-with-code/single-line.json new file mode 100644 index 0000000..9dce5a0 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/css/single-line-with-code/single-line.scss b/tests/tokenizer/css/single-line-with-code/single-line.scss new file mode 100644 index 0000000..abd8f81 --- /dev/null +++ b/tests/tokenizer/css/single-line-with-code/single-line.scss @@ -0,0 +1,4 @@ +/*# @name single line slash */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss new file mode 100644 index 0000000..bd5f617 --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments-with-trailing-line.scss @@ -0,0 +1,5 @@ +/*# one */ + +/*# two */ + +/*# three */ diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments.json b/tests/tokenizer/css/single-line/multiple-single-line-comments.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/multiple-single-line-comments.scss b/tests/tokenizer/css/single-line/multiple-single-line-comments.scss new file mode 100644 index 0000000..13f8ec9 --- /dev/null +++ b/tests/tokenizer/css/single-line/multiple-single-line-comments.scss @@ -0,0 +1,5 @@ +/*# one */ + +/*# two */ + +/*# three */ \ No newline at end of file diff --git a/tests/tokenizer/css/single-line/single-line-with-trailing-line.json b/tests/tokenizer/css/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/single-line-with-trailing-line.scss b/tests/tokenizer/css/single-line/single-line-with-trailing-line.scss new file mode 100644 index 0000000..343fcd3 --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line-with-trailing-line.scss @@ -0,0 +1 @@ +/*# @name single line slash */ diff --git a/tests/tokenizer/css/single-line/single-line.json b/tests/tokenizer/css/single-line/single-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/single-line/single-line.scss b/tests/tokenizer/css/single-line/single-line.scss new file mode 100644 index 0000000..165e32b --- /dev/null +++ b/tests/tokenizer/css/single-line/single-line.scss @@ -0,0 +1 @@ +/*# @name single line slash */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..be7323e --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,7 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json new file mode 100644 index 0000000..ba52b90 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss new file mode 100644 index 0000000..b533ed6 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/comments-after-start-and-end.scss @@ -0,0 +1,7 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..319fc47 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 4, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 10, + "end": 12 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 13, + "end": 15 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 16, + "end": 18 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..0b4010e --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,18 @@ +/* + * Block 1 + */ +.foo { + background: blue; +} +/* + * Block 2 + */ +.foo { + background: blue; +} +/* + * Block 3 + */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..e5337d8 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,23 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks.json b/tests/tokenizer/css/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..8a99c11 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks.json @@ -0,0 +1,59 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 5, + "end": 7 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 9, + "end": 12 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 13, + "end": 15 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 17, + "end": 20 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 21, + "end": 23 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/multiple-blocks.scss b/tests/tokenizer/css/start-end-with-code/multiple-blocks.scss new file mode 100644 index 0000000..289a42f --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/multiple-blocks.scss @@ -0,0 +1,23 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss new file mode 100644 index 0000000..b0d7ea8 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block-with-trailing-line.scss @@ -0,0 +1,9 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ +.foo { + background: blue; +} diff --git a/tests/tokenizer/css/start-end-with-code/single-block.json b/tests/tokenizer/css/start-end-with-code/single-block.json new file mode 100644 index 0000000..4fac6cd --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block.json @@ -0,0 +1,23 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + ".foo {", + " background: blue;", + "}" + ], + "start": 7, + "end": 9 + } + } +] diff --git a/tests/tokenizer/css/start-end-with-code/single-block.scss b/tests/tokenizer/css/start-end-with-code/single-block.scss new file mode 100644 index 0000000..0ef32c3 --- /dev/null +++ b/tests/tokenizer/css/start-end-with-code/single-block.scss @@ -0,0 +1,9 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ +.foo { + background: blue; +} \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss new file mode 100644 index 0000000..66c5304 --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end-with-trailing-line.scss @@ -0,0 +1,4 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end.json b/tests/tokenizer/css/start-end/comments-after-start-and-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/comments-after-start-and-end.scss b/tests/tokenizer/css/start-end/comments-after-start-and-end.scss new file mode 100644 index 0000000..cc0b4dd --- /dev/null +++ b/tests/tokenizer/css/start-end/comments-after-start-and-end.scss @@ -0,0 +1,4 @@ +/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +obcaecati ullam. */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss new file mode 100644 index 0000000..a8d2f89 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-no-space-between.scss @@ -0,0 +1,9 @@ +/* + * Block 1 + */ +/* + * Block 2 + */ +/* + * Block 3 + */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss new file mode 100644 index 0000000..03dad6e --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks-with-trailing-line.scss @@ -0,0 +1,14 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ diff --git a/tests/tokenizer/css/start-end/multiple-blocks.json b/tests/tokenizer/css/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/multiple-blocks.scss b/tests/tokenizer/css/start-end/multiple-blocks.scss new file mode 100644 index 0000000..1694249 --- /dev/null +++ b/tests/tokenizer/css/start-end/multiple-blocks.scss @@ -0,0 +1,14 @@ +/* + * Block 1 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 2 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ + +/* + * Block 3 + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. + */ \ No newline at end of file diff --git a/tests/tokenizer/css/start-end/single-block-with-trailing-line.json b/tests/tokenizer/css/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/single-block-with-trailing-line.scss b/tests/tokenizer/css/start-end/single-block-with-trailing-line.scss new file mode 100644 index 0000000..769571a --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block-with-trailing-line.scss @@ -0,0 +1,6 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ diff --git a/tests/tokenizer/css/start-end/single-block.json b/tests/tokenizer/css/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/css/start-end/single-block.scss b/tests/tokenizer/css/start-end/single-block.scss new file mode 100644 index 0000000..923547f --- /dev/null +++ b/tests/tokenizer/css/start-end/single-block.scss @@ -0,0 +1,6 @@ +/* + * Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente + * necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non + * qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non + * obcaecati ullam. + */ \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee new file mode 100644 index 0000000..a2520a0 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.coffee @@ -0,0 +1,32 @@ +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json new file mode 100644 index 0000000..3acfe1a --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-comments.json @@ -0,0 +1,74 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 6, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 12, + "end": 16 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 17, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 23, + "end": 27 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 28, + "end": 32 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..a63a083 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,32 @@ +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..3acfe1a --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,74 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 6, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 12, + "end": 16 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 17, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 23, + "end": 27 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 28, + "end": 32 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..9093164 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.coffee @@ -0,0 +1,8 @@ +## foo +## bar +## baz +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..20cfa86 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block-with-trailing-line.json @@ -0,0 +1,24 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 4, + "end": 8 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee new file mode 100644 index 0000000..d8ccbe6 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.coffee @@ -0,0 +1,8 @@ +## foo +## bar +## baz +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json new file mode 100644 index 0000000..20cfa86 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line-with-code/single-block.json @@ -0,0 +1,24 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 4, + "end": 8 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..d66c52e --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,19 @@ +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. + + +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. + + +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione, +## voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi +## molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime +## hic! Repellendus. diff --git a/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..efb6713 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/multiple-blocks-with-trailing-line.json @@ -0,0 +1,56 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 1, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 8, + "end": 12 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ratione,", + "voluptatum dolorem cumque facere sapiente necessitatibus ad nobis, commodi", + "molestias ipsum officiis vel culpa pariatur corrupti nulla, maxime", + "hic! Repellendus." + ], + "start": 15, + "end": 19 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..898e97d --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.coffee @@ -0,0 +1,3 @@ +## foo +## bar +## baz diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block.coffee b/tests/tokenizer/hash-style/multi-single-line/single-block.coffee new file mode 100644 index 0000000..6580104 --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block.coffee @@ -0,0 +1,3 @@ +## foo +## bar +## baz \ No newline at end of file diff --git a/tests/tokenizer/hash-style/multi-single-line/single-block.json b/tests/tokenizer/hash-style/multi-single-line/single-block.json new file mode 100644 index 0000000..eafd07e --- /dev/null +++ b/tests/tokenizer/hash-style/multi-single-line/single-block.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "foo", + "bar", + "baz" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee new file mode 100644 index 0000000..108ad9c --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.coffee @@ -0,0 +1,5 @@ +$foo = { + 'bar': 'prop value 1', ##$ one + 'baz': 'prop value 2', ##$ two + 'qux': 'prop value 3', ##$ three +} diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json new file mode 100644 index 0000000..71cfbf1 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'prop value 1'," + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "'baz': 'prop value 2'," + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "'qux': 'prop value 3'," + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee new file mode 100644 index 0000000..543c7e4 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.coffee @@ -0,0 +1,20 @@ +##$ one +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ two +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ three +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..b8a9a93 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,62 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 8, + "end": 8 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 9, + "end": 13 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 15, + "end": 15 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 16, + "end": 20 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee new file mode 100644 index 0000000..0e4bcc5 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.coffee @@ -0,0 +1,20 @@ +##$ one +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ two +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +##$ three +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json new file mode 100644 index 0000000..b8a9a93 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/multiple-single-line-comments.json @@ -0,0 +1,62 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 8, + "end": 8 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 9, + "end": 13 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 15, + "end": 15 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 16, + "end": 20 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee new file mode 100644 index 0000000..af445ae --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.coffee @@ -0,0 +1 @@ +$foo = { 'bar': 'baz' }; ##$ bock 1 diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json new file mode 100644 index 0000000..829f525 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2-with-trailing-line.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo = { 'bar': 'baz' };" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee new file mode 100644 index 0000000..01c4dc6 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.coffee @@ -0,0 +1 @@ +$foo = { 'bar': 'baz' }; ##$ bock 1 \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json new file mode 100644 index 0000000..829f525 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before-2.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "$foo = { 'bar': 'baz' };" + ], + "start": 1, + "end": 1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee new file mode 100644 index 0000000..465b756 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.coffee @@ -0,0 +1,3 @@ +$foo = { + 'bar': 'baz' ##$ bock 1 +}; \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..3774e72 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,18 @@ +[ + { + "comment": { + "contents": [ + "bock 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "'bar': 'baz'" + ], + "start": 2, + "end": 2 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee new file mode 100644 index 0000000..e06127b --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.coffee @@ -0,0 +1,6 @@ +##$ @name single line slash +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..3ded535 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line.coffee b/tests/tokenizer/hash-style/single-line-with-code/single-line.coffee new file mode 100644 index 0000000..c0a6796 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line.coffee @@ -0,0 +1,6 @@ +##$ @name single line slash +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line-with-code/single-line.json b/tests/tokenizer/hash-style/single-line-with-code/single-line.json new file mode 100644 index 0000000..3ded535 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line-with-code/single-line.json @@ -0,0 +1,22 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 2, + "end": 6 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee new file mode 100644 index 0000000..7e53ce3 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.coffee @@ -0,0 +1,5 @@ +##$ one + +##$ two + +##$ three diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee new file mode 100644 index 0000000..317cb63 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.coffee @@ -0,0 +1,5 @@ +##$ one + +##$ two + +##$ three \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json new file mode 100644 index 0000000..79403ea --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/multiple-single-line-comments.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "one" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "two" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "three" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee new file mode 100644 index 0000000..d47a914 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.coffee @@ -0,0 +1 @@ +##$ @name single line slash diff --git a/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/single-line/single-line.coffee b/tests/tokenizer/hash-style/single-line/single-line.coffee new file mode 100644 index 0000000..8a1674f --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line.coffee @@ -0,0 +1 @@ +##$ @name single line slash \ No newline at end of file diff --git a/tests/tokenizer/hash-style/single-line/single-line.json b/tests/tokenizer/hash-style/single-line/single-line.json new file mode 100644 index 0000000..d7c4b12 --- /dev/null +++ b/tests/tokenizer/hash-style/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "@name single line slash" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee new file mode 100644 index 0000000..53e9788 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.coffee @@ -0,0 +1,9 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..8e4380a --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee new file mode 100644 index 0000000..ee4b3fd --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.coffee @@ -0,0 +1,9 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json new file mode 100644 index 0000000..8e4380a --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/comments-after-start-and-end.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee new file mode 100644 index 0000000..0ec7d73 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.coffee @@ -0,0 +1,24 @@ +### +## Block 1 +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() +### +## Block 2 +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() +### +## Block 3 +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e0de964 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,62 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 4, + "end": 8 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 9, + "end": 11 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 12, + "end": 16 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 17, + "end": 19 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 20, + "end": 24 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..efc32c0 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,29 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..ba10743 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,65 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 15, + "end": 19 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 21, + "end": 24 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 25, + "end": 29 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee new file mode 100644 index 0000000..2574b84 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.coffee @@ -0,0 +1,29 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..ba10743 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/multiple-blocks.json @@ -0,0 +1,65 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 5, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 15, + "end": 19 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 21, + "end": 24 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 25, + "end": 29 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..e5e903f --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.coffee @@ -0,0 +1,11 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..9d1d9b0 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 7, + "end": 11 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block.coffee b/tests/tokenizer/hash-style/start-end-with-code/single-block.coffee new file mode 100644 index 0000000..e6cf56d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block.coffee @@ -0,0 +1,11 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### +outer = 1 +changeNumbers = -> + inner = -1 + outer = 10 +inner = changeNumbers() \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end-with-code/single-block.json b/tests/tokenizer/hash-style/start-end-with-code/single-block.json new file mode 100644 index 0000000..9d1d9b0 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end-with-code/single-block.json @@ -0,0 +1,25 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "outer = 1", + "changeNumbers = ->", + " inner = -1", + " outer = 10", + "inner = changeNumbers()" + ], + "start": 7, + "end": 11 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee new file mode 100644 index 0000000..fc6c463 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.coffee @@ -0,0 +1,4 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee new file mode 100644 index 0000000..afc40d4 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.coffee @@ -0,0 +1,4 @@ +### Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +### obcaecati ullam. \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/comments-after-start-and-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee new file mode 100644 index 0000000..056de77 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.coffee @@ -0,0 +1,9 @@ +### +## Block 1 +### +### +## Block 2 +### +### +## Block 3 +### \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee new file mode 100644 index 0000000..7ea0d57 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.coffee @@ -0,0 +1,14 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks.coffee b/tests/tokenizer/hash-style/start-end/multiple-blocks.coffee new file mode 100644 index 0000000..f65134d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks.coffee @@ -0,0 +1,14 @@ +### +## Block 1 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 2 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### + +### +## Block 3 +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. +### \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/multiple-blocks.json b/tests/tokenizer/hash-style/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee new file mode 100644 index 0000000..777d073 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.coffee @@ -0,0 +1,6 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### diff --git a/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/hash-style/start-end/single-block.coffee b/tests/tokenizer/hash-style/start-end/single-block.coffee new file mode 100644 index 0000000..89988b7 --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block.coffee @@ -0,0 +1,6 @@ +### +## Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente +## necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non +## qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non +## obcaecati ullam. +### \ No newline at end of file diff --git a/tests/tokenizer/hash-style/start-end/single-block.json b/tests/tokenizer/hash-style/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/hash-style/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html new file mode 100644 index 0000000..7d2be29 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.html @@ -0,0 +1,7 @@ +
    +
  • List Item 1
  • + +
  • List Item 2
  • + +
  • List Item 3
  • +
\ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json new file mode 100644 index 0000000..9259b00 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before-with-space-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 4, + "end": 4 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 6, + "end": 6 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html new file mode 100644 index 0000000..e65a9b2 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.html @@ -0,0 +1,5 @@ +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json new file mode 100644 index 0000000..2a5478f --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-code-before.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 2, + "end": 2 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 4, + "end": 4 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html new file mode 100644 index 0000000..29c3e88 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.html @@ -0,0 +1,8 @@ +
      + +
    • List Item 1
    • + +
    • List Item 2
    • + +
    • List Item 3
    • +
    diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json new file mode 100644 index 0000000..82d052b --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line-with-trailing-line.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 5, + "end": 5 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 7, + "end": 7 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line.html b/tests/tokenizer/html/single-line-with-code/multiple-single-line.html new file mode 100644 index 0000000..4ef069a --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line.html @@ -0,0 +1,8 @@ +
      + +
    • List Item 1
    • + +
    • List Item 2
    • + +
    • List Item 3
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/multiple-single-line.json b/tests/tokenizer/html/single-line-with-code/multiple-single-line.json new file mode 100644 index 0000000..82d052b --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/multiple-single-line.json @@ -0,0 +1,50 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [ + "
  • List Item 1
  • " + ], + "start": 3, + "end": 3 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 4, + "end": 4 + }, + "code": { + "contents": [ + "
  • List Item 2
  • " + ], + "start": 5, + "end": 5 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 6, + "end": 6 + }, + "code": { + "contents": [ + "
  • List Item 3
  • " + ], + "start": 7, + "end": 7 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html new file mode 100644 index 0000000..105b761 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.html @@ -0,0 +1,3 @@ +
      +
    • List Item 1
    • +
    diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json new file mode 100644 index 0000000..c044d13 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 1, + "end": 3 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html new file mode 100644 index 0000000..65707c1 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.html @@ -0,0 +1,3 @@ +
      +
    • List Item 1
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json new file mode 100644 index 0000000..c044d13 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-code-before.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 1, + "end": 3 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html new file mode 100644 index 0000000..56dd87d --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.html @@ -0,0 +1,4 @@ + +
      +
    • List Item 1
    • +
    diff --git a/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json new file mode 100644 index 0000000..c536fb6 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line-with-trailing-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/html/single-line-with-code/single-line.html b/tests/tokenizer/html/single-line-with-code/single-line.html new file mode 100644 index 0000000..9d954ca --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line.html @@ -0,0 +1,4 @@ + +
      +
    • List Item 1
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/single-line-with-code/single-line.json b/tests/tokenizer/html/single-line-with-code/single-line.json new file mode 100644 index 0000000..c536fb6 --- /dev/null +++ b/tests/tokenizer/html/single-line-with-code/single-line.json @@ -0,0 +1,20 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    " + ], + "start": 2, + "end": 4 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html new file mode 100644 index 0000000..842f400 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json new file mode 100644 index 0000000..f669684 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html new file mode 100644 index 0000000..3199b38 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json new file mode 100644 index 0000000..f669684 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 2, + "end": 2 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html new file mode 100644 index 0000000..636145e --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.html @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json new file mode 100644 index 0000000..4b4de85 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line-with-trailing-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/multiple-single-line.html b/tests/tokenizer/html/single-line/multiple-single-line.html new file mode 100644 index 0000000..b8b2f08 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/tokenizer/html/single-line/multiple-single-line.json b/tests/tokenizer/html/single-line/multiple-single-line.json new file mode 100644 index 0000000..4b4de85 --- /dev/null +++ b/tests/tokenizer/html/single-line/multiple-single-line.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "block 1" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 2" + ], + "start": 3, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "block 3" + ], + "start": 5, + "end": 5 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/single-line-with-trailing-line.html b/tests/tokenizer/html/single-line/single-line-with-trailing-line.html new file mode 100644 index 0000000..898f7cd --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line-with-trailing-line.html @@ -0,0 +1 @@ + diff --git a/tests/tokenizer/html/single-line/single-line-with-trailing-line.json b/tests/tokenizer/html/single-line/single-line-with-trailing-line.json new file mode 100644 index 0000000..aa9253d --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line-with-trailing-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/single-line/single-line.html b/tests/tokenizer/html/single-line/single-line.html new file mode 100644 index 0000000..b87d3c8 --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/tokenizer/html/single-line/single-line.json b/tests/tokenizer/html/single-line/single-line.json new file mode 100644 index 0000000..aa9253d --- /dev/null +++ b/tests/tokenizer/html/single-line/single-line.json @@ -0,0 +1,16 @@ +[ + { + "comment": { + "contents": [ + "some awesome comment" + ], + "start": 1, + "end": 1 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html new file mode 100644 index 0000000..fa59f4a --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.html @@ -0,0 +1,10 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json new file mode 100644 index 0000000..5ea0c4f --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end-with-trailing-line.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html new file mode 100644 index 0000000..3588fba --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.html @@ -0,0 +1,10 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json new file mode 100644 index 0000000..5ea0c4f --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/comments-after-start-and-before-end.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html new file mode 100644 index 0000000..1519dbf --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.html @@ -0,0 +1,27 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..7a28995 --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-no-space-between.json @@ -0,0 +1,65 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 4, + "end": 9 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 10, + "end": 12 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 13, + "end": 18 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 19, + "end": 21 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 22, + "end": 27 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html new file mode 100644 index 0000000..178ac77 --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.html @@ -0,0 +1,32 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..e61b55a --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks-with-trailing-line.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 12, + "end": 15 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 16, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 23, + "end": 26 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 27, + "end": 32 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks.html b/tests/tokenizer/html/start-end-with-code/multiple-blocks.html new file mode 100644 index 0000000..26c0c5e --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks.html @@ -0,0 +1,32 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    + + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/multiple-blocks.json b/tests/tokenizer/html/start-end-with-code/multiple-blocks.json new file mode 100644 index 0000000..e61b55a --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/multiple-blocks.json @@ -0,0 +1,68 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 5, + "end": 10 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 12, + "end": 15 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 16, + "end": 21 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 23, + "end": 26 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 27, + "end": 32 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html new file mode 100644 index 0000000..4cb666b --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.html @@ -0,0 +1,12 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    diff --git a/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json new file mode 100644 index 0000000..eff603e --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block-with-trailing-line.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 7, + "end": 12 + } + } +] diff --git a/tests/tokenizer/html/start-end-with-code/single-block.html b/tests/tokenizer/html/start-end-with-code/single-block.html new file mode 100644 index 0000000..bec20d3 --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block.html @@ -0,0 +1,12 @@ + +
      +
    • List Item 1
    • +
    • List Item 2
    • +
    • List Item 3
    • +
    • List Item 4
    • +
    \ No newline at end of file diff --git a/tests/tokenizer/html/start-end-with-code/single-block.json b/tests/tokenizer/html/start-end-with-code/single-block.json new file mode 100644 index 0000000..eff603e --- /dev/null +++ b/tests/tokenizer/html/start-end-with-code/single-block.json @@ -0,0 +1,26 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [ + "
      ", + "
    • List Item 1
    • ", + "
    • List Item 2
    • ", + "
    • List Item 3
    • ", + "
    • List Item 4
    • ", + "
    " + ], + "start": 7, + "end": 12 + } + } +] diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html new file mode 100644 index 0000000..786b52d --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.html @@ -0,0 +1,4 @@ + diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end.html b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.html new file mode 100644 index 0000000..bd80aa8 --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.html @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/comments-after-start-and-before-end.json b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.json new file mode 100644 index 0000000..5c73c8f --- /dev/null +++ b/tests/tokenizer/html/start-end/comments-after-start-and-before-end.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html new file mode 100644 index 0000000..81b44e8 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.html @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json new file mode 100644 index 0000000..e8ce7df --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-no-space-between.json @@ -0,0 +1,44 @@ +[ + { + "comment": { + "contents": [ + "Block 1" + ], + "start": 1, + "end": 3 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2" + ], + "start": 4, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3" + ], + "start": 7, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html new file mode 100644 index 0000000..d981a16 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.html @@ -0,0 +1,14 @@ + + + + + diff --git a/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks-with-trailing-line.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/multiple-blocks.html b/tests/tokenizer/html/start-end/multiple-blocks.html new file mode 100644 index 0000000..c9b183f --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks.html @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/multiple-blocks.json b/tests/tokenizer/html/start-end/multiple-blocks.json new file mode 100644 index 0000000..fc0fca4 --- /dev/null +++ b/tests/tokenizer/html/start-end/multiple-blocks.json @@ -0,0 +1,47 @@ +[ + { + "comment": { + "contents": [ + "Block 1", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 1, + "end": 4 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 2", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 6, + "end": 9 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + }, + { + "comment": { + "contents": [ + "Block 3", + "Lorem ipsum dolor sit amet, consectetur adipisicing elit." + ], + "start": 11, + "end": 14 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/single-block-with-trailing-line.html b/tests/tokenizer/html/start-end/single-block-with-trailing-line.html new file mode 100644 index 0000000..df8589b --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block-with-trailing-line.html @@ -0,0 +1,6 @@ + diff --git a/tests/tokenizer/html/start-end/single-block-with-trailing-line.json b/tests/tokenizer/html/start-end/single-block-with-trailing-line.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block-with-trailing-line.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tests/tokenizer/html/start-end/single-block.html b/tests/tokenizer/html/start-end/single-block.html new file mode 100644 index 0000000..2fd83fa --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/tests/tokenizer/html/start-end/single-block.json b/tests/tokenizer/html/start-end/single-block.json new file mode 100644 index 0000000..896b74d --- /dev/null +++ b/tests/tokenizer/html/start-end/single-block.json @@ -0,0 +1,19 @@ +[ + { + "comment": { + "contents": [ + "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sapiente", + "necessitatibus suscipit aliquid consequatur recusandae, magnam dolore non", + "qui quo voluptatem autem, culpa, quidem nam alias? Repellendus non", + "obcaecati ullam." + ], + "start": 1, + "end": 6 + }, + "code": { + "contents": [], + "start": -1, + "end": -1 + } + } +] diff --git a/tools/generate-test.js b/tools/generate-test.js index d9ee582..3b488c3 100755 --- a/tools/generate-test.js +++ b/tools/generate-test.js @@ -4,6 +4,7 @@ var docs = require('..').default +var Tokenizer = require('../dist/new-parser/tokenizer.js').default var path = require('path') var clor = require('clor') var utils = require('../dist/utils') @@ -33,6 +34,8 @@ function sortTest(file) { case 'cases': case 'file-types': return caseTest(file) + case 'tokenizer': + return tokenizerTest(file) case 'annotations': return annotationTest(file) default: @@ -40,6 +43,13 @@ function sortTest(file) { } } +function output(file, data) { + return utils.fs.outputJson( + file.replace(path.extname(file), '.json').replace('docs/', ''), + data, + { spaces: 2 } + ) +} function annotationTest(file) { @@ -53,16 +63,13 @@ function annotationTest(file) { ignore: '.*' }) .then(function(parsed) { - return utils.fs.outputJson( - file.replace(path.extname(file), '.json').replace('docs/', ''), - parsed[path.join('docs', file)], - { spaces: 2 } - ) + return output(file, parsed[path.join('docs', file)]) }) .then(function() { resolve(clor.green(file) + '') }) - .catch(function() { + .catch(function(err) { + console.trace(err) resolve(clor.red(file) + '') }) }) @@ -80,17 +87,38 @@ function caseTest(file) { ignore: '.*' }) .then(function(parsed) { - return utils.fs.outputJson( - file.replace(path.extname(file), '.json'), - parsed, - { spaces: 2 } - ) + return output(file, parsed) }) .then(function() { resolve(clor.green(file) + '') }) - .catch(function() { + .catch(function(err) { + console.trace(err) resolve(clor.red(file) + '') }) }) } + + +var tokenizerHelper = require('../tools/tokenizer-helper.js') +function tokenizerTest(file) { + return new Promise(function(resolve) { + tokenizerHelper(file) + .then(function(obj) { + let result + try { + result = new Tokenizer(obj.str, obj.comment) + } catch (e) { + console.trace(e.stack) + } + return output(file, result) + }) + .then(function() { + resolve(clor.green(file) + '') + }) + .catch(function(err) { + console.trace(err) + resolve(clor.red(file) + '') + }) + }) +} diff --git a/tools/tokenizer-helper.js b/tools/tokenizer-helper.js new file mode 100644 index 0000000..ec5160c --- /dev/null +++ b/tools/tokenizer-helper.js @@ -0,0 +1,90 @@ +// this file is disabled because it has to use es5 syntax because it doesn't get compiled. +/* eslint-disable */ + +// This holds the different comment types to be used by the `tokenizer`. +// It's based off the folder path for example +// `comment_types['single-line'].slash` is for `tests/tokenizer/single-line/slash` +// If you need to add new tests with different comment types just add it to this +// object and create the folder path if needed, or just add your test to the correct +// folder and then generate them. +var comment_types = { + 'css-like': { + 'multi-single-line': { + comment: { start: '', line: '///', end: '' } + }, + 'single-line': { + comment: { start: '', line: '///#', end: '' } + }, + 'start-end': { + comment: { start: '////', line: '///', end: '////' } + }, + }, + 'css': { + 'single-line': { + comment: { start: '/*#', line: '', end: '*/' } + }, + 'start-end': { + comment: { start: '/*', line: '*', end: '*/' } + }, + }, + 'hash-style': { + 'multi-single-line': { + comment: { start: '', line: '##', end: '' } + }, + 'single-line': { + comment: { start: '', line: '##$', end: '' } + }, + 'start-end': { + comment: { start: '###', line: '##', end: '###' } + }, + }, + 'html': { + 'start-end': { + comment: { start: '' } + }, + 'single-line': { + comment: { start: '' } + } + }, + 'js': { + 'single-line': { + comment: { start: '', line: '///', end: '' } + }, + 'start-end': { + comment: { start: '////', line: '///', end: '////' } + }, + }, +} +var path = require('path') +var fs = require('fs') + +function getTokenizerOption(file) { + var type = file.split(path.sep).slice(2, -1) + var comment = type.reduce(function(prev, current) { + var result = (prev || {})[current] + if (!result) { + return (prev || {})[current.replace('-with-code', '')] + } + + return result + }, comment_types) + + return comment || {} +} + +module.exports = exports = function tokenizerHelper(file) { + return new Promise(function(resolve, reject) { + fs.readFile(file, function(err, str) { + if (err) { + console.trace(err) + reject(err) + } + str += '' + + resolve({ + str: str, + comment: getTokenizerOption(file) + }) + }) + }) +} From 9c3a96ca37b369267c978572da8166c65dd778e6 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 21 Mar 2016 16:51:53 -0400 Subject: [PATCH 247/273] updated a few functions in the `to` lib --- app/utils/to.js | 221 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 183 insertions(+), 38 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index 8b6aa20..5654312 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -223,35 +223,65 @@ let to = { /// // Output: /// // 0: Jane /// // 1: Doe - entries: (obj) => { + entries(obj, from_index = 0, to_index) { + const done = { done: true } + let iterator = { + [Symbol.iterator]() { + return this + } + } + if (is.array(obj)) { - return obj.entries() + if (is.undefined(to_index)) { + to_index = obj.length + } + + if (from_index < to_index) { + iterator.next = () => { + if (from_index < to_index) { + return { value: [ from_index, obj[from_index++] ] } + } + return done + } + } else { + iterator.next = () => { + if (from_index > to_index) { + return { value: [ from_index, obj[from_index--] ] } + } + return done + } + } + + return iterator } - let index = 0 // 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(to_index)) { + to_index = keys.length + } - return { - [Symbol.iterator]() { - return this - }, - next() { - if (index < keys.length) { - let key = keys[index] - index++ - return { - value: [ key, obj[key], index - 1 ] - } + if (from_index < to_index) { + iterator.next = () => { + if (from_index < to_index) { + let key = keys[from_index] + return { value: [ key, obj[key], from_index++ ] } } - - return { - done: true + return done + } + } else { + iterator.next = () => { + if (from_index > to_index) { + let key = keys[from_index] + return { value: [ key, obj[key], from_index-- ] } } + return done } } + + return iterator }, /// @name object entries @@ -314,32 +344,147 @@ let to = { /// @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: (content, leading = true, trailing = leading) => { - content = to.array(content) // this allows arrays and strings to be passed - - // remove leading blank lines - if (leading) { - while (content.length && !!!content[0].trim().length) content.shift() + 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() + } } - // remove trailing blank lines - if (trailing) { - while (content.length && !!!(content[content.length - 1].trim()).length) content.pop() + if (options.trailing) { + while (content.length && !!!(content[content.length - 1].trim()).length) { + trailing-- + content.pop() + } } - let trim_by = content.join('\n') // converts content to string to 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 + const indent = to.indentLevel(content) - return content - .map((line) => line.slice(trim_by)) // remove extra whitespace from the beginning of each line + 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)) { + to.extend(result, arg) + } else { + result[keys[i] || i] = arg + } + } + + return to.extend(defaults, result) }, /// @name to.extend @@ -367,7 +512,6 @@ let to = { return a }, - /// @name to.clone /// @description /// This will clone argument so the passed arg doesn't change @@ -490,7 +634,7 @@ let to = { /// @arg {object} - The object to convert /// @arg {number} - The spacing to use /// @returns {json} - json: (arg, spacing = 2) => is.object(arg) && JSON.stringify(arg, null, spacing), + json: (arg, spacing = 2) => (is.object(arg) || is.string(arg)) && JSON.stringify(arg, null, spacing), /// @name to.array /// @description @@ -504,7 +648,8 @@ let to = { } else if (is.arguments(arg)) { return arraySlice(arg) } else if (is.string(arg)) { - return arg.split(glue) + arg = arg.split(glue) + return arg.length === 1 && arg[0] === '' ? [] : arg } else if (is.plainObject(arg) || is.number(arg)) { return [ arg ] } From 38aeaee3de5870e529a4941a3bc73182cfa3638c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 21 Mar 2016 17:07:52 -0400 Subject: [PATCH 248/273] removed the debug information by default --- app/new-parser/tokenizer.js | 35 +++++++++++++++++------------------ app/utils/debug.js | 4 ++-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index e6c216e..028cab5 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -19,14 +19,15 @@ export default class Tokenizer { // Update the content { - const { str: _str, string, source, code, content } = options - options.content = _str || string || source || code || content + const { str: _str, string, source, code, content, contents, ...rest } = options + str = _str || string || source || code || content || contents + this.options = rest } // ensures that the comment style that was passed will work { - let { start, line, single, end } = options.comment + let { start, line, single, end } = this.options.comment single = single || line // this ensures there aren't any errors while looking comment lines @@ -47,26 +48,23 @@ export default class Tokenizer { throw new Error('The start and end comments must be longer than the single comment') } - options.comment = { start, single, end } - } - - const { content, ...rest } = options + this.options.comment = { start, single, end } - this.options = rest + this.is_multi = is.all.truthy(start, end) + this.is_same_multi = this.is_multi && start === end + } // holds the parsed tokens this.tokens = [] - this.is_multi = is.all.truthy(options.comment.start, options.comment.end) - this.is_same_multi = this.is_multi && options.comment.start === options.comment.end - const debug = this.debugSet('options') debug.push('this.options', this.options, '') - if (!!content) { + if (!!str) { debug.push('has content in the options').run() - return this.parse(content) + this.parse(str) + return this.tokens } debug.run() return @@ -250,8 +248,9 @@ export default class Tokenizer { } debug.push('', '', '', '').run() - - return this.getTokens() + if (!this.options.restrict) { + return this.getTokens() + } } /// @name this.getBefore @@ -472,11 +471,11 @@ export default class Tokenizer { /// @arg {boolean} condition setDebug(condition) { if (is.undefined(condition)) { - condition = this.should_debug + condition = this.should_debug || false } - this.debugParse = this.debugSet('parse', condition, { spaces: 0 }) - this.debugGetTokens = this.debugSet('parse', condition, { spaces: 0 }) + this.debugParse = this.debugSet('parse', { condition, spaces: 0 }) + this.debugGetTokens = this.debugSet('parse', { condition, spaces: 0 }) this.debugGetSingleComment = this.debugGetTokens.set('getSingleComment', 0) this.debugGetMultiComment = this.debugGetTokens.set('getMultiComment', 0) this.debugGetCode = this.debugGetTokens.set('getCode', 0) diff --git a/app/utils/debug.js b/app/utils/debug.js index 974081d..293bb0b 100644 --- a/app/utils/debug.js +++ b/app/utils/debug.js @@ -94,10 +94,10 @@ export default function debug(default_name = 'DEBUG', default_should_debug = fal default_name = clor[default_options.color].bold(`${icon_chevron}[${default_name}]: `) - function Debugger(name = 'Define a Name', should_debug, options = {}) { + 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 || default_should_debug + should_debug = options.should_debug || options.condition || default_should_debug } this.should_debug = should_debug this.debug_list = [] From ef773e6d5713f708aaee81138011359bd052e7d3 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 22 Mar 2016 13:27:05 -0400 Subject: [PATCH 249/273] Moved the setting of the options to be in it's own function --- app/new-parser/tokenizer.js | 129 ++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 56 deletions(-) diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index 028cab5..8ffc723 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -7,27 +7,38 @@ import clor from 'clor' @_debug('Tokenizer') export default class Tokenizer { constructor(str, options = {}) { // eslint-disable-line + this.options = {} + this.setOptions(arguments) + + if (!is.empty(this.stash)) { + return this.parse() + } + return + } + + setOptions(options) { // eslint-disable-line + const debug = this.debugSet('options') options = to.arguments({ content: '', - comment: { start: '', line: '///', end: '' }, // the default comment style to look for - blank_lines: default_options.blank_lines, - verbose: false, // determins if all the extra line info will be returned or if it will just return strings - strip: false, // determins if the comment should be stripped from the line - restrict: false, - indent: true, + lineno: 0, + comment: this.options.comment || { start: '', line: '///', end: '', type: undefined }, // the default comment style to look for + blank_lines: this.options.blank_lines || default_options.blank_lines, + // determins if all the extra line info will be returned or if it will just return strings + verbose: !is.undefined(this.options.verbose) ? this.options.verbose : false, + // determins if the comment should be stripped from the line + strip: !is.undefined(this.options.strip) ? this.options.strip : false, + // if true this option will only return the first token + restrict: !is.undefined(this.options.restrict) ? this.options.restrict : false, + // determins if the code below should stop parsing if the indent level is less than the starting indent level + indent: !is.undefined(this.options.indent) ? this.options.indent : true, }, arguments) - // Update the content - { - const { str: _str, string, source, code, content, contents, ...rest } = options - str = _str || string || source || code || content || contents - this.options = rest - } + debug.push('options 1:', options) - // ensures that the comment style that was passed will work - { - let { start, line, single, end } = this.options.comment + { // parse the comment to ensure the settings are valid, and attempt to update them + // to be valid if they aren't valid + let { start, line, single, end, type } = options.comment single = single || line // this ensures there aren't any errors while looking comment lines @@ -48,26 +59,39 @@ export default class Tokenizer { throw new Error('The start and end comments must be longer than the single comment') } - this.options.comment = { start, single, end } - + options.comment = { start, single, end, type } this.is_multi = is.all.truthy(start, end) this.is_same_multi = this.is_multi && start === end } + { // set the lineno to start with + const { i, index, lineno, start_at, ...rest } = options + this.lineno = i || index || start_at || lineno || 0 + options = rest + } + + + let stash + { // set the string to use + let { str, string, source, code, content, contents, ...rest } = options + stash = str || string || source || code || content || contents || '' + options = rest + } + + // update the options + this.options = options + // holds the parsed tokens this.tokens = [] - const debug = this.debugSet('options') + // update the stash + this.stash = this.getStash(stash) - debug.push('this.options', this.options, '') + // update the iterator to use + this.iterator = to.entries(this.stash, this.lineno) - if (!!str) { - debug.push('has content in the options').run() - this.parse(str) - return this.tokens - } + debug.push('this.options', this.options, '') debug.run() - return } /// @name hasNext @@ -153,7 +177,6 @@ export default class Tokenizer { return stash } - /// @name parse /// @description /// This will parse the passed content @@ -163,34 +186,18 @@ export default class Tokenizer { /// @returns {array} - Of parsed tokens /// @note {5} This function also accepts a object to be passed with named arguments /// @markup Usage - parse(content = '', start_at = 0, verbose) { // eslint-disable-line - let options = to.arguments({ - content: '', - start_at: this.options.start_at || 0, - verbose: this.options.verbose, - }, arguments) - - // update the verbose option incase it changed - this.verbose = options.verbose - - // update the stash to use the passed content - this.stash = options.content = this.getStash(options.content) - - // holds the current position in the stash to start from - this.lineno = options.i || options.index || options.lineno || options.start_at || 0 - - // update the iterator to use - this.iterator = to.entries(this.stash, this.lineno) - - // holds the parsed tokens - this.tokens = [] + parse(content = '', start_at = 0) { // eslint-disable-line + if (is.empty(this.stash)) { + this.setOptions(arguments) + } this.setDebug() const debug = this.debugParse - const result = this.getTokens() - debug.push('parsed:', result) - debug.run() - + const result = to.clone(this.getTokens()) + this.tokens = [] // reset the tokens list to be empty + this.stash = [] // resets the stash to be empty + this.token = undefined // reset the current token to be empty + debug.push('parsed:', result).run() return result } @@ -216,7 +223,8 @@ export default class Tokenizer { if ( debug.ifTrue(is.empty(`${this.line}`.trim()), "the line was empty, and isn't in a token already") || - debug.ifTrue(!this.line.has_comment, "The line doesn't have a comment, and isn't in a token already") + debug.ifTrue(!this.line.has_comment, "The line doesn't have a comment, and isn't in a token already") || + debug.ifTrue(this.is_multi && !this.line.index.start, "The line doesn't have a starting comment") ) { debug.push('', '', '', '').run() return this.getTokens() @@ -224,8 +232,18 @@ export default class Tokenizer { debug.push(`line [${this.lineno}]: ${clor.bgBlue(this.line)}`, this.line).run() - if (this.line.has_comment) { + if ( + this.line.has_comment + ) { this.token = new Token() + + { + const { type } = this.options.comment + if (type) { + this.token.comment.type = type + } + } + debug.push('has comment').run() if (this.is_same_multi && this.line.index.start === this.line.index.end) { @@ -248,9 +266,8 @@ export default class Tokenizer { } debug.push('', '', '', '').run() - if (!this.options.restrict) { - return this.getTokens() - } + + return !this.options.restrict ? this.getTokens() : this.tokens } /// @name this.getBefore From bc1041795ccf799fb984c7399019a73d5aa4940f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 22 Mar 2016 13:30:01 -0400 Subject: [PATCH 250/273] made the `to.arguments` smarter --- app/utils/to.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index 5654312..98466e3 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -478,7 +478,15 @@ let to = { arg = to.arguments(defaults, ...arraySlice(arg)) } if (is.plainObject(arg)) { - to.extend(result, 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 } From d88a7fb586f49606ec2ccecf8aea8bfd49854821 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:14:52 -0400 Subject: [PATCH 251/273] Updated the annotation-api --- app/new-annotation-api.js | 140 +++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 78 deletions(-) diff --git a/app/new-annotation-api.js b/app/new-annotation-api.js index 0abe1a1..d85ad96 100644 --- a/app/new-annotation-api.js +++ b/app/new-annotation-api.js @@ -35,7 +35,7 @@ const annotation_base = { export default class AnnotationApi { - constructor({ annotations, file }) { + constructor({ annotations, file, type }) { // object of the all the annotation // This object holds all the annotations this.annotations_list = { @@ -50,7 +50,7 @@ export default class AnnotationApi { // } } - this.file = file + this.file = file || { type } // stores the current annotation that is being added @@ -96,7 +96,7 @@ export default class AnnotationApi { return to.extend(previous, { [current]: this.list(current) }) - }, { main: this.list() }) + }, { parse: this.list() }) } /// @name add @@ -110,12 +110,12 @@ export default class AnnotationApi { /// @returns {this} /// /// @markup {js} **Example:** Declaring a basic annotation - /// annoationsApi.add("name", function(){ + /// annotationsApi.add("name", function(){ /// return this.annotation.line /// }) /// /// @markup {js} **Example:** Declaring a annotation with more options - /// annoationsApi.add("name", { + /// annotationsApi.add("name", { /// alias: ['title', 'heading'], /// parse(){ /// return this.annotation.line @@ -125,7 +125,7 @@ export default class AnnotationApi { /// }) /// /// @markup {js} **Example** Specifing a file specific annotation - /// annoationsApi.add('promise', { + /// 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 @@ -238,85 +238,69 @@ export default class AnnotationApi { }) } - /// @name run_annotation - /// @access private - /// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) - run(options) { - let { - annotation, - annotation_types, - block = {}, - file, - log - } = 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(annotation_types.alias, name) ? annotation_types.alias[name] : [], - line: to.normalize(contents[0]), - contents, - start: null, - end: null - }, - annotation_types, - ...block, - log - }) + run(type, options) { + { + const base = { contents: [], start: -1, end: -1 } + options = to.arguments({ + type: 'parse', + annotation: { name: '', alias: '', ...base }, + file: { path: '', name: '', type: '', options: {}, ...base }, + comment: { ...base }, + code: { ...base }, + }, arguments) } - // removes the first line because it's the `line` of the annotation - annotation.contents.shift() - - // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents) - - // normalizes the current annotation line - annotation.line = to.normalize(annotation.line) - - // Merges the data together so it can be used to run all the annotations - let result = { - // sets the annotation block information to be in it's own namespace of `annotation` - annotation, - - // adds the comment, code, and file information - ...block, - - add, - - // adds the ability to add logging information - log - } - - // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if (is.all.truthy((this.annotations_list[file.type] || {})[annotation.name], ((this.annotations_list.default || {})[annotation.name]) || {}).parse) { - result.default = this.annotations_list.default[annotation.name].parse.call(result) + let { type: fn_name, ...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 } = base + const fn = (list[file.type] || {})[annotation.name] + let default_fn = (list.default || {})[annotation.name] + + if (fn && default_fn && (default_fn = default_fn[fn_name])) { + base.default = () => default_fn.call(base) + } } - return annotation_types.main[annotation.name].parse.call(result) + const fn = this.getAnnotationFn(base.annotation.name, fn_name) + let result = is.function(fn) ? fn.call(base) : fn + return result } - - _run({ list, parsed, block }) { - let parsed_keys = to.keys(parsed) - - for (let [ annotation, fn ] of to.entries(list)) { - if (!is.in(parsed_keys, annotation)) { - const result = is.fn(fn) ? fn.call(block) : fn - if (result != null) { - parsed[annotation] = result - } - } + getAnnotationFn(name, type) { + let fn = this.annotations + // console.log('fn 1:', fn) + fn = fn[type] || {} + fn = fn[name] || {} + if (is.function(fn)) { + return fn } - - return parsed + fn = fn[type] || {} + return fn } alias_check() { From ac071ec1b9ec0a97b5904b4d9d4ad7caee42b8cd Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:15:14 -0400 Subject: [PATCH 252/273] updated the main parser to be awesome --- app/new-parser/index.js | 375 +++++++++++++++++++++++++++++++--------- 1 file changed, 296 insertions(+), 79 deletions(-) diff --git a/app/new-parser/index.js b/app/new-parser/index.js index 40f5782..a001e12 100644 --- a/app/new-parser/index.js +++ b/app/new-parser/index.js @@ -1,104 +1,321 @@ -import { info, fs, is, to } from '../utils' +import { fs, is, to, Logger } from '../utils' import AnnotationApi from '../new-annotation-api' -import * as annotations from '../annotations' import path from 'path' // import getBlocks from '../../get-blocks' // import parseBlocks from '../parser/parse-blocks' -import getConfig from '../config' -import tokenizer from './tokenizer' -import clor from 'clor' - -export default async function parser(file_path, settings = {}) { - if (is.empty(settings)) { - settings = await getConfig() - } - // { - // languages, - // annotations, - // blank_lines, - // sort, - // log - // } - - const contents = to.normalString(await fs.readFile(file_path)) - - // { - // file_path, - // comments, - // languages, - // annotations, - // blank_lines, - // sort, - // log - // } - return new Parser({ path: file_path, contents }, settings) -} +// import getConfig from '../config' +import Tokenizer from './tokenizer' +// import clor from 'clor' + +export default class Parser { + constructor(options) { // eslint-disable-line + this.setOptions(arguments) + } + + setOptions(options) { + options = to.arguments({ + language: { + prefix: '@', + + // header comment style + // @note {10} only 1 of these can be used per file + header: { start: '////', line: '///', end: '////', type: 'header' }, -// parser.prototype.fn = Parser.prototype + // body comment style + body: { start: '', line: '///', end: '', type: 'body' }, -class Parser extends AnnotationApi { - constructor(file, settings) { - // the filetype of the current file - const type = path.extname(file.path).replace('.', '') + // inline comment style + inline: { start: '', line: '///#', end: '', type: 'inline' }, - // file.contents = replaceAliases() - const language = settings.languages[type] ? settings.languages[type] : settings.languages.default + // this is used for any interpolations that might occur in annotations. + // I don't see this needing to change but just incase I'm making it a setting. + // @note {10} This setting is used to create a RegExp so certain characters need to be escaped + interpolation: { start: '\\${', end: '}' }, + }, + type: undefined, + blank_lines: 4, + indent: true, + annotations: {}, + sort: (a, b) => a.localeCompare(b), // same as the default sort function + log: new Logger() + }, arguments) - to.extend(file, { - path: path.join(info.dir, path.relative(info.root, file.path)) || file.path, // path of the file - name: path.basename(file.path, `.${type}`), // name of the file - type, // filetype of the file - options: language, // @todo remove this - settings: language, - start: 1, // starting point of the file - end: to.array(file.contents).length - 1 // ending point of the file + let { annotations, type, ...rest } = options + this.options = rest + this.api = new AnnotationApi({ annotations, type }) + + { + let { alias, parse } = this.api.annotations + parse = to.keys(parse) + const reverse_alias_list = to.reduce(alias, (previous, { key, value }) => { + value = value + .filter((_alias) => !is.in(parse, _alias)) + .reduce((a, b) => to.extend(a, { [b]: key }), {}) + return to.extend(previous, value) + }, {}) + const regex = new RegExp(`^\s*${this.options.language.prefix}(?:(${to.keys(reverse_alias_list).join('|')})|(${parse.join('|')}))\\b\\s*`) + + this.annotations_list = { reverse_alias_list, regex } + } + } + + async parse(file = {}) { + file = is.plainObject(file) ? file : { path: file } + file.type = file.type || path.extname(file.path).replace('.', '') + file.contents = file.contents || to.string(await fs.readFile(file.path)) + file.name = path.basename(file.path, `.${file.type}`) // name of the file + file.options = this.options.language + file.start = 1 // starting point of the file + file.end = to.array(file.contents).length - 1 // ending point of the file + this.file = file + + let tokens = this.getTokens(file.contents) + tokens = this.getAnnotations(tokens) + tokens = this.parseTokens(tokens) + tokens = this.autofillTokens(tokens) + tokens = this.resolveTokens(tokens) + // console.log('') + // console.log('') + // console.log('') + // console.log('') + console.log(to.json(tokens)) + return tokens + } + + getTokens(contents = '') { + const { language, blank_lines, indent } = this.options + const base = { blank_lines, indent, verbose: true } + const header = new Tokenizer(contents, 0, language.header, { restrict: true, ...base })[0] || {} + let body = new Tokenizer(contents, header.comment ? header.comment.end : 0, language.body, base) + const inline_tokenizer = new Tokenizer({ comment: language.inline, ...base }) + + body = body.map((token) => { + let { start: offset } = token.code + offset -= 1 + token.inline = inline_tokenizer.parse(token.code.contents, { offset }) + return token }) - super({ annotations, file }) + return { header, body } + } - this.language = language + map({ header, body }, callback) { + const map = (token) => { + if (is.empty(token)) return {} + token = callback(token) - to.extend(this, to.filter(settings, ({ key }) => { - return is.in([ 'blank_lines', 'sort', 'log' ], key) - })) + if (token.inline && !is.empty(token.inline)) { + token.inline = to.map(token.inline, map) + } - // removes aliases from the file contents - this.replaceAliases() + return token + } - // a) The file doesn't contain any header level comments, or body level comments - if (!is.any.in(file.contents, ...to.values(file.options.header, '!type'), ...to.values(file.options.body, '!type'))) { - this.log.emit('warning', `Well shitfire, ${clor.bold(file.path)} doesn't contain any sweet documentation`) - return [] + header = map(header) + body = to.map(body, map) + return { header, body } + } + + getAnnotations({ header, body }) { + const { language } = this.options + const { reverse_alias_list, regex } = this.annotations_list + const hasAnnotation = (line) => { + line.has_annotation = false // by default each line doesn't have a annotation + // remove the annotation from the line + line.str = `${line}`.replace(regex, (match, alias, annotation) => { + if (alias) { + // find the correct annotation to use if an alias is found + annotation = reverse_alias_list[alias] + } + line.raw_without_comment = line.str // save the origial string with the annotation just in case it needs to be used later + line.annotation = annotation || '' // if an annotation was found then set the name of the annotation + line.raw_annotation = !!annotation ? `${language.prefix}${annotation}` : '' // set the raw annotation with the prefix + line.alias = alias || '' // if an alias was used the save it + line.has_annotation = true + return '' + }) + + return line } - return this.parse() + return this.map({ header, body }, (token) => { + let { comment, code, inline } = token + + // find lines that have annotations and set the correct annotation if an alias is found + comment.contents = to.map(comment.contents, hasAnnotation) + + comment.contents = new Lines(comment.contents) + code.contents = new Lines(code.contents) + + // get the annotations that are in the comment + const annotations = new Annotations(comment.contents.raw, language.prefix) + + return { comment, code, inline, annotations } + }) } - parse() { - let tokens = tokenizer(this) + parseTokens(tokens) { + const { log } = this.options + const file = this.file + + return this.map(tokens, (token) => { + if (is.empty(token)) return token + const { annotations, ...base } = token + token.parsed = to.reduce(annotations, (result, annotation) => { + const current = this.api.run('parse', { annotation, ...base, file, log }) + if (result != null) { + return to.merge(result, { + [annotation.name]: current + }) + } + }, {}) + + return token + }) } - replaceAliases() { - let comment_types = to.flatten([ - ...to.values(this.language.header, '!type', '!end'), - ...to.values(this.language.body, '!type', '!end') - ]) - .filter(Boolean) - .map((comment_type) => '\\' + comment_type.split('').join('\\')) // this escapes every character (aka `/**` ==> `\\/\\*\\*`) - comment_types = `(?:${comment_types.join('|')})` - let block_comment = `(?:^(?:\\s*${comment_types})?\\s*)` - let inline_comment = `(?:${comment_types}?${this.language.inline_prefix}\\s+)` - let comment_regex = `((?:${block_comment}|${inline_comment})${this.language.prefix})` + autofillTokens(tokens) { + const { log } = this.options + const file = this.file + const autofill_list = to.keys(this.api.annotations.autofill) + + return this.map(tokens, (token) => { + const base = { file, log, ...token } + const parsed_keys = to.keys(token.parsed) + for (let name of autofill_list) { + if (!is.in(parsed_keys, name)) { + const result = this.api.run('autofill', { name }, base) + if (result != null) { + token.parsed[name] = result + } + } + } + + return token + }) + } - let alias_obj = to.reduce(this.annotations.alias, (previous, { key, value }) => { - value = value - .filter((alias) => !is.in(this.annotations.main, alias)) - .reduce((a, b) => to.extend(a, { [b]: key }), {}) - return to.extend(previous, value) - }, {}) + resolveTokens(tokens) { + const { log, sort } = this.options + const file = this.file + let resolve_list = to.keys(this.api.annotations.resolve) + // sort the parsed object before the annotations are resolved + if (is.fn(sort)) { + resolve_list = to.sort(resolve_list, sort) + } - const alias_list_regex = new RegExp(`${comment_regex}(${to.keys(alias_obj).join('|')})\\b`, 'gm') + return this.map(tokens, (token) => { + const keys = to.keys(token.parsed) + const list = resolve_list.filter((name) => is.in(keys, name)) + for (let name of list) { + const result = this.api.run('resolve', { name, ...token, file, log, }) + if (result != null) { + token.parsed[name] = result + } + } + return token + }) + } +} + + +class Annotations { + constructor(lines) { + this.annotations = [] + this.stash = lines + this.iterator = to.entries(this.stash) + this.index = 0 + this.getAnnotations() + return this.annotations + } + + peak(amount = 1) { + return this.stash[this.index + amount] + } + + next() { + const obj = this.iterator.next().value + if (!obj) return false + this.index = obj[0] + this.line = obj[1] + return true + } + + hasNext() { + return !!this.peak() + } + + getAnnotations() { + this.next() + this.annotation = new Annotation(this.line) + // console.log(this.line) + if (this.hasNext() && !this.peak().has_annotation) { + this.next() + this.getContent() + } + + this.pushAnnotation() + this.annotation = undefined + + if (this.hasNext()) { + return this.getAnnotations() + } + + return this.annotations + } + + pushAnnotation() { + let { contents, start, end, ...rest } = this.annotation + + // line.str = to.normalize(`${line}`) + let { content, leading, trailing } = to.normalize(contents.join('\n'), { info: true }) + + trailing += contents.length + content = to.array(content) + if (is.empty(content)) { + contents = [] + } else { + contents = contents + .filter((a, i) => i >= leading && i < trailing) // filter out the lines that were removed + .map((_line, i) => { + _line.str = content[i] // update the lines content to be the normalized version + return _line + }) + } + + start = (contents[0] || {}).lineno || start || -1 // get the starting line of the comment + end = (contents.slice(-1)[0] || {}).lineno || end || start || -1 // get the end line of the comment + contents = new Lines(contents) + this.annotations.push({ contents, start, end, ...rest }) + } + + getContent() { + // console.log(this.line) + this.annotation.contents.push(this.line) + if (this.hasNext() && !this.peak().has_annotation) { + this.next() + return this.getContent() + } + } +} + +class Annotation { + constructor(line) { + const { annotation: name, alias, lineno: start } = line + return { + name, // sets the current annotation name + alias, + contents: [ line ], + start, + end: 0 + } + } +} - this.file.contents.replace(alias_list_regex, (match, comment_match, alias) => comment_match + alias_obj[alias]) +class Lines { + constructor(lines) { + this.lines = to.array(to.string(lines)) + this.lines.raw = lines + return this.lines } } From 791042cc3bc5849544767cc2d7114be6d8503bb9 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:17:18 -0400 Subject: [PATCH 253/273] Updated the tokenizer to use `line.str` instead of `line.line` This change was to improve readability --- app/new-parser/tokenizer.js | 44 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index 8ffc723..4cc1149 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -306,9 +306,9 @@ export default class Tokenizer { !line.index.start && line.index.end ) { - line.line = `${line}`.slice(line.index.end + this.options.comment.end.length + 1) + line.str = `${line}`.slice(line.index.end + this.options.comment.end.length + 1) } else { - line.line = `${line}`.slice(1, line.index.start || line.index.single || line.index.end || undefined) + line.str = `${line}`.slice(1, line.index.start || line.index.single || line.index.end || undefined) } @@ -322,10 +322,10 @@ export default class Tokenizer { if ( this.hasNext() && - debug.ifTrue(!this.is_same_multi || !line.has_comment, `the current line(${line.lineno}) doesn't have a comment: ${clor.bgGreen(line)}`) + debug.ifTrue(!this.is_same_multi || !line.has_comment, `the current line(${line.strno}) doesn't have a comment: ${clor.bgGreen(line)}`) ) { const next_line = this.peak() - const next_msg = `the next line(${next_line.lineno}) has a comment: ${clor.bgRed(next_line)}` + const next_msg = `the next line(${next_line.strno}) has a comment: ${clor.bgRed(next_line)}` return debug.ifFalse(!next_line.has_comment, next_msg) && this.next() && recursiveCode() } } @@ -342,14 +342,14 @@ export default class Tokenizer { const debug = this.debugGetSingleComment const { comment } = this.options let line = to.clone(this.line) - line.line = this.getAfter(comment.single, `${line}`) + line.str = this.getAfter(comment.single, `${line}`) this.token.comment.contents.push(line) - const current_msg = `the current line(${line.lineno}) doesn't have code: ${clor.bgGreen(line)}` + const current_msg = `the current line(${line.strno}) doesn't have code: ${clor.bgGreen(line)}` if (debug.ifTrue(!line.has_code, current_msg) && this.hasNext()) { const next_line = this.peak() const context = next_line.has_code ? 'has code' : 'is empty' - const next_msg = `the next line(${next_line.lineno}) ${context}: ${clor.bgRed(next_line)}` + const next_msg = `the next line(${next_line.strno}) ${context}: ${clor.bgRed(next_line)}` this.next() return debug.ifFalse(next_line.has_comment && !next_line.has_code, next_msg, true) && this.getSingleComment() @@ -381,17 +381,17 @@ export default class Tokenizer { } } - line.line = str + line.str = str this.token.comment.contents.push(line) debug.push(line) if (this.hasNext()) { - if (debug.ifTrue(!line.index.end, `the current line(${line.lineno}) wasn't the last comment: ${clor.bgGreen(this.line)}`)) { + if (debug.ifTrue(!line.index.end, `the current line(${line.strno}) wasn't the last comment: ${clor.bgGreen(this.line)}`)) { debug.run() return this.next() && this.getMultiComment() } const next = this.peak() if ( - debug.ifTrue(!line.index.code, `the current line(${line.lineno}) doesn't has code: ${clor.bgGreen(line)}`) && + debug.ifTrue(!line.index.code, `the current line(${line.strno}) doesn't has code: ${clor.bgGreen(line)}`) && debug.ifTrue(!next.has_comment, `the next line(${next.lineno}) doesn't have a comment: ${clor.bgGreen(next)}`) ) { debug.run() @@ -427,7 +427,7 @@ export default class Tokenizer { obj.contents = obj.contents .filter((line, i) => i >= leading && i < trailing) // filter out the lines that were removed .map((line, i) => { - line.line = lines[i] // update the lines content to be the normalized version + line.str = lines[i] // update the lines content to be the normalized version return line }) @@ -438,11 +438,7 @@ export default class Tokenizer { return obj } - - // obj.raw_contents = content.split('\n') - // @todo uncomment these lines after everything setup and working if (!this.options.verbose) { - // obj.raw_contents = obj.contents obj.contents = content.split('\n') } @@ -518,27 +514,19 @@ class Token { class Line { constructor(...args) { args = to.arguments({ - line: '', + str: '', lineno: '' }, ...args) to.extend(this, args) - this.raw = this.line - this.indent = to.indentLevel(this.line) + this.raw = this.str + this.indent = to.indentLevel(this.str) } get length() { - return this.line.length + return this.str.length } toString() { - return this.line - } - - get str() { - return this.line - } - - get string() { - return this.line + return this.str } } From 62b2bd048bc6b8951cdbd67c1d98e3cf03b4e1ba Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:18:06 -0400 Subject: [PATCH 254/273] added an `offset` option to the tokenizer This allows you to specify an offset for the lineno if needed. --- app/new-parser/tokenizer.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/new-parser/tokenizer.js b/app/new-parser/tokenizer.js index 4cc1149..5f82a26 100644 --- a/app/new-parser/tokenizer.js +++ b/app/new-parser/tokenizer.js @@ -31,6 +31,7 @@ export default class Tokenizer { restrict: !is.undefined(this.options.restrict) ? this.options.restrict : false, // determins if the code below should stop parsing if the indent level is less than the starting indent level indent: !is.undefined(this.options.indent) ? this.options.indent : true, + offset: 0, }, arguments) @@ -410,9 +411,17 @@ export default class Tokenizer { /// determin the starting and ending point for the comment and code. pushToken() { const debug = this.debugPushToken + const { offset } = this.options let token = to.clone(this.token) const normalizeContent = (obj, set_start_end_before = false) => { + if (is.number(offset) && offset > 0) { + obj.contents = to.map(obj.contents, (line) => { + line.lineno += offset + return line + }) + } + // normalize the contents of the obj let { content, leading, trailing } = to.normalize(obj.contents.join('\n'), { info: true }) let lines = to.array(content) From 8b5f84144e574c1a7636d3ad31cdbff0c8111e86 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:18:34 -0400 Subject: [PATCH 255/273] updated the markdown funtion to always convert the argument to a string. --- app/utils/to.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/to.js b/app/utils/to.js index 98466e3..4d1796e 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -12,7 +12,7 @@ let to = { /// 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, + markdown: (arg) => markdown(to.string(arg)), ...changeCase, From d614d0f6d3c545959bb2db4f7106acb51506e083 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:20:38 -0400 Subject: [PATCH 256/273] Updated the config to use better options for the inline-comment option This makes it more flexible --- app/config.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/config.js b/app/config.js index c97305f..fb68098 100644 --- a/app/config.js +++ b/app/config.js @@ -56,9 +56,6 @@ export const default_options = { // need to be changed it should be changed to be a special character. prefix: '@', - // @todo add support for this single line prefix for comments inside of the code below the comment block - inline_prefix: '#', - // header comment style // @note {10} only 1 of these can be used per file header: { start: '////', line: '///', end: '////', type: 'header' }, @@ -66,6 +63,9 @@ export const default_options = { // body comment style body: { start: '', line: '///', end: '', type: 'body' }, + // @todo add support for this single line prefix for comments inside of the code below the comment block + inline: { start: '', line: '///#', end: '', type: 'inline' }, + // this is used for any interpolations that might occur in annotations. // I don't see this needing to change but just incase I'm making it a setting. // @note {10} This setting is used to create a RegExp so certain characters need to be escaped @@ -76,23 +76,28 @@ export const default_options = { }, css: { header: { start: '/***', line: '*', end: '***/' }, - body: { start: '/**', line: '*', end: '**/' } + body: { start: '/**', line: '*', end: '**/' }, + inline: { start: '/**#', line: '', end: '**/' } }, 'rb, py, coffee, sh, bash, pl': { header: { start: '###', line: '##', end: '###' }, - body: { line: '##' } + body: { line: '##' }, + inline: { line: '##$' } }, 'html, md, markdown, mark, mdown, mkdn, mdml, mkd, mdwn, mdtxt, mdtext, text': { header: { start: '' }, - body: { start: '' } + body: { start: '' }, + inline: { start: '' } }, jade: { header: { start: '//-//', line: '//-/', end: '//-//' }, - body: { line: '//-/' } + body: { line: '//-/' }, + inline: { line: '//-#' } }, cfm: { header: { start: '' }, - body: { start: '' } + body: { start: '' }, + inline: { start: '' } } }, From 6a3334c534c80605767d1f74bcd88b93e341310b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:20:51 -0400 Subject: [PATCH 257/273] added the indent option --- app/config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/config.js b/app/config.js index fb68098..2050cc9 100644 --- a/app/config.js +++ b/app/config.js @@ -37,6 +37,9 @@ export const default_options = { warning: true, timestamps: true, + // stop adding code to the token.code.contents if the indent is less than the starting line indent + indent: true, + // this will return the raw data by file, aka data won't be sorted raw: false, From d5538b8515c224e306bcf38cfc3cfa42d064d36e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:22:09 -0400 Subject: [PATCH 258/273] added a property annotation --- app/annotations/index.js | 3 ++- app/annotations/property.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/annotations/property.js diff --git a/app/annotations/index.js b/app/annotations/index.js index c66c0b1..99114d0 100644 --- a/app/annotations/index.js +++ b/app/annotations/index.js @@ -11,7 +11,7 @@ export markup from './markup' export name from './name' export note from './note' export page from './page' -module.exports.type = require('./type') +export property from './property' module.exports['raw-code'] = require('./raw-code.js') export readonly from './readonly' export requires from './requires' @@ -20,4 +20,5 @@ 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/property.js b/app/annotations/property.js new file mode 100644 index 0000000..695fbc5 --- /dev/null +++ b/app/annotations/property.js @@ -0,0 +1,33 @@ +import { markdown, regex, list } from './annotation-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 [ + types = [], + name = '', + value = '', + description = '', + ] = regex('property', this.annotation.line) + + return [ + { + types: list(types), + name, + value, + description: markdown(description, this.annotation.contents) + } + ] + } +} From 8aea52851f9c5e836fac4e44b28f4d841a6d36a7 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:23:05 -0400 Subject: [PATCH 259/273] Updated annotation regexes to be better because they're being reused --- app/annotations/annotation-utils.js | 38 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/app/annotations/annotation-utils.js b/app/annotations/annotation-utils.js index b2a383d..48bee69 100644 --- a/app/annotations/annotation-utils.js +++ b/app/annotations/annotation-utils.js @@ -14,21 +14,29 @@ let regexes const id = '(?:\\((.*)\\))?' const description = '(?:\\s*\\-?\\s+)?(.*)?' - regexes = { - arg: new RegExp(types + space + name + space + value + space + description, 'i'), - deprecated: new RegExp(types + space + description, 'i'), - markup: new RegExp(id + space + types + space + value + space + description, 'i'), - note: new RegExp(types + space + description, 'i'), - throws: new RegExp(types + space + description, 'i'), - requires: new RegExp(types + space + name + description, 'i'), - returns: new RegExp(types + space + description, 'i'), - since: new RegExp(types + space + description, 'i'), - state_id: new RegExp(`${id}${space}(.*)`, 'i'), - state: new RegExp(types + space + value + space + description, 'i'), - todo: new RegExp(types + space + value + space + description, 'i'), - type: new RegExp(types + space + description, 'i'), - version: new RegExp(types + space + description, 'i'), - } + let rg = {} + + rg.arg = + rg.property = new RegExp(types + space + name + space + value + space + description, 'i') + + rg.markup = new RegExp(id + space + types + space + value + space + description, 'i') + + rg.deprecated = + rg.note = + rg.throws = + rg.returns = + rg.since = + rg.type = + rg.version = new RegExp(types + space + description, 'i') + + rg.requires = new RegExp(types + space + name + description, 'i') + + rg.state_id = new RegExp(`${id}${space}(.*)`, 'i') + + rg.state = + rg.todo = new RegExp(types + space + value + space + description, 'i') + + regexes = rg } export function regex(name, str) { From 3bdf48ac4289ed42bd8d015224d97577bfb93bc4 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:23:24 -0400 Subject: [PATCH 260/273] updated eslint to include the `#` for inline commits --- .eslintrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index 77371a3..20e9d15 100644 --- a/.eslintrc +++ b/.eslintrc @@ -193,8 +193,8 @@ 2, "always", { - "line": { "markers": [ "/", "#" ], "exceptions": [ "-", "+", "/", "#" ] }, - "block": { "markers": [ "!" ], "exceptions": [ "*" ] } + "line": { "markers": [ "/", "/#" ], "exceptions": [ "-", "+", "/", "#" ] }, + "block": { "markers": [ "!", "*#" ], "exceptions": [ "*", "#" ] } } ], "valid-typeof": 2, From 2b208cf1d0c09df182d28ee5855cc145f2587f4f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 10:28:33 -0400 Subject: [PATCH 261/273] removed extra console.logs --- app/new-parser/index.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/app/new-parser/index.js b/app/new-parser/index.js index a001e12..9bd3f93 100644 --- a/app/new-parser/index.js +++ b/app/new-parser/index.js @@ -1,11 +1,7 @@ import { fs, is, to, Logger } from '../utils' import AnnotationApi from '../new-annotation-api' import path from 'path' -// import getBlocks from '../../get-blocks' -// import parseBlocks from '../parser/parse-blocks' -// import getConfig from '../config' import Tokenizer from './tokenizer' -// import clor from 'clor' export default class Parser { constructor(options) { // eslint-disable-line @@ -74,11 +70,6 @@ export default class Parser { tokens = this.parseTokens(tokens) tokens = this.autofillTokens(tokens) tokens = this.resolveTokens(tokens) - // console.log('') - // console.log('') - // console.log('') - // console.log('') - console.log(to.json(tokens)) return tokens } @@ -248,7 +239,7 @@ class Annotations { getAnnotations() { this.next() this.annotation = new Annotation(this.line) - // console.log(this.line) + if (this.hasNext() && !this.peak().has_annotation) { this.next() this.getContent() @@ -266,8 +257,6 @@ class Annotations { pushAnnotation() { let { contents, start, end, ...rest } = this.annotation - - // line.str = to.normalize(`${line}`) let { content, leading, trailing } = to.normalize(contents.join('\n'), { info: true }) trailing += contents.length @@ -290,7 +279,6 @@ class Annotations { } getContent() { - // console.log(this.line) this.annotation.contents.push(this.line) if (this.hasNext() && !this.peak().has_annotation) { this.next() From 610499198a046fa94aa133e479530cf30c79d1e2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 12:53:17 -0400 Subject: [PATCH 262/273] Removed the old parser --- app/annotation-api.js | 289 ---------------------------------- app/parser/autofill.js | 20 --- app/parser/get-blocks.js | 197 ----------------------- app/parser/index.js | 86 ---------- app/parser/parse-blocks.js | 155 ------------------ app/parser/replace-aliases.js | 36 ----- app/parser/resolve.js | 24 --- 7 files changed, 807 deletions(-) delete mode 100644 app/annotation-api.js delete mode 100644 app/parser/autofill.js delete mode 100644 app/parser/get-blocks.js delete mode 100644 app/parser/index.js delete mode 100644 app/parser/parse-blocks.js delete mode 100644 app/parser/replace-aliases.js delete mode 100644 app/parser/resolve.js diff --git a/app/annotation-api.js b/app/annotation-api.js deleted file mode 100644 index b504be1..0000000 --- a/app/annotation-api.js +++ /dev/null @@ -1,289 +0,0 @@ -'use strict' - -import { is, to } from './utils' - -export default class AnnotationApi { - constructor(annotations) { - // 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 - // } - } - - // add the inital annotations - this.addAnnotations(annotations) - } - - /// @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 - /// 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'], - /// parse: 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 `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: 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 - /// parse: 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 - parse() { - 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 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 - } - - // 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, ...to.keys(base_config))) { - // 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') - 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) { - if (base_config.filetypes.hasOwnProperty(filetype)) { - 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 - 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(filetype, type) { - let list = this.annotations.default - if (!is.undefined(this.annotations[filetype])) { - list = to.extend(to.clone(this.annotations.default), this.annotations[filetype]) - } - - if (is.undefined(type)) { - return list - } - - return to.map(list, ({ key: name, value: annotation }) => { - if (is.truthy(annotation[type]) && !is.empty(annotation[type])) { - return { [name]: annotation[type] } - } - - return false - }) - } - - lists(filetype) { - return to.reduce([ 'alias', 'autofill', 'resolve' ], (previous, current) => { - return to.extend(previous, { - [current]: this.list(filetype, current) - }) - }, { main: this.list(filetype) }) - } - - /// @name run_annotation - /// @access private - /// @arg {object} annotation - the information for the annotation to be called(name, line, content, start, end) - run(options) { - let { - annotation, - annotation_types, - block = {}, - file, - log - } = 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(annotation_types.alias, name) ? annotation_types.alias[name] : [], - line: to.normalize(contents[0]), - contents, - start: null, - end: null - }, - annotation_types, - ...block, - log - }) - } - - // removes the first line because it's the `line` of the annotation - annotation.contents.shift() - - // normalizes the current annotation contents - annotation.contents = to.normalize(annotation.contents) - - // normalizes the current annotation line - annotation.line = to.normalize(annotation.line) - - // Merges the data together so it can be used to run all the annotations - let result = { - // sets the annotation block information to be in it's own namespace of `annotation` - annotation, - - // adds the comment, code, and file information - ...block, - - add, - - // adds the ability to add logging information - log - } - - // a) add the default annotation function to the object so it can be called in the file specific annotation functions if needed - if (is.all.truthy((this.file_list[file.type] || {})[annotation.name], ((this.file_list.default || {})[annotation.name]) || {}).parse) { - result.default = this.file_list.default[annotation.name].parse.call(result) - } - - return annotation_types.main[annotation.name].parse.call(result) - } - - /// @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) { - 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/parser/autofill.js b/app/parser/autofill.js deleted file mode 100644 index 49e5b19..0000000 --- a/app/parser/autofill.js +++ /dev/null @@ -1,20 +0,0 @@ -import { is, to } from '../utils' - -// @name autofill -// @access private -// @description -// This function is used to run the all the functions that autofill if not defined. -export default function autofill({ list, parsed, block/* , log */ }) { - let parsed_keys = to.keys(parsed) - - for (let [ annotation, annotation_autofill ] of to.entries(list)) { - if (!is.in(parsed_keys, annotation)) { - const result = is.fn(annotation_autofill) ? annotation_autofill.call(block) : annotation_autofill - if (result != null) { - parsed[annotation] = result - } - } - } - - return parsed -} diff --git a/app/parser/get-blocks.js b/app/parser/get-blocks.js deleted file mode 100644 index 8e7bfc0..0000000 --- a/app/parser/get-blocks.js +++ /dev/null @@ -1,197 +0,0 @@ -/* eslint-disable complexity, max-statements, max-depth */ -import { is, to } from '../utils' - -/// @name blocks -/// @access private -/// @description Parses the file and returns the comment blocks in an array -/// @returns {array} of the comment blocks -/// @todo {5} - add a line offest argument to this so that you can call parse content on other language types. -export default function getBlocks({ - file, - comment, - restrict = true, - blank_lines, - start_at = 0 -}) { - start_at = to.number(start_at) - - let style = is.all.truthy(comment.start, comment.end) ? 'multi' : 'single' - - // this ensures there aren't any errors looking comment lines - // because `''` will always have an index of `0` - if (comment.line === '') { - comment.line = undefined - } - - let block_base = { - comment: { contents: [], start: -1, end: -1, type: comment.type }, - code: { contents: [], start: -1, end: -1 }, - file - } - - let lines = to.array(file.contents) // lines of the file - let parsed = [] // holds the parsed blocks - let current_blank_lines = 0 // stores the current count of blank lines - let block // stores the current block - let in_comment = false // used to determin that you are in a comment - let in_code = false // used to determin if you are in the code after the comment block - - if (style === 'multi' ? !is.all.in(file.contents, comment.start, comment.end) : !is.in(file.contents, comment.line)) { - return [] - } - - // used for debuging files. to debug a file just change this to false - // @note THIS SHOULD NEVER BE COMMITTED AS `TRUE` - let debug_file = false - function debug(...args) { - if (debug_file && args.length > 0) { - console.log(...args) - } - return debug_file - } - - - function pushBlock(block_to_push) { - block_to_push.comment.contents = to.normalize(block_to_push.comment.contents) - block_to_push.code.contents = to.normalize(block_to_push.code.contents) - parsed.push(block_to_push) - } - - for (let i = start_at, l = lines.length; i < l; i++) { - // If you're trying to debug something between specific lines you - // can use this to narrow down the longs to the lines you're wanting debug - // just pass in the starting line number and end line number both should be 1 - // less that what you're looking for since this is zero based. - // debug = is.between(i, [start line], [end line]) - debug_file = debug_file && is.between(i, 0, 8) - let line = lines[i] - let index = { - start: style === 'multi' && is.in(line, comment.start) ? line.indexOf(comment.start) : false, - line: is.in(line, comment.line) ? line.indexOf(comment.line) : false, - end: style === 'multi' && is.in(line, comment.end) ? line.indexOf(comment.end) : false - } - - debug('') - debug('') - debug(`line ${i}:`) - debug(line) - debug('index:', index) - - // a) The line isn't empty so parse it. - if (!is.empty(line)) { - // reset the current blank line count back to 0 because this line wasn't empty - current_blank_lines = 0 - - // a) is the start and end style or there was an instance of a comment line - if (style === 'multi' && (index.start !== false || in_comment) || index.line !== false) { - // a) is the start of a new block - if (index.start !== false || (style !== 'multi' && !in_comment)) { - debug('start of new block') - // reset code to false - in_code = false - - // a) There was block that has already been processed - if (!is.undefined(block)) { // holds the current block information - block.code.end = i - 1 - pushBlock(block) - - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if (restrict) { - block.comment.end = i - block.code.end = -1 - return parsed - } - } - - // reset the `block` to use on the new block - block = to.clone(block_base) - block.comment.start = i - - in_comment = true - } - - // check for the end comment - if ( - block && - style === 'multi' && - block.comment.start !== i && - index.end !== false - ) { - debug('is end comment') - in_comment = false - block.comment.end = i // sets the end line in the comment block - i++ // skips end comment line - line = lines[i] // updates to be the next line - index.end = (line && is.in(line, comment.end)) ? line.indexOf(comment.end) : false - } - - // a) adds this line to block comment contents - if (in_comment && (index.start === false || index.end === false)) { - // a) removes the `comment.line` from the line. - if (index.line !== false) { - line = line.slice(index.line + comment.line.length) - } else if (index.start !== false) { - line = line.slice(index.start + comment.start.length) - } - - if (!is.empty(line)) { - debug('line was pushed') - block.comment.contents.push(line) - } - } - - // a) The last line in the file is a commment - if (in_comment && (style === 'multi' && index.end !== false ? i === l : i === l - 1)) { - debug('the last line in the file is a comment') - block.comment.end = style === 'multi' ? i - 1 : i - pushBlock(block) - break // ensures that the loop stops because it's the last line in the file - } - - // a) check the next line for an instance of the a line comment - if (style !== 'multi' && !is.in(lines[i + 1], comment.line)) { - in_comment = false - block.comment.end = i // sets the end line in the comment block - i++ // skips end comment line // @todo why does this need to be skipped? - line = lines[i] // updates to be the next line - } - } - - // a) add code to current block - if (!in_comment && index.end === false && !is.undefined(block)) { - // Stops the loop after the first comment block - // has been parsed. This is for file header comments - if (restrict) { - pushBlock(block) - break - } - // a) The previous line was a comment - if (!in_code) { - in_code = true - block.code.start = i - } - - // adds this line to block code contents - block.code.contents.push(line) - - // a) pushes the last block onto the body - if (i === l - 1) { - block.code.end = i - pushBlock(block) - } - } - } else if ( - !is.undefined(block) && ( - ++current_blank_lines === blank_lines || // there were 4 consecutive blank lines so the code is skipped - i === l - 1 && is.truthy(block) // the last line in the file was an empty line. - ) - ) { - block[block.comment.end > -1 ? 'code' : 'comment'].end = i - pushBlock(block) - block = undefined - } - } // end loop - - return parsed -} diff --git a/app/parser/index.js b/app/parser/index.js deleted file mode 100644 index 803b2f5..0000000 --- a/app/parser/index.js +++ /dev/null @@ -1,86 +0,0 @@ -import { info, fs, is, to } from '../utils' -import path from 'path' -import getBlocks from './get-blocks' -import parseBlocks from './parse-blocks' -import replaceAliases from './replace-aliases' -import clor from 'clor' - -export default async function parser(file_path, { - languages, - annotations, - blank_lines, - sort, - log -}) { - // the filetype of the current file - const type = path.extname(file_path).replace('.', '') - - // gets the comments to use on this file - const options = languages[type] ? languages[type] : languages.default - - const contents = '\n' + to.normalString(await fs.readFile(file_path)) - - let file = { - contents, // all of the contents of the file - path: path.join(info.dir, path.relative(info.root, file_path)) || file_path, // path of the file - name: path.basename(file_path, `.${type}`), // name of the file - type, // filetype of the file - options, - start: 1, // starting point of the file - end: to.array(contents).length - 1 // ending point of the file - } - - file.contents = replaceAliases({ file, annotations }) - - // a) The file doesn't contain any header level comments, or body level comments - if ( - !is.any.in( - file.contents, - ...to.values(file.options.header).slice(0, -1), - ...to.values(file.options.body).slice(0, -1) - ) - ) { - log.emit('warning', `Well shitfire, ${clor.bold(file.path)} doesn't contain any sweet documentation`) - return [] - } - - let header = getBlocks({ - file, - blank_lines, - comment: file.options.header - }) - - let body = getBlocks({ - file, - blank_lines, - comment: file.options.body, - restrict: false, - start_at: !is.empty(header) ? header[0].comment.end + 1 : 0 - }) - - header = parseBlocks({ - file, - blocks: header, - annotations, - sort, - log - })[0] || {} - - body = parseBlocks({ - file, - blocks: body, - annotations, - sort, - log - }) - - return { - [file.path]: { header, body } - } -} - -export { - getBlocks, - parseBlocks, - replaceAliases -} diff --git a/app/parser/parse-blocks.js b/app/parser/parse-blocks.js deleted file mode 100644 index 4601b85..0000000 --- a/app/parser/parse-blocks.js +++ /dev/null @@ -1,155 +0,0 @@ -import { is, to } from '../utils' -import autofill from './autofill' -import resolve from './resolve' - -// @name parsed_blocks -// @access private -// @description -// Used to parse an array of blocks and runs the annotations function and returns the result -// @arg {array} - The block/blocks you want to have parsed -// @returns {array} of parsed blocks -export default function parseBlocks({ - file, - blocks, - annotations, - sort, - log -}) { - if (is.empty(blocks)) { - return [] - } - - let parsed_blocks = [] - - let annotation_types = annotations.lists(file.type) - - // sort the parsed object before the annotations are resolved - if (is.fn(sort)) { - annotation_types.resolve = to.sort(annotation_types.resolve, sort) - } - - // loop over each block - for (let block of blocks) { - block.comment.contents = to.normalize(block.comment.contents) - block.code.contents = to.normalize(block.code.contents) - - let parsed = parseBlock({ - annotations, - annotation_types, - block, - file, - log - }) - - // run the autofill functions for all the annotations that have a autofill function - parsed = autofill({ list: annotation_types.autofill, parsed, block, log }) - - if (!is.empty(parsed)) { - // run the resolve function for all the annotations that have a resolve function - parsed = resolve({ list: annotation_types.resolve, parsed, block, log }) - parsed_blocks.push(parsed) - } - } // end blocks loop - - return parsed_blocks -} - - -// @name parseBlock -// @description -// This parses the content passed to it seperates out each annotation -// parses and figures out the annotation line, and the content after it. -// Then once it has all the information it calls the annotation function(the annotation one it found) -// for this file type or the default function. -// @arg {object} - The blocks to parse -function parseBlock(options = {}) { - let { - annotations, - annotation_types, - block, - file, - log - } = options - - let keys = to.keys(annotation_types.main) - - let contents = to.array(block.comment.contents) - let block_annotations = {} - let annotation = {} // holds the current annotation - - // loop over each line in the comment block - for (let i = 0, l = contents.length; i < l; i++) { - let line = contents[i] - let prefix_index = -1 - - if ( - !is.any.in( - line, - `${file.options.header.line} ${file.options.prefix}`, - `${file.options.body.line} ${file.options.prefix}`, - `\\${file.options.prefix}` - ) - ) { - prefix_index = line.indexOf(file.options.prefix) - } - - - // a) there is an index of the annotation prefix - if (prefix_index >= 0) { - let first_space = line.indexOf(' ', prefix_index) - let name = line.slice(prefix_index + 1, first_space >= 0 ? first_space : line.length) - - // a) the name is one of the annotation names - if (keys.indexOf(name) >= 0) { - // a) parse the current annotation - if (!is.empty(annotation)) { - annotation.end = i - 1 - - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [annotation.name]: annotations.run({ - annotation, - annotation_types, - block, - file, - log - }) - }) - } - - // redefines resets the current annotation to be blank - annotation = { - name, // sets the current annotation name - line: line.slice(prefix_index + 1 + name.length), // removes the current annotation name and it's prefix from the first line - alias: is.in(annotation_types.alias, name) ? annotation_types.alias[name] : [], - contents: [], - start: i, // sets the starting line of the annotation - end: 0 - } - } - } - - // a) adds the current line to the contents - if (!is.empty(annotation)) { - annotation.contents.push(line) - } - - // a) is the last line in the comment block - if (i === l - 1 && !is.empty(annotation)) { - annotation.end = i - - // run the annotation function and merge it with the other annotations in the block - to.merge(block_annotations, { - [annotation.name]: annotations.run({ - annotation, - annotation_types, - block, - file, - log - }) - }) - } - } // end block loop - - return block_annotations -} diff --git a/app/parser/replace-aliases.js b/app/parser/replace-aliases.js deleted file mode 100644 index a7f6845..0000000 --- a/app/parser/replace-aliases.js +++ /dev/null @@ -1,36 +0,0 @@ -import { is, to } from '../utils' - -/// @name aliases -/// @access private -/// @description -/// This function is used to replace all instances of aliases in a file -/// @returns {string} - The file with the instances of aliases removed -export default function aliases(options = {}) { - let { file, annotations } = options /* , log */ - - let main_annotation_list = to.keys(annotations.list(file.type)) - - let comment_types = [ - to.values(file.options.header, '!type', '!end'), - to.values(file.options.body, '!type', '!end') - ] - - comment_types = to.flatten(comment_types) - .filter(Boolean) - .map((comment_type) => '\\' + comment_type.split('').join('\\')) - comment_types = `(?:${comment_types.join('|')})` - let block_comment = `(?:^(?:\\s*${comment_types})?\\s*)` - let inline_comment = `(?:${comment_types}?${file.options.inline_prefix}\\s+)` - let comment_regex = `((?:${block_comment}|${inline_comment})${file.options.prefix})` - - let alias_obj = to.reduce(annotations.list(file.type, 'alias'), (previous, { key, value }) => { - value = value - .filter((alias) => !is.in(main_annotation_list, alias)) - .reduce((a, b) => to.extend(a, { [b]: key }), {}) - return to.extend(previous, value) - }, {}) - - const alias_list_regex = new RegExp(`${comment_regex}(${to.keys(alias_obj).join('|')})\\b`, 'gm') - - return file.contents.replace(alias_list_regex, (match, comment_match, alias) => comment_match + alias_obj[alias]) -} diff --git a/app/parser/resolve.js b/app/parser/resolve.js deleted file mode 100644 index b782794..0000000 --- a/app/parser/resolve.js +++ /dev/null @@ -1,24 +0,0 @@ -import { is, to } from '../utils' - -// @name autofill -// @access private -// @description -// This function is used to run the all the functions that autofill if not defined. -export default function resolve({ list, parsed, block, log }) { - let parsed_keys = to.keys(parsed) - - for (let [ annotation, annotation_resolve ] of to.entries(list)) { - if (is.in(parsed_keys, annotation)) { - let result = annotation_resolve - if (is.fn(annotation_resolve)) { - result = annotation_resolve.call(parsed[annotation], { parsed, block, log }) - } - - if (result != null) { - parsed[annotation] = result - } - } - } - - return parsed -} From 9aa47fbcf2e27788fd33c29946058c02397e69bc Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 12:54:16 -0400 Subject: [PATCH 263/273] added the new annotation-api --- app/{new-annotation-api.js => annotation-api.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/{new-annotation-api.js => annotation-api.js} (100%) diff --git a/app/new-annotation-api.js b/app/annotation-api.js similarity index 100% rename from app/new-annotation-api.js rename to app/annotation-api.js From 7d88a09811430d73acd7fd94dd365652157b3d93 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 12:55:09 -0400 Subject: [PATCH 264/273] renamed the parser folder --- app/{new-parser => parser}/index.js | 17 ++++++++++------- app/{new-parser => parser}/tokenizer.js | 0 2 files changed, 10 insertions(+), 7 deletions(-) rename app/{new-parser => parser}/index.js (95%) rename app/{new-parser => parser}/tokenizer.js (100%) diff --git a/app/new-parser/index.js b/app/parser/index.js similarity index 95% rename from app/new-parser/index.js rename to app/parser/index.js index 9bd3f93..b88b39d 100644 --- a/app/new-parser/index.js +++ b/app/parser/index.js @@ -91,12 +91,15 @@ export default class Parser { } map({ header, body }, callback) { - const map = (token) => { + const map = (token, parent = {}) => { if (is.empty(token)) return {} - token = callback(token) + if (parent.inline) { + delete parent.inline + } + token = callback(token, parent) if (token.inline && !is.empty(token.inline)) { - token.inline = to.map(token.inline, map) + token.inline = to.map(token.inline, (obj) => map(obj, token)) } return token @@ -149,11 +152,11 @@ export default class Parser { const { log } = this.options const file = this.file - return this.map(tokens, (token) => { + return this.map(tokens, (token, parent) => { if (is.empty(token)) return token const { annotations, ...base } = token token.parsed = to.reduce(annotations, (result, annotation) => { - const current = this.api.run('parse', { annotation, ...base, file, log }) + const current = this.api.run('parse', { annotation, ...base, parent, file, log }) if (result != null) { return to.merge(result, { [annotation.name]: current @@ -170,8 +173,8 @@ export default class Parser { const file = this.file const autofill_list = to.keys(this.api.annotations.autofill) - return this.map(tokens, (token) => { - const base = { file, log, ...token } + return this.map(tokens, (token, parent) => { + const base = { ...token, parent, file, log } const parsed_keys = to.keys(token.parsed) for (let name of autofill_list) { if (!is.in(parsed_keys, name)) { diff --git a/app/new-parser/tokenizer.js b/app/parser/tokenizer.js similarity index 100% rename from app/new-parser/tokenizer.js rename to app/parser/tokenizer.js From 3b6ec7e10ede032effdc56c6064d2335865d8f9c Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 15:50:40 -0400 Subject: [PATCH 265/273] added better error handling when calling an annotation --- app/annotation-api.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/annotation-api.js b/app/annotation-api.js index d85ad96..22582b4 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -286,8 +286,15 @@ export default class AnnotationApi { } } - const fn = this.getAnnotationFn(base.annotation.name, fn_name) - let result = is.function(fn) ? fn.call(base) : fn + let result + try { + const fn = this.getAnnotationFn(base.annotation.name, fn_name) + result = is.function(fn) ? fn.call(base) : fn + } catch (e) { + this.log.error(e) + throw new Error(e) + } + return result } From 474fe8620309c90c6d2775426ff538300fb28706 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 15:53:34 -0400 Subject: [PATCH 266/273] Updated the neccissary file to suppor the new parser --- app/config.js | 3 --- app/docs.js | 29 ++++++++++++++++++++-- app/parser/index.js | 55 ++++++++++++++++++++++++++++++------------ tools/generate-test.js | 2 +- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/app/config.js b/app/config.js index 2050cc9..c7a6ecd 100644 --- a/app/config.js +++ b/app/config.js @@ -2,7 +2,6 @@ import { info, fs, is, to, Logger } from './utils' import path from 'path' import * as annotations from './annotations' -import AnnotationApi from './annotation-api' let log = new Logger() @@ -154,8 +153,6 @@ export default async function config(options = {}) { options.languages = parseLanguages(options.languages) - options.annotations = new AnnotationApi(options.annotations) - options.log = new Logger({ debug: options.debug, warning: options.warning, diff --git a/app/docs.js b/app/docs.js index 87680bc..6b4a373 100644 --- a/app/docs.js +++ b/app/docs.js @@ -7,7 +7,7 @@ import { fs, glob, } from './utils' -import parser from './parser' +import Parser from './parser' import sorter from './sorter' import getConfig from './config' import { map } from 'async-array-methods' @@ -34,6 +34,7 @@ export default async function docs(options = {}) { warning, timestamps, raw, + indent, sort, annotations, watch, @@ -43,6 +44,7 @@ export default async function docs(options = {}) { /* eslint-enable no-unused-vars */ let json = {} + let parsers = {} let ignored let walk = async (files) => { @@ -62,9 +64,26 @@ export default async function docs(options = {}) { log.emit('complete', 'paths', paths_message) log.emit('start', 'parser') - files = await map(files, (file_path) => parser(file_path, options)) + options.annotationsApi = annotations + const parser_options = { blank_lines, indent, annotations, sort, log } + + const parse = async ({ file, type }) => { + return { + [path.join('docs', file)]: await parsers[type].parse(file) + } + } + + files = await map(files, (file) => { + const type = path.extname(file).replace('.', '') + if (!parsers[type]) { + parsers[type] = new Parser(languages[type] || languages.default, type, parser_options) + } + + return parse({ file, type }) + }) + log.emit('complete', 'parser') // Loop through the parsed files and update the @@ -113,3 +132,9 @@ export default async function docs(options = {}) { } }) } + +// Catch uncaught exceptions +process.on('uncaughtException', (err) => { + // handle the error safely + console.log(err) +}) diff --git a/app/parser/index.js b/app/parser/index.js index b88b39d..25b4218 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -1,5 +1,5 @@ import { fs, is, to, Logger } from '../utils' -import AnnotationApi from '../new-annotation-api' +import AnnotationApi from '../annotation-api' import path from 'path' import Tokenizer from './tokenizer' @@ -59,10 +59,11 @@ export default class Parser { file = is.plainObject(file) ? file : { path: file } file.type = file.type || path.extname(file.path).replace('.', '') file.contents = file.contents || to.string(await fs.readFile(file.path)) + file.path = path.join(process.cwd().split(path.sep).pop(), file.path) file.name = path.basename(file.path, `.${file.type}`) // name of the file file.options = this.options.language file.start = 1 // starting point of the file - file.end = to.array(file.contents).length - 1 // ending point of the file + file.end = to.array(file.contents).length // ending point of the file this.file = file let tokens = this.getTokens(file.contents) @@ -70,6 +71,7 @@ export default class Parser { tokens = this.parseTokens(tokens) tokens = this.autofillTokens(tokens) tokens = this.resolveTokens(tokens) + tokens = this.cleanupTokens(tokens) return tokens } @@ -77,7 +79,7 @@ export default class Parser { const { language, blank_lines, indent } = this.options const base = { blank_lines, indent, verbose: true } const header = new Tokenizer(contents, 0, language.header, { restrict: true, ...base })[0] || {} - let body = new Tokenizer(contents, header.comment ? header.comment.end : 0, language.body, base) + let body = new Tokenizer(contents, header.comment ? header.comment.end + 1 : 0, language.body, base) const inline_tokenizer = new Tokenizer({ comment: language.inline, ...base }) body = body.map((token) => { @@ -91,7 +93,7 @@ export default class Parser { } map({ header, body }, callback) { - const map = (token, parent = {}) => { + const map = (token, index, parent = false) => { if (is.empty(token)) return {} if (parent.inline) { delete parent.inline @@ -99,7 +101,7 @@ export default class Parser { token = callback(token, parent) if (token.inline && !is.empty(token.inline)) { - token.inline = to.map(token.inline, (obj) => map(obj, token)) + token.inline = to.map(token.inline, (obj, i) => map(obj, i, token)) } return token @@ -153,10 +155,8 @@ export default class Parser { const file = this.file return this.map(tokens, (token, parent) => { - if (is.empty(token)) return token - const { annotations, ...base } = token - token.parsed = to.reduce(annotations, (result, annotation) => { - const current = this.api.run('parse', { annotation, ...base, parent, file, log }) + token.parsed = to.reduce(token.annotations, (result, annotation) => { + const current = this.api.run('parse', { annotation, ...token, parent, file, log }) if (result != null) { return to.merge(result, { [annotation.name]: current @@ -198,18 +198,41 @@ export default class Parser { resolve_list = to.sort(resolve_list, sort) } - return this.map(tokens, (token) => { - const keys = to.keys(token.parsed) - const list = resolve_list.filter((name) => is.in(keys, name)) - for (let name of list) { - const result = this.api.run('resolve', { name, ...token, file, log, }) - if (result != null) { - token.parsed[name] = result + return this.map(tokens, (token, parent) => { + const base = { ...token, parent, file, log, } + const parsed_keys = to.keys(token.parsed) + for (let name of resolve_list) { + if (is.in(parsed_keys, name)) { + const result = this.api.run('resolve', { name }, base) + if (result != null) { + token.parsed[name] = result + } } } return token }) } + + cleanupTokens(tokens) { + let { header, body } = tokens + let autofill_keys = to.keys(this.api.annotations.autofill) + const cleanup = ({ inline, parsed }) => { + if (!parsed) return {} + if (inline) { + return to.merge(parsed, to.reduce(inline, (prev, next) => { + return to.merge(prev, to.filter(next.parsed, ({ key }) => { + return !is.in(autofill_keys, key) + })) + }, {})) + } + return parsed + } + + header = cleanup(header) + body = to.map(body, cleanup) + + return { header, body } + } } diff --git a/tools/generate-test.js b/tools/generate-test.js index 3b488c3..e645409 100755 --- a/tools/generate-test.js +++ b/tools/generate-test.js @@ -4,7 +4,7 @@ var docs = require('..').default -var Tokenizer = require('../dist/new-parser/tokenizer.js').default +var Tokenizer = require('../dist/parser/tokenizer.js').default var path = require('path') var clor = require('clor') var utils = require('../dist/utils') From d6a27a556f272d45cf6059c1523441e06a7a1b17 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 24 Mar 2016 15:54:54 -0400 Subject: [PATCH 267/273] Updated the annotations and their tests The only thing that really changed for the tests is that there's no more instances of code that just contains blank lines --- app/annotation-api.js | 53 ++++- app/annotations/access.js | 14 +- app/annotations/alias.js | 2 +- app/annotations/annotation-utils.js | 58 +++-- app/annotations/arg.js | 8 +- app/annotations/author.js | 4 +- app/annotations/chainable.js | 9 +- app/annotations/deprecated.js | 9 +- app/annotations/description.js | 4 +- app/annotations/markup.js | 24 +- app/annotations/name.js | 5 +- app/annotations/note.js | 10 +- app/annotations/page.js | 2 +- app/annotations/property.js | 8 +- app/annotations/raw-code.js | 8 +- app/annotations/readonly.js | 2 +- app/annotations/requires.js | 8 +- app/annotations/returns.js | 8 +- app/annotations/since.js | 9 +- app/annotations/states.js | 57 +++-- app/annotations/throws.js | 9 +- app/annotations/todo.js | 13 +- app/annotations/type.js | 8 +- app/annotations/version.js | 11 +- app/parser/index.js | 48 ++-- .../access/access.autofill.body.json | 4 +- tests/annotations/access/access.options.json | 12 +- tests/annotations/alias/alias.json | 12 +- tests/annotations/arg/arg.aliases.json | 12 +- tests/annotations/arg/arg.json | 24 +- tests/annotations/author/author.alias.json | 4 +- tests/annotations/author/author.body.json | 4 +- tests/annotations/author/author.multiple.json | 12 +- tests/annotations/chainable/chainable.json | 28 +-- .../depricated/depricated.body.json | 16 +- .../description/description.alias.json | 48 ++-- .../description/description.body.json | 12 +- tests/annotations/markdown/mark.json | 4 +- tests/annotations/markdown/markdown.json | 4 +- tests/annotations/markdown/md.json | 4 +- tests/annotations/markdown/mdml.json | 4 +- tests/annotations/markdown/mdown.json | 4 +- tests/annotations/markdown/mdtext.json | 4 +- tests/annotations/markdown/mdtxt.json | 4 +- tests/annotations/markdown/mdwn.json | 4 +- tests/annotations/markdown/mkd.json | 4 +- tests/annotations/markdown/mkdn.json | 4 +- tests/annotations/markdown/text.json | 4 +- tests/annotations/name/name.aliases.json | 12 +- tests/annotations/name/name.json | 4 +- tests/annotations/note/note.alias.json | 8 +- tests/annotations/note/note.json | 24 +- tests/annotations/page/page.alias.json | 12 +- .../annotations/page/page.body.autofill.json | 4 +- tests/annotations/page/page.body.json | 12 +- .../annotations/property/property.aliases.js | 16 ++ .../property/property.aliases.json | 178 +++++++++++++++ tests/annotations/property/property.inline.js | 44 ++++ .../annotations/property/property.inline.json | 208 ++++++++++++++++++ tests/annotations/property/property.js | 16 ++ tests/annotations/property/property.json | 178 +++++++++++++++ .../raw-code/raw-code.escaped.html | 10 + .../raw-code/raw-code.escaped.json | 28 +++ tests/annotations/raw-code/raw-code.js | 4 + tests/annotations/raw-code/raw-code.json | 28 +++ tests/annotations/readonly/readonly.json | 12 +- .../annotations/requires/requires.alias.json | 4 +- tests/annotations/requires/requires.body.json | 28 +-- tests/annotations/returns/returns.alias.json | 28 +-- tests/annotations/returns/returns.json | 28 +-- tests/annotations/since/since.body.json | 16 +- ...tiple-markup-by-id-with-custom-props.json} | 4 +- ...tiple-markup-by-id-with-custom-props.scss} | 0 .../states-multiple-markup-by-id.json} | 4 +- .../states-multiple-markup-by-id.scss} | 0 ...es-multiple-markup-with-custom-props.json} | 4 +- ...es-multiple-markup-with-custom-props.scss} | 0 .../states-multiple-markup.json} | 4 +- .../states-multiple-markup.scss} | 0 .../states-with-custom-props.json} | 4 +- .../states-with-custom-props.scss} | 0 .../states.json} | 4 +- .../states.scss} | 0 .../single-markup.json} | 4 +- .../single-markup.scss} | 0 .../blocks-with-different-states.json} | 4 +- .../blocks-with-different-states.scss} | 0 .../blocks.json} | 4 +- .../blocks.scss} | 0 .../simple-with-description.json} | 12 +- .../simple-with-description.scss} | 0 .../simple-with-notations.json} | 12 +- .../simple-with-notations.scss} | 0 .../simple.json} | 4 +- .../simple.scss} | 0 .../simple.json} | 4 +- .../simple.scss} | 0 .../with-description.json} | 12 +- .../with-description.scss} | 0 .../with-notations.json} | 12 +- .../with-notations.scss} | 0 tests/annotations/throws/throws.alias.json | 16 +- tests/annotations/throws/throws.json | 24 +- tests/annotations/todo/todo.body.json | 24 +- tests/annotations/type/type.json | 28 +-- tests/annotations/version/version.json | 20 +- 106 files changed, 1271 insertions(+), 458 deletions(-) create mode 100644 tests/annotations/property/property.aliases.js create mode 100644 tests/annotations/property/property.aliases.json create mode 100644 tests/annotations/property/property.inline.js create mode 100644 tests/annotations/property/property.inline.json create mode 100644 tests/annotations/property/property.js create mode 100644 tests/annotations/property/property.json create mode 100644 tests/annotations/raw-code/raw-code.escaped.html create mode 100644 tests/annotations/raw-code/raw-code.escaped.json create mode 100644 tests/annotations/raw-code/raw-code.js create mode 100644 tests/annotations/raw-code/raw-code.json rename tests/annotations/state/{state-complex-multiple-states-multiple-markup-by-id-with-custom-props.json => complex-multiple/states-multiple-markup-by-id-with-custom-props.json} (98%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup-by-id-with-custom-props.scss => complex-multiple/states-multiple-markup-by-id-with-custom-props.scss} (100%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup-by-id.json => complex-multiple/states-multiple-markup-by-id.json} (98%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup-by-id.scss => complex-multiple/states-multiple-markup-by-id.scss} (100%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup-with-custom-props.json => complex-multiple/states-multiple-markup-with-custom-props.json} (98%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup-with-custom-props.scss => complex-multiple/states-multiple-markup-with-custom-props.scss} (100%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup.json => complex-multiple/states-multiple-markup.json} (98%) rename tests/annotations/state/{state-complex-multiple-states-multiple-markup.scss => complex-multiple/states-multiple-markup.scss} (100%) rename tests/annotations/state/{state-complex-multiple-states-with-custom-props.json => complex-multiple/states-with-custom-props.json} (97%) rename tests/annotations/state/{state-complex-multiple-states-with-custom-props.scss => complex-multiple/states-with-custom-props.scss} (100%) rename tests/annotations/state/{state-complex-multiple-states.json => complex-multiple/states.json} (97%) rename tests/annotations/state/{state-complex-multiple-states.scss => complex-multiple/states.scss} (100%) rename tests/annotations/state/{state-complex-single-markup.json => complex/single-markup.json} (96%) rename tests/annotations/state/{state-complex-single-markup.scss => complex/single-markup.scss} (100%) rename tests/annotations/state/{state-multiple-markup-blocks-with-different-states.json => multiple-markup/blocks-with-different-states.json} (97%) rename tests/annotations/state/{state-multiple-markup-blocks-with-different-states.scss => multiple-markup/blocks-with-different-states.scss} (100%) rename tests/annotations/state/{state-multiple-markup-blocks.json => multiple-markup/blocks.json} (97%) rename tests/annotations/state/{state-multiple-markup-blocks.scss => multiple-markup/blocks.scss} (100%) rename tests/annotations/state/{state-multiple-stupid-simple-with-description.json => stupid-simple-multiple/simple-with-description.json} (96%) rename tests/annotations/state/{state-multiple-stupid-simple-with-description.scss => stupid-simple-multiple/simple-with-description.scss} (100%) rename tests/annotations/state/{state-multiple-stupid-simple-with-notations.json => stupid-simple-multiple/simple-with-notations.json} (95%) rename tests/annotations/state/{state-multiple-stupid-simple-with-notations.scss => stupid-simple-multiple/simple-with-notations.scss} (100%) rename tests/annotations/state/{state-multiple-stupid-simple.json => stupid-simple-multiple/simple.json} (96%) rename tests/annotations/state/{state-multiple-stupid-simple.scss => stupid-simple-multiple/simple.scss} (100%) rename tests/annotations/state/{state-stupid-simple.json => stupid-simple/simple.json} (93%) rename tests/annotations/state/{state-stupid-simple.scss => stupid-simple/simple.scss} (100%) rename tests/annotations/state/{state-stupid-simple-with-description.json => stupid-simple/with-description.json} (93%) rename tests/annotations/state/{state-stupid-simple-with-description.scss => stupid-simple/with-description.scss} (100%) rename tests/annotations/state/{state-stupid-simple-with-notations.json => stupid-simple/with-notations.json} (93%) rename tests/annotations/state/{state-stupid-simple-with-notations.scss => stupid-simple/with-notations.scss} (100%) diff --git a/app/annotation-api.js b/app/annotation-api.js index 22582b4..59a981b 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -286,21 +286,64 @@ export default class AnnotationApi { } } - let result + let to_call = base + let details + try { const fn = this.getAnnotationFn(base.annotation.name, fn_name) - result = is.function(fn) ? fn.call(base) : fn + + if (fn_name === 'parse') { + to_call = copyInvisible(details = base.annotation, base) + } else if (fn_name === 'resolve') { + to_call = copyInvisible(details = base.parsed[base.annotation.name], base) + } + + let result = is.function(fn) ? fn.call(to_call) : fn + + if (fn_name === 'parse' && !is.any.undefined(details, result)) { + if (is.array(result) && result.length === 1) { + result = to.map(result, (obj) => copyInvisible(obj, { details })) + } + + result = copyInvisible(result, { details }) + } + + return result } catch (e) { - this.log.error(e) throw new Error(e) } - return result + + 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 - // console.log('fn 1:', fn) fn = fn[type] || {} fn = fn[name] || {} if (is.function(fn)) { diff --git a/app/annotations/access.js b/app/annotations/access.js index b28f7b8..6eeb942 100644 --- a/app/annotations/access.js +++ b/app/annotations/access.js @@ -9,13 +9,21 @@ /// /// @access private /// /// /// @access protected -/// @note This is autofilled on every header or body comment +/// @note This is autofilled on every comment block export default { autofill() { - return 'public' + 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.line + const line = `${this.annotation.contents[0]}` if ( line === 'private' || line === 'protected' diff --git a/app/annotations/alias.js b/app/annotations/alias.js index c61aac6..5618c8e 100644 --- a/app/annotations/alias.js +++ b/app/annotations/alias.js @@ -15,7 +15,7 @@ import { list, logAnnotationError } from './annotation-utils' /// /// @alias bar export default { parse() { - let alias_list = list(this.annotation.line) + 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]')) } diff --git a/app/annotations/annotation-utils.js b/app/annotations/annotation-utils.js index 48bee69..e73173a 100644 --- a/app/annotations/annotation-utils.js +++ b/app/annotations/annotation-utils.js @@ -17,9 +17,9 @@ let regexes let rg = {} rg.arg = - rg.property = new RegExp(types + space + name + space + value + space + description, 'i') + rg.property = to.regex(types, space, name, space, value, space, description, 'i') - rg.markup = new RegExp(id + space + types + space + value + space + description, 'i') + rg.markup = to.regex(id, space, types, space, value, space, description, 'i') rg.deprecated = rg.note = @@ -27,56 +27,55 @@ let regexes rg.returns = rg.since = rg.type = - rg.version = new RegExp(types + space + description, 'i') + rg.version = to.regex(types, space, description, 'i') - rg.requires = new RegExp(types + space + name + description, 'i') + rg.requires = to.regex(types, space, name, description, 'i') - rg.state_id = new RegExp(`${id}${space}(.*)`, 'i') + rg.state_id = to.regex(id, space, '(.*)', 'i') rg.state = - rg.todo = new RegExp(types + space + value + space + description, 'i') + rg.todo = to.regex(types, space, value, space, description, 'i') regexes = rg } export function regex(name, str) { - return regexes[name].exec(str).slice(1) + return regexes[name].exec(`${str}`).slice(1) } -export function list(str) { - return to.array(str, ',').map((item) => item.trim()).filter(Boolean) -} +function list(arg) { + if (is.array(arg)) { + return to.map(arg, list) + } + if (arg == null) { + return [] + } -export function multiple(annotation) { - return to.flatten([ - ...(annotation.line.split(',')), - ...(annotation.contents.split('\n').map((item) => item.split(','))) - ]) - .map((author) => author.trim()) - .filter(Boolean) + return to.array(`${arg}`, ',').map((item) => item.trim()).filter(Boolean) } -export function toBoolean(annotation) { - let line = annotation.line +export { list } - if (annotation.contents.length > 0) { +export function toBoolean(contents) { + let line = `${contents[0]}` + if (!is.empty(contents.slice(1))) { return undefined } if (line === 'false') { return false - } else if (line.length === 0 || line === 'true') { + } else if ( + is.undefined(line) || + line.length === 0 || + line === 'true' + ) { return true } return undefined } -export function markdown(...args) { - return to.markdown([ ...args ].filter(Boolean).join('\n')) -} - export function logAnnotationError(obj, expected) { expected = to.array(expected) const { @@ -93,8 +92,8 @@ export function logAnnotationError(obj, expected) { const getSpaces = (number) => (number + '').split('').filter(Boolean).map(() => ' ').slice(1).join('') - comment.contents = comment.contents.split('\n') - code.contents = code.contents.split('\n') + 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) @@ -175,9 +174,8 @@ export function logAnnotationError(obj, expected) { } -export function escape(str) { - return str - .split('\n') +export function escape(arg) { + return to.array(arg) .map((line) => { return line.replace(/[&<>'"]/g, (match) => { return { diff --git a/app/annotations/arg.js b/app/annotations/arg.js index d42f30d..b2bcad9 100644 --- a/app/annotations/arg.js +++ b/app/annotations/arg.js @@ -1,4 +1,5 @@ -import { markdown, regex, list } from './annotation-utils' +import { regex, list } from './annotation-utils' +import { to } from '../utils' /// @name @arg /// @page annotations @@ -14,19 +15,20 @@ import { markdown, regex, list } from './annotation-utils' export default { alias: [ 'argument', 'param', 'parameter' ], parse() { + let { contents } = this.annotation let [ types = [], name = '', value = '', description = '', - ] = regex('arg', this.annotation.line) + ] = regex('arg', contents.shift() || '') return [ { types: list(types), name, value, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } ] } diff --git a/app/annotations/author.js b/app/annotations/author.js index 30083e1..e76a94c 100644 --- a/app/annotations/author.js +++ b/app/annotations/author.js @@ -1,4 +1,4 @@ -import { multiple } from './annotation-utils' +import { list } from './annotation-utils' /// @name @author /// @page annotations /// @alias @authors @@ -14,6 +14,6 @@ import { multiple } from './annotation-utils' export default { alias: [ 'authors' ], parse() { - return multiple(this.annotation) + return list(this.annotation.contents) } } diff --git a/app/annotations/chainable.js b/app/annotations/chainable.js index 7021365..99e4709 100644 --- a/app/annotations/chainable.js +++ b/app/annotations/chainable.js @@ -1,4 +1,4 @@ -import { toBoolean, multiple } from './annotation-utils' +import { toBoolean, list } from './annotation-utils' /// @name @chainable /// @page annotations @@ -19,12 +19,11 @@ import { toBoolean, multiple } from './annotation-utils' export default { alias: [ 'chain' ], parse() { - let bool = toBoolean(this.annotation) - + const { contents } = this.annotation + let bool = toBoolean(contents) if (bool !== undefined) { return bool } - - return multiple(this.annotation) + return list(contents) } } diff --git a/app/annotations/deprecated.js b/app/annotations/deprecated.js index b619fa8..b60b884 100644 --- a/app/annotations/deprecated.js +++ b/app/annotations/deprecated.js @@ -1,5 +1,5 @@ -import { markdown, regex } from './annotation-utils' - +import { regex } from './annotation-utils' +import { to } from '../utils' /// @name @deprecated /// @page annotations /// @description Lets you know that a mixin/function has been depricated @@ -20,10 +20,11 @@ import { markdown, regex } from './annotation-utils' /// /// more of the description export default { parse() { - let [ version = '0', description ] = regex('deprecated', this.annotation.line) + let { contents } = this + let [ version = '0', description = '' ] = regex('deprecated', contents.shift() || '') return { version, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } } } diff --git a/app/annotations/description.js b/app/annotations/description.js index e15983d..f9e6bd2 100644 --- a/app/annotations/description.js +++ b/app/annotations/description.js @@ -1,4 +1,4 @@ -import { markdown } from './annotation-utils' +import { to } from '../utils' /// @name @description /// @page annotations @@ -19,6 +19,6 @@ export default { 'writeup', 'summary', 'summarization' ], parse() { - return markdown(this.annotation.line, this.annotation.contents) + return to.markdown(this.annotation.contents) } } diff --git a/app/annotations/markup.js b/app/annotations/markup.js index 86937de..d315dbd 100644 --- a/app/annotations/markup.js +++ b/app/annotations/markup.js @@ -1,6 +1,5 @@ import { is, to } from '../utils' -import { regex, list, markdown, escape } from './annotation-utils' - +import { regex, list, escape } from './annotation-utils' /// @name @markup /// @page annotations /// @alias @code, @example, @output, @outputs @@ -50,18 +49,25 @@ import { regex, list, markdown, escape } from './annotation-utils' export default { alias: [ 'code', 'example', 'output', 'outputs' ], parse() { + let { contents } = this let [ id = null, language = this.file.type, settings = {}, description - ] = regex('markup', this.annotation.line) + ] = regex('markup', contents.shift() || '') - let raw = this.annotation.contents - let { interpolation, prefix } = this.file.options + let raw = to.string(contents) let escaped = escape(raw) + let state_interpolation + + { + const { interpolation, prefix } = this.file.options + const { start, end } = interpolation + + state_interpolation = `${start}${prefix}states?[^${end}]*${end}` + } - let state_interpolation = `${interpolation.start}${prefix}states?[^${interpolation.end}]*${interpolation.end}` state_interpolation = new RegExp(`\\s*${state_interpolation}\\s*`, 'gi') let raw_stateless = raw.replace(state_interpolation, '') let escaped_stateless = escaped.replace(state_interpolation, '') @@ -75,19 +81,17 @@ export default { id, language, settings, - description: markdown(description), + description: to.markdown(description), raw, escaped, raw_stateless, escaped_stateless, } - Object.defineProperty(result, '__details', { __proto__: null, value: this }) - return [ result ] }, resolve() { - return this.map((obj, i) => { + return to.map(this, (obj, i) => { if (obj.id === null) { obj.id = `${i}` } diff --git a/app/annotations/name.js b/app/annotations/name.js index 6ea4c2a..20e22ba 100644 --- a/app/annotations/name.js +++ b/app/annotations/name.js @@ -7,5 +7,8 @@ /// @markup Usage /// /// @name Name of the documented item export default { - alias: [ 'title', 'heading', 'header' ] + alias: [ 'title', 'heading', 'header' ], + parse() { + return `${this.annotation.contents[0]}` + } } diff --git a/app/annotations/note.js b/app/annotations/note.js index 860956f..d370fd9 100644 --- a/app/annotations/note.js +++ b/app/annotations/note.js @@ -1,5 +1,5 @@ -import { regex, markdown } from './annotation-utils' - +import { regex } from './annotation-utils' +import { to } from '../utils' /// @name @note /// @page annotations /// @alias @notes @@ -18,12 +18,14 @@ import { regex, markdown } from './annotation-utils' export default { alias: [ 'notes' ], parse() { - let [ importance = '0', description ] = regex('note', this.annotation.line) + let { contents } = this.annotation + let line = contents.shift() + let [ importance = '0', description = '' ] = regex('note', line || '') return [ { importance, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } ] } diff --git a/app/annotations/page.js b/app/annotations/page.js index cc08a56..047d914 100644 --- a/app/annotations/page.js +++ b/app/annotations/page.js @@ -41,7 +41,7 @@ import { list } from './annotation-utils' export default { alias: [ 'group' ], parse() { - return list(this.annotation.line) + return list(this.annotation.contents[0] || '') }, autofill() { // autofill header comments diff --git a/app/annotations/property.js b/app/annotations/property.js index 695fbc5..229d89f 100644 --- a/app/annotations/property.js +++ b/app/annotations/property.js @@ -1,4 +1,5 @@ -import { markdown, regex, list } from './annotation-utils' +import { regex, list } from './annotation-utils' +import { to } from '../utils' /// @name @property /// @page annotations @@ -14,19 +15,20 @@ import { markdown, regex, list } from './annotation-utils' export default { alias: [ 'prop', 'key' ], parse() { + let { contents } = this.annotation let [ types = [], name = '', value = '', description = '', - ] = regex('property', this.annotation.line) + ] = regex('property', contents.shift() || '') return [ { types: list(types), name, value, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } ] } diff --git a/app/annotations/raw-code.js b/app/annotations/raw-code.js index 89e3a28..d10dd2c 100644 --- a/app/annotations/raw-code.js +++ b/app/annotations/raw-code.js @@ -1,5 +1,5 @@ import { escape } from './annotation-utils' - +import { to } from '../utils' /// @name @raw-code /// @page annotations /// @description @@ -7,9 +7,7 @@ import { escape } from './annotation-utils' /// @returns {object} export default { parse() { - return { - raw: this.code.contents, - escaped: escape(this.code.contents) - } + const raw = to.string(this.code.contents) + return { raw, escaped: escape(raw) } } } diff --git a/app/annotations/readonly.js b/app/annotations/readonly.js index ec44f31..bf651bb 100644 --- a/app/annotations/readonly.js +++ b/app/annotations/readonly.js @@ -16,7 +16,7 @@ import { toBoolean } from './annotation-utils' /// /// @readonly false export default { parse() { - let bool = toBoolean(this.annotation) + let bool = toBoolean(this.annotation.contents) if (bool !== undefined) { return bool diff --git a/app/annotations/requires.js b/app/annotations/requires.js index a1b37f8..e0c21d1 100644 --- a/app/annotations/requires.js +++ b/app/annotations/requires.js @@ -1,4 +1,5 @@ -import { regex, list, markdown } from './annotation-utils' +import { regex, list } from './annotation-utils' +import { to } from '../utils' /// @name @requires /// @page annotations @@ -19,13 +20,14 @@ import { regex, list, markdown } from './annotation-utils' export default { alias: [ 'require' ], parse() { - let [ types, name = '', description ] = regex('requires', this.annotation.line) + let { contents } = this.annotation + const [ types, name = '', description ] = regex('requires', contents.shift() || '') return [ { types: list(types), name, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } ] } diff --git a/app/annotations/returns.js b/app/annotations/returns.js index be07dc3..e336f34 100644 --- a/app/annotations/returns.js +++ b/app/annotations/returns.js @@ -1,4 +1,5 @@ -import { regex, list, markdown } from './annotation-utils' +import { regex, list } from './annotation-utils' +import { to } from '../utils' /// @name @returns /// @page annotations @@ -21,7 +22,8 @@ import { regex, list, markdown } from './annotation-utils' export default { alias: [ 'return' ], parse() { - let [ types, description ] = regex('returns', this.annotation.line) + let { contents } = this.annotation + let [ types, description ] = regex('returns', contents.shift() || '') if ( types == null || @@ -32,7 +34,7 @@ export default { return { types: list(types), - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } } } diff --git a/app/annotations/since.js b/app/annotations/since.js index 35f1c41..1144365 100644 --- a/app/annotations/since.js +++ b/app/annotations/since.js @@ -1,5 +1,5 @@ -import { regex, markdown } from './annotation-utils' - +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 @@ -17,11 +17,12 @@ import { regex, markdown } from './annotation-utils' /// /// description export default { parse() { - let [ version = 'undefined', description ] = regex('since', this.annotation.line) + let { contents } = this.annotation + let [ version = 'undefined', description = '' ] = regex('since', contents.shift() || '') return { version, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } } } diff --git a/app/annotations/states.js b/app/annotations/states.js index bb7b562..d9a690d 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -1,5 +1,5 @@ import { is, to } from '../utils' -import { regex, markdown } from './annotation-utils' +import { regex } from './annotation-utils' /// @name @states /// @page annotations @@ -29,36 +29,40 @@ import { regex, markdown } from './annotation-utils' export default { alias: [ 'state' ], parse() { - let [ markup_id = null, state_line ] = regex('state_id', this.annotation.line) - let state = [ state_line, ...to.array(this.annotation.contents) ].filter(Boolean) + 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: markdown(description) } + [id]: { state, description: to.markdown(description) } }) }, {}) - Object.defineProperty(state, '__details', { __proto__: null, value: this }) + // Object.defineProperty(state, '__details', { __proto__: null, get: () => this }) return [ { markup_id, state } ] }, - resolve({ parsed, block, log }) { - return this.reduce((previous, { markup_id, state }) => { + resolve() { + let { parsed, log, file } = this + + return this.reduce((previous, current) => { + let { markup_id, state, details } = current let markup - let start_at = state.__details.annotation.start + let start_at = details.start // throw an error because a state should always be accompanied by a `@markup` block if (!parsed.markup) { log.emit('error', "There's no instance of a '@markup' annotation") } else if (is.falsy(markup_id)) { markup = findMarkupAfter(parsed.markup, start_at) - markup_id = markup.id + markup_id = (markup || {}).id if (!markup) { log.emit('error', to.normalize(` - There's no instance of a '@markup' annotation after line ${block.comment.start + start_at} - in ${block.file.path} + There's no instance of a '@markup' annotation after line ${start_at} + in ${file.path} `)) } } else { @@ -66,7 +70,7 @@ export default { if (!markup) { log.emit('error', to.normalize(` There's no instance of a '@markup' annotation with an id of ${markup_id} - in ${block.file.path} + in ${file.path} `)) } } @@ -79,7 +83,6 @@ export default { }) } - // 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')) @@ -87,9 +90,11 @@ export default { // 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(markup.raw, _state, state.__details) - markup.escaped = replaceStates(markup.escaped, _state, state.__details) + markup.raw = replaceStates.call(this, markup.raw, _state) + markup.escaped = replaceStates.call(this, markup.escaped, _state) return to.merge(previous, { [markup_id]: [ { state, markup } ] @@ -98,13 +103,19 @@ export default { } } +/* 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.file.options + const { start, end } = interpolation -function replaceStates(str, states, options) { - let names = [ options.annotation.name, ...options.annotation.alias ].join('|') - let { interpolation, prefix } = options.file.options + state_interpolation = new RegExp(`${start}${prefix}(?:${names})[^${end}]*${end}`, 'g') + replacement = new RegExp(`${start}${prefix}(?:${names})|${end}`, 'g') + } - const state_interpolation = new RegExp(`${interpolation.start}${prefix}(?:${names})[^${interpolation.end}]*${interpolation.end}`, 'g') - const replacement = new RegExp(`${interpolation.start}${prefix}(?:${names})|${interpolation.end}`, 'g') return str.replace(state_interpolation, (original_match) => { let match = original_match.replace(replacement, '').slice(1) @@ -146,9 +157,9 @@ function findMarkupById(markup, id) { } function findMarkupAfter(markup, start_at) { - for (let markup_block of markup) { - if (start_at < markup_block.__details.annotation.start) { - return markup_block + 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 index aeac9a3..45464e5 100644 --- a/app/annotations/throws.js +++ b/app/annotations/throws.js @@ -1,5 +1,5 @@ -import { regex, list, markdown } from './annotation-utils' - +import { regex, list } from './annotation-utils' +import { to } from '../utils' /// @name @throws /// @page annotations /// @alias @throw, @exception, @error, @catch @@ -22,12 +22,13 @@ import { regex, list, markdown } from './annotation-utils' export default { alias: [ 'throw', 'exception', 'error', 'catch' ], parse() { - let [ types, description ] = regex('throws', this.annotation.line) + let { contents } = this.annotation + let [ types, description = '' ] = regex('throws', contents.shift() || '') return [ { types: list(types), - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } ] } diff --git a/app/annotations/todo.js b/app/annotations/todo.js index 34f82bf..96001af 100644 --- a/app/annotations/todo.js +++ b/app/annotations/todo.js @@ -1,4 +1,5 @@ -import { regex, list, markdown } from './annotation-utils' +import { regex, list } from './annotation-utils' +import { to } from '../utils' /// @name @todo /// @page annotations @@ -20,18 +21,22 @@ import { regex, list, markdown } from './annotation-utils' /// /// description export default { parse() { + let { contents } = this.annotation let [ importance = '0', assignees, - description - ] = regex('todo', this.annotation.line) + description = '' + ] = regex('todo', contents.shift() || '') return [ { importance, assignees: list(assignees), - description: markdown(description, this.annotation.contents) + 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 index 9faf1c5..5f6120c 100644 --- a/app/annotations/type.js +++ b/app/annotations/type.js @@ -1,4 +1,5 @@ -import { regex, markdown, logAnnotationError } from './annotation-utils' +import { regex, logAnnotationError } from './annotation-utils' +import { to } from '../utils' import clor from 'clor' /// @name @type @@ -18,7 +19,8 @@ import clor from 'clor' /// /// description export default { parse() { - let [ type, description ] = regex('type', this.annotation.line) + let { contents } = this.annotation + let [ type, description = '' ] = regex('type', contents.shift() || '') if (!type) { this.log.emit( @@ -31,7 +33,7 @@ export default { return { type, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } } } diff --git a/app/annotations/version.js b/app/annotations/version.js index c0ba4b5..c645b4c 100644 --- a/app/annotations/version.js +++ b/app/annotations/version.js @@ -1,4 +1,5 @@ -import { logAnnotationError, regex, markdown } from './annotation-utils' +import { logAnnotationError, regex } from './annotation-utils' +import { to } from '../utils' import clor from 'clor' /// @name @version @@ -18,20 +19,20 @@ import clor from 'clor' /// /// description export default { parse() { - let [ version, description ] = regex('version', this.annotation.line) + let { contents } = this.annotation + let [ version = 'undefined', description = '' ] = regex('version', contents.shift() || '') - if (!version) { + if (version === 'undefined') { this.log.emit( 'warning', `You didn't pass in a version to ${clor.bold('@version ')}`, logAnnotationError(this, `@version {version}${description ? ' - ' + description : ''}`) ) - version = 'undefined' } return { version, - description: markdown(description, this.annotation.contents) + description: to.markdown(description, contents) } } } diff --git a/app/parser/index.js b/app/parser/index.js index 25b4218..3f49221 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -40,6 +40,16 @@ export default class Parser { this.options = rest this.api = new AnnotationApi({ annotations, type }) + { + const { language } = this.options + this.comment_values = to.flatten([ + ...to.values(language.header, '!type'), + ...to.values(language.body, '!type'), + ...to.values(language.inline, '!type') + ]) + this.comment_values = to.unique(this.comment_values).filter(Boolean) + } + { let { alias, parse } = this.api.annotations parse = to.keys(parse) @@ -66,6 +76,15 @@ export default class Parser { file.end = to.array(file.contents).length // ending point of the file this.file = file + // if the file is empty or there aren't any comments then + // just return the the empty values + if ( + is.empty(file.contents) || + !is.any.in(file.contents, ...(this.comment_values)) + ) { + return { header: {}, body: [] } + } + let tokens = this.getTokens(file.contents) tokens = this.getAnnotations(tokens) tokens = this.parseTokens(tokens) @@ -140,11 +159,8 @@ export default class Parser { // find lines that have annotations and set the correct annotation if an alias is found comment.contents = to.map(comment.contents, hasAnnotation) - comment.contents = new Lines(comment.contents) - code.contents = new Lines(code.contents) - // get the annotations that are in the comment - const annotations = new Annotations(comment.contents.raw, language.prefix) + const annotations = new Annotations(comment.contents, language.prefix) return { comment, code, inline, annotations } }) @@ -190,7 +206,8 @@ export default class Parser { } resolveTokens(tokens) { - const { log, sort } = this.options + const { options } = this + const { log, sort } = options const file = this.file let resolve_list = to.keys(this.api.annotations.resolve) // sort the parsed object before the annotations are resolved @@ -203,7 +220,7 @@ export default class Parser { const parsed_keys = to.keys(token.parsed) for (let name of resolve_list) { if (is.in(parsed_keys, name)) { - const result = this.api.run('resolve', { name }, base) + const result = this.api.run('resolve', { name, alias: this.api.annotations.alias[name] }, base) if (result != null) { token.parsed[name] = result } @@ -283,6 +300,12 @@ class Annotations { pushAnnotation() { let { contents, start, end, ...rest } = this.annotation + + // this ensures that the line of the annotation always stays intact + // even if it's empty + let line = contents.shift() + line.str = `${line}`.trim() + let { content, leading, trailing } = to.normalize(contents.join('\n'), { info: true }) trailing += contents.length @@ -298,9 +321,12 @@ class Annotations { }) } + // prepend the line back onto the contents + contents.unshift(line) + start = (contents[0] || {}).lineno || start || -1 // get the starting line of the comment end = (contents.slice(-1)[0] || {}).lineno || end || start || -1 // get the end line of the comment - contents = new Lines(contents) + this.annotations.push({ contents, start, end, ...rest }) } @@ -325,11 +351,3 @@ class Annotation { } } } - -class Lines { - constructor(lines) { - this.lines = to.array(to.string(lines)) - this.lines.raw = lines - return this.lines - } -} diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json index de35441..d863d86 100644 --- a/tests/annotations/access/access.autofill.body.json +++ b/tests/annotations/access/access.autofill.body.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/access/access.autofill.body.js", diff --git a/tests/annotations/access/access.options.json b/tests/annotations/access/access.options.json index 6110468..a85291f 100644 --- a/tests/annotations/access/access.options.json +++ b/tests/annotations/access/access.options.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/access/access.options.js", @@ -29,8 +29,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/access/access.options.js", @@ -48,8 +48,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/access/access.options.js", diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json index a8df25d..2009d1e 100644 --- a/tests/annotations/alias/alias.json +++ b/tests/annotations/alias/alias.json @@ -12,8 +12,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/alias/alias.js", @@ -35,8 +35,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/alias/alias.js", @@ -58,8 +58,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/alias/alias.js", diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json index 8594525..ca546eb 100644 --- a/tests/annotations/arg/arg.aliases.json +++ b/tests/annotations/arg/arg.aliases.json @@ -19,8 +19,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.aliases.js", @@ -48,8 +48,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.aliases.js", @@ -77,8 +77,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.aliases.js", diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json index 73bfb11..99bdd0f 100644 --- a/tests/annotations/arg/arg.json +++ b/tests/annotations/arg/arg.json @@ -17,8 +17,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.js", @@ -46,8 +46,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.js", @@ -76,8 +76,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.js", @@ -105,8 +105,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.js", @@ -134,8 +134,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.js", @@ -163,8 +163,8 @@ "type": "body" }, "code": { - "start": 17, - "end": 17 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/arg/arg.js", diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json index 673fe1d..8a6e970 100644 --- a/tests/annotations/author/author.alias.json +++ b/tests/annotations/author/author.alias.json @@ -14,8 +14,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/author/author.alias.js", diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json index f54e53f..52cc9f0 100644 --- a/tests/annotations/author/author.body.json +++ b/tests/annotations/author/author.body.json @@ -12,8 +12,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/author/author.body.js", diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index d98bbd0..ae0cae5 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -38,8 +38,8 @@ "type": "body" }, "code": { - "start": 7, - "end": 7 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/author/author.multiple.js", @@ -61,8 +61,8 @@ "type": "body" }, "code": { - "start": 9, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/author/author.multiple.js", @@ -84,8 +84,8 @@ "type": "body" }, "code": { - "start": 14, - "end": 14 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/author/author.multiple.js", diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json index ba2aa81..9d10972 100644 --- a/tests/annotations/chainable/chainable.json +++ b/tests/annotations/chainable/chainable.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", @@ -30,8 +30,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", @@ -50,8 +50,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", @@ -72,8 +72,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", @@ -95,8 +95,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", @@ -118,8 +118,8 @@ "type": "body" }, "code": { - "start": 14, - "end": 14 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", @@ -141,8 +141,8 @@ "type": "body" }, "code": { - "start": 18, - "end": 18 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/chainable/chainable.js", diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json index 9ef4503..4f8711e 100644 --- a/tests/annotations/depricated/depricated.body.json +++ b/tests/annotations/depricated/depricated.body.json @@ -13,8 +13,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/depricated/depricated.body.js", @@ -36,8 +36,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/depricated/depricated.body.js", @@ -59,8 +59,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/depricated/depricated.body.js", @@ -82,8 +82,8 @@ "type": "body" }, "code": { - "start": 11, - "end": 11 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/depricated/depricated.body.js", diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json index 030edd2..33c8471 100644 --- a/tests/annotations/description/description.alias.json +++ b/tests/annotations/description/description.alias.json @@ -11,8 +11,8 @@ "type": "body" }, "code": { - "start": 3, - "end": 3 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -32,8 +32,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -53,8 +53,8 @@ "type": "body" }, "code": { - "start": 13, - "end": 13 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -74,8 +74,8 @@ "type": "body" }, "code": { - "start": 18, - "end": 20 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -95,8 +95,8 @@ "type": "body" }, "code": { - "start": 23, - "end": 23 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -116,8 +116,8 @@ "type": "body" }, "code": { - "start": 28, - "end": 30 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -137,8 +137,8 @@ "type": "body" }, "code": { - "start": 33, - "end": 33 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -158,8 +158,8 @@ "type": "body" }, "code": { - "start": 38, - "end": 40 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -179,8 +179,8 @@ "type": "body" }, "code": { - "start": 43, - "end": 43 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -200,8 +200,8 @@ "type": "body" }, "code": { - "start": 48, - "end": 50 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -221,8 +221,8 @@ "type": "body" }, "code": { - "start": 53, - "end": 53 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", @@ -242,8 +242,8 @@ "type": "body" }, "code": { - "start": 58, - "end": 58 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.alias.js", diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json index 17775d5..598a35f 100644 --- a/tests/annotations/description/description.body.json +++ b/tests/annotations/description/description.body.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 3, - "end": 3 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.body.js", @@ -30,8 +30,8 @@ "type": "body" }, "code": { - "start": 9, - "end": 9 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.body.js", @@ -50,8 +50,8 @@ "type": "body" }, "code": { - "start": 15, - "end": 15 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/description/description.body.js", diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index 00c872a..cffdff0 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mark.mark", diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 63e8963..3686882 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/markdown.markdown", diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index fd873ec..91ac095 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/md.md", diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index 142c2c9..6cd004d 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mdml.mdml", diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index 3bd2f59..0ee4367 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mdown.mdown", diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index 96dee95..cd24904 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mdtext.mdtext", diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index 5bd8fbf..ff4cdf2 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mdtxt.mdtxt", diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index 374b422..88fe963 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mdwn.mdwn", diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index b3ec690..9ea14fa 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mkd.mkd", diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index f77b483..12effb0 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/mkdn.mkdn", diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index e7b299e..c972f14 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -8,8 +8,8 @@ "type": "header" }, "code": { - "start": -1, - "end": -1 + "start": 4, + "end": 12 }, "file": { "path": "docs/tests/annotations/markdown/text.text", diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json index 49a420d..803fd97 100644 --- a/tests/annotations/name/name.aliases.json +++ b/tests/annotations/name/name.aliases.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/name/name.aliases.js", @@ -30,8 +30,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/name/name.aliases.js", @@ -50,8 +50,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/name/name.aliases.js", diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json index 7cec0e4..0cfd6ff 100644 --- a/tests/annotations/name/name.json +++ b/tests/annotations/name/name.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/name/name.js", diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json index 6c1b292..9b8c0e3 100644 --- a/tests/annotations/note/note.alias.json +++ b/tests/annotations/note/note.alias.json @@ -15,8 +15,8 @@ "type": "body" }, "code": { - "start": 5, - "end": 5 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.alias.js", @@ -40,8 +40,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.alias.js", diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json index 6fa19d7..7572be6 100644 --- a/tests/annotations/note/note.json +++ b/tests/annotations/note/note.json @@ -15,8 +15,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.js", @@ -40,8 +40,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.js", @@ -65,8 +65,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.js", @@ -90,8 +90,8 @@ "type": "body" }, "code": { - "start": 12, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.js", @@ -115,8 +115,8 @@ "type": "body" }, "code": { - "start": 14, - "end": 14 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.js", @@ -140,8 +140,8 @@ "type": "body" }, "code": { - "start": 20, - "end": 20 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/note/note.js", diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json index 21035be..08bebdd 100644 --- a/tests/annotations/page/page.alias.json +++ b/tests/annotations/page/page.alias.json @@ -12,8 +12,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.alias.js", @@ -34,8 +34,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.alias.js", @@ -57,8 +57,8 @@ "type": "body" }, "code": { - "start": 7, - "end": 7 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.alias.js", diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json index 8bbc01b..8c24c79 100644 --- a/tests/annotations/page/page.body.autofill.json +++ b/tests/annotations/page/page.body.autofill.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.body.autofill.js", diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json index f6a867c..873644b 100644 --- a/tests/annotations/page/page.body.json +++ b/tests/annotations/page/page.body.json @@ -12,8 +12,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.body.js", @@ -34,8 +34,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.body.js", @@ -57,8 +57,8 @@ "type": "body" }, "code": { - "start": 7, - "end": 7 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/page/page.body.js", 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..e41949a --- /dev/null +++ b/tests/annotations/property/property.aliases.json @@ -0,0 +1,178 @@ +{ + "header": {}, + "body": [ + { + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.aliases.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + } + ] +} 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..0ec8ade --- /dev/null +++ b/tests/annotations/property/property.inline.json @@ -0,0 +1,208 @@ +{ + "header": {}, + "body": [ + { + "name": "one", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 4, + "end": 5, + "type": "body" + }, + "code": { + "start": 6, + "end": 8 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ] + }, + { + "name": "two", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 10, + "end": 11, + "type": "body" + }, + "code": { + "start": 12, + "end": 14 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "property": [ + { + "types": [ + "number" + ], + "name": "bar.value", + "value": "", + "description": "" + } + ] + }, + { + "name": "three", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 16, + "end": 17, + "type": "body" + }, + "code": { + "start": 18, + "end": 20 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "property": [ + { + "types": [ + "number", + "array" + ], + "name": "baz.value", + "value": "", + "description": "" + } + ] + }, + { + "name": "four", + "type": { + "type": "object", + "description": "" + }, + "blockinfo": { + "comment": { + "start": 22, + "end": 23, + "type": "body" + }, + "code": { + "start": 24, + "end": 28 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public", + "property": [ + { + "types": [ + "function" + ], + "name": "qux.value", + "value": "", + "description": "

    description

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

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

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

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" + } + ] + } + ] +} 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..63cc246 --- /dev/null +++ b/tests/annotations/property/property.json @@ -0,0 +1,178 @@ +{ + "header": {}, + "body": [ + { + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 1, + "end": 1, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "property": [ + { + "types": [ + "type" + ], + "name": "key.name", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 3, + "end": 3, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + }, + { + "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/tests/annotations/property/property.js", + "start": 1, + "end": 17 + } + }, + "access": "public" + } + ] +} 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..590b710 --- /dev/null +++ b/tests/annotations/raw-code/raw-code.escaped.json @@ -0,0 +1,28 @@ +{ + "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/tests/annotations/raw-code/raw-code.escaped.html", + "start": 1, + "end": 10 + } + }, + "access": "public" + } + ] +} 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..f5d21f5 --- /dev/null +++ b/tests/annotations/raw-code/raw-code.json @@ -0,0 +1,28 @@ +{ + "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/tests/annotations/raw-code/raw-code.js", + "start": 1, + "end": 4 + } + }, + "access": "public" + } + ] +} diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json index 4430f95..a87a039 100644 --- a/tests/annotations/readonly/readonly.json +++ b/tests/annotations/readonly/readonly.json @@ -10,8 +10,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/readonly/readonly.js", @@ -30,8 +30,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/readonly/readonly.js", @@ -50,8 +50,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/readonly/readonly.js", diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json index 4d3bd3c..d5b4a59 100644 --- a/tests/annotations/requires/requires.alias.json +++ b/tests/annotations/requires/requires.alias.json @@ -16,8 +16,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.alias.js", diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json index 5cae026..e0a35bc 100644 --- a/tests/annotations/requires/requires.body.json +++ b/tests/annotations/requires/requires.body.json @@ -16,8 +16,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", @@ -44,8 +44,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", @@ -75,8 +75,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", @@ -101,8 +101,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", @@ -127,8 +127,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", @@ -155,8 +155,8 @@ "type": "body" }, "code": { - "start": 12, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", @@ -186,8 +186,8 @@ "type": "body" }, "code": { - "start": 15, - "end": 15 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/requires/requires.body.js", diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json index 894f6fc..b8cc193 100644 --- a/tests/annotations/returns/returns.alias.json +++ b/tests/annotations/returns/returns.alias.json @@ -15,8 +15,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", @@ -40,8 +40,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", @@ -67,8 +67,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", @@ -94,8 +94,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", @@ -119,8 +119,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", @@ -144,8 +144,8 @@ "type": "body" }, "code": { - "start": 12, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", @@ -169,8 +169,8 @@ "type": "body" }, "code": { - "start": 23, - "end": 23 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.alias.js", diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json index 980e140..defc5b2 100644 --- a/tests/annotations/returns/returns.json +++ b/tests/annotations/returns/returns.json @@ -15,8 +15,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", @@ -40,8 +40,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", @@ -67,8 +67,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", @@ -94,8 +94,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", @@ -119,8 +119,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", @@ -144,8 +144,8 @@ "type": "body" }, "code": { - "start": 12, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", @@ -169,8 +169,8 @@ "type": "body" }, "code": { - "start": 23, - "end": 23 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/returns/returns.js", diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json index 652342e..2f20afd 100644 --- a/tests/annotations/since/since.body.json +++ b/tests/annotations/since/since.body.json @@ -13,8 +13,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/since/since.body.js", @@ -36,8 +36,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/since/since.body.js", @@ -59,8 +59,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/since/since.body.js", @@ -82,8 +82,8 @@ "type": "body" }, "code": { - "start": 11, - "end": 11 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/since/since.body.js", diff --git a/tests/annotations/state/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 similarity index 98% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.json rename to tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.json index cfddee8..8071b41 100644 --- a/tests/annotations/state/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 @@ -158,10 +158,10 @@ }, "code": { "start": 41, - "end": 60 + "end": 59 }, "file": { - "path": "docs/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.scss", + "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.scss b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss similarity index 100% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id-with-custom-props.scss rename to tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.json b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json similarity index 98% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.json rename to tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json index 4f93181..2ceab65 100644 --- a/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json @@ -158,10 +158,10 @@ }, "code": { "start": 41, - "end": 60 + "end": 59 }, "file": { - "path": "docs/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.scss", + "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.scss b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss similarity index 100% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup-by-id.scss rename to tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.json b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json similarity index 98% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.json rename to tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json index 7ab5978..077b214 100644 --- a/tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json @@ -158,10 +158,10 @@ }, "code": { "start": 41, - "end": 60 + "end": 59 }, "file": { - "path": "docs/tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.scss", + "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.scss b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss similarity index 100% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup-with-custom-props.scss rename to tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup.json b/tests/annotations/state/complex-multiple/states-multiple-markup.json similarity index 98% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup.json rename to tests/annotations/state/complex-multiple/states-multiple-markup.json index e44ee2f..b53207e 100644 --- a/tests/annotations/state/state-complex-multiple-states-multiple-markup.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup.json @@ -158,10 +158,10 @@ }, "code": { "start": 41, - "end": 60 + "end": 59 }, "file": { - "path": "docs/tests/annotations/state/state-complex-multiple-states-multiple-markup.scss", + "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/state-complex-multiple-states-multiple-markup.scss b/tests/annotations/state/complex-multiple/states-multiple-markup.scss similarity index 100% rename from tests/annotations/state/state-complex-multiple-states-multiple-markup.scss rename to tests/annotations/state/complex-multiple/states-multiple-markup.scss diff --git a/tests/annotations/state/state-complex-multiple-states-with-custom-props.json b/tests/annotations/state/complex-multiple/states-with-custom-props.json similarity index 97% rename from tests/annotations/state/state-complex-multiple-states-with-custom-props.json rename to tests/annotations/state/complex-multiple/states-with-custom-props.json index 4b42eb8..699cf5f 100644 --- a/tests/annotations/state/state-complex-multiple-states-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-with-custom-props.json @@ -86,10 +86,10 @@ }, "code": { "start": 20, - "end": 39 + "end": 38 }, "file": { - "path": "docs/tests/annotations/state/state-complex-multiple-states-with-custom-props.scss", + "path": "docs/tests/annotations/state/complex-multiple/states-with-custom-props.scss", "start": 1, "end": 39 } diff --git a/tests/annotations/state/state-complex-multiple-states-with-custom-props.scss b/tests/annotations/state/complex-multiple/states-with-custom-props.scss similarity index 100% rename from tests/annotations/state/state-complex-multiple-states-with-custom-props.scss rename to tests/annotations/state/complex-multiple/states-with-custom-props.scss diff --git a/tests/annotations/state/state-complex-multiple-states.json b/tests/annotations/state/complex-multiple/states.json similarity index 97% rename from tests/annotations/state/state-complex-multiple-states.json rename to tests/annotations/state/complex-multiple/states.json index 6fd6735..b7b36ee 100644 --- a/tests/annotations/state/state-complex-multiple-states.json +++ b/tests/annotations/state/complex-multiple/states.json @@ -86,10 +86,10 @@ }, "code": { "start": 20, - "end": 39 + "end": 38 }, "file": { - "path": "docs/tests/annotations/state/state-complex-multiple-states.scss", + "path": "docs/tests/annotations/state/complex-multiple/states.scss", "start": 1, "end": 39 } diff --git a/tests/annotations/state/state-complex-multiple-states.scss b/tests/annotations/state/complex-multiple/states.scss similarity index 100% rename from tests/annotations/state/state-complex-multiple-states.scss rename to tests/annotations/state/complex-multiple/states.scss diff --git a/tests/annotations/state/state-complex-single-markup.json b/tests/annotations/state/complex/single-markup.json similarity index 96% rename from tests/annotations/state/state-complex-single-markup.json rename to tests/annotations/state/complex/single-markup.json index 45a0fc4..ce8b1f2 100644 --- a/tests/annotations/state/state-complex-single-markup.json +++ b/tests/annotations/state/complex/single-markup.json @@ -46,10 +46,10 @@ }, "code": { "start": 12, - "end": 31 + "end": 30 }, "file": { - "path": "docs/tests/annotations/state/state-complex-single-markup.scss", + "path": "docs/tests/annotations/state/complex/single-markup.scss", "start": 1, "end": 31 } diff --git a/tests/annotations/state/state-complex-single-markup.scss b/tests/annotations/state/complex/single-markup.scss similarity index 100% rename from tests/annotations/state/state-complex-single-markup.scss rename to tests/annotations/state/complex/single-markup.scss diff --git a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json b/tests/annotations/state/multiple-markup/blocks-with-different-states.json similarity index 97% rename from tests/annotations/state/state-multiple-markup-blocks-with-different-states.json rename to tests/annotations/state/multiple-markup/blocks-with-different-states.json index d582671..3b4eb7b 100644 --- a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.json +++ b/tests/annotations/state/multiple-markup/blocks-with-different-states.json @@ -102,10 +102,10 @@ }, "code": { "start": 16, - "end": 27 + "end": 26 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss", + "path": "docs/tests/annotations/state/multiple-markup/blocks-with-different-states.scss", "start": 1, "end": 27 } diff --git a/tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss b/tests/annotations/state/multiple-markup/blocks-with-different-states.scss similarity index 100% rename from tests/annotations/state/state-multiple-markup-blocks-with-different-states.scss rename to tests/annotations/state/multiple-markup/blocks-with-different-states.scss diff --git a/tests/annotations/state/state-multiple-markup-blocks.json b/tests/annotations/state/multiple-markup/blocks.json similarity index 97% rename from tests/annotations/state/state-multiple-markup-blocks.json rename to tests/annotations/state/multiple-markup/blocks.json index b729f35..d79aae7 100644 --- a/tests/annotations/state/state-multiple-markup-blocks.json +++ b/tests/annotations/state/multiple-markup/blocks.json @@ -68,10 +68,10 @@ }, "code": { "start": 17, - "end": 24 + "end": 23 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-markup-blocks.scss", + "path": "docs/tests/annotations/state/multiple-markup/blocks.scss", "start": 1, "end": 24 } diff --git a/tests/annotations/state/state-multiple-markup-blocks.scss b/tests/annotations/state/multiple-markup/blocks.scss similarity index 100% rename from tests/annotations/state/state-multiple-markup-blocks.scss rename to tests/annotations/state/multiple-markup/blocks.scss diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-description.json b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json similarity index 96% rename from tests/annotations/state/state-multiple-stupid-simple-with-description.json rename to tests/annotations/state/stupid-simple-multiple/simple-with-description.json index 45e0c8a..25efe4b 100644 --- a/tests/annotations/state/state-multiple-stupid-simple-with-description.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json @@ -74,10 +74,10 @@ }, "code": { "start": 9, - "end": 25 + "end": 23 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-description.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", "start": 1, "end": 74 } @@ -157,10 +157,10 @@ }, "code": { "start": 34, - "end": 50 + "end": 48 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-description.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", "start": 1, "end": 74 } @@ -240,10 +240,10 @@ }, "code": { "start": 59, - "end": 74 + "end": 73 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-description.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", "start": 1, "end": 74 } diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-description.scss b/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss similarity index 100% rename from tests/annotations/state/state-multiple-stupid-simple-with-description.scss rename to tests/annotations/state/stupid-simple-multiple/simple-with-description.scss diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-notations.json b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json similarity index 95% rename from tests/annotations/state/state-multiple-stupid-simple-with-notations.json rename to tests/annotations/state/stupid-simple-multiple/simple-with-notations.json index 3bdfed4..1695133 100644 --- a/tests/annotations/state/state-multiple-stupid-simple-with-notations.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json @@ -74,10 +74,10 @@ }, "code": { "start": 9, - "end": 25 + "end": 23 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", "start": 1, "end": 74 } @@ -157,10 +157,10 @@ }, "code": { "start": 34, - "end": 50 + "end": 48 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", "start": 1, "end": 74 } @@ -240,10 +240,10 @@ }, "code": { "start": 59, - "end": 74 + "end": 73 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", "start": 1, "end": 74 } diff --git a/tests/annotations/state/state-multiple-stupid-simple-with-notations.scss b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss similarity index 100% rename from tests/annotations/state/state-multiple-stupid-simple-with-notations.scss rename to tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss diff --git a/tests/annotations/state/state-multiple-stupid-simple.json b/tests/annotations/state/stupid-simple-multiple/simple.json similarity index 96% rename from tests/annotations/state/state-multiple-stupid-simple.json rename to tests/annotations/state/stupid-simple-multiple/simple.json index 4fb6a67..9501442 100644 --- a/tests/annotations/state/state-multiple-stupid-simple.json +++ b/tests/annotations/state/stupid-simple-multiple/simple.json @@ -74,10 +74,10 @@ }, "code": { "start": 9, - "end": 24 + "end": 23 }, "file": { - "path": "docs/tests/annotations/state/state-multiple-stupid-simple.scss", + "path": "docs/tests/annotations/state/stupid-simple-multiple/simple.scss", "start": 1, "end": 24 } diff --git a/tests/annotations/state/state-multiple-stupid-simple.scss b/tests/annotations/state/stupid-simple-multiple/simple.scss similarity index 100% rename from tests/annotations/state/state-multiple-stupid-simple.scss rename to tests/annotations/state/stupid-simple-multiple/simple.scss diff --git a/tests/annotations/state/state-stupid-simple.json b/tests/annotations/state/stupid-simple/simple.json similarity index 93% rename from tests/annotations/state/state-stupid-simple.json rename to tests/annotations/state/stupid-simple/simple.json index 614d667..438fed8 100644 --- a/tests/annotations/state/state-stupid-simple.json +++ b/tests/annotations/state/stupid-simple/simple.json @@ -42,10 +42,10 @@ }, "code": { "start": 7, - "end": 14 + "end": 13 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple.scss", + "path": "docs/tests/annotations/state/stupid-simple/simple.scss", "start": 1, "end": 14 } diff --git a/tests/annotations/state/state-stupid-simple.scss b/tests/annotations/state/stupid-simple/simple.scss similarity index 100% rename from tests/annotations/state/state-stupid-simple.scss rename to tests/annotations/state/stupid-simple/simple.scss diff --git a/tests/annotations/state/state-stupid-simple-with-description.json b/tests/annotations/state/stupid-simple/with-description.json similarity index 93% rename from tests/annotations/state/state-stupid-simple-with-description.json rename to tests/annotations/state/stupid-simple/with-description.json index 546770c..0dcbc2c 100644 --- a/tests/annotations/state/state-stupid-simple-with-description.json +++ b/tests/annotations/state/stupid-simple/with-description.json @@ -42,10 +42,10 @@ }, "code": { "start": 7, - "end": 15 + "end": 13 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple-with-description.scss", + "path": "docs/tests/annotations/state/stupid-simple/with-description.scss", "start": 1, "end": 43 } @@ -93,10 +93,10 @@ }, "code": { "start": 22, - "end": 29 + "end": 28 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple-with-description.scss", + "path": "docs/tests/annotations/state/stupid-simple/with-description.scss", "start": 1, "end": 43 } @@ -144,10 +144,10 @@ }, "code": { "start": 36, - "end": 43 + "end": 42 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple-with-description.scss", + "path": "docs/tests/annotations/state/stupid-simple/with-description.scss", "start": 1, "end": 43 } diff --git a/tests/annotations/state/state-stupid-simple-with-description.scss b/tests/annotations/state/stupid-simple/with-description.scss similarity index 100% rename from tests/annotations/state/state-stupid-simple-with-description.scss rename to tests/annotations/state/stupid-simple/with-description.scss diff --git a/tests/annotations/state/state-stupid-simple-with-notations.json b/tests/annotations/state/stupid-simple/with-notations.json similarity index 93% rename from tests/annotations/state/state-stupid-simple-with-notations.json rename to tests/annotations/state/stupid-simple/with-notations.json index c7ee554..f695bee 100644 --- a/tests/annotations/state/state-stupid-simple-with-notations.json +++ b/tests/annotations/state/stupid-simple/with-notations.json @@ -42,10 +42,10 @@ }, "code": { "start": 7, - "end": 15 + "end": 13 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple-with-notations.scss", + "path": "docs/tests/annotations/state/stupid-simple/with-notations.scss", "start": 1, "end": 44 } @@ -93,10 +93,10 @@ }, "code": { "start": 22, - "end": 30 + "end": 28 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple-with-notations.scss", + "path": "docs/tests/annotations/state/stupid-simple/with-notations.scss", "start": 1, "end": 44 } @@ -144,10 +144,10 @@ }, "code": { "start": 37, - "end": 44 + "end": 43 }, "file": { - "path": "docs/tests/annotations/state/state-stupid-simple-with-notations.scss", + "path": "docs/tests/annotations/state/stupid-simple/with-notations.scss", "start": 1, "end": 44 } diff --git a/tests/annotations/state/state-stupid-simple-with-notations.scss b/tests/annotations/state/stupid-simple/with-notations.scss similarity index 100% rename from tests/annotations/state/state-stupid-simple-with-notations.scss rename to tests/annotations/state/stupid-simple/with-notations.scss diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json index 73f3274..cf93f87 100644 --- a/tests/annotations/throws/throws.alias.json +++ b/tests/annotations/throws/throws.alias.json @@ -17,8 +17,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.alias.js", @@ -44,8 +44,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.alias.js", @@ -71,8 +71,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.alias.js", @@ -98,8 +98,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.alias.js", diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json index ea2df0d..e06c15a 100644 --- a/tests/annotations/throws/throws.json +++ b/tests/annotations/throws/throws.json @@ -15,8 +15,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.js", @@ -42,8 +42,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.js", @@ -69,8 +69,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.js", @@ -96,8 +96,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.js", @@ -123,8 +123,8 @@ "type": "body" }, "code": { - "start": 13, - "end": 13 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.js", @@ -156,8 +156,8 @@ "type": "body" }, "code": { - "start": 16, - "end": 16 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/throws/throws.js", diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json index 8736ca4..0ba39e3 100644 --- a/tests/annotations/todo/todo.body.json +++ b/tests/annotations/todo/todo.body.json @@ -16,8 +16,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/todo/todo.body.js", @@ -42,8 +42,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/todo/todo.body.js", @@ -68,8 +68,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/todo/todo.body.js", @@ -96,8 +96,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/todo/todo.body.js", @@ -125,8 +125,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/todo/todo.body.js", @@ -154,8 +154,8 @@ "type": "body" }, "code": { - "start": 15, - "end": 15 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/todo/todo.body.js", diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json index 580475c..fc513ce 100644 --- a/tests/annotations/type/type.json +++ b/tests/annotations/type/type.json @@ -13,8 +13,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", @@ -36,8 +36,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", @@ -59,8 +59,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", @@ -82,8 +82,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", @@ -105,8 +105,8 @@ "type": "body" }, "code": { - "start": 10, - "end": 10 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", @@ -128,8 +128,8 @@ "type": "body" }, "code": { - "start": 12, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", @@ -151,8 +151,8 @@ "type": "body" }, "code": { - "start": 18, - "end": 18 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/type/type.js", diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json index 2d9ef8b..2587ce6 100644 --- a/tests/annotations/version/version.json +++ b/tests/annotations/version/version.json @@ -13,8 +13,8 @@ "type": "body" }, "code": { - "start": 2, - "end": 2 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/version/version.js", @@ -36,8 +36,8 @@ "type": "body" }, "code": { - "start": 4, - "end": 4 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/version/version.js", @@ -59,8 +59,8 @@ "type": "body" }, "code": { - "start": 6, - "end": 6 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/version/version.js", @@ -82,8 +82,8 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/version/version.js", @@ -105,8 +105,8 @@ "type": "body" }, "code": { - "start": 13, - "end": 13 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/version/version.js", From de85fca39230c0da97dbe3080d2d1f2e6eb9583d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 28 Mar 2016 17:03:58 -0400 Subject: [PATCH 268/273] added a few new features to the `to` lib and cleaned up the rest --- app/utils/to.js | 117 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 37 deletions(-) diff --git a/app/utils/to.js b/app/utils/to.js index 4d1796e..a637efb 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -12,7 +12,7 @@ let to = { /// 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: (arg) => markdown(to.string(arg)), + markdown: (...args) => markdown(to.string(to.flatten(...args))), ...changeCase, @@ -223,8 +223,11 @@ let to = { /// // Output: /// // 0: Jane /// // 1: Doe - entries(obj, from_index = 0, to_index) { + 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 @@ -232,21 +235,21 @@ let to = { } if (is.array(obj)) { - if (is.undefined(to_index)) { - to_index = obj.length + if (is.undefined(end)) { + end = obj.length } - if (from_index < to_index) { + if (i < end) { iterator.next = () => { - if (from_index < to_index) { - return { value: [ from_index, obj[from_index++] ] } + if (i < end) { + return { value: [ i, obj[i++] ] } } return done } } else { iterator.next = () => { - if (from_index > to_index) { - return { value: [ from_index, obj[from_index--] ] } + if (i > end) { + return { value: [ i, obj[i--] ] } } return done } @@ -259,23 +262,23 @@ let to = { // 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(to_index)) { - to_index = keys.length + if (is.undefined(end)) { + end = keys.length } - if (from_index < to_index) { + if (i < end) { iterator.next = () => { - if (from_index < to_index) { - let key = keys[from_index] - return { value: [ key, obj[key], from_index++ ] } + if (i < end) { + let key = keys[i] + return { value: [ key, obj[key], i++ ] } } return done } } else { iterator.next = () => { - if (from_index > to_index) { - let key = keys[from_index] - return { value: [ key, obj[key], from_index-- ] } + if (i > end) { + let key = keys[i] + return { value: [ key, obj[key], i-- ] } } return done } @@ -418,7 +421,7 @@ let to = { /// // } /// /// @returns {string} - The normalized string - normalize: (...args) => { + normalize(...args) { const options = to.arguments({ content: '', leading: true, @@ -502,24 +505,25 @@ let to = { /// @arg {object} a - Source object. /// @arg {object} b - Object to extend with. /// @returns {object} The extended object. - extend: (a, b) => { + extend(a, b) { // Don't touch `null` or `undefined` objects. if (!a || !b) { return a } - let k = to.keys(b) // eslint-disable-line - - for (let i = 0, l = k.length; i < l; i++) { - if (is.plainObject(b[k[i]])) { - a[k[i]] = is.plainObject(a[k[i]]) ? to.extend(a[k[i]], b[k[i]]) : b[k[i]] - } else { - a[k[i]] = b[k[i]] + 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 @@ -627,7 +631,7 @@ let to = { /// @description Converts a json object to a plain object /// @arg {json} - The json to parse /// @returns {object} - object: (arg) => { + object(arg) { if (is.array(arg)) { let result = {} for (let item of arg) result[item[0]] = item[1] @@ -650,7 +654,7 @@ let to = { /// 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') => { + array(arg, glue = '\n') { if (is.array(arg)) { return arg } else if (is.arguments(arg)) { @@ -670,7 +674,10 @@ let to = { /// Flattens an array, and arrays inside of it into a single array /// @arg {array} /// @returnes {array} - single dimensional - // flatten: (arg) => is.array(arg) ? [].concat(...arg.map(to.flatten)) : arg, + // 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)) @@ -722,15 +729,15 @@ let to = { /// @arg {array, object} obj /// @arg {function} callback /// @returns {array, object} that was mapped - map(obj, callback, this_arg) { + map(obj, callback, context = null) { if (is.array(obj)) { - return obj.map(callback, this_arg) + return obj.map(callback, context) } let result = {} for (let [ key, value, i ] of to.entries(obj)) { - let cb_result = callback({ key, value }, i, 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) } @@ -739,6 +746,25 @@ let to = { 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 @@ -761,15 +787,15 @@ let to = { /// @arg {array, object} obj /// @arg {function} callback /// @returns {array, object} that was filtered - filter(obj, callback, this_arg = null) { + filter(obj, callback, context = null) { if (is.array(obj)) { - return obj.filter(callback, this_arg) + return obj.filter(callback, context) } let result = {} for (let [ key, value, i ] of to.entries(obj)) { - if (is.truthy(callback.call(this_arg, { key, value }, i, obj))) { + if (is.truthy(callback.call(context, { key, value }, i, obj))) { to.extend(result, { [key]: value }) } } @@ -782,7 +808,7 @@ let to = { /// Converts `arg` to number /// @arg {number, array, object, string, boolean} /// @returns {number} - number: (arg) => { + number(arg) { if (is.number(arg)) { return arg } else if (is.array(arg)) { @@ -792,6 +818,23 @@ let to = { } 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) } } From eb2f2f539de61e1d176f868e7fa5fd5bcf10933f Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 29 Mar 2016 12:12:17 -0400 Subject: [PATCH 269/273] cleaned up the sorter --- app/sorter/index.js | 11 ++-- app/sorter/pages.js | 139 +++++++++++++++++++++----------------------- 2 files changed, 70 insertions(+), 80 deletions(-) diff --git a/app/sorter/index.js b/app/sorter/index.js index d760a63..8f52cba 100644 --- a/app/sorter/index.js +++ b/app/sorter/index.js @@ -1,5 +1,5 @@ import getPages from './pages' -import getPav from './nav' +import getNav from './nav' /// @name sort /// @description @@ -7,11 +7,8 @@ import getPav from './nav' /// @arg {object} /// @returns {object} export default function sorter(options = {}) { - let pages = getPages(options) - let nav = getPav(pages) + const pages = getPages(options) + const nav = getNav(pages) - return { - nav, - pages - } + return { nav, pages } } diff --git a/app/sorter/pages.js b/app/sorter/pages.js index 287c694..85aef47 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -6,69 +6,75 @@ import clor from 'clor' /// @description /// This function loops over the json that was passed and creates a organized structure /// based on the `@pages` annotations that were passed. -export default function pages(options = {}) { - // placeholder for the result - let result = {} - - let { json, page_fallback, log } = options - - for (let { path, header, body } of to.objectEntries(json, 'path')) { - if (!is.empty(header)) { - if (is.falsy(header.page)) { - if (is.truthy(page_fallback)) { - header.page = [ page_fallback ] - } else { - log.emit('warning', ` - Header comment ${header.name && '(' + header.name + ')'} doesn't have a ${clor.bold('@page')} defined in - ${path} - `) - } +export default function pages(options) { + return new Pages(options) +} + +class Pages { + constructor({ json, page_fallback, log }) { + this.json = json + this.page_fallback = page_fallback + this.log = log + this.base = { page: { header: {}, body: [] } } + this.result = {} + + for (const obj of to.objectEntries(this.json, 'path')) { + let { path, header, body } = this.obj = obj + this.path = path + this.header = header + to.each({ header, body }, this.parse, this) + } + + return this.result + } + + parse({ key, value: val }) { + if (!is.empty(val)) { + if (is.array(val)) { + return to.each(val, (value) => this.parse({ key, value }), this) } - // a) Set the name in the header to be the name of the file - if (is.falsy(header.name)) { - log.emit('warning', '' + - 'The hardest thing in development is naming but you gotta try, add a ' + - clor.bold('@name') + - ' to the header comment in ' + - clor.bold(path) - ) + this.parseToken({ key, value: val }) + } + } + + parseToken({ key: token_type, value: token }) { + let token_title = to.titleCase(token_type) + const is_header = token_type === 'header' + const path = this.path + + if (is.falsy(token.page) && is_header) { + if (is.falsy(this.page_fallback)) { + this.log.emit('warning', to.normalize(` + ${token_title} comment ${token.name && '@name ' + token.name} doesn't have a ${clor.bold('@page')} defined in + ${clor.bold.blue(path)} + `)) + return } - // set the header for the file - for (let page of header.page) set(page, 'header', header) + this.header.page = [ this.page_fallback ] + } + + if (!is_header && !is.empty(this.header.page)) { + token.page = to.unique([ ...(this.header.page), ...(token.page || []) ]) } - if (!is.empty(body)) { - for (let block of body) { - // warn the user that there isn't a page defined. - if (is.all.empty(header.page, block.page)) { - log.emit('warning', ` - ${block.name || 'a block'} starting on line ${block.__start} doesn't have a \`@page\` defined in - ${path} - `) - } - - // add the block to each page in the header - if (header.page) { - for (let page of header.page) { - set(page, 'body', block) - - let index = (body.page || []).indexOf(page) - - // remove the page from the body comment - if (index > -1) { - block.page.splice(index, 1) - } - } - } - - // add the block to each page in the block - if (block.page && !is.empty(block.page)) { - for (let page of block.page) set(page, 'body', block) - } + + // If the token doesn't contain a name and isn't a header comment it get's skipped + if (is.falsy(token.name)) { + if (!is_header) { + this.log.emit('warning', to.normalize(` + The hardest thing in development is naming all the things but you gotta try, add a ${clor.bold('@name')} annotation + to the comment block starting on line ${token.blockinfo.comment.start} in ${clor.bold.blue(path)} + `)) + return } + + // set the token name to be the filepath name + token.name = to.titleCase(path.split('/').pop().split('.').shift()) } + + for (const page of token.page) this.set(page, token_type, token) } // @name set @@ -77,7 +83,7 @@ export default function pages(options = {}) { // the `base` array if it was passed. // // @returns {object} - The nested object with the set value - function set(path, type, value) { + set(path, type, value) { // ensures values won't change in the passed value value = to.clone(value) @@ -85,7 +91,7 @@ export default function pages(options = {}) { // won't get added to the data delete value.page - let obj = result + let obj = this.result // convert to array, and filter out empty strings let path_list = path.split('/').filter(Boolean) @@ -95,27 +101,16 @@ export default function pages(options = {}) { // 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 = 0; i < length; i++) { - let page = path_list[i] + for (let [ i, page ] of to.entries(path_list, 0, length)) { // eslint-disable-line if (!obj[page]) { - obj[page] = { - page: { - header: {}, - body: [] - } - } + 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]] = { - page: { - header: {}, - body: [] - } - } + obj[path_list[length]] = to.clone(this.base) } if (type === 'header') { @@ -124,6 +119,4 @@ export default function pages(options = {}) { obj[path_list[length]].page.body.push(value) } } - - return result } From 398af2d57f696e8e26ebf875a4c0ebed8aaaf688 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 29 Mar 2016 12:12:55 -0400 Subject: [PATCH 270/273] fixed weird bug with String objects --- app/parser/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/parser/index.js b/app/parser/index.js index 3f49221..de43a7c 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -235,6 +235,7 @@ export default class Parser { let autofill_keys = to.keys(this.api.annotations.autofill) const cleanup = ({ inline, parsed }) => { if (!parsed) return {} + parsed = to.object(to.json(parsed)) // this get's rid of any weird objects that might still be present if (inline) { return to.merge(parsed, to.reduce(inline, (prev, next) => { return to.merge(prev, to.filter(next.parsed, ({ key }) => { From e4c0f1fb2cf807732fa01313cb46dca61b9f9bd9 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 29 Mar 2016 12:22:24 -0400 Subject: [PATCH 271/273] Updated tests This is to update the output of the test cases to add the change to the way the line endings are determined --- app/annotation-api.js | 65 +++------- app/annotations/annotation-utils.js | 5 +- app/annotations/blockinfo.js | 18 ++- app/annotations/markdown.js | 6 +- app/annotations/markup.js | 2 +- app/annotations/page.js | 3 +- app/annotations/states.js | 2 +- app/cli.js | 7 +- app/config.js | 8 +- app/docs.js | 13 +- app/parser/index.js | 72 ++++++----- app/parser/tokenizer.js | 64 +++++----- app/sorter/pages.js | 30 ++++- app/utils/index.js | 1 - app/utils/info.js | 10 -- app/utils/to.js | 4 +- .../access/access.autofill.body.json | 4 +- .../access/access.autofill.header.json | 10 +- tests/annotations/access/access.header.json | 8 +- tests/annotations/alias/alias.json | 12 +- tests/annotations/arg/arg.aliases.json | 12 +- tests/annotations/arg/arg.json | 24 ++-- tests/annotations/author/author.alias.json | 4 +- tests/annotations/author/author.body.json | 4 +- tests/annotations/author/author.header.json | 10 +- tests/annotations/author/author.multiple.json | 22 ++-- tests/annotations/chainable/chainable.json | 28 ++--- .../depricated/depricated.body.json | 16 +-- .../depricated/depricated.header.json | 10 +- .../description/description.alias.json | 48 ++++---- .../description/description.body.json | 12 +- .../description/description.header.json | 10 +- tests/annotations/markdown/mark.json | 14 +-- tests/annotations/markdown/markdown.json | 14 +-- tests/annotations/markdown/md.json | 14 +-- tests/annotations/markdown/mdml.json | 14 +-- tests/annotations/markdown/mdown.json | 14 +-- tests/annotations/markdown/mdtext.json | 14 +-- tests/annotations/markdown/mdtxt.json | 14 +-- tests/annotations/markdown/mdwn.json | 14 +-- tests/annotations/markdown/mkd.json | 14 +-- tests/annotations/markdown/mkdn.json | 14 +-- tests/annotations/markdown/text.json | 14 +-- tests/annotations/name/name.aliases.json | 12 +- tests/annotations/name/name.json | 4 +- tests/annotations/note/note.alias.json | 8 +- tests/annotations/note/note.json | 24 ++-- tests/annotations/page/page.alias.json | 12 +- .../annotations/page/page.body.autofill.json | 4 +- tests/annotations/page/page.body.json | 12 +- .../page/page.header.autofill.json | 10 +- tests/annotations/page/page.header.json | 4 +- .../property/property.aliases.json | 24 ++-- .../annotations/property/property.inline.json | 12 +- tests/annotations/property/property.json | 24 ++-- .../raw-code/raw-code.escaped.json | 4 +- tests/annotations/raw-code/raw-code.json | 4 +- tests/annotations/readonly/readonly.json | 12 +- .../annotations/requires/requires.alias.json | 4 +- tests/annotations/requires/requires.body.json | 28 ++--- .../annotations/requires/requires.header.json | 10 +- tests/annotations/returns/returns.alias.json | 28 ++--- tests/annotations/returns/returns.json | 28 ++--- tests/annotations/since/since.body.json | 16 +-- tests/annotations/since/since.header.json | 10 +- ...ltiple-markup-by-id-with-custom-props.json | 4 +- .../states-multiple-markup-by-id.json | 4 +- ...tes-multiple-markup-with-custom-props.json | 4 +- .../states-multiple-markup.json | 4 +- .../states-with-custom-props.json | 4 +- .../state/complex-multiple/states.json | 4 +- .../state/complex/single-markup.json | 4 +- .../blocks-with-different-states.json | 4 +- .../state/multiple-markup/blocks.json | 4 +- .../simple-with-description.json | 12 +- .../simple-with-notations.json | 12 +- .../state/stupid-simple-multiple/simple.json | 4 +- .../state/stupid-simple/simple.json | 4 +- .../state/stupid-simple/with-description.json | 12 +- .../state/stupid-simple/with-notations.json | 12 +- tests/annotations/throws/throws.alias.json | 16 +-- tests/annotations/throws/throws.json | 24 ++-- tests/annotations/todo/todo.body.json | 24 ++-- tests/annotations/todo/todo.header.json | 10 +- tests/annotations/type/type.json | 28 ++--- tests/annotations/version/version.json | 20 ++-- .../4-blank-lines-between-code-blocks.json | 20 ++-- .../4-blank-lines-between-code-blocks.scss | 1 + tests/cases/header-comment-only.json | 4 +- ...pace-between-header-and-body-comments.json | 10 +- tests/cases/only-body-comments-no-page.json | 113 +++++++++++++++++- tests/cases/only-body-comments.json | 103 +++++++++++++++- tests/cases/only-comments.json | 20 ++-- tests/cases/preserves-blank-lines.json | 16 +-- tests/cases/single-body-comment-no-code.json | 8 +- tests/cases/single-body-comment.json | 6 +- .../cases/space-between-comment-and-code.json | 8 +- tests/cases/starts-and-ends-with-spaces.json | 6 +- tests/file-types/c++/test.json | 22 ++-- tests/file-types/c/test.json | 22 ++-- tests/file-types/coffeescript/test.json | 22 ++-- tests/file-types/coldfusion/test.json | 26 ++-- tests/file-types/cs/test.json | 22 ++-- tests/file-types/css/test.json | 14 +-- tests/file-types/html/test.html | 48 ++++---- tests/file-types/html/test.json | 14 +-- tests/file-types/jade/test.json | 10 +- tests/file-types/java/test.json | 22 ++-- tests/file-types/js/test.json | 18 +-- tests/file-types/less/test.json | 22 ++-- tests/file-types/markdown/mark.json | 4 +- tests/file-types/markdown/markdown.json | 4 +- tests/file-types/markdown/md.json | 4 +- tests/file-types/markdown/mdml.json | 4 +- tests/file-types/markdown/mdown.json | 4 +- tests/file-types/markdown/mdtext.json | 4 +- tests/file-types/markdown/mdtxt.json | 4 +- tests/file-types/markdown/mdwn.json | 4 +- tests/file-types/markdown/mkd.json | 4 +- tests/file-types/markdown/mkdn.json | 4 +- tests/file-types/markdown/text.json | 4 +- tests/file-types/php/test.json | 22 ++-- tests/file-types/python/test.json | 24 ++-- tests/file-types/ruby/test.json | 22 ++-- tests/file-types/scss/inline.json | 109 +++++++++++++++++ tests/file-types/scss/inline.scss | 15 +++ tests/file-types/scss/test.json | 16 +-- tests/file-types/stylus/test.json | 22 ++-- tests/file-types/swift/test.json | 22 ++-- tests/run.test.js | 8 +- .../comments-in-comments.json | 33 +++++ .../comments-in-comments.styl | 20 ++++ tools/generate-test.js | 7 +- tools/tokenizer-helper.js | 2 +- 134 files changed, 1263 insertions(+), 886 deletions(-) delete mode 100644 app/utils/info.js create mode 100644 tests/file-types/scss/inline.json create mode 100644 tests/file-types/scss/inline.scss create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json create mode 100644 tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl diff --git a/app/annotation-api.js b/app/annotation-api.js index 59a981b..b829a10 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -1,39 +1,6 @@ 'use strict' - import { is, to } from './utils' -const 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.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 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 -} - - export default class AnnotationApi { constructor({ annotations, file, type }) { // object of the all the annotation @@ -66,7 +33,7 @@ export default class AnnotationApi { // This function runs when the parser gets // the annotations information parse() { - return this.annotation.line + return this.contents.shift() }, // Runs when the each annotation in the block has been @@ -238,21 +205,17 @@ export default class AnnotationApi { }) } - run(type, options) { + run(type, ...options) { { const base = { contents: [], start: -1, end: -1 } options = to.arguments({ - type: 'parse', annotation: { name: '', alias: '', ...base }, - file: { path: '', name: '', type: '', options: {}, ...base }, + file: { path: '', name: '', type: '', ...base }, comment: { ...base }, code: { ...base }, - }, arguments) + }, ...options) } - let { type: fn_name, ...base } = options - - // /// @name add // /// @page annotation // /// @description Allows you to add a different annotation from within a annotation @@ -277,30 +240,30 @@ export default class AnnotationApi { { const list = this.annotations_list - const { annotation, file } = base + 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[fn_name])) { - base.default = () => default_fn.call(base) + if (fn && default_fn && (default_fn = default_fn[type])) { + options.default = () => default_fn.call(options) } } - let to_call = base + let to_call = options let details try { - const fn = this.getAnnotationFn(base.annotation.name, fn_name) + const fn = this.getAnnotationFn(options.annotation.name, type) - if (fn_name === 'parse') { - to_call = copyInvisible(details = base.annotation, base) - } else if (fn_name === 'resolve') { - to_call = copyInvisible(details = base.parsed[base.annotation.name], base) + if (type === 'parse') { + to_call = copyInvisible(details = options.annotation, options) + } else if (type === 'resolve') { + to_call = copyInvisible(details = options.parsed[options.annotation.name], options) } let result = is.function(fn) ? fn.call(to_call) : fn - if (fn_name === 'parse' && !is.any.undefined(details, result)) { + if (type === 'parse' && !is.any.undefined(details, result)) { if (is.array(result) && result.length === 1) { result = to.map(result, (obj) => copyInvisible(obj, { details })) } diff --git a/app/annotations/annotation-utils.js b/app/annotations/annotation-utils.js index e73173a..8ff1a8f 100644 --- a/app/annotations/annotation-utils.js +++ b/app/annotations/annotation-utils.js @@ -82,7 +82,8 @@ export function logAnnotationError(obj, expected) { annotation, comment, code, - file + file, + options } = obj const total_lines = ~~((11 + (annotation.end - annotation.start)) / 2) @@ -98,7 +99,7 @@ export function logAnnotationError(obj, expected) { // 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 = file.options[comment.type].line + 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 diff --git a/app/annotations/blockinfo.js b/app/annotations/blockinfo.js index b83ae57..b1b1a97 100644 --- a/app/annotations/blockinfo.js +++ b/app/annotations/blockinfo.js @@ -1,5 +1,6 @@ import { to, is } from '../utils' import { logAnnotationError } from './annotation-utils' +import path from 'path' /// @name blockinfo /// @page annotations /// @description @@ -26,6 +27,8 @@ import { logAnnotationError } from './annotation-utils' /// } /// } /// ``` +const root = process.cwd() +const root_dir = root.split(path.sep).pop() export default { autofill() { let obj = to.clone(this) @@ -37,18 +40,13 @@ export default { 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 } - - // @todo {5} decide if `comment` needs the `type` key. If it doesn't need - // it then just use the code below because it removes all the things that - // aren't needed from each of the values in `this` - // const filter = [ 'contents', 'name', 'type', 'comment', 'options' ] - // return to.map(this, (obj) => { - // return { - // [obj.key]: to.filter(obj.value, ({ key }) => !is.in(filter, key)) - // } - // }) }, parse() { this.log.emit('warning', "Passed @blockinfo, it's only supposed to be an autofilled annotation", logAnnotationError(this, '')) diff --git a/app/annotations/markdown.js b/app/annotations/markdown.js index ffcea2c..131422f 100644 --- a/app/annotations/markdown.js +++ b/app/annotations/markdown.js @@ -25,9 +25,9 @@ export default { 'text', 'md' ], parse() { - const options = this.file.options - const start = `(?:${options.header.start}|${options.body.start})`.replace('\\', '\\\\') - const end = `(?:${options.header.end}|${options.body.end})`.replace('\\', '\\\\') + 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 index d315dbd..9bc7710 100644 --- a/app/annotations/markup.js +++ b/app/annotations/markup.js @@ -62,7 +62,7 @@ export default { let state_interpolation { - const { interpolation, prefix } = this.file.options + const { interpolation, prefix } = this.options.language const { start, end } = interpolation state_interpolation = `${start}${prefix}states?[^${end}]*${end}` diff --git a/app/annotations/page.js b/app/annotations/page.js index 047d914..af8cfa2 100644 --- a/app/annotations/page.js +++ b/app/annotations/page.js @@ -38,6 +38,7 @@ import { list } from './annotation-utils' /// /// @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() { @@ -46,7 +47,7 @@ export default { autofill() { // autofill header comments if (this.comment.type === 'header') { - return [ 'other' ] + return [ this.options.page_fallback ] } // don't autofill body comments return diff --git a/app/annotations/states.js b/app/annotations/states.js index d9a690d..c1fb5c4 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -109,7 +109,7 @@ function replaceStates(str, states) { { let names = [ this.annotation.name, ...(this.annotation.alias) ].join('|') - const { interpolation, prefix } = this.file.options + const { interpolation, prefix } = this.options.language const { start, end } = interpolation state_interpolation = new RegExp(`${start}${prefix}(?:${names})[^${end}]*${end}`, 'g') diff --git a/app/cli.js b/app/cli.js index 510216c..b87e965 100644 --- a/app/cli.js +++ b/app/cli.js @@ -1,6 +1,6 @@ /* eslint-disable no-bitwise */ import pkg from '../package.json' -import { info, fs, to } from './utils' +import { fs, to } from './utils' import program from 'commander' import docs from './docs' import { default_options } from './config' @@ -10,6 +10,7 @@ export default function cli() { 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) @@ -20,9 +21,9 @@ export default function cli() { Note: Put globs quotes \`'.*, app/**/*'\` to avoid issues `) - .option('-d, --dest [path]', 'Documentation folder', `${info.root}/docs/docs.json`) + .option('-d, --dest [path]', 'Documentation folder', `${root}/docs/docs.json`) .option('-c, --config [path]', 'Path to configuration file', default_options.config) - .option('-i, --ignore ', 'Paths to ignore', to_list, default_options.ignore) + .option('-i, --ignore ', 'Paths to ignore', to_list, default_options.ignore) .option('-w, --watch', 'Recompile docs on changes', true, default_options.watch) .option('-g, --gitignore', 'Add `gitignore` files to the ignored files', default_options.gitignore) .option('-x, --no-debug', 'Output debugging information', to_boolean, default_options.debug) diff --git a/app/config.js b/app/config.js index c7a6ecd..d0d9d78 100644 --- a/app/config.js +++ b/app/config.js @@ -1,5 +1,5 @@ /* eslint-disable guard-for-in */ -import { info, fs, is, to, Logger } from './utils' +import { fs, is, to, Logger } from './utils' import path from 'path' import * as annotations from './annotations' @@ -7,7 +7,7 @@ let log = new Logger() // changed by `options` key export const default_options = { - config: `${info.root}/.docsfile.js`, + config: `${process.cwd()}/.docsfile.js`, // files to parse for documentation files: [ 'app/**/*', 'src/**/*', '*.md' ], @@ -133,12 +133,12 @@ export default async function config(options = {}) { // merge options with default_options so there's a complete list of settings options = to.extend(to.clone(default_options), options) - + const root = process.cwd() if (options.gitignore) { try { options.ignore = to.flatten([ options.ignore, - to.array(to.string(await fs.readFile(path.join(info.root, '.gitignore')))) + to.array(to.string(await fs.readFile(path.join(root, '.gitignore')))) ]) } catch (err) { // do nothing because there's no `.gitignore` diff --git a/app/docs.js b/app/docs.js index 6b4a373..1d76432 100644 --- a/app/docs.js +++ b/app/docs.js @@ -2,9 +2,7 @@ import path from 'path' import { - info, to, - fs, glob, } from './utils' import Parser from './parser' @@ -45,7 +43,8 @@ export default async function docs(options = {}) { let json = {} let parsers = {} - let ignored + const ignored = await glob(ignore) + const root = process.cwd() let walk = async (files) => { files = to.array(files) @@ -53,10 +52,9 @@ export default async function docs(options = {}) { log.emit('start', 'total') try { log.emit('start', 'paths') - ignored = await glob(ignore) files = await glob(files, ignored) - let paths_message = `%s completed ${to.map(files, (file) => clor.bold(path.join(info.dir, file))).join(', ')} after %dms` + let paths_message = `%s completed ${to.map(files, (file) => clor.bold(path.join(root, file))).join(', ')} after %dms` if (files.length > 3) { let s = files.length > 1 ? 's' : '' // eslint-disable-line paths_message = `%s completed after %dms with ${files.length} file${s} to parse` @@ -65,16 +63,15 @@ export default async function docs(options = {}) { log.emit('start', 'parser') options.annotationsApi = annotations - const parser_options = { blank_lines, indent, annotations, sort, log } const parse = async ({ file, type }) => { return { - [path.join('docs', file)]: await parsers[type].parse(file) + [file]: await parsers[type].parse(file) } } - + const parser_options = { page_fallback, blank_lines, indent, annotations, sort, log } files = await map(files, (file) => { const type = path.extname(file).replace('.', '') if (!parsers[type]) { diff --git a/app/parser/index.js b/app/parser/index.js index de43a7c..10c60b1 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -36,19 +36,22 @@ export default class Parser { log: new Logger() }, arguments) - let { annotations, type, ...rest } = options + let { annotations, type, log, ...rest } = options + this.log = log this.options = rest this.api = new AnnotationApi({ annotations, type }) - { - const { language } = this.options - this.comment_values = to.flatten([ - ...to.values(language.header, '!type'), - ...to.values(language.body, '!type'), - ...to.values(language.inline, '!type') - ]) - this.comment_values = to.unique(this.comment_values).filter(Boolean) - } + // this is used to pass to the annotations when they're called + this.annotation_options = { log: this.log, options: this.options } + + const { language } = this.options + + this.comment_values = to.flatten([ + ...to.values(language.header, '!type'), + ...to.values(language.body, '!type'), + ...to.values(language.inline, '!type') + ]) + this.comment_values = to.unique(this.comment_values).filter(Boolean) { let { alias, parse } = this.api.annotations @@ -59,7 +62,7 @@ export default class Parser { .reduce((a, b) => to.extend(a, { [b]: key }), {}) return to.extend(previous, value) }, {}) - const regex = new RegExp(`^\s*${this.options.language.prefix}(?:(${to.keys(reverse_alias_list).join('|')})|(${parse.join('|')}))\\b\\s*`) + const regex = new RegExp(`^\s*${language.prefix}(?:(${to.keys(reverse_alias_list).join('|')})|(${parse.join('|')}))\\b\\s*`) this.annotations_list = { reverse_alias_list, regex } } @@ -69,12 +72,11 @@ export default class Parser { file = is.plainObject(file) ? file : { path: file } file.type = file.type || path.extname(file.path).replace('.', '') file.contents = file.contents || to.string(await fs.readFile(file.path)) - file.path = path.join(process.cwd().split(path.sep).pop(), file.path) file.name = path.basename(file.path, `.${file.type}`) // name of the file - file.options = this.options.language file.start = 1 // starting point of the file file.end = to.array(file.contents).length // ending point of the file - this.file = file + // add the file to the annotation_options that are passed to the annotation functions + this.annotation_options.file = this.file = file // if the file is empty or there aren't any comments then // just return the the empty values @@ -98,6 +100,12 @@ export default class Parser { const { language, blank_lines, indent } = this.options const base = { blank_lines, indent, verbose: true } const header = new Tokenizer(contents, 0, language.header, { restrict: true, ...base })[0] || {} + + // remove the code from the header comment because it shouldn't be used. + if (header.code) { + header.code = { contents: [], start: -1, end: -1 } + } + let body = new Tokenizer(contents, header.comment ? header.comment.end + 1 : 0, language.body, base) const inline_tokenizer = new Tokenizer({ comment: language.inline, ...base }) @@ -127,7 +135,7 @@ export default class Parser { } header = map(header) - body = to.map(body, map) + body = to.map(body, (token, i) => map(token, i, header)) return { header, body } } @@ -167,12 +175,15 @@ export default class Parser { } parseTokens(tokens) { - const { log } = this.options - const file = this.file - return this.map(tokens, (token, parent) => { token.parsed = to.reduce(token.annotations, (result, annotation) => { - const current = this.api.run('parse', { annotation, ...token, parent, file, log }) + const current = this.api.run('parse', { + annotation, + ...token, + parent, + ...(this.annotation_options) + }) + if (result != null) { return to.merge(result, { [annotation.name]: current @@ -185,16 +196,17 @@ export default class Parser { } autofillTokens(tokens) { - const { log } = this.options - const file = this.file const autofill_list = to.keys(this.api.annotations.autofill) - return this.map(tokens, (token, parent) => { - const base = { ...token, parent, file, log } const parsed_keys = to.keys(token.parsed) for (let name of autofill_list) { if (!is.in(parsed_keys, name)) { - const result = this.api.run('autofill', { name }, base) + const result = this.api.run('autofill', { + annotation: { name }, + ...token, + parent, + ...(this.annotation_options) + }) if (result != null) { token.parsed[name] = result } @@ -206,9 +218,7 @@ export default class Parser { } resolveTokens(tokens) { - const { options } = this - const { log, sort } = options - const file = this.file + const { sort } = this.options let resolve_list = to.keys(this.api.annotations.resolve) // sort the parsed object before the annotations are resolved if (is.fn(sort)) { @@ -216,11 +226,15 @@ export default class Parser { } return this.map(tokens, (token, parent) => { - const base = { ...token, parent, file, log, } const parsed_keys = to.keys(token.parsed) for (let name of resolve_list) { if (is.in(parsed_keys, name)) { - const result = this.api.run('resolve', { name, alias: this.api.annotations.alias[name] }, base) + const result = this.api.run('resolve', { + annotation: { name, alias: this.api.annotations.alias[name] }, + ...token, + parent, + ...(this.annotation_options) + }) if (result != null) { token.parsed[name] = result } diff --git a/app/parser/tokenizer.js b/app/parser/tokenizer.js index 5f82a26..158027f 100644 --- a/app/parser/tokenizer.js +++ b/app/parser/tokenizer.js @@ -85,6 +85,8 @@ export default class Tokenizer { // holds the parsed tokens this.tokens = [] + this.current_blank_lines = 0 + // update the stash this.stash = this.getStash(stash) @@ -140,7 +142,7 @@ export default class Tokenizer { // add a space to each line so the line index is 1 based instead of 0 based. If the line is empty, // a space will not be added so that it's still easy to check if a line is empty or not. Doing this makes it // much easier to determine if any of the indexes are actually falsy or not, and it makes tracking errors easier - let stash = to.map(to.array(content), (line, i) => { + return to.map(to.array(content), (line, i) => { line = new Line(!line ? line : ` ${line}`, i) const str = `${line}` line.index = to.reduce([ 'start', 'single', 'end' ], (prev, next) => { @@ -158,7 +160,9 @@ export default class Tokenizer { const { start, single, end } = this.options.comment let code_exsists // remove the comment and check to see if it has a line has code on it. - if (!this.is_multi && line.index.single) { + if (this.isEmpty(str)) { + code_exsists = true + } else if (!this.is_multi && line.index.single) { code_exsists = !this.isEmpty(this.getBefore(single, str)) } else if (this.is_same_multi || line.index.start) { code_exsists = !this.isEmpty(this.getBefore(start || end, str)) @@ -170,12 +174,10 @@ export default class Tokenizer { } line.has_comment = is.any.truthy(line.index.start, line.index.single, line.index.end) - line.has_code = is.truthy(line.index.code) + line.has_code = is.truthy(this.isEmpty(str) || line.index.code) return line }) - - return stash } /// @name parse @@ -233,16 +235,11 @@ export default class Tokenizer { debug.push(`line [${this.lineno}]: ${clor.bgBlue(this.line)}`, this.line).run() - if ( - this.line.has_comment - ) { + if (this.line.has_comment) { this.token = new Token() - { - const { type } = this.options.comment - if (type) { - this.token.comment.type = type - } + if (this.options.comment.type) { + this.token.comment.type = this.options.comment.type } debug.push('has comment').run() @@ -279,7 +276,7 @@ export default class Tokenizer { /// @returns {string} getBefore(comment, str) { if (!comment || !str) return str - return str.split(comment).shift() + return str.slice(0, str.indexOf(comment)) } /// @name this.getAfter @@ -290,7 +287,7 @@ export default class Tokenizer { /// @returns {string} getAfter(comment, str) { if (!comment || !str) return str - return str.split(comment).pop() + return str.slice(str.indexOf(comment) + comment.length) } /// @name getCode @@ -298,23 +295,30 @@ export default class Tokenizer { /// Recursively pushes the code from each line onto the current token getCode() { const debug = this.debugGetCode + // store the starting lines indent const { indent } = this.line const recursiveCode = () => { let line = to.clone(this.line) + let str = `${line}` if ( !this.is_same_multi && !line.index.start && line.index.end ) { - line.str = `${line}`.slice(line.index.end + this.options.comment.end.length + 1) + line.str = str = str.slice(line.index.end + this.options.comment.end.length + 1) } else { - line.str = `${line}`.slice(1, line.index.start || line.index.single || line.index.end || undefined) + line.str = str = str.slice(1, line.index.start || line.index.single || line.index.end || undefined) } // check to see if the current lines indent is less than the starting indent of the code - if (this.options.indent && !is.empty(line.toString()) && line.indent < indent) { + if (!is.empty(str)) { + this.current_blank_lines = 0 + if (this.options.indent && line.indent < indent) { + return + } + } else if (++this.current_blank_lines >= this.options.blank_lines) { return } @@ -323,10 +327,10 @@ export default class Tokenizer { if ( this.hasNext() && - debug.ifTrue(!this.is_same_multi || !line.has_comment, `the current line(${line.strno}) doesn't have a comment: ${clor.bgGreen(line)}`) + debug.ifTrue(!this.is_same_multi || !line.has_comment, `the current line(${line.lineno}) doesn't have a comment: ${clor.bgGreen(line)}`) ) { const next_line = this.peak() - const next_msg = `the next line(${next_line.strno}) has a comment: ${clor.bgRed(next_line)}` + const next_msg = `the next line(${next_line.lineno}) has a comment: ${clor.bgRed(next_line)}` return debug.ifFalse(!next_line.has_comment, next_msg) && this.next() && recursiveCode() } } @@ -346,11 +350,11 @@ export default class Tokenizer { line.str = this.getAfter(comment.single, `${line}`) this.token.comment.contents.push(line) - const current_msg = `the current line(${line.strno}) doesn't have code: ${clor.bgGreen(line)}` + const current_msg = `the current line(${line.lineno}) doesn't have code: ${clor.bgGreen(line)}` if (debug.ifTrue(!line.has_code, current_msg) && this.hasNext()) { const next_line = this.peak() const context = next_line.has_code ? 'has code' : 'is empty' - const next_msg = `the next line(${next_line.strno}) ${context}: ${clor.bgRed(next_line)}` + const next_msg = `the next line(${next_line.lineno}) ${context}: ${clor.bgRed(next_line)}` this.next() return debug.ifFalse(next_line.has_comment && !next_line.has_code, next_msg, true) && this.getSingleComment() @@ -369,10 +373,6 @@ export default class Tokenizer { let line = to.clone(this.line) let str = `${line}` - if (line.index.start || line.index.single) { - str = this.getAfter(line.index.start ? comment.start : comment.single, str) - } - if (line.index.end) { str = this[this.is_same_multi ? 'getAfter' : 'getBefore'](comment.end, str) @@ -382,17 +382,21 @@ export default class Tokenizer { } } + if (line.index.start || line.index.single) { + str = this.getAfter(line.index.start ? comment.start : comment.single, str) + } + line.str = str this.token.comment.contents.push(line) debug.push(line) if (this.hasNext()) { - if (debug.ifTrue(!line.index.end, `the current line(${line.strno}) wasn't the last comment: ${clor.bgGreen(this.line)}`)) { + if (debug.ifTrue(!line.index.end, `the current line(${line.lineno}) wasn't the last comment: ${clor.bgGreen(this.line)}`)) { debug.run() return this.next() && this.getMultiComment() } const next = this.peak() if ( - debug.ifTrue(!line.index.code, `the current line(${line.strno}) doesn't has code: ${clor.bgGreen(line)}`) && + debug.ifTrue(!line.index.code, `the current line(${line.lineno}) doesn't has code: ${clor.bgGreen(line)}`) && debug.ifTrue(!next.has_comment, `the next line(${next.lineno}) doesn't have a comment: ${clor.bgGreen(next)}`) ) { debug.run() @@ -459,6 +463,7 @@ export default class Tokenizer { debug.push(token).run() this.tokens.push(token) this.token = undefined + this.current_blank_lines = 0 } /// @name commentExisits @@ -477,8 +482,7 @@ export default class Tokenizer { if (index > -1) { if ( is.in(line, `${comment_type} `) || // check to see if the required space after the comment_type exisits - line.length === index + comment_type.length || // check to see if the comment_type is the last thing on that line (aka ) - !line.slice(0, index).trim() + line.length === index + comment_type.length // check to see if the comment_type is the last thing on that line (aka ) ) { return index } diff --git a/app/sorter/pages.js b/app/sorter/pages.js index 85aef47..0fb5950 100644 --- a/app/sorter/pages.js +++ b/app/sorter/pages.js @@ -34,7 +34,9 @@ class Pages { return to.each(val, (value) => this.parse({ key, value }), this) } - this.parseToken({ key, value: val }) + if (!is.empty(val)) { + this.parseToken({ key, value: val }) + } } } @@ -55,10 +57,19 @@ class Pages { this.header.page = [ this.page_fallback ] } - if (!is_header && !is.empty(this.header.page)) { - token.page = to.unique([ ...(this.header.page), ...(token.page || []) ]) + let page_list = [] + // if the header doesn't exist or the page is empty + if (!token.page || is.empty(token.page)) { + if (this.header.page && !is.empty(this.header.page)) { + page_list.push(...(this.header.page)) + } else if (!this.header.page || is.empty(this.header.page)) { + page_list.push(this.page_fallback) + } } + page_list.push(token.page || '') + + token.page = page_list = to.unique(to.flatten(to.filter(page_list))) // If the token doesn't contain a name and isn't a header comment it get's skipped if (is.falsy(token.name)) { @@ -67,13 +78,22 @@ class Pages { The hardest thing in development is naming all the things but you gotta try, add a ${clor.bold('@name')} annotation to the comment block starting on line ${token.blockinfo.comment.start} in ${clor.bold.blue(path)} `)) - return + // return } // set the token name to be the filepath name - token.name = to.titleCase(path.split('/').pop().split('.').shift()) + // let name = path.split('/').pop() + // token.name = name.split('.') + // token.name = `${to.titleCase(token.name[0])} ${to.upperCase(token.name[1])} File` // `(${name})` } + if (is.empty(page_list)) { + this.log.emit('warning', to.normalize(` + The documentation starting on line ${token.blockinfo.comment.start} isn't being added because a ${clor.bold('@page')} annotation doesn't exist + ${clor.bold.blue(path)} + `)) + return + } for (const page of token.page) this.set(page, token_type, token) } diff --git a/app/utils/index.js b/app/utils/index.js index 1245f06..cb8e966 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -2,7 +2,6 @@ export Logger from './logger' export { Purdy } from './purdy' export fs from './fs' export glob from './glob' -export info from './info' export is from './is' export to from './to' export debug from './debug' diff --git a/app/utils/info.js b/app/utils/info.js deleted file mode 100644 index e76c239..0000000 --- a/app/utils/info.js +++ /dev/null @@ -1,10 +0,0 @@ -import path from '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 - -export default info diff --git a/app/utils/to.js b/app/utils/to.js index a637efb..b52c25b 100644 --- a/app/utils/to.js +++ b/app/utils/to.js @@ -785,9 +785,9 @@ let to = { /// @name to.filter /// @description This function allows you to filter an array or object /// @arg {array, object} obj - /// @arg {function} callback + /// @arg {function} callback [Boolean] /// @returns {array, object} that was filtered - filter(obj, callback, context = null) { + filter(obj, callback = Boolean, context = null) { if (is.array(obj)) { return obj.filter(callback, context) } diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json index d863d86..6838adb 100644 --- a/tests/annotations/access/access.autofill.body.json +++ b/tests/annotations/access/access.autofill.body.json @@ -3,6 +3,7 @@ "body": [ { "name": "autofill access", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,8 +19,7 @@ "start": 1, "end": 2 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json index cca80df..1665da7 100644 --- a/tests/annotations/access/access.autofill.header.json +++ b/tests/annotations/access/access.autofill.header.json @@ -1,6 +1,10 @@ { "header": { "name": "autofill access", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -16,11 +20,7 @@ "start": 1, "end": 4 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/access/access.header.json b/tests/annotations/access/access.header.json index 1074d28..48e6336 100644 --- a/tests/annotations/access/access.header.json +++ b/tests/annotations/access/access.header.json @@ -1,6 +1,9 @@ { "header": { "access": "private", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -16,10 +19,7 @@ "start": 1, "end": 4 } - }, - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json index 2009d1e..c4af7e9 100644 --- a/tests/annotations/alias/alias.json +++ b/tests/annotations/alias/alias.json @@ -5,6 +5,7 @@ "alias": [ "foo" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,14 +21,14 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "alias": [ "foo", "bar" ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -43,14 +44,14 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "alias": [ "foo", "bar" ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -66,8 +67,7 @@ "start": 1, "end": 6 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json index ca546eb..a29797f 100644 --- a/tests/annotations/arg/arg.aliases.json +++ b/tests/annotations/arg/arg.aliases.json @@ -12,6 +12,7 @@ "description": "

    argument alias

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -27,8 +28,7 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "arg": [ @@ -41,6 +41,7 @@ "description": "

    param alias

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -56,8 +57,7 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "arg": [ @@ -70,6 +70,7 @@ "description": "

    parameter alias

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -85,8 +86,7 @@ "start": 1, "end": 6 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json index 99bdd0f..45349b8 100644 --- a/tests/annotations/arg/arg.json +++ b/tests/annotations/arg/arg.json @@ -10,6 +10,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,8 +26,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "arg": [ @@ -39,6 +39,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -54,8 +55,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "arg": [ @@ -69,6 +69,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -84,8 +85,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "arg": [ @@ -98,6 +98,7 @@ "description": "

    description

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -113,8 +114,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "arg": [ @@ -127,6 +127,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -142,8 +143,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "arg": [ @@ -156,6 +156,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -171,8 +172,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json index 8a6e970..aa7ed99 100644 --- a/tests/annotations/author/author.alias.json +++ b/tests/annotations/author/author.alias.json @@ -7,6 +7,7 @@ "Author Two", "Author Three" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,8 +23,7 @@ "start": 1, "end": 2 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json index 52cc9f0..9b8f382 100644 --- a/tests/annotations/author/author.body.json +++ b/tests/annotations/author/author.body.json @@ -5,6 +5,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,8 +21,7 @@ "start": 1, "end": 2 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json index 75e9a9e..d3276d9 100644 --- a/tests/annotations/author/author.header.json +++ b/tests/annotations/author/author.header.json @@ -3,6 +3,10 @@ "author": [ "Tyler Benton" ], + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -18,11 +22,7 @@ "start": 1, "end": 4 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index ae0cae5..37ed0fd 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -4,6 +4,10 @@ "Author One", "Author Two" ], + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -19,11 +23,7 @@ "start": 1, "end": 14 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [ { @@ -31,6 +31,7 @@ "Author One", "Author Two" ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -46,14 +47,14 @@ "start": 1, "end": 14 } - }, - "access": "public" + } }, { "author": [ "Author One", "Author Two" ], + "access": "public", "blockinfo": { "comment": { "start": 8, @@ -69,14 +70,14 @@ "start": 1, "end": 14 } - }, - "access": "public" + } }, { "author": [ "Author One", "Author Two" ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -92,8 +93,7 @@ "start": 1, "end": 14 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json index 9d10972..9ae5092 100644 --- a/tests/annotations/chainable/chainable.json +++ b/tests/annotations/chainable/chainable.json @@ -3,6 +3,7 @@ "body": [ { "chainable": true, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,11 +19,11 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "chainable": true, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -38,11 +39,11 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "chainable": false, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -58,13 +59,13 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "chainable": [ "Object.prototype" ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -80,14 +81,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "chainable": [ "One", "Two" ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -103,14 +104,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "chainable": [ "One", "Two" ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -126,14 +127,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "chainable": [ "One", "Two" ], + "access": "public", "blockinfo": { "comment": { "start": 15, @@ -149,8 +150,7 @@ "start": 1, "end": 18 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json index 4f8711e..9ff0f94 100644 --- a/tests/annotations/depricated/depricated.body.json +++ b/tests/annotations/depricated/depricated.body.json @@ -6,6 +6,7 @@ "version": "0", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,14 +22,14 @@ "start": 1, "end": 11 } - }, - "access": "public" + } }, { "deprecated": { "version": "0.0.1", "description": "

    Lorem

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -44,14 +45,14 @@ "start": 1, "end": 11 } - }, - "access": "public" + } }, { "deprecated": { "version": "0.0.1", "description": "

    Lorem

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -67,14 +68,14 @@ "start": 1, "end": 11 } - }, - "access": "public" + } }, { "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" }, + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -90,8 +91,7 @@ "start": 1, "end": 11 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json index 62970eb..381ca8b 100644 --- a/tests/annotations/depricated/depricated.header.json +++ b/tests/annotations/depricated/depricated.header.json @@ -4,6 +4,10 @@ "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" }, + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -19,11 +23,7 @@ "start": 1, "end": 7 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json index 33c8471..f3cef05 100644 --- a/tests/annotations/description/description.alias.json +++ b/tests/annotations/description/description.alias.json @@ -4,6 +4,7 @@ { "name": "single-line `desc`", "description": "

    Lorem ipsum

    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,12 +20,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "multi-line `desc`", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 4, @@ -40,12 +41,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "single-line `definition`", "description": "

    Lorem ipsum

    \n", + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -61,12 +62,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "multi-line `definition`", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 14, @@ -82,12 +83,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "single-line `explanation`", "description": "

    Lorem ipsum

    \n", + "access": "public", "blockinfo": { "comment": { "start": 21, @@ -103,12 +104,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "multi-line `explanation`", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 24, @@ -124,12 +125,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "single-line `writeup`", "description": "

    Lorem ipsum

    \n", + "access": "public", "blockinfo": { "comment": { "start": 31, @@ -145,12 +146,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "multi-line `writeup`", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 34, @@ -166,12 +167,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "single-line `summary`", "description": "

    Lorem ipsum

    \n", + "access": "public", "blockinfo": { "comment": { "start": 41, @@ -187,12 +188,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "multi-line `summary`", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 44, @@ -208,12 +209,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "single-line `summarization`", "description": "

    Lorem ipsum

    \n", + "access": "public", "blockinfo": { "comment": { "start": 51, @@ -229,12 +230,12 @@ "start": 1, "end": 58 } - }, - "access": "public" + } }, { "name": "multi-line `summarization`", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 54, @@ -250,8 +251,7 @@ "start": 1, "end": 58 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json index 598a35f..fd105a9 100644 --- a/tests/annotations/description/description.body.json +++ b/tests/annotations/description/description.body.json @@ -3,6 +3,7 @@ "body": [ { "description": "

    Lorem ipsum dolor sit amet

    \n", + "access": "public", "blockinfo": { "comment": { "start": 2, @@ -18,11 +19,11 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "description": "

    Line one\nOther\nlines\nbelow\nit

    \n", + "access": "public", "blockinfo": { "comment": { "start": 4, @@ -38,11 +39,11 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "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", + "access": "public", "blockinfo": { "comment": { "start": 10, @@ -58,8 +59,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json index 4ef4def..5b38d07 100644 --- a/tests/annotations/description/description.header.json +++ b/tests/annotations/description/description.header.json @@ -1,6 +1,10 @@ { "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", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -16,11 +20,7 @@ "start": 1, "end": 8 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index cffdff0..9713e9a 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mark.mark", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 3686882..48eeda0 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/markdown.markdown", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index 91ac095..3f9cee8 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/md.md", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index 6cd004d..5d7d26d 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mdml.mdml", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index 0ee4367..0916249 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mdown.mdown", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index cd24904..d822d5f 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mdtext.mdtext", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index ff4cdf2..7e57696 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mdtxt.mdtxt", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index 88fe963..aa76784 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mdwn.mdwn", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index 9ea14fa..03d0d13 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mkd.mkd", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index 12effb0..4c828f0 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/mkdn.mkdn", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index c972f14..6a015c6 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -1,6 +1,10 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -8,19 +12,15 @@ "type": "header" }, "code": { - "start": 4, - "end": 12 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/annotations/markdown/text.text", "start": 1, "end": 13 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json index 803fd97..9013c9f 100644 --- a/tests/annotations/name/name.aliases.json +++ b/tests/annotations/name/name.aliases.json @@ -3,6 +3,7 @@ "body": [ { "name": "Title", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,11 +19,11 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "name": "Heading", + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -38,11 +39,11 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "name": "Header", + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -58,8 +59,7 @@ "start": 1, "end": 6 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json index 0cfd6ff..1220da7 100644 --- a/tests/annotations/name/name.json +++ b/tests/annotations/name/name.json @@ -3,6 +3,7 @@ "body": [ { "name": "Foo", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,8 +19,7 @@ "start": 1, "end": 2 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json index 9b8c0e3..4676aef 100644 --- a/tests/annotations/note/note.alias.json +++ b/tests/annotations/note/note.alias.json @@ -8,6 +8,7 @@ "description": "
      \n
    • note 1
    • \n
    • note 2
    • \n
    • note 3
    • \n
    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,8 +24,7 @@ "start": 1, "end": 10 } - }, - "access": "public" + } }, { "note": [ @@ -33,6 +33,7 @@ "description": "
      \n
    • note 1
    • \n
    • note 2
    • \n
    • note 3
    • \n
    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -48,8 +49,7 @@ "start": 1, "end": 10 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json index 7572be6..af25a69 100644 --- a/tests/annotations/note/note.json +++ b/tests/annotations/note/note.json @@ -8,6 +8,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,8 +24,7 @@ "start": 1, "end": 20 } - }, - "access": "public" + } }, { "note": [ @@ -33,6 +33,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -48,8 +49,7 @@ "start": 1, "end": 20 } - }, - "access": "public" + } }, { "note": [ @@ -58,6 +58,7 @@ "description": "

    Lorem ipsum dolor sit amet

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -73,8 +74,7 @@ "start": 1, "end": 20 } - }, - "access": "public" + } }, { "note": [ @@ -83,6 +83,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -98,8 +99,7 @@ "start": 1, "end": 20 } - }, - "access": "public" + } }, { "note": [ @@ -108,6 +108,7 @@ "description": "

    Lorem ipsum dolor sit amet

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 13, @@ -123,8 +124,7 @@ "start": 1, "end": 20 } - }, - "access": "public" + } }, { "note": [ @@ -133,6 +133,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 15, @@ -148,8 +149,7 @@ "start": 1, "end": 20 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json index 08bebdd..d86ad7b 100644 --- a/tests/annotations/page/page.alias.json +++ b/tests/annotations/page/page.alias.json @@ -5,6 +5,7 @@ "page": [ "level 1" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,13 +21,13 @@ "start": 1, "end": 7 } - }, - "access": "public" + } }, { "page": [ "level 1/level 2" ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -42,14 +43,14 @@ "start": 1, "end": 7 } - }, - "access": "public" + } }, { "page": [ "page 1/level 2", "page 2/level 2" ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -65,8 +66,7 @@ "start": 1, "end": 7 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json index 8c24c79..d5330e6 100644 --- a/tests/annotations/page/page.body.autofill.json +++ b/tests/annotations/page/page.body.autofill.json @@ -3,6 +3,7 @@ "body": [ { "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,8 +19,7 @@ "start": 1, "end": 2 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json index 873644b..843930d 100644 --- a/tests/annotations/page/page.body.json +++ b/tests/annotations/page/page.body.json @@ -5,6 +5,7 @@ "page": [ "level 1" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,13 +21,13 @@ "start": 1, "end": 7 } - }, - "access": "public" + } }, { "page": [ "level 1/level 2" ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -42,14 +43,14 @@ "start": 1, "end": 7 } - }, - "access": "public" + } }, { "page": [ "page 1/level 2", "page 2/level 2" ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -65,8 +66,7 @@ "start": 1, "end": 7 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json index f2c7321..eb5dfd3 100644 --- a/tests/annotations/page/page.header.autofill.json +++ b/tests/annotations/page/page.header.autofill.json @@ -1,6 +1,10 @@ { "header": { "name": "page autofill test", + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -16,11 +20,7 @@ "start": 1, "end": 4 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/page/page.header.json b/tests/annotations/page/page.header.json index 49a5c27..35bc7ce 100644 --- a/tests/annotations/page/page.header.json +++ b/tests/annotations/page/page.header.json @@ -3,6 +3,7 @@ "page": [ "level 1/level 2" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,8 +19,7 @@ "start": 1, "end": 4 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/annotations/property/property.aliases.json b/tests/annotations/property/property.aliases.json index e41949a..a8ec35d 100644 --- a/tests/annotations/property/property.aliases.json +++ b/tests/annotations/property/property.aliases.json @@ -10,6 +10,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,8 +26,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -39,6 +39,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -54,8 +55,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -69,6 +69,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -84,8 +85,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -98,6 +98,7 @@ "description": "

    description

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -113,8 +114,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -127,6 +127,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -142,8 +143,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -156,6 +156,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -171,8 +172,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/property/property.inline.json b/tests/annotations/property/property.inline.json index 0ec8ade..e0ea8b5 100644 --- a/tests/annotations/property/property.inline.json +++ b/tests/annotations/property/property.inline.json @@ -7,6 +7,7 @@ "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 4, @@ -23,7 +24,6 @@ "end": 45 } }, - "access": "public", "property": [ { "types": [], @@ -39,6 +39,7 @@ "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 10, @@ -55,7 +56,6 @@ "end": 45 } }, - "access": "public", "property": [ { "types": [ @@ -73,6 +73,7 @@ "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 16, @@ -89,7 +90,6 @@ "end": 45 } }, - "access": "public", "property": [ { "types": [ @@ -108,6 +108,7 @@ "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 22, @@ -124,7 +125,6 @@ "end": 45 } }, - "access": "public", "property": [ { "types": [ @@ -142,6 +142,7 @@ "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 30, @@ -158,7 +159,6 @@ "end": 45 } }, - "access": "public", "property": [ { "types": [ @@ -176,6 +176,7 @@ "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 37, @@ -192,7 +193,6 @@ "end": 45 } }, - "access": "public", "property": [ { "types": [ diff --git a/tests/annotations/property/property.json b/tests/annotations/property/property.json index 63cc246..70527b3 100644 --- a/tests/annotations/property/property.json +++ b/tests/annotations/property/property.json @@ -10,6 +10,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,8 +26,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -39,6 +39,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -54,8 +55,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -69,6 +69,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -84,8 +85,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -98,6 +98,7 @@ "description": "

    description

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -113,8 +114,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -127,6 +127,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -142,8 +143,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } }, { "property": [ @@ -156,6 +156,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -171,8 +172,7 @@ "start": 1, "end": 17 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/raw-code/raw-code.escaped.json b/tests/annotations/raw-code/raw-code.escaped.json index 590b710..fcca9b0 100644 --- a/tests/annotations/raw-code/raw-code.escaped.json +++ b/tests/annotations/raw-code/raw-code.escaped.json @@ -6,6 +6,7 @@ "raw": "", "escaped": "<nav>\n <ul>\n <li>Item 1</li>\n <li>Item 2</li>\n <li>Item 3</li>\n </ul>\n</nav>" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,8 +22,7 @@ "start": 1, "end": 10 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/raw-code/raw-code.json b/tests/annotations/raw-code/raw-code.json index f5d21f5..fc612b0 100644 --- a/tests/annotations/raw-code/raw-code.json +++ b/tests/annotations/raw-code/raw-code.json @@ -6,6 +6,7 @@ "raw": "function rawCode() {\n\n}", "escaped": "function rawCode() {\n\n}" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,8 +22,7 @@ "start": 1, "end": 4 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json index a87a039..97b51bf 100644 --- a/tests/annotations/readonly/readonly.json +++ b/tests/annotations/readonly/readonly.json @@ -3,6 +3,7 @@ "body": [ { "readonly": true, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -18,11 +19,11 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "readonly": true, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -38,11 +39,11 @@ "start": 1, "end": 6 } - }, - "access": "public" + } }, { "readonly": false, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -58,8 +59,7 @@ "start": 1, "end": 6 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json index d5b4a59..29d1403 100644 --- a/tests/annotations/requires/requires.alias.json +++ b/tests/annotations/requires/requires.alias.json @@ -9,6 +9,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,8 +25,7 @@ "start": 1, "end": 2 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json index e0a35bc..71c7e60 100644 --- a/tests/annotations/requires/requires.body.json +++ b/tests/annotations/requires/requires.body.json @@ -9,6 +9,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,8 +25,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "requires": [ @@ -37,6 +37,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -52,8 +53,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "requires": [ @@ -68,6 +68,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -83,8 +84,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "requires": [ @@ -94,6 +94,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -109,8 +110,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "requires": [ @@ -120,6 +120,7 @@ "description": "

    the path function from node

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -135,8 +136,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "requires": [ @@ -148,6 +148,7 @@ "description": "

    the path function from node

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -163,8 +164,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "requires": [ @@ -179,6 +179,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 13, @@ -194,8 +195,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json index b8ccce6..289c64f 100644 --- a/tests/annotations/requires/requires.header.json +++ b/tests/annotations/requires/requires.header.json @@ -9,6 +9,10 @@ "description": "

    the path function from node

    \n" } ], + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -24,11 +28,7 @@ "start": 1, "end": 4 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json index b8cc193..0ba18a7 100644 --- a/tests/annotations/returns/returns.alias.json +++ b/tests/annotations/returns/returns.alias.json @@ -8,6 +8,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,8 +24,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -33,6 +33,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -48,8 +49,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -60,6 +60,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -75,8 +76,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -87,6 +87,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -102,8 +103,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -112,6 +112,7 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -127,8 +128,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -137,6 +137,7 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -152,8 +153,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -162,6 +162,7 @@ ], "description": "

    This super awesome object

    \n
    {\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 13, @@ -177,8 +178,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json index defc5b2..9538672 100644 --- a/tests/annotations/returns/returns.json +++ b/tests/annotations/returns/returns.json @@ -8,6 +8,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,8 +24,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -33,6 +33,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -48,8 +49,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -60,6 +60,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -75,8 +76,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -87,6 +87,7 @@ ], "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -102,8 +103,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -112,6 +112,7 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -127,8 +128,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -137,6 +137,7 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -152,8 +153,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } }, { "returns": { @@ -162,6 +162,7 @@ ], "description": "

    This super awesome object

    \n
    {\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 13, @@ -177,8 +178,7 @@ "start": 1, "end": 23 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json index 2f20afd..3b6e153 100644 --- a/tests/annotations/since/since.body.json +++ b/tests/annotations/since/since.body.json @@ -6,6 +6,7 @@ "version": "undefined", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,14 +22,14 @@ "start": 1, "end": 11 } - }, - "access": "public" + } }, { "since": { "version": "0.0.1", "description": "

    Lorem

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -44,14 +45,14 @@ "start": 1, "end": 11 } - }, - "access": "public" + } }, { "since": { "version": "0.0.1", "description": "

    Lorem

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -67,14 +68,14 @@ "start": 1, "end": 11 } - }, - "access": "public" + } }, { "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" }, + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -90,8 +91,7 @@ "start": 1, "end": 11 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json index c5c52bc..05c8794 100644 --- a/tests/annotations/since/since.header.json +++ b/tests/annotations/since/since.header.json @@ -4,6 +4,10 @@ "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" }, + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -19,11 +23,7 @@ "start": 1, "end": 7 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "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 index 8071b41..d760340 100644 --- 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 @@ -150,6 +150,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -165,8 +166,7 @@ "start": 1, "end": 60 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json index 2ceab65..d7e77e0 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json @@ -150,6 +150,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -165,8 +166,7 @@ "start": 1, "end": 60 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json index 077b214..cc6b96a 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json @@ -150,6 +150,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -165,8 +166,7 @@ "start": 1, "end": 60 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup.json b/tests/annotations/state/complex-multiple/states-multiple-markup.json index b53207e..ac7fd52 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup.json @@ -150,6 +150,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -165,8 +166,7 @@ "start": 1, "end": 60 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/complex-multiple/states-with-custom-props.json b/tests/annotations/state/complex-multiple/states-with-custom-props.json index 699cf5f..1625a26 100644 --- a/tests/annotations/state/complex-multiple/states-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-with-custom-props.json @@ -78,6 +78,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -93,8 +94,7 @@ "start": 1, "end": 39 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/complex-multiple/states.json b/tests/annotations/state/complex-multiple/states.json index b7b36ee..a47275f 100644 --- a/tests/annotations/state/complex-multiple/states.json +++ b/tests/annotations/state/complex-multiple/states.json @@ -78,6 +78,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -93,8 +94,7 @@ "start": 1, "end": 39 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/complex/single-markup.json b/tests/annotations/state/complex/single-markup.json index ce8b1f2..ce9ae02 100644 --- a/tests/annotations/state/complex/single-markup.json +++ b/tests/annotations/state/complex/single-markup.json @@ -38,6 +38,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -53,8 +54,7 @@ "start": 1, "end": 31 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/multiple-markup/blocks-with-different-states.json b/tests/annotations/state/multiple-markup/blocks-with-different-states.json index 3b4eb7b..7120bb1 100644 --- a/tests/annotations/state/multiple-markup/blocks-with-different-states.json +++ b/tests/annotations/state/multiple-markup/blocks-with-different-states.json @@ -94,6 +94,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -109,8 +110,7 @@ "start": 1, "end": 27 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/multiple-markup/blocks.json b/tests/annotations/state/multiple-markup/blocks.json index d79aae7..abc977b 100644 --- a/tests/annotations/state/multiple-markup/blocks.json +++ b/tests/annotations/state/multiple-markup/blocks.json @@ -60,6 +60,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -75,8 +76,7 @@ "start": 1, "end": 24 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json index 25efe4b..344f66a 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json @@ -66,6 +66,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -81,8 +82,7 @@ "start": 1, "end": 74 } - }, - "access": "public" + } }, { "states": { @@ -149,6 +149,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 26, @@ -164,8 +165,7 @@ "start": 1, "end": 74 } - }, - "access": "public" + } }, { "states": { @@ -232,6 +232,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 51, @@ -247,8 +248,7 @@ "start": 1, "end": 74 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json index 1695133..dae1eb2 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json @@ -66,6 +66,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -81,8 +82,7 @@ "start": 1, "end": 74 } - }, - "access": "public" + } }, { "states": { @@ -149,6 +149,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 26, @@ -164,8 +165,7 @@ "start": 1, "end": 74 } - }, - "access": "public" + } }, { "states": { @@ -232,6 +232,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 51, @@ -247,8 +248,7 @@ "start": 1, "end": 74 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/stupid-simple-multiple/simple.json b/tests/annotations/state/stupid-simple-multiple/simple.json index 9501442..fb2c40c 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple.json +++ b/tests/annotations/state/stupid-simple-multiple/simple.json @@ -66,6 +66,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -81,8 +82,7 @@ "start": 1, "end": 24 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/stupid-simple/simple.json b/tests/annotations/state/stupid-simple/simple.json index 438fed8..d4a0e33 100644 --- a/tests/annotations/state/stupid-simple/simple.json +++ b/tests/annotations/state/stupid-simple/simple.json @@ -34,6 +34,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -49,8 +50,7 @@ "start": 1, "end": 14 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/stupid-simple/with-description.json b/tests/annotations/state/stupid-simple/with-description.json index 0dcbc2c..28a1799 100644 --- a/tests/annotations/state/stupid-simple/with-description.json +++ b/tests/annotations/state/stupid-simple/with-description.json @@ -34,6 +34,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -49,8 +50,7 @@ "start": 1, "end": 43 } - }, - "access": "public" + } }, { "states": { @@ -85,6 +85,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 16, @@ -100,8 +101,7 @@ "start": 1, "end": 43 } - }, - "access": "public" + } }, { "states": { @@ -136,6 +136,7 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 30, @@ -151,8 +152,7 @@ "start": 1, "end": 43 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/state/stupid-simple/with-notations.json b/tests/annotations/state/stupid-simple/with-notations.json index f695bee..09b6a5c 100644 --- a/tests/annotations/state/stupid-simple/with-notations.json +++ b/tests/annotations/state/stupid-simple/with-notations.json @@ -34,6 +34,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -49,8 +50,7 @@ "start": 1, "end": 44 } - }, - "access": "public" + } }, { "states": { @@ -85,6 +85,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 16, @@ -100,8 +101,7 @@ "start": 1, "end": 44 } - }, - "access": "public" + } }, { "states": { @@ -136,6 +136,7 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], + "access": "public", "blockinfo": { "comment": { "start": 31, @@ -151,8 +152,7 @@ "start": 1, "end": 44 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json index cf93f87..4c02913 100644 --- a/tests/annotations/throws/throws.alias.json +++ b/tests/annotations/throws/throws.alias.json @@ -10,6 +10,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,8 +26,7 @@ "start": 1, "end": 8 } - }, - "access": "public" + } }, { "throws": [ @@ -37,6 +37,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -52,8 +53,7 @@ "start": 1, "end": 8 } - }, - "access": "public" + } }, { "throws": [ @@ -64,6 +64,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -79,8 +80,7 @@ "start": 1, "end": 8 } - }, - "access": "public" + } }, { "throws": [ @@ -91,6 +91,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -106,8 +107,7 @@ "start": 1, "end": 8 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json index e06c15a..9fde8e3 100644 --- a/tests/annotations/throws/throws.json +++ b/tests/annotations/throws/throws.json @@ -8,6 +8,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,8 +24,7 @@ "start": 1, "end": 16 } - }, - "access": "public" + } }, { "throws": [ @@ -35,6 +35,7 @@ "description": "" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -50,8 +51,7 @@ "start": 1, "end": 16 } - }, - "access": "public" + } }, { "throws": [ @@ -62,6 +62,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -77,8 +78,7 @@ "start": 1, "end": 16 } - }, - "access": "public" + } }, { "throws": [ @@ -89,6 +89,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -104,8 +105,7 @@ "start": 1, "end": 16 } - }, - "access": "public" + } }, { "throws": [ @@ -116,6 +116,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -131,8 +132,7 @@ "start": 1, "end": 16 } - }, - "access": "public" + } }, { "throws": [ @@ -149,6 +149,7 @@ "description": "

    when something goes wrong

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 14, @@ -164,8 +165,7 @@ "start": 1, "end": 16 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json index 0ba39e3..3df330b 100644 --- a/tests/annotations/todo/todo.body.json +++ b/tests/annotations/todo/todo.body.json @@ -9,6 +9,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,8 +25,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "todo": [ @@ -35,6 +35,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -50,8 +51,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "todo": [ @@ -61,6 +61,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -76,8 +77,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "todo": [ @@ -89,6 +89,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -104,8 +105,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "todo": [ @@ -118,6 +118,7 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -133,8 +134,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } }, { "todo": [ @@ -147,6 +147,7 @@ "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -162,8 +163,7 @@ "start": 1, "end": 15 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json index 2588d4b..bff8f16 100644 --- a/tests/annotations/todo/todo.header.json +++ b/tests/annotations/todo/todo.header.json @@ -10,6 +10,10 @@ "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" } ], + "access": "public", + "page": [ + "general" + ], "blockinfo": { "comment": { "start": 1, @@ -25,11 +29,7 @@ "start": 1, "end": 7 } - }, - "access": "public", - "page": [ - "other" - ] + } }, "body": [] } diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json index fc513ce..ee6e05f 100644 --- a/tests/annotations/type/type.json +++ b/tests/annotations/type/type.json @@ -6,6 +6,7 @@ "type": "undefined", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,14 +22,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "type": { "type": "object", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -44,14 +45,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "type": { "type": "undefined", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -67,14 +68,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "type": { "type": "undefined", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -90,14 +91,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "type": { "type": "array", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -113,14 +114,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "type": { "type": "array", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 11, @@ -136,14 +137,14 @@ "start": 1, "end": 18 } - }, - "access": "public" + } }, { "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" }, + "access": "public", "blockinfo": { "comment": { "start": 13, @@ -159,8 +160,7 @@ "start": 1, "end": 18 } - }, - "access": "public" + } } ] } diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json index 2587ce6..92ee076 100644 --- a/tests/annotations/version/version.json +++ b/tests/annotations/version/version.json @@ -6,6 +6,7 @@ "version": "undefined", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,14 +22,14 @@ "start": 1, "end": 13 } - }, - "access": "public" + } }, { "version": { "version": "0.0.1", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 3, @@ -44,14 +45,14 @@ "start": 1, "end": 13 } - }, - "access": "public" + } }, { "version": { "version": "^0.0.1", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -67,14 +68,14 @@ "start": 1, "end": 13 } - }, - "access": "public" + } }, { "version": { "version": "^0.0.1", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -90,14 +91,14 @@ "start": 1, "end": 13 } - }, - "access": "public" + } }, { "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" }, + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -113,8 +114,7 @@ "start": 1, "end": 13 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/4-blank-lines-between-code-blocks.json b/tests/cases/4-blank-lines-between-code-blocks.json index 4d859f6..5669e1e 100644 --- a/tests/cases/4-blank-lines-between-code-blocks.json +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -3,7 +3,12 @@ { "title": "4 Blank Lines Between Code Blocks", "href": "/4-blank-lines-between-code-blocks", - "body": [], + "body": [ + { + "title": "moz-only", + "href": "/4-blank-lines-between-code-blocks#moz-only" + } + ], "subpages": [] } ], @@ -13,27 +18,28 @@ "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}" }, + "access": "public", "blockinfo": { "comment": { "start": 1, - "end": 2, + "end": 3, "type": "body" }, "code": { - "start": 3, - "end": 16 + "start": 4, + "end": 13 }, "file": { "path": "docs/tests/cases/4-blank-lines-between-code-blocks.scss", "start": 1, - "end": 33 + "end": 34 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/4-blank-lines-between-code-blocks.scss b/tests/cases/4-blank-lines-between-code-blocks.scss index 1667b17..f2bd9b3 100644 --- a/tests/cases/4-blank-lines-between-code-blocks.scss +++ b/tests/cases/4-blank-lines-between-code-blocks.scss @@ -1,3 +1,4 @@ +/// @name moz-only /// @page 4-blank-lines-between-code-blocks /// @raw-code @mixin moz-only() { diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json index 4743995..c0018d3 100644 --- a/tests/cases/header-comment-only.json +++ b/tests/cases/header-comment-only.json @@ -16,6 +16,7 @@ "Tyler Benton" ], "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -31,8 +32,7 @@ "start": 1, "end": 8 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index eedac16..d65d7d1 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -19,6 +19,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -34,8 +35,7 @@ "start": 1, "end": 28 } - }, - "access": "public" + } }, "body": [ { @@ -55,6 +55,7 @@ "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}" } ], + "access": "public", "blockinfo": { "comment": { "start": 5, @@ -63,15 +64,14 @@ }, "code": { "start": 18, - "end": 28 + "end": 27 }, "file": { "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", "start": 1, "end": 28 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/only-body-comments-no-page.json b/tests/cases/only-body-comments-no-page.json index fc22cd6..526df85 100644 --- a/tests/cases/only-body-comments-no-page.json +++ b/tests/cases/only-body-comments-no-page.json @@ -1,4 +1,113 @@ { - "nav": [], - "pages": {} + "nav": [ + { + "title": "General", + "href": "/general", + "body": [ + { + "title": "Button group", + "href": "/general#button-group" + }, + { + "title": "Test", + "href": "/general#test" + } + ], + "subpages": [] + } + ], + "pages": { + "general": { + "page": { + "header": {}, + "body": [ + { + "name": "Button group", + "description": "

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

    \n", + "markup": [ + { + "id": "0", + "language": "scss", + "settings": {}, + "description": "", + "raw": "
    \n Button (a.button)\n \n \n
    ", + "escaped": "<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>", + "raw_stateless": "
    \n Button (a.button)\n \n \n
    ", + "escaped_stateless": "<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>" + } + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 10, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/only-body-comments-no-page.scss", + "start": 1, + "end": 21 + } + } + }, + { + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 12, + "end": 20, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/only-body-comments-no-page.scss", + "start": 1, + "end": 21 + } + } + } + ] + } + } + } } diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index f72e47c..7a341d5 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -12,6 +12,21 @@ "subpages": [] } ] + }, + { + "title": "General", + "href": "/general", + "body": [ + { + "title": "Button group", + "href": "/general#button-group" + }, + { + "title": "Test", + "href": "/general#test" + } + ], + "subpages": [] } ], "pages": { @@ -29,6 +44,7 @@ "Tyler Benton" ], "description": "

    Your standard form button.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -36,20 +52,99 @@ "type": "body" }, "code": { - "start": 5, - "end": 5 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/cases/only-body-comments.scss", "start": 1, "end": 19 } - }, - "access": "public" + } } ] } } + }, + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 6, + "end": 8, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/only-body-comments.scss", + "start": 1, + "end": 19 + } + } + }, + { + "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", + "access": "public", + "blockinfo": { + "comment": { + "start": 10, + "end": 18, + "type": "body" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/cases/only-body-comments.scss", + "start": 1, + "end": 19 + } + } + } + ] + } } } } diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json index 010e1a2..6c74dc8 100644 --- a/tests/cases/only-comments.json +++ b/tests/cases/only-comments.json @@ -23,6 +23,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -38,8 +39,7 @@ "start": 1, "end": 27 } - }, - "access": "public" + } }, "body": [ { @@ -62,6 +62,7 @@ "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}" } ], + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,20 +70,20 @@ "type": "body" }, "code": { - "start": 20, - "end": 20 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/cases/only-comments.scss", "start": 1, "end": 27 } - }, - "access": "public" + } }, { "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", + "access": "public", "blockinfo": { "comment": { "start": 21, @@ -90,16 +91,15 @@ "type": "body" }, "code": { - "start": 27, - "end": 27 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/cases/only-comments.scss", "start": 1, "end": 27 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/preserves-blank-lines.json b/tests/cases/preserves-blank-lines.json index 5de3a8e..9f056a3 100644 --- a/tests/cases/preserves-blank-lines.json +++ b/tests/cases/preserves-blank-lines.json @@ -25,12 +25,13 @@ "language": "scss", "settings": {}, "description": "", - "raw": "Button (a.button)\n\n", - "escaped": "<a href="#" class="c-btn @state">Button (a.button)</a>\n<button class="c-btn @state">Button (button)</button>\n<input class="c-btn @state" type="button" value="Button (input.button)">", - "raw_stateless": "Button (a.button)\n\n", - "escaped_stateless": "<a href="#" class="c-btn @state">Button (a.button)</a>\n<button class="c-btn @state">Button (button)</button>\n<input class="c-btn @state" type="button" value="Button (input.button)">" + "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)">" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -38,16 +39,15 @@ "type": "body" }, "code": { - "start": 13, - "end": 13 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/cases/preserves-blank-lines.scss", "start": 1, "end": 13 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/single-body-comment-no-code.json b/tests/cases/single-body-comment-no-code.json index c721897..6aa6334 100644 --- a/tests/cases/single-body-comment-no-code.json +++ b/tests/cases/single-body-comment-no-code.json @@ -20,6 +20,7 @@ { "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", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -27,16 +28,15 @@ "type": "body" }, "code": { - "start": 8, - "end": 8 + "start": -1, + "end": -1 }, "file": { "path": "docs/tests/cases/single-body-comment-no-code.scss", "start": 1, "end": 8 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/single-body-comment.json b/tests/cases/single-body-comment.json index bf49fc2..49710e7 100644 --- a/tests/cases/single-body-comment.json +++ b/tests/cases/single-body-comment.json @@ -37,6 +37,7 @@ "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}" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -45,15 +46,14 @@ }, "code": { "start": 16, - "end": 27 + "end": 26 }, "file": { "path": "docs/tests/cases/single-body-comment.scss", "start": 1, "end": 27 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/space-between-comment-and-code.json b/tests/cases/space-between-comment-and-code.json index ff95335..c97de62 100644 --- a/tests/cases/space-between-comment-and-code.json +++ b/tests/cases/space-between-comment-and-code.json @@ -40,6 +40,7 @@ "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}" } ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,16 +48,15 @@ "type": "body" }, "code": { - "start": 16, - "end": 28 + "start": 17, + "end": 27 }, "file": { "path": "docs/tests/cases/space-between-comment-and-code.scss", "start": 1, "end": 28 } - }, - "access": "public" + } } ] } diff --git a/tests/cases/starts-and-ends-with-spaces.json b/tests/cases/starts-and-ends-with-spaces.json index 8f100eb..46168e4 100644 --- a/tests/cases/starts-and-ends-with-spaces.json +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -37,6 +37,7 @@ "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}" } ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -45,15 +46,14 @@ }, "code": { "start": 23, - "end": 36 + "end": 32 }, "file": { "path": "docs/tests/cases/starts-and-ends-with-spaces.scss", "start": 1, "end": 38 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/c++/test.json b/tests/file-types/c++/test.json index fe54062..21e1ec6 100644 --- a/tests/file-types/c++/test.json +++ b/tests/file-types/c++/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 93 } - }, - "access": "public" + } }, "body": [ { "name": "one", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 8, - "end": 34 + "end": 32 }, "file": { "path": "docs/tests/file-types/c++/test.c", "start": 1, "end": 93 } - }, - "access": "public" + } }, { "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", + "access": "public", "blockinfo": { "comment": { "start": 35, @@ -90,19 +91,19 @@ }, "code": { "start": 41, - "end": 67 + "end": 66 }, "file": { "path": "docs/tests/file-types/c++/test.c", "start": 1, "end": 93 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 68, @@ -111,15 +112,14 @@ }, "code": { "start": 71, - "end": 93 + "end": 92 }, "file": { "path": "docs/tests/file-types/c++/test.c", "start": 1, "end": 93 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/c/test.json b/tests/file-types/c/test.json index 01e2902..0abe6d1 100644 --- a/tests/file-types/c/test.json +++ b/tests/file-types/c/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 89 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 9, - "end": 33 + "end": 32 }, "file": { "path": "docs/tests/file-types/c/test.c", "start": 1, "end": 89 } - }, - "access": "public" + } }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 34, @@ -90,19 +91,19 @@ }, "code": { "start": 37, - "end": 63 + "end": 62 }, "file": { "path": "docs/tests/file-types/c/test.c", "start": 1, "end": 89 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 64, @@ -111,15 +112,14 @@ }, "code": { "start": 67, - "end": 89 + "end": 88 }, "file": { "path": "docs/tests/file-types/c/test.c", "start": 1, "end": 89 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/coffeescript/test.json b/tests/file-types/coffeescript/test.json index 37ef0a4..f315902 100644 --- a/tests/file-types/coffeescript/test.json +++ b/tests/file-types/coffeescript/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 40 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -69,19 +70,19 @@ }, "code": { "start": 10, - "end": 16 + "end": 14 }, "file": { "path": "docs/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } - }, - "access": "public" + } }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 17, @@ -90,19 +91,19 @@ }, "code": { "start": 20, - "end": 30 + "end": 28 }, "file": { "path": "docs/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normla multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 31, @@ -111,15 +112,14 @@ }, "code": { "start": 34, - "end": 40 + "end": 39 }, "file": { "path": "docs/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/coldfusion/test.json b/tests/file-types/coldfusion/test.json index d64c78a..17e9a52 100644 --- a/tests/file-types/coldfusion/test.json +++ b/tests/file-types/coldfusion/test.json @@ -43,6 +43,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -58,13 +59,13 @@ "start": 1, "end": 61 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -73,19 +74,19 @@ }, "code": { "start": 11, - "end": 17 + "end": 16 }, "file": { "path": "docs/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } - }, - "access": "public" + } }, { "name": "Two", "description": "

    This is a normal multi-line coldfusion comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 18, @@ -101,12 +102,12 @@ "start": 1, "end": 61 } - }, - "access": "public" + } }, { "name": "Three", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 34, @@ -115,19 +116,19 @@ }, "code": { "start": 40, - "end": 50 + "end": 49 }, "file": { "path": "docs/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } - }, - "access": "public" + } }, { "name": "Four", "description": "

    This is another normal multi-line coldfusion comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 51, @@ -136,15 +137,14 @@ }, "code": { "start": 56, - "end": 61 + "end": 60 }, "file": { "path": "docs/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/cs/test.json b/tests/file-types/cs/test.json index 02efd95..e29f973 100644 --- a/tests/file-types/cs/test.json +++ b/tests/file-types/cs/test.json @@ -40,6 +40,7 @@ "Tyler Benton" ], "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +56,13 @@ "start": 1, "end": 95 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 10, @@ -70,19 +71,19 @@ }, "code": { "start": 15, - "end": 39 + "end": 38 }, "file": { "path": "docs/tests/file-types/cs/test.cs", "start": 1, "end": 95 } - }, - "access": "public" + } }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 40, @@ -91,19 +92,19 @@ }, "code": { "start": 43, - "end": 69 + "end": 68 }, "file": { "path": "docs/tests/file-types/cs/test.cs", "start": 1, "end": 95 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 70, @@ -112,15 +113,14 @@ }, "code": { "start": 73, - "end": 95 + "end": 94 }, "file": { "path": "docs/tests/file-types/cs/test.cs", "start": 1, "end": 95 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/css/test.json b/tests/file-types/css/test.json index 7b48421..1c2c4d4 100644 --- a/tests/file-types/css/test.json +++ b/tests/file-types/css/test.json @@ -35,6 +35,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,13 +51,13 @@ "start": 1, "end": 31 } - }, - "access": "public" + } }, "body": [ { "name": "Base Styles", "description": "
      \n
    1. Set default font family to sans-serif.
    2. \n
    3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
    4. \n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -65,19 +66,19 @@ }, "code": { "start": 13, - "end": 19 + "end": 17 }, "file": { "path": "docs/tests/file-types/css/test.css", "start": 1, "end": 31 } - }, - "access": "public" + } }, { "name": "Input", "description": "
      \n
    1. Address appearance set to searchfield in Safari 5 and Chrome.
    2. \n
    3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
    4. \n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 20, @@ -93,8 +94,7 @@ "start": 1, "end": 31 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/html/test.html b/tests/file-types/html/test.html index 69f56bd..6a9ddce 100755 --- a/tests/file-types/html/test.html +++ b/tests/file-types/html/test.html @@ -4,32 +4,32 @@ Document - + - -
    - Home - My Account -
    + +
    + Home + My Account +
    -
    - -
    - -
    +
    + +
    + +
    -
    +
    diff --git a/tests/file-types/html/test.json b/tests/file-types/html/test.json index 602eea3..bb93c52 100644 --- a/tests/file-types/html/test.json +++ b/tests/file-types/html/test.json @@ -36,6 +36,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -51,13 +52,13 @@ "start": 1, "end": 36 } - }, - "access": "public" + } }, "body": [ { "name": "Body Block 1", "description": "

    This is the main header of the site

    \n", + "access": "public", "blockinfo": { "comment": { "start": 13, @@ -73,12 +74,12 @@ "start": 1, "end": 36 } - }, - "access": "public" + } }, { "name": "Body Block 2", "description": "

    This is the main footer of the site

    \n", + "access": "public", "blockinfo": { "comment": { "start": 26, @@ -87,15 +88,14 @@ }, "code": { "start": 31, - "end": 36 + "end": 33 }, "file": { "path": "docs/tests/file-types/html/test.html", "start": 1, "end": 36 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/jade/test.json b/tests/file-types/jade/test.json index f5f70e0..05434ee 100644 --- a/tests/file-types/jade/test.json +++ b/tests/file-types/jade/test.json @@ -31,6 +31,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -46,13 +47,13 @@ "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", + "access": "public", "blockinfo": { "comment": { "start": 7, @@ -61,15 +62,14 @@ }, "code": { "start": 12, - "end": 16 + "end": 15 }, "file": { "path": "docs/tests/file-types/jade/test.jade", "start": 1, "end": 16 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/java/test.json b/tests/file-types/java/test.json index 98daac6..3a5c1a5 100644 --- a/tests/file-types/java/test.json +++ b/tests/file-types/java/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 34 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

    A very simple class to print out Hello World

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 9, - "end": 16 + "end": 15 }, "file": { "path": "docs/tests/file-types/java/test.java", "start": 1, "end": 34 } - }, - "access": "public" + } }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 17, @@ -90,19 +91,19 @@ }, "code": { "start": 20, - "end": 25 + "end": 24 }, "file": { "path": "docs/tests/file-types/java/test.java", "start": 1, "end": 34 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 26, @@ -111,15 +112,14 @@ }, "code": { "start": 29, - "end": 34 + "end": 33 }, "file": { "path": "docs/tests/file-types/java/test.java", "start": 1, "end": 34 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/js/test.json b/tests/file-types/js/test.json index 3c29ae2..4868c5a 100644 --- a/tests/file-types/js/test.json +++ b/tests/file-types/js/test.json @@ -31,6 +31,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -46,8 +47,7 @@ "start": 1, "end": 28 } - }, - "access": "public" + } }, "body": [ { @@ -68,12 +68,13 @@ "language": "js", "settings": {}, "description": "

    Usage

    \n", - "raw": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two", - "escaped": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two", - "raw_stateless": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two", - "escaped_stateless": "/// @author Author's name\n/// @author Author One, Author Two\n/// @author Author One\n/// @author Author Two" + "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" } ], + "access": "public", "blockinfo": { "comment": { "start": 8, @@ -82,15 +83,14 @@ }, "code": { "start": 19, - "end": 28 + "end": 27 }, "file": { "path": "docs/tests/file-types/js/test.js", "start": 1, "end": 28 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json index 1369cad..28e2df6 100644 --- a/tests/file-types/less/test.json +++ b/tests/file-types/less/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,8 +55,7 @@ "start": 1, "end": 59 } - }, - "access": "public" + } }, "body": [ { @@ -76,6 +76,7 @@ "escaped_stateless": "\\@name" } ], + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -84,15 +85,14 @@ }, "code": { "start": 10, - "end": 15 + "end": 14 }, "file": { "path": "docs/tests/file-types/less/test.less", "start": 1, "end": 59 } - }, - "access": "public" + } }, { "name": "Two", @@ -109,6 +109,7 @@ "escaped_stateless": "<nav>\n <a href="">One</a>\n <a href="">Two</a>\n <a href="">Three</a>\n</nav>" } ], + "access": "public", "blockinfo": { "comment": { "start": 16, @@ -117,15 +118,14 @@ }, "code": { "start": 25, - "end": 42 + "end": 41 }, "file": { "path": "docs/tests/file-types/less/test.less", "start": 1, "end": 59 } - }, - "access": "public" + } }, { "name": "Three", @@ -152,6 +152,7 @@ "escaped_stateless": ".foo {\n .opacity(.3);\n}" } ], + "access": "public", "blockinfo": { "comment": { "start": 43, @@ -160,15 +161,14 @@ }, "code": { "start": 51, - "end": 59 + "end": 58 }, "file": { "path": "docs/tests/file-types/less/test.less", "start": 1, "end": 59 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/markdown/mark.json b/tests/file-types/markdown/mark.json index 70b5ed6..71748d5 100644 --- a/tests/file-types/markdown/mark.json +++ b/tests/file-types/markdown/mark.json @@ -25,6 +25,7 @@ "header": { "name": "mark", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/markdown.json b/tests/file-types/markdown/markdown.json index 399e9c3..25790f0 100644 --- a/tests/file-types/markdown/markdown.json +++ b/tests/file-types/markdown/markdown.json @@ -25,6 +25,7 @@ "header": { "name": "markdown", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/md.json b/tests/file-types/markdown/md.json index 94c435c..82b47e3 100644 --- a/tests/file-types/markdown/md.json +++ b/tests/file-types/markdown/md.json @@ -25,6 +25,7 @@ "header": { "name": "md", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mdml.json b/tests/file-types/markdown/mdml.json index 801a40c..b54f037 100644 --- a/tests/file-types/markdown/mdml.json +++ b/tests/file-types/markdown/mdml.json @@ -25,6 +25,7 @@ "header": { "name": "mdml", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mdown.json b/tests/file-types/markdown/mdown.json index 79a6be8..7b7b904 100644 --- a/tests/file-types/markdown/mdown.json +++ b/tests/file-types/markdown/mdown.json @@ -25,6 +25,7 @@ "header": { "name": "mdown", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mdtext.json b/tests/file-types/markdown/mdtext.json index ba3d4fd..7b43fb0 100644 --- a/tests/file-types/markdown/mdtext.json +++ b/tests/file-types/markdown/mdtext.json @@ -25,6 +25,7 @@ "header": { "name": "mdtext", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mdtxt.json b/tests/file-types/markdown/mdtxt.json index c41d58b..2d18726 100644 --- a/tests/file-types/markdown/mdtxt.json +++ b/tests/file-types/markdown/mdtxt.json @@ -25,6 +25,7 @@ "header": { "name": "mdtxt", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mdwn.json b/tests/file-types/markdown/mdwn.json index 253f621..601b9a4 100644 --- a/tests/file-types/markdown/mdwn.json +++ b/tests/file-types/markdown/mdwn.json @@ -25,6 +25,7 @@ "header": { "name": "mdwn", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mkd.json b/tests/file-types/markdown/mkd.json index 86f2c79..2519cac 100644 --- a/tests/file-types/markdown/mkd.json +++ b/tests/file-types/markdown/mkd.json @@ -25,6 +25,7 @@ "header": { "name": "mkd", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/mkdn.json b/tests/file-types/markdown/mkdn.json index 76d77d4..59303da 100644 --- a/tests/file-types/markdown/mkdn.json +++ b/tests/file-types/markdown/mkdn.json @@ -25,6 +25,7 @@ "header": { "name": "mkdn", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/markdown/text.json b/tests/file-types/markdown/text.json index 092e484..cd58ead 100644 --- a/tests/file-types/markdown/text.json +++ b/tests/file-types/markdown/text.json @@ -25,6 +25,7 @@ "header": { "name": "text", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -40,8 +41,7 @@ "start": 1, "end": 21 } - }, - "access": "public" + } }, "body": [] } diff --git a/tests/file-types/php/test.json b/tests/file-types/php/test.json index 4eb1e54..4c465be 100644 --- a/tests/file-types/php/test.json +++ b/tests/file-types/php/test.json @@ -40,6 +40,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 2, @@ -55,13 +56,13 @@ "start": 1, "end": 37 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 9, @@ -70,19 +71,19 @@ }, "code": { "start": 12, - "end": 13 + "end": 12 }, "file": { "path": "docs/tests/file-types/php/test.php", "start": 1, "end": 37 } - }, - "access": "public" + } }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 14, @@ -91,19 +92,19 @@ }, "code": { "start": 17, - "end": 26 + "end": 25 }, "file": { "path": "docs/tests/file-types/php/test.php", "start": 1, "end": 37 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 27, @@ -112,15 +113,14 @@ }, "code": { "start": 30, - "end": 37 + "end": 35 }, "file": { "path": "docs/tests/file-types/php/test.php", "start": 1, "end": 37 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/python/test.json b/tests/file-types/python/test.json index fcad486..632d824 100644 --- a/tests/file-types/python/test.json +++ b/tests/file-types/python/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 43 } - }, - "access": "public" + } }, "body": [ { "name": "main", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 9, - "end": 22 + "end": 21 }, "file": { "path": "docs/tests/file-types/python/test.py", "start": 1, "end": 43 } - }, - "access": "public" + } }, { "name": "something", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 23, @@ -89,20 +90,20 @@ "type": "body" }, "code": { - "start": 26, - "end": 31 + "start": 27, + "end": 29 }, "file": { "path": "docs/tests/file-types/python/test.py", "start": 1, "end": 43 } - }, - "access": "public" + } }, { "name": "something else", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 32, @@ -110,7 +111,7 @@ "type": "body" }, "code": { - "start": 35, + "start": 36, "end": 43 }, "file": { @@ -118,8 +119,7 @@ "start": 1, "end": 43 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/ruby/test.json b/tests/file-types/ruby/test.json index 077e874..9d8b7b0 100644 --- a/tests/file-types/ruby/test.json +++ b/tests/file-types/ruby/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 43 } - }, - "access": "public" + } }, "body": [ { "name": "One", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 9, - "end": 14 + "end": 12 }, "file": { "path": "docs/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } - }, - "access": "public" + } }, { "name": "Two", "description": "

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

    \n", + "access": "public", "blockinfo": { "comment": { "start": 15, @@ -90,19 +91,19 @@ }, "code": { "start": 18, - "end": 23 + "end": 21 }, "file": { "path": "docs/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } - }, - "access": "public" + } }, { "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", + "access": "public", "blockinfo": { "comment": { "start": 24, @@ -111,15 +112,14 @@ }, "code": { "start": 30, - "end": 38 + "end": 34 }, "file": { "path": "docs/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/scss/inline.json b/tests/file-types/scss/inline.json new file mode 100644 index 0000000..faed2b5 --- /dev/null +++ b/tests/file-types/scss/inline.json @@ -0,0 +1,109 @@ +{ + "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" + ], + "access": "public", + "blockinfo": { + "comment": { + "start": 1, + "end": 4, + "type": "header" + }, + "code": { + "start": -1, + "end": -1 + }, + "file": { + "path": "docs/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + } + }, + "body": [ + { + "name": "$colors", + "type": { + "type": "map", + "description": "" + }, + "description": "

    what up\nshoot

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

    description

    \n" + }, + { + "types": [ + "color" + ], + "name": "b", + "value": "", + "description": "

    description

    \n" + }, + { + "types": [ + "color" + ], + "name": "c", + "value": "", + "description": "

    description

    \n" + } + ] + } + ] + } + } + } + } +} 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 index 4d69883..0f4e2ec 100644 --- a/tests/file-types/scss/test.json +++ b/tests/file-types/scss/test.json @@ -35,6 +35,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,8 +51,7 @@ "start": 1, "end": 39 } - }, - "access": "public" + } }, "body": [ { @@ -60,6 +60,7 @@ "type": "color", "description": "" }, + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -68,15 +69,14 @@ }, "code": { "start": 8, - "end": 11 + "end": 8 }, "file": { "path": "docs/tests/file-types/scss/test.scss", "start": 1, "end": 39 } - }, - "access": "public" + } }, { "name": "moz-only", @@ -117,6 +117,7 @@ "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}" } ], + "access": "public", "blockinfo": { "comment": { "start": 12, @@ -125,15 +126,14 @@ }, "code": { "start": 29, - "end": 39 + "end": 38 }, "file": { "path": "docs/tests/file-types/scss/test.scss", "start": 1, "end": 39 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/stylus/test.json b/tests/file-types/stylus/test.json index 19f54fc..096e573 100644 --- a/tests/file-types/stylus/test.json +++ b/tests/file-types/stylus/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "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", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 11, - "end": 15 + "end": 14 }, "file": { "path": "docs/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } - }, - "access": "public" + } }, { "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", + "access": "public", "blockinfo": { "comment": { "start": 16, @@ -90,19 +91,19 @@ }, "code": { "start": 22, - "end": 26 + "end": 25 }, "file": { "path": "docs/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } - }, - "access": "public" + } }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 27, @@ -111,15 +112,14 @@ }, "code": { "start": 30, - "end": 37 + "end": 34 }, "file": { "path": "docs/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } - }, - "access": "public" + } } ] } diff --git a/tests/file-types/swift/test.json b/tests/file-types/swift/test.json index 1414c66..39f763e 100644 --- a/tests/file-types/swift/test.json +++ b/tests/file-types/swift/test.json @@ -39,6 +39,7 @@ "author": [ "Tyler Benton" ], + "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,13 +55,13 @@ "start": 1, "end": 49 } - }, - "access": "public" + } }, "body": [ { "name": "main", "description": "

    main method

    \n", + "access": "public", "blockinfo": { "comment": { "start": 6, @@ -69,19 +70,19 @@ }, "code": { "start": 9, - "end": 22 + "end": 20 }, "file": { "path": "docs/tests/file-types/swift/test.swift", "start": 1, "end": 49 } - }, - "access": "public" + } }, { "name": "Something", "description": "

    This is a normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 23, @@ -90,19 +91,19 @@ }, "code": { "start": 26, - "end": 33 + "end": 31 }, "file": { "path": "docs/tests/file-types/swift/test.swift", "start": 1, "end": 49 } - }, - "access": "public" + } }, { "name": "Something else", "description": "

    This is another normal multi-line comment.

    \n", + "access": "public", "blockinfo": { "comment": { "start": 34, @@ -111,15 +112,14 @@ }, "code": { "start": 37, - "end": 49 + "end": 48 }, "file": { "path": "docs/tests/file-types/swift/test.swift", "start": 1, "end": 49 } - }, - "access": "public" + } } ] } diff --git a/tests/run.test.js b/tests/run.test.js index b161198..af54bcf 100644 --- a/tests/run.test.js +++ b/tests/run.test.js @@ -1,7 +1,7 @@ /* eslint-disable no-loop-func */ import path from 'path' import docs from '../dist/index.js' -import Tokenizer from '../dist/new-parser/tokenizer.js' +import Tokenizer from '../dist/parser/tokenizer.js' import { fs, glob } from '../dist/utils' import assert from 'core-assert' import { map } from 'async-array-methods' @@ -53,7 +53,7 @@ addSuite('annotations', async ({ paths, expected }) => { let _path = paths[i] test(`${i}: ${_path}`, () => { assert.deepStrictEqual( - actual[i]['docs' + _path.split('/docs')[1]], + actual[i][_path], expected[i] ) }) @@ -106,8 +106,8 @@ function addSuite(name, folder, callback) { return asyncSuite( name, async () => { - const base = path.join(__dirname, folder) - const paths = await glob(path.join(base, '**', '*'), [ path.join(base, '**', '*.json') ]) + folder = path.join(__dirname, folder) + const paths = await glob(path.join(folder, '**', '*'), [ path.join(folder, '**', '*.json') ]) return { paths, expected: await map(paths, (file) => fs.readJson(file.replace(path.extname(file), '.json'))) diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json new file mode 100644 index 0000000..a1a020f --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.json @@ -0,0 +1,33 @@ +[ + { + "comment": { + "contents": [ + "@name @author", + "@alias @authors", + "@description Author of the documented item", + "@returns {string}", + "@markup Usage", + "/// @author Author's name", + "", + "/// @author Author One, Author Two", + "", + "/// @author Author One", + "/// @author Author Two" + ], + "start": 3, + "end": 13 + }, + "code": { + "contents": [ + "annotations.author = {", + " alias: [ 'authors' ],", + " parse: @(annotation) {", + " return multiple(annotation)", + " }", + "}" + ], + "start": 14, + "end": 19 + } + } +] diff --git a/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl new file mode 100644 index 0000000..c2bc4ad --- /dev/null +++ b/tests/tokenizer/css-like/multi-single-line-with-code/comments-in-comments.styl @@ -0,0 +1,20 @@ +annotations = {} + +/// @name @author +/// @alias @authors +/// @description Author of the documented item +/// @returns {string} +/// @markup Usage +/// /// @author Author's name +/// +/// /// @author Author One, Author Two +/// +/// /// @author Author One +/// /// @author Author Two +annotations.author = { + alias: [ 'authors' ], + parse: @(annotation) { + return multiple(annotation) + } +} + diff --git a/tools/generate-test.js b/tools/generate-test.js index e645409..d5de721 100755 --- a/tools/generate-test.js +++ b/tools/generate-test.js @@ -9,12 +9,13 @@ var path = require('path') var clor = require('clor') var utils = require('../dist/utils') var argv = process.argv.slice(2) +const root = process.cwd() utils.glob(argv, [ 'tests/**/*.json' ]) .then(function(files) { var promises = [] for (var i = 0; i < files.length; i++) { - promises.push(sortTest(files[i])) + promises.push(sortTest(path.join(root, files[i]))) } return Promise.all(promises) @@ -45,7 +46,7 @@ function sortTest(file) { function output(file, data) { return utils.fs.outputJson( - file.replace(path.extname(file), '.json').replace('docs/', ''), + file.replace(path.extname(file), '.json'), data, { spaces: 2 } ) @@ -63,7 +64,7 @@ function annotationTest(file) { ignore: '.*' }) .then(function(parsed) { - return output(file, parsed[path.join('docs', file)]) + return output(file, parsed[file]) }) .then(function() { resolve(clor.green(file) + '') diff --git a/tools/tokenizer-helper.js b/tools/tokenizer-helper.js index ec5160c..bcddc5b 100644 --- a/tools/tokenizer-helper.js +++ b/tools/tokenizer-helper.js @@ -59,7 +59,7 @@ var path = require('path') var fs = require('fs') function getTokenizerOption(file) { - var type = file.split(path.sep).slice(2, -1) + var type = file.split(/tests\//).pop().split(path.sep).slice(1, -1) var comment = type.reduce(function(prev, current) { var result = (prev || {})[current] if (!result) { From a77b01da919c79147bedd81218b410dc1839edb5 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 31 Mar 2016 13:28:24 -0400 Subject: [PATCH 272/273] Updated @state to work with inline comments --- README.md | 74 ++---- app/annotation-api.js | 12 +- app/annotations/states.js | 37 +-- app/cli.js | 3 +- app/config.js | 19 +- app/docs.js | 52 +++- app/parser/index.js | 7 + package.json | 4 +- .../access/access.autofill.body.json | 5 +- .../access/access.autofill.header.json | 4 +- tests/annotations/access/access.options.json | 9 +- tests/annotations/alias/alias.json | 15 +- tests/annotations/arg/arg.aliases.json | 15 +- tests/annotations/arg/arg.json | 30 ++- tests/annotations/author/author.alias.json | 5 +- tests/annotations/author/author.body.json | 5 +- tests/annotations/author/author.header.json | 4 +- tests/annotations/author/author.multiple.json | 19 +- tests/annotations/chainable/chainable.json | 35 ++- .../depricated/depricated.body.json | 20 +- .../depricated/depricated.header.json | 4 +- .../description/description.alias.json | 60 +++-- .../description/description.body.json | 15 +- .../description/description.header.json | 4 +- tests/annotations/markdown/mark.json | 4 +- tests/annotations/markdown/markdown.json | 4 +- tests/annotations/markdown/md.json | 4 +- tests/annotations/markdown/mdml.json | 4 +- tests/annotations/markdown/mdown.json | 4 +- tests/annotations/markdown/mdtext.json | 4 +- tests/annotations/markdown/mdtxt.json | 4 +- tests/annotations/markdown/mdwn.json | 4 +- tests/annotations/markdown/mkd.json | 4 +- tests/annotations/markdown/mkdn.json | 4 +- tests/annotations/markdown/text.json | 4 +- tests/annotations/name/name.aliases.json | 15 +- tests/annotations/name/name.json | 5 +- tests/annotations/note/note.alias.json | 10 +- tests/annotations/note/note.json | 30 ++- tests/annotations/page/page.alias.json | 15 +- .../annotations/page/page.body.autofill.json | 5 +- tests/annotations/page/page.body.json | 15 +- .../page/page.header.autofill.json | 4 +- tests/annotations/page/page.header.json | 4 +- .../property/property.aliases.json | 30 ++- .../annotations/property/property.inline.json | 210 ++++++++++++--- tests/annotations/property/property.json | 30 ++- .../raw-code/raw-code.escaped.json | 5 +- tests/annotations/raw-code/raw-code.json | 5 +- tests/annotations/readonly/readonly.json | 15 +- .../annotations/requires/requires.alias.json | 5 +- tests/annotations/requires/requires.body.json | 35 ++- .../annotations/requires/requires.header.json | 4 +- tests/annotations/returns/returns.alias.json | 35 ++- tests/annotations/returns/returns.json | 35 ++- tests/annotations/since/since.body.json | 20 +- tests/annotations/since/since.header.json | 4 +- ...ltiple-markup-by-id-with-custom-props.json | 5 +- .../states-multiple-markup-by-id.json | 5 +- ...tes-multiple-markup-with-custom-props.json | 5 +- .../states-multiple-markup.json | 5 +- .../states-with-custom-props.json | 5 +- .../state/complex-multiple/states.json | 5 +- .../state/complex/single-markup.json | 5 +- .../blocks-with-different-states.json | 5 +- .../state/multiple-markup/blocks.json | 5 +- .../simple-with-description.json | 15 +- .../simple-with-notations.json | 15 +- .../state/stupid-simple-multiple/simple.json | 5 +- .../state/stupid-simple/simple.json | 5 +- .../state/stupid-simple/with-description.json | 15 +- .../state/stupid-simple/with-notations.json | 15 +- tests/annotations/throws/throws.alias.json | 20 +- tests/annotations/throws/throws.json | 30 ++- tests/annotations/todo/todo.body.json | 30 ++- tests/annotations/todo/todo.header.json | 4 +- tests/annotations/type/type.json | 35 ++- tests/annotations/version/version.json | 25 +- .../4-blank-lines-between-code-blocks.json | 5 +- tests/cases/allthethings-js.js | 23 ++ tests/cases/allthethings-js.json | 129 ++++++++++ tests/cases/allthethings-scss.json | 218 ++++++++++++++++ tests/cases/allthethings-scss.scss | 239 ++++++++++++++++++ tests/cases/header-comment-only.json | 4 +- ...pace-between-header-and-body-comments.json | 9 +- tests/cases/only-body-comments-no-page.json | 10 +- tests/cases/only-body-comments.json | 15 +- tests/cases/only-comments.json | 14 +- tests/cases/preserves-blank-lines.json | 5 +- tests/cases/single-body-comment-no-code.json | 5 +- tests/cases/single-body-comment.json | 5 +- .../cases/space-between-comment-and-code.json | 5 +- tests/cases/starts-and-ends-with-spaces.json | 5 +- tests/file-types/c++/test.json | 19 +- tests/file-types/c/test.json | 19 +- tests/file-types/coffeescript/test.json | 19 +- tests/file-types/coldfusion/test.json | 24 +- tests/file-types/cs/test.json | 19 +- tests/file-types/css/test.json | 14 +- tests/file-types/html/test.json | 14 +- tests/file-types/jade/test.json | 9 +- tests/file-types/java/test.json | 19 +- tests/file-types/js/test.json | 9 +- tests/file-types/less/test.json | 19 +- tests/file-types/markdown/mark.json | 4 +- tests/file-types/markdown/markdown.json | 4 +- tests/file-types/markdown/md.json | 4 +- tests/file-types/markdown/mdml.json | 4 +- tests/file-types/markdown/mdown.json | 4 +- tests/file-types/markdown/mdtext.json | 4 +- tests/file-types/markdown/mdtxt.json | 4 +- tests/file-types/markdown/mdwn.json | 4 +- tests/file-types/markdown/mkd.json | 4 +- tests/file-types/markdown/mkdn.json | 4 +- tests/file-types/markdown/text.json | 4 +- tests/file-types/php/test.json | 19 +- tests/file-types/python/test.json | 19 +- tests/file-types/ruby/test.json | 19 +- tests/file-types/scss/inline.json | 101 ++++++-- tests/file-types/scss/test.json | 14 +- tests/file-types/stylus/test.json | 19 +- tests/file-types/swift/test.json | 19 +- 122 files changed, 1728 insertions(+), 697 deletions(-) create mode 100644 tests/cases/allthethings-js.js create mode 100644 tests/cases/allthethings-js.json create mode 100644 tests/cases/allthethings-scss.json create mode 100644 tests/cases/allthethings-scss.scss diff --git a/README.md b/README.md index ecc5a60..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`: @@ -338,8 +349,6 @@ This type of comment can only occur **once** per file. Any annotations that are }) } ``` - - ~~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. - 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 @@ -350,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; } ``` @@ -422,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 @@ -523,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 index b829a10..c2282ee 100644 --- a/app/annotation-api.js +++ b/app/annotation-api.js @@ -249,21 +249,23 @@ export default class AnnotationApi { } } - let to_call = options - let details + let details = options try { const fn = this.getAnnotationFn(options.annotation.name, type) if (type === 'parse') { - to_call = copyInvisible(details = options.annotation, options) + details = copyInvisible(options.annotation, options) } else if (type === 'resolve') { - to_call = copyInvisible(details = options.parsed[options.annotation.name], options) + details = copyInvisible(options.parsed[options.annotation.name], options) } - let result = is.function(fn) ? fn.call(to_call) : fn + + 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 })) } diff --git a/app/annotations/states.js b/app/annotations/states.js index c1fb5c4..2bc5d9c 100644 --- a/app/annotations/states.js +++ b/app/annotations/states.js @@ -40,38 +40,43 @@ export default { }) }, {}) - // Object.defineProperty(state, '__details', { __proto__: null, get: () => this }) - return [ { markup_id, state } ] }, resolve() { - let { parsed, log, file } = this + const { parsed, log, file, parent } = this - return this.reduce((previous, current) => { + const is_inline = this.comment.type === 'inline' + return this.reduce((previous, current) => { // eslint-disable-line let { markup_id, state, details } = current - let markup - let start_at = details.start + 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 (!parsed.markup) { - log.emit('error', "There's no instance of a '@markup' annotation") + 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)) { - markup = findMarkupAfter(parsed.markup, start_at) + 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', to.normalize(` + log.emit('error', ` There's no instance of a '@markup' annotation after line ${start_at} in ${file.path} - `)) + `) } } else { - markup = findMarkupById(parsed.markup, markup_id) + markup = findMarkupById(markup, markup_id) if (!markup) { - log.emit('error', to.normalize(` - There's no instance of a '@markup' annotation with an id of ${markup_id} + log.emit('error', ` + There's no instance of a '@markup' annotation with an id of ${markup_id}. in ${file.path} - `)) + `) } } diff --git a/app/cli.js b/app/cli.js index b87e965..487b383 100644 --- a/app/cli.js +++ b/app/cli.js @@ -21,7 +21,7 @@ export default function cli() { Note: Put globs quotes \`'.*, app/**/*'\` to avoid issues `) - .option('-d, --dest [path]', 'Documentation folder', `${root}/docs/docs.json`) + .option('-d, --dest [path]', 'Documentation folder', default_options.dest) .option('-c, --config [path]', 'Path to configuration file', default_options.config) .option('-i, --ignore ', 'Paths to ignore', to_list, default_options.ignore) .option('-w, --watch', 'Recompile docs on changes', true, default_options.watch) @@ -61,6 +61,7 @@ export default function cli() { files, ignore, gitignore, + dest, debug, warning, timestamps, diff --git a/app/config.js b/app/config.js index d0d9d78..16d172d 100644 --- a/app/config.js +++ b/app/config.js @@ -2,7 +2,7 @@ import { fs, is, to, Logger } from './utils' import path from 'path' import * as annotations from './annotations' - +import clor from 'clor' let log = new Logger() // changed by `options` key @@ -23,6 +23,8 @@ export const default_options = { // when true it will watch files for changes watch: false, + dest: `${process.cwd()}/docs/docs.json`, + page_fallback: 'general', // used if `@page` isn't defined // add gitignore files to the ignore list. Depending on ignored files it @@ -65,7 +67,7 @@ export const default_options = { // body comment style body: { start: '', line: '///', end: '', type: 'body' }, - // @todo add support for this single line prefix for comments inside of the code below the comment block + // inline comments for body comments inline: { start: '', line: '///#', end: '', type: 'inline' }, // this is used for any interpolations that might occur in annotations. @@ -159,6 +161,14 @@ export default async function config(options = {}) { timestamps: options.timestamps }) + + { + const { inline } = options.annotations + if (inline) { + options.log.error(`you can't have an ${clor.bold.red('@inline')} annotation because it's reserved`) + } + } + return options } @@ -199,8 +209,6 @@ export function parseLanguages(languages) { delete parsed[lang].extend } - // console.log(parsed) - return parsed } @@ -214,14 +222,13 @@ let valid_language_options = to.keys(default_options.languages.default) function ensureValidConfig(user_config) { for (let key in user_config) { if (!is.in(valid_options, key)) { - log.emit('warning', `'${key}' is not a valid option, see docs options for more details`) //# @todo add link to the doc options + log.emit('warning', `'${key}' is not a valid option, see docs options for more details`) ///# @todo add link to the doc options } } // ensures the newly added language has the correct comment format if (user_config.languages) { for (let [ lang, options ] of to.entries(user_config.languages)) { - // console.log('type', type) for (let [ key ] of to.entries(options)) { if (!is.in(valid_language_options, key)) { log.emit( diff --git a/app/docs.js b/app/docs.js index 1d76432..79cf978 100644 --- a/app/docs.js +++ b/app/docs.js @@ -2,16 +2,31 @@ import path from 'path' import { + fs, to, glob, } from './utils' import Parser from './parser' import sorter from './sorter' import getConfig from './config' -import { map } from 'async-array-methods' +import array, { map } from 'async-array-methods' import chokidar from 'chokidar' import clor from 'clor' +export { + fs, + glob, + is, + to, + debug +} from './utils' + +export { + Parser, + getConfig, + array +} + //// /// @name docs.js /// @author Tyler Benton @@ -19,8 +34,9 @@ import clor from 'clor' /// This is used to parse any filetype that you want to and gets the /// documentation for it and returns an `{}` of the document data //// -export default async function docs(options = {}) { +export default async function docs(options = {}, callback) { options = await getConfig(options) + /* eslint-disable no-unused-vars */ // these are all the options that can be used let { @@ -28,6 +44,7 @@ export default async function docs(options = {}) { ignore, blank_lines, page_fallback, + dest, debug, warning, timestamps, @@ -54,7 +71,7 @@ export default async function docs(options = {}) { log.emit('start', 'paths') files = await glob(files, ignored) - let paths_message = `%s completed ${to.map(files, (file) => clor.bold(path.join(root, file))).join(', ')} after %dms` + let paths_message = `%s completed ${to.map(files, (file) => clor.bold(file.replace(process.cwd() + '/', ''))).join(', ')} after %dms` if (files.length > 3) { let s = files.length > 1 ? 's' : '' // eslint-disable-line paths_message = `%s completed after %dms with ${files.length} file${s} to parse` @@ -72,7 +89,7 @@ export default async function docs(options = {}) { const parser_options = { page_fallback, blank_lines, indent, annotations, sort, log } - files = await map(files, (file) => { + const parsed_files = await map(files, (file) => { const type = path.extname(file).replace('.', '') if (!parsers[type]) { parsers[type] = new Parser(languages[type] || languages.default, type, parser_options) @@ -85,7 +102,7 @@ export default async function docs(options = {}) { // Loop through the parsed files and update the // json data that was stored. - for (let file of files) { + for (let file of parsed_files) { to.extend(json, file) } @@ -100,14 +117,27 @@ export default async function docs(options = {}) { log.emit('complete', 'total') timestamps && log.space() + if (typeof callback === 'function') { + callback(result, files) + } else if (watch) { + console.log('updated: ', dest) + await fs.outputJson(dest, result) + } + return result } catch (err) { log.error(err.stack) } } + + + let result = await walk(initial_files) + initial_files = initial_files.map((_glob) => !path.isAbsolute(_glob) ? path.join(root, _glob) : _glob) + initial_files = await glob(initial_files, ignored) + if (!watch) { return result } @@ -115,12 +145,16 @@ export default async function docs(options = {}) { let watcher = chokidar.watch(initial_files, { ignored, persistent: true, ignoreInitial: true }) log.space() - log.print('Watching', to.map(initial_files, (file) => clor.bold(file)).join(', ')) - log.print('Excluding', to.map(ignore, (file) => clor.bold(file)).join(', ')) + log.print('Watching', to.map(initial_files, (file) => clor.bold(file.replace(`${root}/`, ''))).join(', ')) + log.print('Excluding', to.map(ignore, (file) => clor.bold(file.replace(`${root}/`, ''))).join(', ')) log.space() watcher.on('all', async (type, file) => { - if (type === 'add' || type === 'changed') { + if ( + type === 'add' || + type === 'changed' || + type === 'change' + ) { try { await walk(file) } catch (err) { @@ -128,6 +162,8 @@ export default async function docs(options = {}) { } } }) + + return watcher } // Catch uncaught exceptions diff --git a/app/parser/index.js b/app/parser/index.js index 10c60b1..a6b9d0c 100644 --- a/app/parser/index.js +++ b/app/parser/index.js @@ -245,6 +245,13 @@ export default class Parser { } cleanupTokens(tokens) { + // option a + // return + return this.map(tokens, ({ parsed, inline }) => { + return to.object(to.json({ ...parsed, inline })) + }) + + // option b let { header, body } = tokens let autofill_keys = to.keys(this.api.annotations.autofill) const cleanup = ({ inline, parsed }) => { diff --git a/package.json b/package.json index aabd7f0..d615d78 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "babel-cli": "^6.6.5", - "babel-eslint": "^5.0.0", + "babel-eslint": "^6.0.4", "babel-plugin-syntax-async-functions": "^6.5.0", "babel-plugin-transform-async-to-generator": "^6.7.0", "babel-plugin-transform-decorators-legacy": "^1.3.4", @@ -72,7 +72,7 @@ "babel-register": "^6.6.5", "core-assert": "^0.1.3", "coveralls": "^2.11.8", - "eslint": "^2.3.0", + "eslint": "^2.5.3", "eslint-plugin-babel": "^3.1.0", "mocha": "^2.4.5", "nyc": "^6.0.0", diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json index 6838adb..f37668c 100644 --- a/tests/annotations/access/access.autofill.body.json +++ b/tests/annotations/access/access.autofill.body.json @@ -3,7 +3,6 @@ "body": [ { "name": "autofill access", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,9 @@ "start": 1, "end": 2 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json index 1665da7..c114f67 100644 --- a/tests/annotations/access/access.autofill.header.json +++ b/tests/annotations/access/access.autofill.header.json @@ -1,7 +1,6 @@ { "header": { "name": "autofill access", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 4 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/access/access.options.json b/tests/annotations/access/access.options.json index a85291f..c649983 100644 --- a/tests/annotations/access/access.options.json +++ b/tests/annotations/access/access.options.json @@ -18,7 +18,8 @@ "start": 1, "end": 6 } - } + }, + "inline": [] }, { "access": "public", @@ -37,7 +38,8 @@ "start": 1, "end": 6 } - } + }, + "inline": [] }, { "access": "private", @@ -56,7 +58,8 @@ "start": 1, "end": 6 } - } + }, + "inline": [] } ] } diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json index c4af7e9..f35dff1 100644 --- a/tests/annotations/alias/alias.json +++ b/tests/annotations/alias/alias.json @@ -5,7 +5,6 @@ "alias": [ "foo" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,14 +20,15 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "alias": [ "foo", "bar" ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -44,14 +44,15 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "alias": [ "foo", "bar" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -67,7 +68,9 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json index a29797f..156eed6 100644 --- a/tests/annotations/arg/arg.aliases.json +++ b/tests/annotations/arg/arg.aliases.json @@ -12,7 +12,6 @@ "description": "

    argument alias

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -28,7 +27,9 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -41,7 +42,6 @@ "description": "

    param alias

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -57,7 +57,9 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -70,7 +72,6 @@ "description": "

    parameter alias

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -86,7 +87,9 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json index 45349b8..4ad55ae 100644 --- a/tests/annotations/arg/arg.json +++ b/tests/annotations/arg/arg.json @@ -10,7 +10,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,7 +25,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -39,7 +40,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -55,7 +55,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -69,7 +71,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -85,7 +86,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -98,7 +101,6 @@ "description": "

    description

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -114,7 +116,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -127,7 +131,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -143,7 +146,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "arg": [ @@ -156,7 +161,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -172,7 +176,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json index aa7ed99..6ea0027 100644 --- a/tests/annotations/author/author.alias.json +++ b/tests/annotations/author/author.alias.json @@ -7,7 +7,6 @@ "Author Two", "Author Three" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -23,7 +22,9 @@ "start": 1, "end": 2 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json index 9b8f382..8d42a76 100644 --- a/tests/annotations/author/author.body.json +++ b/tests/annotations/author/author.body.json @@ -5,7 +5,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,7 +20,9 @@ "start": 1, "end": 2 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json index d3276d9..d5b9649 100644 --- a/tests/annotations/author/author.header.json +++ b/tests/annotations/author/author.header.json @@ -3,7 +3,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "page": [ "general" ], @@ -22,7 +21,8 @@ "start": 1, "end": 4 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index 37ed0fd..dbb2ada 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -4,7 +4,6 @@ "Author One", "Author Two" ], - "access": "public", "page": [ "general" ], @@ -23,7 +22,8 @@ "start": 1, "end": 14 } - } + }, + "access": "public" }, "body": [ { @@ -31,7 +31,6 @@ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -47,14 +46,15 @@ "start": 1, "end": 14 } - } + }, + "access": "public", + "inline": [] }, { "author": [ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 8, @@ -70,14 +70,15 @@ "start": 1, "end": 14 } - } + }, + "access": "public", + "inline": [] }, { "author": [ "Author One", "Author Two" ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -93,7 +94,9 @@ "start": 1, "end": 14 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json index 9ae5092..c95a80c 100644 --- a/tests/annotations/chainable/chainable.json +++ b/tests/annotations/chainable/chainable.json @@ -3,7 +3,6 @@ "body": [ { "chainable": true, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,11 +18,12 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "chainable": true, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -39,11 +39,12 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "chainable": false, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -59,13 +60,14 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "chainable": [ "Object.prototype" ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -81,14 +83,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "chainable": [ "One", "Two" ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -104,14 +107,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "chainable": [ "One", "Two" ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -127,14 +131,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "chainable": [ "One", "Two" ], - "access": "public", "blockinfo": { "comment": { "start": 15, @@ -150,7 +155,9 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json index 9ff0f94..a602d87 100644 --- a/tests/annotations/depricated/depricated.body.json +++ b/tests/annotations/depricated/depricated.body.json @@ -6,7 +6,6 @@ "version": "0", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,15 @@ "start": 1, "end": 11 } - } + }, + "access": "public", + "inline": [] }, { "deprecated": { "version": "0.0.1", "description": "

    Lorem

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +45,15 @@ "start": 1, "end": 11 } - } + }, + "access": "public", + "inline": [] }, { "deprecated": { "version": "0.0.1", "description": "

    Lorem

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +69,15 @@ "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" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,7 +93,9 @@ "start": 1, "end": 11 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json index 381ca8b..85b25ae 100644 --- a/tests/annotations/depricated/depricated.header.json +++ b/tests/annotations/depricated/depricated.header.json @@ -4,7 +4,6 @@ "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" }, - "access": "public", "page": [ "general" ], @@ -23,7 +22,8 @@ "start": 1, "end": 7 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json index f3cef05..3181276 100644 --- a/tests/annotations/description/description.alias.json +++ b/tests/annotations/description/description.alias.json @@ -4,7 +4,6 @@ { "name": "single-line `desc`", "description": "

    Lorem ipsum

    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -20,12 +19,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 4, @@ -41,12 +41,13 @@ "start": 1, "end": 58 } - } + }, + "access": "public", + "inline": [] }, { "name": "single-line `definition`", "description": "

    Lorem ipsum

    \n", - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -62,12 +63,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 14, @@ -83,12 +85,13 @@ "start": 1, "end": 58 } - } + }, + "access": "public", + "inline": [] }, { "name": "single-line `explanation`", "description": "

    Lorem ipsum

    \n", - "access": "public", "blockinfo": { "comment": { "start": 21, @@ -104,12 +107,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 24, @@ -125,12 +129,13 @@ "start": 1, "end": 58 } - } + }, + "access": "public", + "inline": [] }, { "name": "single-line `writeup`", "description": "

    Lorem ipsum

    \n", - "access": "public", "blockinfo": { "comment": { "start": 31, @@ -146,12 +151,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -167,12 +173,13 @@ "start": 1, "end": 58 } - } + }, + "access": "public", + "inline": [] }, { "name": "single-line `summary`", "description": "

    Lorem ipsum

    \n", - "access": "public", "blockinfo": { "comment": { "start": 41, @@ -188,12 +195,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 44, @@ -209,12 +217,13 @@ "start": 1, "end": 58 } - } + }, + "access": "public", + "inline": [] }, { "name": "single-line `summarization`", "description": "

    Lorem ipsum

    \n", - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -230,12 +239,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 54, @@ -251,7 +261,9 @@ "start": 1, "end": 58 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json index fd105a9..ab315b8 100644 --- a/tests/annotations/description/description.body.json +++ b/tests/annotations/description/description.body.json @@ -3,7 +3,6 @@ "body": [ { "description": "

    Lorem ipsum dolor sit amet

    \n", - "access": "public", "blockinfo": { "comment": { "start": 2, @@ -19,11 +18,12 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "description": "

    Line one\nOther\nlines\nbelow\nit

    \n", - "access": "public", "blockinfo": { "comment": { "start": 4, @@ -39,11 +39,12 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 10, @@ -59,7 +60,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json index 5b38d07..b3f7438 100644 --- a/tests/annotations/description/description.header.json +++ b/tests/annotations/description/description.header.json @@ -1,7 +1,6 @@ { "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", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index 9713e9a..0eadb34 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 48eeda0..7a3a662 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index 3f9cee8..01e0f16 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index 5d7d26d..a781c87 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index 0916249..aec2291 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index d822d5f..70222cc 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index 7e57696..62bfdae 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index aa76784..1455f01 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index 03d0d13..a5663f6 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index 4c828f0..490f3e0 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index 6a015c6..90a75bc 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -1,7 +1,6 @@ { "header": { "markdown": "

    H1 Tag

    \n
    .foo {\n  .bar {\n    background: blue;\n  }\n}\n
    \n", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 13 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json index 9013c9f..cb7a64b 100644 --- a/tests/annotations/name/name.aliases.json +++ b/tests/annotations/name/name.aliases.json @@ -3,7 +3,6 @@ "body": [ { "name": "Title", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,11 +18,12 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "name": "Heading", - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -39,11 +39,12 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "name": "Header", - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -59,7 +60,9 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json index 1220da7..1de5448 100644 --- a/tests/annotations/name/name.json +++ b/tests/annotations/name/name.json @@ -3,7 +3,6 @@ "body": [ { "name": "Foo", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,9 @@ "start": 1, "end": 2 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json index 4676aef..23285cd 100644 --- a/tests/annotations/note/note.alias.json +++ b/tests/annotations/note/note.alias.json @@ -8,7 +8,6 @@ "description": "
      \n
    • note 1
    • \n
    • note 2
    • \n
    • note 3
    • \n
    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,9 @@ "start": 1, "end": 10 } - } + }, + "access": "public", + "inline": [] }, { "note": [ @@ -33,7 +34,6 @@ "description": "
      \n
    • note 1
    • \n
    • note 2
    • \n
    • note 3
    • \n
    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -49,7 +49,9 @@ "start": 1, "end": 10 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json index af25a69..ce3f945 100644 --- a/tests/annotations/note/note.json +++ b/tests/annotations/note/note.json @@ -8,7 +8,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,9 @@ "start": 1, "end": 20 } - } + }, + "access": "public", + "inline": [] }, { "note": [ @@ -33,7 +34,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -49,7 +49,9 @@ "start": 1, "end": 20 } - } + }, + "access": "public", + "inline": [] }, { "note": [ @@ -58,7 +60,6 @@ "description": "

    Lorem ipsum dolor sit amet

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -74,7 +75,9 @@ "start": 1, "end": 20 } - } + }, + "access": "public", + "inline": [] }, { "note": [ @@ -83,7 +86,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -99,7 +101,9 @@ "start": 1, "end": 20 } - } + }, + "access": "public", + "inline": [] }, { "note": [ @@ -108,7 +112,6 @@ "description": "

    Lorem ipsum dolor sit amet

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -124,7 +127,9 @@ "start": 1, "end": 20 } - } + }, + "access": "public", + "inline": [] }, { "note": [ @@ -133,7 +138,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 15, @@ -149,7 +153,9 @@ "start": 1, "end": 20 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json index d86ad7b..579e973 100644 --- a/tests/annotations/page/page.alias.json +++ b/tests/annotations/page/page.alias.json @@ -5,7 +5,6 @@ "page": [ "level 1" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,13 +20,14 @@ "start": 1, "end": 7 } - } + }, + "access": "public", + "inline": [] }, { "page": [ "level 1/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -43,14 +43,15 @@ "start": 1, "end": 7 } - } + }, + "access": "public", + "inline": [] }, { "page": [ "page 1/level 2", "page 2/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -66,7 +67,9 @@ "start": 1, "end": 7 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json index d5330e6..7b4b198 100644 --- a/tests/annotations/page/page.body.autofill.json +++ b/tests/annotations/page/page.body.autofill.json @@ -3,7 +3,6 @@ "body": [ { "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,9 @@ "start": 1, "end": 2 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json index 843930d..541dc14 100644 --- a/tests/annotations/page/page.body.json +++ b/tests/annotations/page/page.body.json @@ -5,7 +5,6 @@ "page": [ "level 1" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -21,13 +20,14 @@ "start": 1, "end": 7 } - } + }, + "access": "public", + "inline": [] }, { "page": [ "level 1/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -43,14 +43,15 @@ "start": 1, "end": 7 } - } + }, + "access": "public", + "inline": [] }, { "page": [ "page 1/level 2", "page 2/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -66,7 +67,9 @@ "start": 1, "end": 7 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json index eb5dfd3..3d31c62 100644 --- a/tests/annotations/page/page.header.autofill.json +++ b/tests/annotations/page/page.header.autofill.json @@ -1,7 +1,6 @@ { "header": { "name": "page autofill test", - "access": "public", "page": [ "general" ], @@ -20,7 +19,8 @@ "start": 1, "end": 4 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/page/page.header.json b/tests/annotations/page/page.header.json index 35bc7ce..49a5c27 100644 --- a/tests/annotations/page/page.header.json +++ b/tests/annotations/page/page.header.json @@ -3,7 +3,6 @@ "page": [ "level 1/level 2" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,7 +18,8 @@ "start": 1, "end": 4 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/property/property.aliases.json b/tests/annotations/property/property.aliases.json index a8ec35d..7d1b0fa 100644 --- a/tests/annotations/property/property.aliases.json +++ b/tests/annotations/property/property.aliases.json @@ -10,7 +10,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,7 +25,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -39,7 +40,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -55,7 +55,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -69,7 +71,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -85,7 +86,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -98,7 +101,6 @@ "description": "

    description

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -114,7 +116,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -127,7 +131,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -143,7 +146,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -156,7 +161,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -172,7 +176,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/property/property.inline.json b/tests/annotations/property/property.inline.json index e0ea8b5..9e862ed 100644 --- a/tests/annotations/property/property.inline.json +++ b/tests/annotations/property/property.inline.json @@ -7,7 +7,6 @@ "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 4, @@ -24,12 +23,34 @@ "end": 45 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [], - "name": "", - "value": "", - "description": "" + "property": [ + { + "types": [], + "name": "", + "value": "", + "description": "" + } + ], + "blockinfo": { + "comment": { + "start": 7, + "end": 7, + "type": "inline" + }, + "code": { + "start": 7, + "end": 7 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" } ] }, @@ -39,7 +60,6 @@ "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 10, @@ -56,14 +76,36 @@ "end": 45 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [ - "number" + "property": [ + { + "types": [ + "number" + ], + "name": "bar.value", + "value": "", + "description": "" + } ], - "name": "bar.value", - "value": "", - "description": "" + "blockinfo": { + "comment": { + "start": 13, + "end": 13, + "type": "inline" + }, + "code": { + "start": 13, + "end": 13 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" } ] }, @@ -73,7 +115,6 @@ "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -90,15 +131,37 @@ "end": 45 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [ - "number", - "array" + "property": [ + { + "types": [ + "number", + "array" + ], + "name": "baz.value", + "value": "", + "description": "" + } ], - "name": "baz.value", - "value": "", - "description": "" + "blockinfo": { + "comment": { + "start": 19, + "end": 19, + "type": "inline" + }, + "code": { + "start": 19, + "end": 19 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" } ] }, @@ -108,7 +171,6 @@ "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 22, @@ -125,14 +187,36 @@ "end": 45 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [ - "function" + "property": [ + { + "types": [ + "function" + ], + "name": "qux.value", + "value": "", + "description": "

    description

    \n" + } ], - "name": "qux.value", - "value": "", - "description": "

    description

    \n" + "blockinfo": { + "comment": { + "start": 25, + "end": 25, + "type": "inline" + }, + "code": { + "start": 25, + "end": 27 + }, + "file": { + "path": "docs/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" } ] }, @@ -142,7 +226,6 @@ "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 30, @@ -159,14 +242,36 @@ "end": 45 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [ - "number" + "property": [ + { + "types": [ + "number" + ], + "name": "corge.value", + "value": "5", + "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" + } ], - "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/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" } ] }, @@ -176,7 +281,6 @@ "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 37, @@ -193,14 +297,36 @@ "end": 45 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [ - "function" + "property": [ + { + "types": [ + "function" + ], + "name": "quux.value", + "value": "'whatup'", + "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" + } ], - "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/tests/annotations/property/property.inline.js", + "start": 1, + "end": 45 + } + }, + "access": "public" } ] } diff --git a/tests/annotations/property/property.json b/tests/annotations/property/property.json index 70527b3..ef2eae4 100644 --- a/tests/annotations/property/property.json +++ b/tests/annotations/property/property.json @@ -10,7 +10,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,7 +25,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -39,7 +40,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -55,7 +55,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -69,7 +71,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -85,7 +86,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -98,7 +101,6 @@ "description": "

    description

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -114,7 +116,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -127,7 +131,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -143,7 +146,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] }, { "property": [ @@ -156,7 +161,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -172,7 +176,9 @@ "start": 1, "end": 17 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/raw-code/raw-code.escaped.json b/tests/annotations/raw-code/raw-code.escaped.json index fcca9b0..0cd7467 100644 --- a/tests/annotations/raw-code/raw-code.escaped.json +++ b/tests/annotations/raw-code/raw-code.escaped.json @@ -6,7 +6,6 @@ "raw": "", "escaped": "<nav>\n <ul>\n <li>Item 1</li>\n <li>Item 2</li>\n <li>Item 3</li>\n </ul>\n</nav>" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,7 +21,9 @@ "start": 1, "end": 10 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/raw-code/raw-code.json b/tests/annotations/raw-code/raw-code.json index fc612b0..fb04618 100644 --- a/tests/annotations/raw-code/raw-code.json +++ b/tests/annotations/raw-code/raw-code.json @@ -6,7 +6,6 @@ "raw": "function rawCode() {\n\n}", "escaped": "function rawCode() {\n\n}" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,7 +21,9 @@ "start": 1, "end": 4 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json index 97b51bf..dc75b74 100644 --- a/tests/annotations/readonly/readonly.json +++ b/tests/annotations/readonly/readonly.json @@ -3,7 +3,6 @@ "body": [ { "readonly": true, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -19,11 +18,12 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "readonly": true, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -39,11 +39,12 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] }, { "readonly": false, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -59,7 +60,9 @@ "start": 1, "end": 6 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json index 29d1403..d2a2aa3 100644 --- a/tests/annotations/requires/requires.alias.json +++ b/tests/annotations/requires/requires.alias.json @@ -9,7 +9,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,7 +24,9 @@ "start": 1, "end": 2 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json index 71c7e60..c1fe1a5 100644 --- a/tests/annotations/requires/requires.body.json +++ b/tests/annotations/requires/requires.body.json @@ -9,7 +9,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,7 +24,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "requires": [ @@ -37,7 +38,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -53,7 +53,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "requires": [ @@ -68,7 +70,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -84,7 +85,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "requires": [ @@ -94,7 +97,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -110,7 +112,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "requires": [ @@ -120,7 +124,6 @@ "description": "

    the path function from node

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -136,7 +139,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "requires": [ @@ -148,7 +153,6 @@ "description": "

    the path function from node

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -164,7 +168,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "requires": [ @@ -179,7 +185,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -195,7 +200,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json index 289c64f..677b268 100644 --- a/tests/annotations/requires/requires.header.json +++ b/tests/annotations/requires/requires.header.json @@ -9,7 +9,6 @@ "description": "

    the path function from node

    \n" } ], - "access": "public", "page": [ "general" ], @@ -28,7 +27,8 @@ "start": 1, "end": 4 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json index 0ba18a7..a9effae 100644 --- a/tests/annotations/returns/returns.alias.json +++ b/tests/annotations/returns/returns.alias.json @@ -8,7 +8,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -33,7 +34,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -49,7 +49,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -60,7 +62,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -76,7 +77,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -87,7 +90,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -103,7 +105,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -112,7 +116,6 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -128,7 +131,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -137,7 +142,6 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -153,7 +157,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -162,7 +168,6 @@ ], "description": "

    This super awesome object

    \n
    {\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -178,7 +183,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json index 9538672..dcc75c5 100644 --- a/tests/annotations/returns/returns.json +++ b/tests/annotations/returns/returns.json @@ -8,7 +8,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -33,7 +34,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -49,7 +49,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -60,7 +62,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -76,7 +77,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -87,7 +90,6 @@ ], "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -103,7 +105,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -112,7 +116,6 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -128,7 +131,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -137,7 +142,6 @@ ], "description": "

    Lorem ipsum dolor sit amet

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -153,7 +157,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] }, { "returns": { @@ -162,7 +168,6 @@ ], "description": "

    This super awesome object

    \n
    {\n  i: {\n    found: {\n      waldo: 'Shoot, you found me'\n    }\n  }\n}\n
    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -178,7 +183,9 @@ "start": 1, "end": 23 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json index 3b6e153..6300404 100644 --- a/tests/annotations/since/since.body.json +++ b/tests/annotations/since/since.body.json @@ -6,7 +6,6 @@ "version": "undefined", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,15 @@ "start": 1, "end": 11 } - } + }, + "access": "public", + "inline": [] }, { "since": { "version": "0.0.1", "description": "

    Lorem

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +45,15 @@ "start": 1, "end": 11 } - } + }, + "access": "public", + "inline": [] }, { "since": { "version": "0.0.1", "description": "

    Lorem

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +69,15 @@ "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" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,7 +93,9 @@ "start": 1, "end": 11 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json index 05c8794..e5608f9 100644 --- a/tests/annotations/since/since.header.json +++ b/tests/annotations/since/since.header.json @@ -4,7 +4,6 @@ "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" }, - "access": "public", "page": [ "general" ], @@ -23,7 +22,8 @@ "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 index d760340..b518de3 100644 --- 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 @@ -150,7 +150,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -166,7 +165,9 @@ "start": 1, "end": 60 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json index d7e77e0..eacceb2 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json @@ -150,7 +150,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -166,7 +165,9 @@ "start": 1, "end": 60 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json index cc6b96a..db2a0c1 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json @@ -150,7 +150,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -166,7 +165,9 @@ "start": 1, "end": 60 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup.json b/tests/annotations/state/complex-multiple/states-multiple-markup.json index ac7fd52..539edbd 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup.json @@ -150,7 +150,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3>Example 2</h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -166,7 +165,9 @@ "start": 1, "end": 60 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/complex-multiple/states-with-custom-props.json b/tests/annotations/state/complex-multiple/states-with-custom-props.json index 1625a26..965fd79 100644 --- a/tests/annotations/state/complex-multiple/states-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-with-custom-props.json @@ -78,7 +78,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -94,7 +93,9 @@ "start": 1, "end": 39 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/complex-multiple/states.json b/tests/annotations/state/complex-multiple/states.json index a47275f..e4ceb1f 100644 --- a/tests/annotations/state/complex-multiple/states.json +++ b/tests/annotations/state/complex-multiple/states.json @@ -78,7 +78,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -94,7 +93,9 @@ "start": 1, "end": 39 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/complex/single-markup.json b/tests/annotations/state/complex/single-markup.json index ce9ae02..32b3de7 100644 --- a/tests/annotations/state/complex/single-markup.json +++ b/tests/annotations/state/complex/single-markup.json @@ -38,7 +38,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n <h3></h3>\n <ul>\n <li class="something-super-awesome__item"></li>\n </ul>\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -54,7 +53,9 @@ "start": 1, "end": 31 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/multiple-markup/blocks-with-different-states.json b/tests/annotations/state/multiple-markup/blocks-with-different-states.json index 7120bb1..489ad6a 100644 --- a/tests/annotations/state/multiple-markup/blocks-with-different-states.json +++ b/tests/annotations/state/multiple-markup/blocks-with-different-states.json @@ -94,7 +94,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -110,7 +109,9 @@ "start": 1, "end": 27 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/multiple-markup/blocks.json b/tests/annotations/state/multiple-markup/blocks.json index abc977b..0153961 100644 --- a/tests/annotations/state/multiple-markup/blocks.json +++ b/tests/annotations/state/multiple-markup/blocks.json @@ -60,7 +60,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n There are no states created with this markup because it is the\n second markup annotation in the comment block and there was no\n id set so the id is 1 by default. If you are looking for an example\n of multiple markup blocks with seperate states see\n `state-multiple-markup-blocks-with-different-states.scss`\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -76,7 +75,9 @@ "start": 1, "end": 24 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json index 344f66a..70ff1e0 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json @@ -66,7 +66,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -82,7 +81,9 @@ "start": 1, "end": 74 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -149,7 +150,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -165,7 +165,9 @@ "start": 1, "end": 74 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -232,7 +234,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -248,7 +249,9 @@ "start": 1, "end": 74 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json index dae1eb2..dcd61aa 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json @@ -66,7 +66,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -82,7 +81,9 @@ "start": 1, "end": 74 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -149,7 +150,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -165,7 +165,9 @@ "start": 1, "end": 74 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -232,7 +234,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -248,7 +249,9 @@ "start": 1, "end": 74 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/stupid-simple-multiple/simple.json b/tests/annotations/state/stupid-simple-multiple/simple.json index fb2c40c..07e9c4e 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple.json +++ b/tests/annotations/state/stupid-simple-multiple/simple.json @@ -66,7 +66,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -82,7 +81,9 @@ "start": 1, "end": 24 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/stupid-simple/simple.json b/tests/annotations/state/stupid-simple/simple.json index d4a0e33..6c00abb 100644 --- a/tests/annotations/state/stupid-simple/simple.json +++ b/tests/annotations/state/stupid-simple/simple.json @@ -34,7 +34,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,7 +49,9 @@ "start": 1, "end": 14 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/stupid-simple/with-description.json b/tests/annotations/state/stupid-simple/with-description.json index 28a1799..e7fe963 100644 --- a/tests/annotations/state/stupid-simple/with-description.json +++ b/tests/annotations/state/stupid-simple/with-description.json @@ -34,7 +34,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,7 +49,9 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -85,7 +86,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -101,7 +101,9 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -136,7 +138,6 @@ "escaped_stateless": "<div class="something-super-awesome"></div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 30, @@ -152,7 +153,9 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/state/stupid-simple/with-notations.json b/tests/annotations/state/stupid-simple/with-notations.json index 09b6a5c..c5ed8cb 100644 --- a/tests/annotations/state/stupid-simple/with-notations.json +++ b/tests/annotations/state/stupid-simple/with-notations.json @@ -34,7 +34,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -50,7 +49,9 @@ "start": 1, "end": 44 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -85,7 +86,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -101,7 +101,9 @@ "start": 1, "end": 44 } - } + }, + "access": "public", + "inline": [] }, { "states": { @@ -136,7 +138,6 @@ "escaped_stateless": "<div class="something-super-awesome">\n Mind blown\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 31, @@ -152,7 +153,9 @@ "start": 1, "end": 44 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json index 4c02913..303b0e9 100644 --- a/tests/annotations/throws/throws.alias.json +++ b/tests/annotations/throws/throws.alias.json @@ -10,7 +10,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -26,7 +25,9 @@ "start": 1, "end": 8 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -37,7 +38,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -53,7 +53,9 @@ "start": 1, "end": 8 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -64,7 +66,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -80,7 +81,9 @@ "start": 1, "end": 8 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -91,7 +94,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -107,7 +109,9 @@ "start": 1, "end": 8 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json index 9fde8e3..480c0b5 100644 --- a/tests/annotations/throws/throws.json +++ b/tests/annotations/throws/throws.json @@ -8,7 +8,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -24,7 +23,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -35,7 +36,6 @@ "description": "" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -51,7 +51,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -62,7 +64,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -78,7 +79,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -89,7 +92,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -105,7 +107,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -116,7 +120,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -132,7 +135,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] }, { "throws": [ @@ -149,7 +154,6 @@ "description": "

    when something goes wrong

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 14, @@ -165,7 +169,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json index 3df330b..ee90b68 100644 --- a/tests/annotations/todo/todo.body.json +++ b/tests/annotations/todo/todo.body.json @@ -9,7 +9,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -25,7 +24,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "todo": [ @@ -35,7 +36,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -51,7 +51,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "todo": [ @@ -61,7 +63,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -77,7 +78,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "todo": [ @@ -89,7 +92,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -105,7 +107,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "todo": [ @@ -118,7 +122,6 @@ "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" } ], - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -134,7 +137,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] }, { "todo": [ @@ -147,7 +152,6 @@ "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" } ], - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -163,7 +167,9 @@ "start": 1, "end": 15 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json index bff8f16..9cecdc8 100644 --- a/tests/annotations/todo/todo.header.json +++ b/tests/annotations/todo/todo.header.json @@ -10,7 +10,6 @@ "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" } ], - "access": "public", "page": [ "general" ], @@ -29,7 +28,8 @@ "start": 1, "end": 7 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json index ee6e05f..a5b8cbf 100644 --- a/tests/annotations/type/type.json +++ b/tests/annotations/type/type.json @@ -6,7 +6,6 @@ "type": "undefined", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "type": { "type": "object", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +45,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "type": { "type": "undefined", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +69,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "type": { "type": "undefined", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,14 +93,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "type": { "type": "array", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -114,14 +117,15 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] }, { "type": { "type": "array", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 11, @@ -137,14 +141,15 @@ "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" }, - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -160,7 +165,9 @@ "start": 1, "end": 18 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json index 92ee076..1e27588 100644 --- a/tests/annotations/version/version.json +++ b/tests/annotations/version/version.json @@ -6,7 +6,6 @@ "version": "undefined", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -22,14 +21,15 @@ "start": 1, "end": 13 } - } + }, + "access": "public", + "inline": [] }, { "version": { "version": "0.0.1", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 3, @@ -45,14 +45,15 @@ "start": 1, "end": 13 } - } + }, + "access": "public", + "inline": [] }, { "version": { "version": "^0.0.1", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -68,14 +69,15 @@ "start": 1, "end": 13 } - } + }, + "access": "public", + "inline": [] }, { "version": { "version": "^0.0.1", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n" }, - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -91,14 +93,15 @@ "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" }, - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -114,7 +117,9 @@ "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 index 5669e1e..5729ffd 100644 --- a/tests/cases/4-blank-lines-between-code-blocks.json +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -23,7 +23,6 @@ "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}" }, - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -39,7 +38,9 @@ "start": 1, "end": 34 } - } + }, + "access": "public", + "inline": [] } ] } 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..638ba40 --- /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/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/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/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/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..d621a47 --- /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/tests/cases/allthethings-scss.scss", + "start": 1, + "end": 239 + } + }, + "access": "public" + }, + "body": [ + { + "name": "Buttons", + "description": "

    Your standard form button.

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

    @state inline

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

    EXAMPLE 1

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

    EXAMPLE 1

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

    * EXAMPLE 2 *

    \n", + "raw": "

    THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

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

    THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

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

    * EXAMPLE 2 *

    \n", + "raw": "

    THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

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

    EXAMPLE 1

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

    EXAMPLE 1

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

    THIS IS SOME COMPLETELY DIFFERENT EXAMPLE ;)

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

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -32,7 +31,8 @@ "start": 1, "end": 8 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index d65d7d1..1fe4bbe 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -19,7 +19,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -35,7 +34,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" }, "body": [ { @@ -55,7 +55,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 5, @@ -71,7 +70,9 @@ "start": 1, "end": 28 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/only-body-comments-no-page.json b/tests/cases/only-body-comments-no-page.json index 526df85..788eb25 100644 --- a/tests/cases/only-body-comments-no-page.json +++ b/tests/cases/only-body-comments-no-page.json @@ -36,7 +36,6 @@ "escaped_stateless": "<div class="c-btn-group">\n <a href="#" class="c-btn">Button (a.button)</a>\n <button class="c-btn">Button (button)</button>\n <input class="c-btn" type="button" value="Button (input.button)">\n</div>" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -52,7 +51,9 @@ "start": 1, "end": 21 } - } + }, + "access": "public", + "inline": [] }, { "name": "Test", @@ -88,7 +89,6 @@ ] }, "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", - "access": "public", "blockinfo": { "comment": { "start": 12, @@ -104,7 +104,9 @@ "start": 1, "end": 21 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index 7a341d5..baaabc0 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -44,7 +44,6 @@ "Tyler Benton" ], "description": "

    Your standard form button.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -60,7 +59,9 @@ "start": 1, "end": 19 } - } + }, + "access": "public", + "inline": [] } ] } @@ -73,7 +74,6 @@ { "name": "Button group", "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -89,7 +89,9 @@ "start": 1, "end": 19 } - } + }, + "access": "public", + "inline": [] }, { "name": "Test", @@ -125,7 +127,6 @@ ] }, "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", - "access": "public", "blockinfo": { "comment": { "start": 10, @@ -141,7 +142,9 @@ "start": 1, "end": 19 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json index 6c74dc8..ecc54a6 100644 --- a/tests/cases/only-comments.json +++ b/tests/cases/only-comments.json @@ -23,7 +23,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -39,7 +38,8 @@ "start": 1, "end": 27 } - } + }, + "access": "public" }, "body": [ { @@ -62,7 +62,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -78,12 +77,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 21, @@ -99,7 +99,9 @@ "start": 1, "end": 27 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/preserves-blank-lines.json b/tests/cases/preserves-blank-lines.json index 9f056a3..e52140c 100644 --- a/tests/cases/preserves-blank-lines.json +++ b/tests/cases/preserves-blank-lines.json @@ -31,7 +31,6 @@ "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)">" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,7 +46,9 @@ "start": 1, "end": 13 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/single-body-comment-no-code.json b/tests/cases/single-body-comment-no-code.json index 6aa6334..7c11694 100644 --- a/tests/cases/single-body-comment-no-code.json +++ b/tests/cases/single-body-comment-no-code.json @@ -20,7 +20,6 @@ { "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", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -36,7 +35,9 @@ "start": 1, "end": 8 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/single-body-comment.json b/tests/cases/single-body-comment.json index 49710e7..5c792b0 100644 --- a/tests/cases/single-body-comment.json +++ b/tests/cases/single-body-comment.json @@ -37,7 +37,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -53,7 +52,9 @@ "start": 1, "end": 27 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/space-between-comment-and-code.json b/tests/cases/space-between-comment-and-code.json index c97de62..61eb116 100644 --- a/tests/cases/space-between-comment-and-code.json +++ b/tests/cases/space-between-comment-and-code.json @@ -40,7 +40,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -56,7 +55,9 @@ "start": 1, "end": 28 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/cases/starts-and-ends-with-spaces.json b/tests/cases/starts-and-ends-with-spaces.json index 46168e4..cb14df9 100644 --- a/tests/cases/starts-and-ends-with-spaces.json +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -37,7 +37,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -53,7 +52,9 @@ "start": 1, "end": 38 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/c++/test.json b/tests/file-types/c++/test.json index 21e1ec6..53a63c5 100644 --- a/tests/file-types/c++/test.json +++ b/tests/file-types/c++/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 93 } - } + }, + "access": "public" }, "body": [ { "name": "one", "description": "

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 35, @@ -98,12 +98,13 @@ "start": 1, "end": 93 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 68, @@ -119,7 +120,9 @@ "start": 1, "end": 93 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/c/test.json b/tests/file-types/c/test.json index 0abe6d1..8a244fd 100644 --- a/tests/file-types/c/test.json +++ b/tests/file-types/c/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 89 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "start": 1, "end": 89 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -98,12 +98,13 @@ "start": 1, "end": 89 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 64, @@ -119,7 +120,9 @@ "start": 1, "end": 89 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/coffeescript/test.json b/tests/file-types/coffeescript/test.json index f315902..dd8845b 100644 --- a/tests/file-types/coffeescript/test.json +++ b/tests/file-types/coffeescript/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 40 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -77,12 +76,13 @@ "start": 1, "end": 40 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 17, @@ -98,12 +98,13 @@ "start": 1, "end": 40 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normla multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 31, @@ -119,7 +120,9 @@ "start": 1, "end": 40 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/coldfusion/test.json b/tests/file-types/coldfusion/test.json index 17e9a52..25062e2 100644 --- a/tests/file-types/coldfusion/test.json +++ b/tests/file-types/coldfusion/test.json @@ -43,7 +43,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -59,13 +58,13 @@ "start": 1, "end": 61 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -81,12 +80,13 @@ "start": 1, "end": 61 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

    This is a normal multi-line coldfusion comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 18, @@ -102,12 +102,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -123,12 +124,13 @@ "start": 1, "end": 61 } - } + }, + "access": "public", + "inline": [] }, { "name": "Four", "description": "

    This is another normal multi-line coldfusion comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 51, @@ -144,7 +146,9 @@ "start": 1, "end": 61 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/cs/test.json b/tests/file-types/cs/test.json index e29f973..51835d8 100644 --- a/tests/file-types/cs/test.json +++ b/tests/file-types/cs/test.json @@ -40,7 +40,6 @@ "Tyler Benton" ], "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -56,13 +55,13 @@ "start": 1, "end": 95 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 10, @@ -78,12 +77,13 @@ "start": 1, "end": 95 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 40, @@ -99,12 +99,13 @@ "start": 1, "end": 95 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 70, @@ -120,7 +121,9 @@ "start": 1, "end": 95 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/css/test.json b/tests/file-types/css/test.json index 1c2c4d4..510e5b4 100644 --- a/tests/file-types/css/test.json +++ b/tests/file-types/css/test.json @@ -35,7 +35,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -51,13 +50,13 @@ "start": 1, "end": 31 } - } + }, + "access": "public" }, "body": [ { "name": "Base Styles", "description": "
      \n
    1. Set default font family to sans-serif.
    2. \n
    3. Prevent iOS text size adjust after orientation change, without disabling\nuser zoom.
    4. \n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -73,12 +72,13 @@ "start": 1, "end": 31 } - } + }, + "access": "public", + "inline": [] }, { "name": "Input", "description": "
      \n
    1. Address appearance set to searchfield in Safari 5 and Chrome.
    2. \n
    3. Address box-sizing set to border-box in Safari 5 and Chrome\n(include -moz to future-proof).
    4. \n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 20, @@ -94,7 +94,9 @@ "start": 1, "end": 31 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/html/test.json b/tests/file-types/html/test.json index bb93c52..933b2bd 100644 --- a/tests/file-types/html/test.json +++ b/tests/file-types/html/test.json @@ -36,7 +36,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -52,13 +51,13 @@ "start": 1, "end": 36 } - } + }, + "access": "public" }, "body": [ { "name": "Body Block 1", "description": "

    This is the main header of the site

    \n", - "access": "public", "blockinfo": { "comment": { "start": 13, @@ -74,12 +73,13 @@ "start": 1, "end": 36 } - } + }, + "access": "public", + "inline": [] }, { "name": "Body Block 2", "description": "

    This is the main footer of the site

    \n", - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -95,7 +95,9 @@ "start": 1, "end": 36 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/jade/test.json b/tests/file-types/jade/test.json index 05434ee..9323cb5 100644 --- a/tests/file-types/jade/test.json +++ b/tests/file-types/jade/test.json @@ -31,7 +31,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,13 +46,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 7, @@ -69,7 +68,9 @@ "start": 1, "end": 16 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/java/test.json b/tests/file-types/java/test.json index 3a5c1a5..2a1fe3c 100644 --- a/tests/file-types/java/test.json +++ b/tests/file-types/java/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 34 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

    A very simple class to print out Hello World

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "start": 1, "end": 34 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 17, @@ -98,12 +98,13 @@ "start": 1, "end": 34 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 26, @@ -119,7 +120,9 @@ "start": 1, "end": 34 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/js/test.json b/tests/file-types/js/test.json index 4868c5a..e36db3a 100644 --- a/tests/file-types/js/test.json +++ b/tests/file-types/js/test.json @@ -31,7 +31,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,7 +46,8 @@ "start": 1, "end": 28 } - } + }, + "access": "public" }, "body": [ { @@ -74,7 +74,6 @@ "escaped_stateless": "/// @author Author's name\n\n/// @author Author One, Author Two\n\n/// @author Author One\n/// @author Author Two" } ], - "access": "public", "blockinfo": { "comment": { "start": 8, @@ -90,7 +89,9 @@ "start": 1, "end": 28 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json index 28e2df6..d216834 100644 --- a/tests/file-types/less/test.json +++ b/tests/file-types/less/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,7 +54,8 @@ "start": 1, "end": 59 } - } + }, + "access": "public" }, "body": [ { @@ -76,7 +76,6 @@ "escaped_stateless": "\\@name" } ], - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -92,7 +91,9 @@ "start": 1, "end": 59 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", @@ -109,7 +110,6 @@ "escaped_stateless": "<nav>\n <a href="">One</a>\n <a href="">Two</a>\n <a href="">Three</a>\n</nav>" } ], - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -125,7 +125,9 @@ "start": 1, "end": 59 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", @@ -152,7 +154,6 @@ "escaped_stateless": ".foo {\n .opacity(.3);\n}" } ], - "access": "public", "blockinfo": { "comment": { "start": 43, @@ -168,7 +169,9 @@ "start": 1, "end": 59 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/markdown/mark.json b/tests/file-types/markdown/mark.json index 71748d5..70b5ed6 100644 --- a/tests/file-types/markdown/mark.json +++ b/tests/file-types/markdown/mark.json @@ -25,7 +25,6 @@ "header": { "name": "mark", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/markdown.json b/tests/file-types/markdown/markdown.json index 25790f0..399e9c3 100644 --- a/tests/file-types/markdown/markdown.json +++ b/tests/file-types/markdown/markdown.json @@ -25,7 +25,6 @@ "header": { "name": "markdown", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/md.json b/tests/file-types/markdown/md.json index 82b47e3..94c435c 100644 --- a/tests/file-types/markdown/md.json +++ b/tests/file-types/markdown/md.json @@ -25,7 +25,6 @@ "header": { "name": "md", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdml.json b/tests/file-types/markdown/mdml.json index b54f037..801a40c 100644 --- a/tests/file-types/markdown/mdml.json +++ b/tests/file-types/markdown/mdml.json @@ -25,7 +25,6 @@ "header": { "name": "mdml", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdown.json b/tests/file-types/markdown/mdown.json index 7b7b904..79a6be8 100644 --- a/tests/file-types/markdown/mdown.json +++ b/tests/file-types/markdown/mdown.json @@ -25,7 +25,6 @@ "header": { "name": "mdown", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdtext.json b/tests/file-types/markdown/mdtext.json index 7b43fb0..ba3d4fd 100644 --- a/tests/file-types/markdown/mdtext.json +++ b/tests/file-types/markdown/mdtext.json @@ -25,7 +25,6 @@ "header": { "name": "mdtext", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdtxt.json b/tests/file-types/markdown/mdtxt.json index 2d18726..c41d58b 100644 --- a/tests/file-types/markdown/mdtxt.json +++ b/tests/file-types/markdown/mdtxt.json @@ -25,7 +25,6 @@ "header": { "name": "mdtxt", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mdwn.json b/tests/file-types/markdown/mdwn.json index 601b9a4..253f621 100644 --- a/tests/file-types/markdown/mdwn.json +++ b/tests/file-types/markdown/mdwn.json @@ -25,7 +25,6 @@ "header": { "name": "mdwn", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mkd.json b/tests/file-types/markdown/mkd.json index 2519cac..86f2c79 100644 --- a/tests/file-types/markdown/mkd.json +++ b/tests/file-types/markdown/mkd.json @@ -25,7 +25,6 @@ "header": { "name": "mkd", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/mkdn.json b/tests/file-types/markdown/mkdn.json index 59303da..76d77d4 100644 --- a/tests/file-types/markdown/mkdn.json +++ b/tests/file-types/markdown/mkdn.json @@ -25,7 +25,6 @@ "header": { "name": "mkdn", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/markdown/text.json b/tests/file-types/markdown/text.json index cd58ead..092e484 100644 --- a/tests/file-types/markdown/text.json +++ b/tests/file-types/markdown/text.json @@ -25,7 +25,6 @@ "header": { "name": "text", "markdown": "

    Default Annotations

    \n

    @name

    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    AttributeValue
    DescriptionName of the documented item
    Multiplefalse
    Default-
    Aliases-
    Autofilled-
    \n
    Example
    \n
    /// @name Name\n
    \n", - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -41,7 +40,8 @@ "start": 1, "end": 21 } - } + }, + "access": "public" }, "body": [] } diff --git a/tests/file-types/php/test.json b/tests/file-types/php/test.json index 4c465be..bc857fc 100644 --- a/tests/file-types/php/test.json +++ b/tests/file-types/php/test.json @@ -40,7 +40,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 2, @@ -56,13 +55,13 @@ "start": 1, "end": 37 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 9, @@ -78,12 +77,13 @@ "start": 1, "end": 37 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

    This is a normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 14, @@ -99,12 +99,13 @@ "start": 1, "end": 37 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 27, @@ -120,7 +121,9 @@ "start": 1, "end": 37 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/python/test.json b/tests/file-types/python/test.json index 632d824..c0c3b51 100644 --- a/tests/file-types/python/test.json +++ b/tests/file-types/python/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, "body": [ { "name": "main", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] }, { "name": "something", "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 23, @@ -98,12 +98,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] }, { "name": "something else", "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 32, @@ -119,7 +120,9 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/ruby/test.json b/tests/file-types/ruby/test.json index 9d8b7b0..6c57f05 100644 --- a/tests/file-types/ruby/test.json +++ b/tests/file-types/ruby/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public" }, "body": [ { "name": "One", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] }, { "name": "Two", "description": "

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

    \n", - "access": "public", "blockinfo": { "comment": { "start": 15, @@ -98,12 +98,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 24, @@ -119,7 +120,9 @@ "start": 1, "end": 43 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/scss/inline.json b/tests/file-types/scss/inline.json index faed2b5..c233de4 100644 --- a/tests/file-types/scss/inline.json +++ b/tests/file-types/scss/inline.json @@ -31,7 +31,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -47,7 +46,8 @@ "start": 1, "end": 15 } - } + }, + "access": "public" }, "body": [ { @@ -57,7 +57,6 @@ "description": "" }, "description": "

    what up\nshoot

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -74,30 +73,94 @@ "end": 15 } }, - "property": [ + "access": "public", + "inline": [ { - "types": [ - "color" + "property": [ + { + "types": [ + "color" + ], + "name": "a", + "value": "", + "description": "

    description

    \n" + } ], - "name": "a", - "value": "", - "description": "

    description

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

    description

    \n" + } ], - "name": "b", - "value": "", - "description": "

    description

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

    description

    \n" + } ], - "name": "c", - "value": "", - "description": "

    description

    \n" + "blockinfo": { + "comment": { + "start": 14, + "end": 14, + "type": "inline" + }, + "code": { + "start": 14, + "end": 14 + }, + "file": { + "path": "docs/tests/file-types/scss/inline.scss", + "start": 1, + "end": 15 + } + }, + "access": "public" } ] } diff --git a/tests/file-types/scss/test.json b/tests/file-types/scss/test.json index 0f4e2ec..f925e2f 100644 --- a/tests/file-types/scss/test.json +++ b/tests/file-types/scss/test.json @@ -35,7 +35,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -51,7 +50,8 @@ "start": 1, "end": 39 } - } + }, + "access": "public" }, "body": [ { @@ -60,7 +60,6 @@ "type": "color", "description": "" }, - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -76,7 +75,9 @@ "start": 1, "end": 39 } - } + }, + "access": "public", + "inline": [] }, { "name": "moz-only", @@ -117,7 +118,6 @@ "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}" } ], - "access": "public", "blockinfo": { "comment": { "start": 12, @@ -133,7 +133,9 @@ "start": 1, "end": 39 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/stylus/test.json b/tests/file-types/stylus/test.json index 096e573..d82f824 100644 --- a/tests/file-types/stylus/test.json +++ b/tests/file-types/stylus/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "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", - "access": "public", "blockinfo": { "comment": { "start": 16, @@ -98,12 +98,13 @@ "start": 1, "end": 37 } - } + }, + "access": "public", + "inline": [] }, { "name": "Three", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 27, @@ -119,7 +120,9 @@ "start": 1, "end": 37 } - } + }, + "access": "public", + "inline": [] } ] } diff --git a/tests/file-types/swift/test.json b/tests/file-types/swift/test.json index 39f763e..26d03bb 100644 --- a/tests/file-types/swift/test.json +++ b/tests/file-types/swift/test.json @@ -39,7 +39,6 @@ "author": [ "Tyler Benton" ], - "access": "public", "blockinfo": { "comment": { "start": 1, @@ -55,13 +54,13 @@ "start": 1, "end": 49 } - } + }, + "access": "public" }, "body": [ { "name": "main", "description": "

    main method

    \n", - "access": "public", "blockinfo": { "comment": { "start": 6, @@ -77,12 +76,13 @@ "start": 1, "end": 49 } - } + }, + "access": "public", + "inline": [] }, { "name": "Something", "description": "

    This is a normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 23, @@ -98,12 +98,13 @@ "start": 1, "end": 49 } - } + }, + "access": "public", + "inline": [] }, { "name": "Something else", "description": "

    This is another normal multi-line comment.

    \n", - "access": "public", "blockinfo": { "comment": { "start": 34, @@ -119,7 +120,9 @@ "start": 1, "end": 49 } - } + }, + "access": "public", + "inline": [] } ] } From a388679e42478e49e442139d89102537b171792b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 5 May 2016 15:21:48 -0400 Subject: [PATCH 273/273] updated tests to work with new package name --- .../access/access.autofill.body.json | 2 +- .../access/access.autofill.header.json | 2 +- tests/annotations/access/access.header.json | 2 +- tests/annotations/access/access.options.json | 6 ++--- tests/annotations/alias/alias.json | 6 ++--- tests/annotations/arg/arg.aliases.json | 6 ++--- tests/annotations/arg/arg.json | 12 +++++----- tests/annotations/author/author.alias.json | 2 +- tests/annotations/author/author.body.json | 2 +- tests/annotations/author/author.header.json | 2 +- tests/annotations/author/author.multiple.json | 8 +++---- tests/annotations/chainable/chainable.json | 14 +++++------ .../depricated/depricated.body.json | 8 +++---- .../depricated/depricated.header.json | 2 +- .../description/description.alias.json | 24 +++++++++---------- .../description/description.body.json | 6 ++--- .../description/description.header.json | 2 +- tests/annotations/markdown/mark.json | 2 +- tests/annotations/markdown/markdown.json | 2 +- tests/annotations/markdown/md.json | 2 +- tests/annotations/markdown/mdml.json | 2 +- tests/annotations/markdown/mdown.json | 2 +- tests/annotations/markdown/mdtext.json | 2 +- tests/annotations/markdown/mdtxt.json | 2 +- tests/annotations/markdown/mdwn.json | 2 +- tests/annotations/markdown/mkd.json | 2 +- tests/annotations/markdown/mkdn.json | 2 +- tests/annotations/markdown/text.json | 2 +- tests/annotations/name/name.aliases.json | 6 ++--- tests/annotations/name/name.json | 2 +- tests/annotations/note/note.alias.json | 4 ++-- tests/annotations/note/note.json | 12 +++++----- tests/annotations/page/page.alias.json | 6 ++--- .../annotations/page/page.body.autofill.json | 2 +- tests/annotations/page/page.body.json | 6 ++--- .../page/page.header.autofill.json | 2 +- tests/annotations/page/page.header.json | 2 +- .../property/property.aliases.json | 12 +++++----- .../annotations/property/property.inline.json | 24 +++++++++---------- tests/annotations/property/property.json | 12 +++++----- .../raw-code/raw-code.escaped.json | 2 +- tests/annotations/raw-code/raw-code.json | 2 +- tests/annotations/readonly/readonly.json | 6 ++--- .../annotations/requires/requires.alias.json | 2 +- tests/annotations/requires/requires.body.json | 14 +++++------ .../annotations/requires/requires.header.json | 2 +- tests/annotations/returns/returns.alias.json | 14 +++++------ tests/annotations/returns/returns.json | 14 +++++------ tests/annotations/since/since.body.json | 8 +++---- tests/annotations/since/since.header.json | 2 +- ...ltiple-markup-by-id-with-custom-props.json | 2 +- .../states-multiple-markup-by-id.json | 2 +- ...tes-multiple-markup-with-custom-props.json | 2 +- .../states-multiple-markup.json | 2 +- .../states-with-custom-props.json | 2 +- .../state/complex-multiple/states.json | 2 +- .../state/complex/single-markup.json | 2 +- .../blocks-with-different-states.json | 2 +- .../state/multiple-markup/blocks.json | 2 +- .../simple-with-description.json | 6 ++--- .../simple-with-notations.json | 6 ++--- .../state/stupid-simple-multiple/simple.json | 2 +- .../state/stupid-simple/simple.json | 2 +- .../state/stupid-simple/with-description.json | 6 ++--- .../state/stupid-simple/with-notations.json | 6 ++--- tests/annotations/throws/throws.alias.json | 8 +++---- tests/annotations/throws/throws.json | 12 +++++----- tests/annotations/todo/todo.body.json | 12 +++++----- tests/annotations/todo/todo.header.json | 2 +- tests/annotations/type/type.json | 14 +++++------ tests/annotations/version/version.json | 10 ++++---- .../4-blank-lines-between-code-blocks.json | 2 +- tests/cases/allthethings-js.json | 8 +++---- tests/cases/allthethings-scss.json | 8 +++---- tests/cases/header-comment-only.json | 2 +- ...pace-between-header-and-body-comments.json | 4 ++-- tests/cases/only-body-comments-no-page.json | 4 ++-- tests/cases/only-body-comments.json | 6 ++--- tests/cases/only-comments.json | 6 ++--- tests/cases/preserves-blank-lines.json | 2 +- tests/cases/single-body-comment-no-code.json | 2 +- tests/cases/single-body-comment.json | 2 +- .../cases/space-between-comment-and-code.json | 2 +- tests/cases/starts-and-ends-with-spaces.json | 2 +- tests/file-types/c++/test.json | 8 +++---- tests/file-types/c/test.json | 8 +++---- tests/file-types/coffeescript/test.json | 8 +++---- tests/file-types/coldfusion/test.json | 10 ++++---- tests/file-types/cs/test.json | 8 +++---- tests/file-types/css/test.json | 6 ++--- tests/file-types/html/test.json | 6 ++--- tests/file-types/jade/test.json | 4 ++-- tests/file-types/java/test.json | 8 +++---- tests/file-types/js/test.json | 4 ++-- tests/file-types/less/test.json | 8 +++---- tests/file-types/markdown/mark.json | 2 +- tests/file-types/markdown/markdown.json | 2 +- tests/file-types/markdown/md.json | 2 +- tests/file-types/markdown/mdml.json | 2 +- tests/file-types/markdown/mdown.json | 2 +- tests/file-types/markdown/mdtext.json | 2 +- tests/file-types/markdown/mdtxt.json | 2 +- tests/file-types/markdown/mdwn.json | 2 +- tests/file-types/markdown/mkd.json | 2 +- tests/file-types/markdown/mkdn.json | 2 +- tests/file-types/markdown/text.json | 2 +- tests/file-types/php/test.json | 8 +++---- tests/file-types/python/test.json | 8 +++---- tests/file-types/ruby/test.json | 8 +++---- tests/file-types/scss/inline.json | 10 ++++---- tests/file-types/scss/test.json | 6 ++--- tests/file-types/stylus/test.json | 8 +++---- tests/file-types/swift/test.json | 8 +++---- 113 files changed, 297 insertions(+), 297 deletions(-) diff --git a/tests/annotations/access/access.autofill.body.json b/tests/annotations/access/access.autofill.body.json index f37668c..b524c66 100644 --- a/tests/annotations/access/access.autofill.body.json +++ b/tests/annotations/access/access.autofill.body.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/access/access.autofill.body.js", + "path": "docs-parser/tests/annotations/access/access.autofill.body.js", "start": 1, "end": 2 } diff --git a/tests/annotations/access/access.autofill.header.json b/tests/annotations/access/access.autofill.header.json index c114f67..0cd8ec6 100644 --- a/tests/annotations/access/access.autofill.header.json +++ b/tests/annotations/access/access.autofill.header.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/access/access.autofill.header.js", + "path": "docs-parser/tests/annotations/access/access.autofill.header.js", "start": 1, "end": 4 } diff --git a/tests/annotations/access/access.header.json b/tests/annotations/access/access.header.json index 48e6336..d843d2e 100644 --- a/tests/annotations/access/access.header.json +++ b/tests/annotations/access/access.header.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/access/access.header.js", + "path": "docs-parser/tests/annotations/access/access.header.js", "start": 1, "end": 4 } diff --git a/tests/annotations/access/access.options.json b/tests/annotations/access/access.options.json index c649983..d88a579 100644 --- a/tests/annotations/access/access.options.json +++ b/tests/annotations/access/access.options.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/access/access.options.js", + "path": "docs-parser/tests/annotations/access/access.options.js", "start": 1, "end": 6 } @@ -34,7 +34,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/access/access.options.js", + "path": "docs-parser/tests/annotations/access/access.options.js", "start": 1, "end": 6 } @@ -54,7 +54,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/access/access.options.js", + "path": "docs-parser/tests/annotations/access/access.options.js", "start": 1, "end": 6 } diff --git a/tests/annotations/alias/alias.json b/tests/annotations/alias/alias.json index f35dff1..a436f66 100644 --- a/tests/annotations/alias/alias.json +++ b/tests/annotations/alias/alias.json @@ -16,7 +16,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/alias/alias.js", + "path": "docs-parser/tests/annotations/alias/alias.js", "start": 1, "end": 6 } @@ -40,7 +40,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/alias/alias.js", + "path": "docs-parser/tests/annotations/alias/alias.js", "start": 1, "end": 6 } @@ -64,7 +64,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/alias/alias.js", + "path": "docs-parser/tests/annotations/alias/alias.js", "start": 1, "end": 6 } diff --git a/tests/annotations/arg/arg.aliases.json b/tests/annotations/arg/arg.aliases.json index 156eed6..7bb12e0 100644 --- a/tests/annotations/arg/arg.aliases.json +++ b/tests/annotations/arg/arg.aliases.json @@ -23,7 +23,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.aliases.js", + "path": "docs-parser/tests/annotations/arg/arg.aliases.js", "start": 1, "end": 6 } @@ -53,7 +53,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.aliases.js", + "path": "docs-parser/tests/annotations/arg/arg.aliases.js", "start": 1, "end": 6 } @@ -83,7 +83,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.aliases.js", + "path": "docs-parser/tests/annotations/arg/arg.aliases.js", "start": 1, "end": 6 } diff --git a/tests/annotations/arg/arg.json b/tests/annotations/arg/arg.json index 4ad55ae..36de179 100644 --- a/tests/annotations/arg/arg.json +++ b/tests/annotations/arg/arg.json @@ -21,7 +21,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.js", + "path": "docs-parser/tests/annotations/arg/arg.js", "start": 1, "end": 17 } @@ -51,7 +51,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.js", + "path": "docs-parser/tests/annotations/arg/arg.js", "start": 1, "end": 17 } @@ -82,7 +82,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.js", + "path": "docs-parser/tests/annotations/arg/arg.js", "start": 1, "end": 17 } @@ -112,7 +112,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.js", + "path": "docs-parser/tests/annotations/arg/arg.js", "start": 1, "end": 17 } @@ -142,7 +142,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.js", + "path": "docs-parser/tests/annotations/arg/arg.js", "start": 1, "end": 17 } @@ -172,7 +172,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/arg/arg.js", + "path": "docs-parser/tests/annotations/arg/arg.js", "start": 1, "end": 17 } diff --git a/tests/annotations/author/author.alias.json b/tests/annotations/author/author.alias.json index 6ea0027..5567adf 100644 --- a/tests/annotations/author/author.alias.json +++ b/tests/annotations/author/author.alias.json @@ -18,7 +18,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.alias.js", + "path": "docs-parser/tests/annotations/author/author.alias.js", "start": 1, "end": 2 } diff --git a/tests/annotations/author/author.body.json b/tests/annotations/author/author.body.json index 8d42a76..1680355 100644 --- a/tests/annotations/author/author.body.json +++ b/tests/annotations/author/author.body.json @@ -16,7 +16,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.body.js", + "path": "docs-parser/tests/annotations/author/author.body.js", "start": 1, "end": 2 } diff --git a/tests/annotations/author/author.header.json b/tests/annotations/author/author.header.json index d5b9649..4447579 100644 --- a/tests/annotations/author/author.header.json +++ b/tests/annotations/author/author.header.json @@ -17,7 +17,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.header.js", + "path": "docs-parser/tests/annotations/author/author.header.js", "start": 1, "end": 4 } diff --git a/tests/annotations/author/author.multiple.json b/tests/annotations/author/author.multiple.json index dbb2ada..3f94c1c 100644 --- a/tests/annotations/author/author.multiple.json +++ b/tests/annotations/author/author.multiple.json @@ -18,7 +18,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.multiple.js", + "path": "docs-parser/tests/annotations/author/author.multiple.js", "start": 1, "end": 14 } @@ -42,7 +42,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.multiple.js", + "path": "docs-parser/tests/annotations/author/author.multiple.js", "start": 1, "end": 14 } @@ -66,7 +66,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.multiple.js", + "path": "docs-parser/tests/annotations/author/author.multiple.js", "start": 1, "end": 14 } @@ -90,7 +90,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/author/author.multiple.js", + "path": "docs-parser/tests/annotations/author/author.multiple.js", "start": 1, "end": 14 } diff --git a/tests/annotations/chainable/chainable.json b/tests/annotations/chainable/chainable.json index c95a80c..4052ff0 100644 --- a/tests/annotations/chainable/chainable.json +++ b/tests/annotations/chainable/chainable.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } @@ -35,7 +35,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } @@ -56,7 +56,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } @@ -79,7 +79,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } @@ -103,7 +103,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } @@ -127,7 +127,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } @@ -151,7 +151,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/chainable/chainable.js", + "path": "docs-parser/tests/annotations/chainable/chainable.js", "start": 1, "end": 18 } diff --git a/tests/annotations/depricated/depricated.body.json b/tests/annotations/depricated/depricated.body.json index a602d87..2cb66cc 100644 --- a/tests/annotations/depricated/depricated.body.json +++ b/tests/annotations/depricated/depricated.body.json @@ -17,7 +17,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/depricated/depricated.body.js", + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", "start": 1, "end": 11 } @@ -41,7 +41,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/depricated/depricated.body.js", + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", "start": 1, "end": 11 } @@ -65,7 +65,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/depricated/depricated.body.js", + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", "start": 1, "end": 11 } @@ -89,7 +89,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/depricated/depricated.body.js", + "path": "docs-parser/tests/annotations/depricated/depricated.body.js", "start": 1, "end": 11 } diff --git a/tests/annotations/depricated/depricated.header.json b/tests/annotations/depricated/depricated.header.json index 85b25ae..38f0234 100644 --- a/tests/annotations/depricated/depricated.header.json +++ b/tests/annotations/depricated/depricated.header.json @@ -18,7 +18,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/depricated/depricated.header.js", + "path": "docs-parser/tests/annotations/depricated/depricated.header.js", "start": 1, "end": 7 } diff --git a/tests/annotations/description/description.alias.json b/tests/annotations/description/description.alias.json index 3181276..d8438eb 100644 --- a/tests/annotations/description/description.alias.json +++ b/tests/annotations/description/description.alias.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -37,7 +37,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -59,7 +59,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -81,7 +81,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -103,7 +103,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -125,7 +125,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -147,7 +147,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -169,7 +169,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -191,7 +191,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -213,7 +213,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -235,7 +235,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } @@ -257,7 +257,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.alias.js", + "path": "docs-parser/tests/annotations/description/description.alias.js", "start": 1, "end": 58 } diff --git a/tests/annotations/description/description.body.json b/tests/annotations/description/description.body.json index ab315b8..f10982c 100644 --- a/tests/annotations/description/description.body.json +++ b/tests/annotations/description/description.body.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.body.js", + "path": "docs-parser/tests/annotations/description/description.body.js", "start": 1, "end": 15 } @@ -35,7 +35,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.body.js", + "path": "docs-parser/tests/annotations/description/description.body.js", "start": 1, "end": 15 } @@ -56,7 +56,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.body.js", + "path": "docs-parser/tests/annotations/description/description.body.js", "start": 1, "end": 15 } diff --git a/tests/annotations/description/description.header.json b/tests/annotations/description/description.header.json index b3f7438..9ce9653 100644 --- a/tests/annotations/description/description.header.json +++ b/tests/annotations/description/description.header.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/description/description.header.js", + "path": "docs-parser/tests/annotations/description/description.header.js", "start": 1, "end": 8 } diff --git a/tests/annotations/markdown/mark.json b/tests/annotations/markdown/mark.json index 0eadb34..a0b3bf7 100644 --- a/tests/annotations/markdown/mark.json +++ b/tests/annotations/markdown/mark.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mark.mark", + "path": "docs-parser/tests/annotations/markdown/mark.mark", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/markdown.json b/tests/annotations/markdown/markdown.json index 7a3a662..c4123ed 100644 --- a/tests/annotations/markdown/markdown.json +++ b/tests/annotations/markdown/markdown.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/markdown.markdown", + "path": "docs-parser/tests/annotations/markdown/markdown.markdown", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/md.json b/tests/annotations/markdown/md.json index 01e0f16..8d10089 100644 --- a/tests/annotations/markdown/md.json +++ b/tests/annotations/markdown/md.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/md.md", + "path": "docs-parser/tests/annotations/markdown/md.md", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mdml.json b/tests/annotations/markdown/mdml.json index a781c87..8458431 100644 --- a/tests/annotations/markdown/mdml.json +++ b/tests/annotations/markdown/mdml.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mdml.mdml", + "path": "docs-parser/tests/annotations/markdown/mdml.mdml", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mdown.json b/tests/annotations/markdown/mdown.json index aec2291..3ff16bb 100644 --- a/tests/annotations/markdown/mdown.json +++ b/tests/annotations/markdown/mdown.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mdown.mdown", + "path": "docs-parser/tests/annotations/markdown/mdown.mdown", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mdtext.json b/tests/annotations/markdown/mdtext.json index 70222cc..b6bc884 100644 --- a/tests/annotations/markdown/mdtext.json +++ b/tests/annotations/markdown/mdtext.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mdtext.mdtext", + "path": "docs-parser/tests/annotations/markdown/mdtext.mdtext", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mdtxt.json b/tests/annotations/markdown/mdtxt.json index 62bfdae..4204583 100644 --- a/tests/annotations/markdown/mdtxt.json +++ b/tests/annotations/markdown/mdtxt.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mdtxt.mdtxt", + "path": "docs-parser/tests/annotations/markdown/mdtxt.mdtxt", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mdwn.json b/tests/annotations/markdown/mdwn.json index 1455f01..37a2d88 100644 --- a/tests/annotations/markdown/mdwn.json +++ b/tests/annotations/markdown/mdwn.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mdwn.mdwn", + "path": "docs-parser/tests/annotations/markdown/mdwn.mdwn", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mkd.json b/tests/annotations/markdown/mkd.json index a5663f6..6c4447a 100644 --- a/tests/annotations/markdown/mkd.json +++ b/tests/annotations/markdown/mkd.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mkd.mkd", + "path": "docs-parser/tests/annotations/markdown/mkd.mkd", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/mkdn.json b/tests/annotations/markdown/mkdn.json index 490f3e0..496186f 100644 --- a/tests/annotations/markdown/mkdn.json +++ b/tests/annotations/markdown/mkdn.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/mkdn.mkdn", + "path": "docs-parser/tests/annotations/markdown/mkdn.mkdn", "start": 1, "end": 13 } diff --git a/tests/annotations/markdown/text.json b/tests/annotations/markdown/text.json index 90a75bc..5595961 100644 --- a/tests/annotations/markdown/text.json +++ b/tests/annotations/markdown/text.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/markdown/text.text", + "path": "docs-parser/tests/annotations/markdown/text.text", "start": 1, "end": 13 } diff --git a/tests/annotations/name/name.aliases.json b/tests/annotations/name/name.aliases.json index cb7a64b..d2285df 100644 --- a/tests/annotations/name/name.aliases.json +++ b/tests/annotations/name/name.aliases.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/name/name.aliases.js", + "path": "docs-parser/tests/annotations/name/name.aliases.js", "start": 1, "end": 6 } @@ -35,7 +35,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/name/name.aliases.js", + "path": "docs-parser/tests/annotations/name/name.aliases.js", "start": 1, "end": 6 } @@ -56,7 +56,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/name/name.aliases.js", + "path": "docs-parser/tests/annotations/name/name.aliases.js", "start": 1, "end": 6 } diff --git a/tests/annotations/name/name.json b/tests/annotations/name/name.json index 1de5448..9254b0e 100644 --- a/tests/annotations/name/name.json +++ b/tests/annotations/name/name.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/name/name.js", + "path": "docs-parser/tests/annotations/name/name.js", "start": 1, "end": 2 } diff --git a/tests/annotations/note/note.alias.json b/tests/annotations/note/note.alias.json index 23285cd..f4ada51 100644 --- a/tests/annotations/note/note.alias.json +++ b/tests/annotations/note/note.alias.json @@ -19,7 +19,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.alias.js", + "path": "docs-parser/tests/annotations/note/note.alias.js", "start": 1, "end": 10 } @@ -45,7 +45,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.alias.js", + "path": "docs-parser/tests/annotations/note/note.alias.js", "start": 1, "end": 10 } diff --git a/tests/annotations/note/note.json b/tests/annotations/note/note.json index ce3f945..aa36a5a 100644 --- a/tests/annotations/note/note.json +++ b/tests/annotations/note/note.json @@ -19,7 +19,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.js", + "path": "docs-parser/tests/annotations/note/note.js", "start": 1, "end": 20 } @@ -45,7 +45,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.js", + "path": "docs-parser/tests/annotations/note/note.js", "start": 1, "end": 20 } @@ -71,7 +71,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.js", + "path": "docs-parser/tests/annotations/note/note.js", "start": 1, "end": 20 } @@ -97,7 +97,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.js", + "path": "docs-parser/tests/annotations/note/note.js", "start": 1, "end": 20 } @@ -123,7 +123,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.js", + "path": "docs-parser/tests/annotations/note/note.js", "start": 1, "end": 20 } @@ -149,7 +149,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/note/note.js", + "path": "docs-parser/tests/annotations/note/note.js", "start": 1, "end": 20 } diff --git a/tests/annotations/page/page.alias.json b/tests/annotations/page/page.alias.json index 579e973..f2887e7 100644 --- a/tests/annotations/page/page.alias.json +++ b/tests/annotations/page/page.alias.json @@ -16,7 +16,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.alias.js", + "path": "docs-parser/tests/annotations/page/page.alias.js", "start": 1, "end": 7 } @@ -39,7 +39,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.alias.js", + "path": "docs-parser/tests/annotations/page/page.alias.js", "start": 1, "end": 7 } @@ -63,7 +63,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.alias.js", + "path": "docs-parser/tests/annotations/page/page.alias.js", "start": 1, "end": 7 } diff --git a/tests/annotations/page/page.body.autofill.json b/tests/annotations/page/page.body.autofill.json index 7b4b198..0ca9c54 100644 --- a/tests/annotations/page/page.body.autofill.json +++ b/tests/annotations/page/page.body.autofill.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.body.autofill.js", + "path": "docs-parser/tests/annotations/page/page.body.autofill.js", "start": 1, "end": 2 } diff --git a/tests/annotations/page/page.body.json b/tests/annotations/page/page.body.json index 541dc14..2374f29 100644 --- a/tests/annotations/page/page.body.json +++ b/tests/annotations/page/page.body.json @@ -16,7 +16,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.body.js", + "path": "docs-parser/tests/annotations/page/page.body.js", "start": 1, "end": 7 } @@ -39,7 +39,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.body.js", + "path": "docs-parser/tests/annotations/page/page.body.js", "start": 1, "end": 7 } @@ -63,7 +63,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.body.js", + "path": "docs-parser/tests/annotations/page/page.body.js", "start": 1, "end": 7 } diff --git a/tests/annotations/page/page.header.autofill.json b/tests/annotations/page/page.header.autofill.json index 3d31c62..acec66f 100644 --- a/tests/annotations/page/page.header.autofill.json +++ b/tests/annotations/page/page.header.autofill.json @@ -15,7 +15,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.header.autofill.js", + "path": "docs-parser/tests/annotations/page/page.header.autofill.js", "start": 1, "end": 4 } diff --git a/tests/annotations/page/page.header.json b/tests/annotations/page/page.header.json index 49a5c27..956078c 100644 --- a/tests/annotations/page/page.header.json +++ b/tests/annotations/page/page.header.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/page/page.header.js", + "path": "docs-parser/tests/annotations/page/page.header.js", "start": 1, "end": 4 } diff --git a/tests/annotations/property/property.aliases.json b/tests/annotations/property/property.aliases.json index 7d1b0fa..31d0775 100644 --- a/tests/annotations/property/property.aliases.json +++ b/tests/annotations/property/property.aliases.json @@ -21,7 +21,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.aliases.js", + "path": "docs-parser/tests/annotations/property/property.aliases.js", "start": 1, "end": 17 } @@ -51,7 +51,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.aliases.js", + "path": "docs-parser/tests/annotations/property/property.aliases.js", "start": 1, "end": 17 } @@ -82,7 +82,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.aliases.js", + "path": "docs-parser/tests/annotations/property/property.aliases.js", "start": 1, "end": 17 } @@ -112,7 +112,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.aliases.js", + "path": "docs-parser/tests/annotations/property/property.aliases.js", "start": 1, "end": 17 } @@ -142,7 +142,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.aliases.js", + "path": "docs-parser/tests/annotations/property/property.aliases.js", "start": 1, "end": 17 } @@ -172,7 +172,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.aliases.js", + "path": "docs-parser/tests/annotations/property/property.aliases.js", "start": 1, "end": 17 } diff --git a/tests/annotations/property/property.inline.json b/tests/annotations/property/property.inline.json index 9e862ed..81db080 100644 --- a/tests/annotations/property/property.inline.json +++ b/tests/annotations/property/property.inline.json @@ -18,7 +18,7 @@ "end": 8 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -45,7 +45,7 @@ "end": 7 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -71,7 +71,7 @@ "end": 14 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -100,7 +100,7 @@ "end": 13 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -126,7 +126,7 @@ "end": 20 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -156,7 +156,7 @@ "end": 19 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -182,7 +182,7 @@ "end": 28 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -211,7 +211,7 @@ "end": 27 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -237,7 +237,7 @@ "end": 34 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -266,7 +266,7 @@ "end": 33 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -292,7 +292,7 @@ "end": 44 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } @@ -321,7 +321,7 @@ "end": 43 }, "file": { - "path": "docs/tests/annotations/property/property.inline.js", + "path": "docs-parser/tests/annotations/property/property.inline.js", "start": 1, "end": 45 } diff --git a/tests/annotations/property/property.json b/tests/annotations/property/property.json index ef2eae4..cd67798 100644 --- a/tests/annotations/property/property.json +++ b/tests/annotations/property/property.json @@ -21,7 +21,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.js", + "path": "docs-parser/tests/annotations/property/property.js", "start": 1, "end": 17 } @@ -51,7 +51,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.js", + "path": "docs-parser/tests/annotations/property/property.js", "start": 1, "end": 17 } @@ -82,7 +82,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.js", + "path": "docs-parser/tests/annotations/property/property.js", "start": 1, "end": 17 } @@ -112,7 +112,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.js", + "path": "docs-parser/tests/annotations/property/property.js", "start": 1, "end": 17 } @@ -142,7 +142,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.js", + "path": "docs-parser/tests/annotations/property/property.js", "start": 1, "end": 17 } @@ -172,7 +172,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/property/property.js", + "path": "docs-parser/tests/annotations/property/property.js", "start": 1, "end": 17 } diff --git a/tests/annotations/raw-code/raw-code.escaped.json b/tests/annotations/raw-code/raw-code.escaped.json index 0cd7467..5f53766 100644 --- a/tests/annotations/raw-code/raw-code.escaped.json +++ b/tests/annotations/raw-code/raw-code.escaped.json @@ -17,7 +17,7 @@ "end": 10 }, "file": { - "path": "docs/tests/annotations/raw-code/raw-code.escaped.html", + "path": "docs-parser/tests/annotations/raw-code/raw-code.escaped.html", "start": 1, "end": 10 } diff --git a/tests/annotations/raw-code/raw-code.json b/tests/annotations/raw-code/raw-code.json index fb04618..23286fe 100644 --- a/tests/annotations/raw-code/raw-code.json +++ b/tests/annotations/raw-code/raw-code.json @@ -17,7 +17,7 @@ "end": 4 }, "file": { - "path": "docs/tests/annotations/raw-code/raw-code.js", + "path": "docs-parser/tests/annotations/raw-code/raw-code.js", "start": 1, "end": 4 } diff --git a/tests/annotations/readonly/readonly.json b/tests/annotations/readonly/readonly.json index dc75b74..2c986bf 100644 --- a/tests/annotations/readonly/readonly.json +++ b/tests/annotations/readonly/readonly.json @@ -14,7 +14,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/readonly/readonly.js", + "path": "docs-parser/tests/annotations/readonly/readonly.js", "start": 1, "end": 6 } @@ -35,7 +35,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/readonly/readonly.js", + "path": "docs-parser/tests/annotations/readonly/readonly.js", "start": 1, "end": 6 } @@ -56,7 +56,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/readonly/readonly.js", + "path": "docs-parser/tests/annotations/readonly/readonly.js", "start": 1, "end": 6 } diff --git a/tests/annotations/requires/requires.alias.json b/tests/annotations/requires/requires.alias.json index d2a2aa3..a5200c7 100644 --- a/tests/annotations/requires/requires.alias.json +++ b/tests/annotations/requires/requires.alias.json @@ -20,7 +20,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.alias.js", + "path": "docs-parser/tests/annotations/requires/requires.alias.js", "start": 1, "end": 2 } diff --git a/tests/annotations/requires/requires.body.json b/tests/annotations/requires/requires.body.json index c1fe1a5..66baa51 100644 --- a/tests/annotations/requires/requires.body.json +++ b/tests/annotations/requires/requires.body.json @@ -20,7 +20,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } @@ -49,7 +49,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } @@ -81,7 +81,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } @@ -108,7 +108,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } @@ -135,7 +135,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } @@ -164,7 +164,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } @@ -196,7 +196,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.body.js", + "path": "docs-parser/tests/annotations/requires/requires.body.js", "start": 1, "end": 15 } diff --git a/tests/annotations/requires/requires.header.json b/tests/annotations/requires/requires.header.json index 677b268..5424ca3 100644 --- a/tests/annotations/requires/requires.header.json +++ b/tests/annotations/requires/requires.header.json @@ -23,7 +23,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/requires/requires.header.js", + "path": "docs-parser/tests/annotations/requires/requires.header.js", "start": 1, "end": 4 } diff --git a/tests/annotations/returns/returns.alias.json b/tests/annotations/returns/returns.alias.json index a9effae..363310f 100644 --- a/tests/annotations/returns/returns.alias.json +++ b/tests/annotations/returns/returns.alias.json @@ -19,7 +19,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } @@ -45,7 +45,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } @@ -73,7 +73,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } @@ -101,7 +101,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } @@ -127,7 +127,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } @@ -153,7 +153,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } @@ -179,7 +179,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.alias.js", + "path": "docs-parser/tests/annotations/returns/returns.alias.js", "start": 1, "end": 23 } diff --git a/tests/annotations/returns/returns.json b/tests/annotations/returns/returns.json index dcc75c5..8304bf0 100644 --- a/tests/annotations/returns/returns.json +++ b/tests/annotations/returns/returns.json @@ -19,7 +19,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } @@ -45,7 +45,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } @@ -73,7 +73,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } @@ -101,7 +101,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } @@ -127,7 +127,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } @@ -153,7 +153,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } @@ -179,7 +179,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/returns/returns.js", + "path": "docs-parser/tests/annotations/returns/returns.js", "start": 1, "end": 23 } diff --git a/tests/annotations/since/since.body.json b/tests/annotations/since/since.body.json index 6300404..96e19fe 100644 --- a/tests/annotations/since/since.body.json +++ b/tests/annotations/since/since.body.json @@ -17,7 +17,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/since/since.body.js", + "path": "docs-parser/tests/annotations/since/since.body.js", "start": 1, "end": 11 } @@ -41,7 +41,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/since/since.body.js", + "path": "docs-parser/tests/annotations/since/since.body.js", "start": 1, "end": 11 } @@ -65,7 +65,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/since/since.body.js", + "path": "docs-parser/tests/annotations/since/since.body.js", "start": 1, "end": 11 } @@ -89,7 +89,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/since/since.body.js", + "path": "docs-parser/tests/annotations/since/since.body.js", "start": 1, "end": 11 } diff --git a/tests/annotations/since/since.header.json b/tests/annotations/since/since.header.json index e5608f9..c576e54 100644 --- a/tests/annotations/since/since.header.json +++ b/tests/annotations/since/since.header.json @@ -18,7 +18,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/since/since.header.js", + "path": "docs-parser/tests/annotations/since/since.header.js", "start": 1, "end": 7 } 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 index b518de3..da85c20 100644 --- 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 @@ -161,7 +161,7 @@ "end": 59 }, "file": { - "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss", + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup-by-id-with-custom-props.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json index eacceb2..e6520d0 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.json @@ -161,7 +161,7 @@ "end": 59 }, "file": { - "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss", + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup-by-id.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json index db2a0c1..0115689 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.json @@ -161,7 +161,7 @@ "end": 59 }, "file": { - "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss", + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup-with-custom-props.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/complex-multiple/states-multiple-markup.json b/tests/annotations/state/complex-multiple/states-multiple-markup.json index 539edbd..7322f5a 100644 --- a/tests/annotations/state/complex-multiple/states-multiple-markup.json +++ b/tests/annotations/state/complex-multiple/states-multiple-markup.json @@ -161,7 +161,7 @@ "end": 59 }, "file": { - "path": "docs/tests/annotations/state/complex-multiple/states-multiple-markup.scss", + "path": "docs-parser/tests/annotations/state/complex-multiple/states-multiple-markup.scss", "start": 1, "end": 60 } diff --git a/tests/annotations/state/complex-multiple/states-with-custom-props.json b/tests/annotations/state/complex-multiple/states-with-custom-props.json index 965fd79..5067c3f 100644 --- a/tests/annotations/state/complex-multiple/states-with-custom-props.json +++ b/tests/annotations/state/complex-multiple/states-with-custom-props.json @@ -89,7 +89,7 @@ "end": 38 }, "file": { - "path": "docs/tests/annotations/state/complex-multiple/states-with-custom-props.scss", + "path": "docs-parser/tests/annotations/state/complex-multiple/states-with-custom-props.scss", "start": 1, "end": 39 } diff --git a/tests/annotations/state/complex-multiple/states.json b/tests/annotations/state/complex-multiple/states.json index e4ceb1f..7f225cc 100644 --- a/tests/annotations/state/complex-multiple/states.json +++ b/tests/annotations/state/complex-multiple/states.json @@ -89,7 +89,7 @@ "end": 38 }, "file": { - "path": "docs/tests/annotations/state/complex-multiple/states.scss", + "path": "docs-parser/tests/annotations/state/complex-multiple/states.scss", "start": 1, "end": 39 } diff --git a/tests/annotations/state/complex/single-markup.json b/tests/annotations/state/complex/single-markup.json index 32b3de7..9aacec9 100644 --- a/tests/annotations/state/complex/single-markup.json +++ b/tests/annotations/state/complex/single-markup.json @@ -49,7 +49,7 @@ "end": 30 }, "file": { - "path": "docs/tests/annotations/state/complex/single-markup.scss", + "path": "docs-parser/tests/annotations/state/complex/single-markup.scss", "start": 1, "end": 31 } diff --git a/tests/annotations/state/multiple-markup/blocks-with-different-states.json b/tests/annotations/state/multiple-markup/blocks-with-different-states.json index 489ad6a..a720ff7 100644 --- a/tests/annotations/state/multiple-markup/blocks-with-different-states.json +++ b/tests/annotations/state/multiple-markup/blocks-with-different-states.json @@ -105,7 +105,7 @@ "end": 26 }, "file": { - "path": "docs/tests/annotations/state/multiple-markup/blocks-with-different-states.scss", + "path": "docs-parser/tests/annotations/state/multiple-markup/blocks-with-different-states.scss", "start": 1, "end": 27 } diff --git a/tests/annotations/state/multiple-markup/blocks.json b/tests/annotations/state/multiple-markup/blocks.json index 0153961..b316f7c 100644 --- a/tests/annotations/state/multiple-markup/blocks.json +++ b/tests/annotations/state/multiple-markup/blocks.json @@ -71,7 +71,7 @@ "end": 23 }, "file": { - "path": "docs/tests/annotations/state/multiple-markup/blocks.scss", + "path": "docs-parser/tests/annotations/state/multiple-markup/blocks.scss", "start": 1, "end": 24 } diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json index 70ff1e0..4dee4d4 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple-with-description.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-description.json @@ -77,7 +77,7 @@ "end": 23 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", "start": 1, "end": 74 } @@ -161,7 +161,7 @@ "end": 48 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", "start": 1, "end": 74 } @@ -245,7 +245,7 @@ "end": 73 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-description.scss", "start": 1, "end": 74 } diff --git a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json index dcd61aa..74a1290 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json +++ b/tests/annotations/state/stupid-simple-multiple/simple-with-notations.json @@ -77,7 +77,7 @@ "end": 23 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", "start": 1, "end": 74 } @@ -161,7 +161,7 @@ "end": 48 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", "start": 1, "end": 74 } @@ -245,7 +245,7 @@ "end": 73 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple-with-notations.scss", "start": 1, "end": 74 } diff --git a/tests/annotations/state/stupid-simple-multiple/simple.json b/tests/annotations/state/stupid-simple-multiple/simple.json index 07e9c4e..33c4a2f 100644 --- a/tests/annotations/state/stupid-simple-multiple/simple.json +++ b/tests/annotations/state/stupid-simple-multiple/simple.json @@ -77,7 +77,7 @@ "end": 23 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple-multiple/simple.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple-multiple/simple.scss", "start": 1, "end": 24 } diff --git a/tests/annotations/state/stupid-simple/simple.json b/tests/annotations/state/stupid-simple/simple.json index 6c00abb..eb79ca8 100644 --- a/tests/annotations/state/stupid-simple/simple.json +++ b/tests/annotations/state/stupid-simple/simple.json @@ -45,7 +45,7 @@ "end": 13 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/simple.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/simple.scss", "start": 1, "end": 14 } diff --git a/tests/annotations/state/stupid-simple/with-description.json b/tests/annotations/state/stupid-simple/with-description.json index e7fe963..955a4ae 100644 --- a/tests/annotations/state/stupid-simple/with-description.json +++ b/tests/annotations/state/stupid-simple/with-description.json @@ -45,7 +45,7 @@ "end": 13 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/with-description.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/with-description.scss", "start": 1, "end": 43 } @@ -97,7 +97,7 @@ "end": 28 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/with-description.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/with-description.scss", "start": 1, "end": 43 } @@ -149,7 +149,7 @@ "end": 42 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/with-description.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/with-description.scss", "start": 1, "end": 43 } diff --git a/tests/annotations/state/stupid-simple/with-notations.json b/tests/annotations/state/stupid-simple/with-notations.json index c5ed8cb..83d9bd4 100644 --- a/tests/annotations/state/stupid-simple/with-notations.json +++ b/tests/annotations/state/stupid-simple/with-notations.json @@ -45,7 +45,7 @@ "end": 13 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/with-notations.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/with-notations.scss", "start": 1, "end": 44 } @@ -97,7 +97,7 @@ "end": 28 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/with-notations.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/with-notations.scss", "start": 1, "end": 44 } @@ -149,7 +149,7 @@ "end": 43 }, "file": { - "path": "docs/tests/annotations/state/stupid-simple/with-notations.scss", + "path": "docs-parser/tests/annotations/state/stupid-simple/with-notations.scss", "start": 1, "end": 44 } diff --git a/tests/annotations/throws/throws.alias.json b/tests/annotations/throws/throws.alias.json index 303b0e9..a5831d7 100644 --- a/tests/annotations/throws/throws.alias.json +++ b/tests/annotations/throws/throws.alias.json @@ -21,7 +21,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.alias.js", + "path": "docs-parser/tests/annotations/throws/throws.alias.js", "start": 1, "end": 8 } @@ -49,7 +49,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.alias.js", + "path": "docs-parser/tests/annotations/throws/throws.alias.js", "start": 1, "end": 8 } @@ -77,7 +77,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.alias.js", + "path": "docs-parser/tests/annotations/throws/throws.alias.js", "start": 1, "end": 8 } @@ -105,7 +105,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.alias.js", + "path": "docs-parser/tests/annotations/throws/throws.alias.js", "start": 1, "end": 8 } diff --git a/tests/annotations/throws/throws.json b/tests/annotations/throws/throws.json index 480c0b5..85ab69d 100644 --- a/tests/annotations/throws/throws.json +++ b/tests/annotations/throws/throws.json @@ -19,7 +19,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.js", + "path": "docs-parser/tests/annotations/throws/throws.js", "start": 1, "end": 16 } @@ -47,7 +47,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.js", + "path": "docs-parser/tests/annotations/throws/throws.js", "start": 1, "end": 16 } @@ -75,7 +75,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.js", + "path": "docs-parser/tests/annotations/throws/throws.js", "start": 1, "end": 16 } @@ -103,7 +103,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.js", + "path": "docs-parser/tests/annotations/throws/throws.js", "start": 1, "end": 16 } @@ -131,7 +131,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.js", + "path": "docs-parser/tests/annotations/throws/throws.js", "start": 1, "end": 16 } @@ -165,7 +165,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/throws/throws.js", + "path": "docs-parser/tests/annotations/throws/throws.js", "start": 1, "end": 16 } diff --git a/tests/annotations/todo/todo.body.json b/tests/annotations/todo/todo.body.json index ee90b68..3bc2685 100644 --- a/tests/annotations/todo/todo.body.json +++ b/tests/annotations/todo/todo.body.json @@ -20,7 +20,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.body.js", + "path": "docs-parser/tests/annotations/todo/todo.body.js", "start": 1, "end": 15 } @@ -47,7 +47,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.body.js", + "path": "docs-parser/tests/annotations/todo/todo.body.js", "start": 1, "end": 15 } @@ -74,7 +74,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.body.js", + "path": "docs-parser/tests/annotations/todo/todo.body.js", "start": 1, "end": 15 } @@ -103,7 +103,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.body.js", + "path": "docs-parser/tests/annotations/todo/todo.body.js", "start": 1, "end": 15 } @@ -133,7 +133,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.body.js", + "path": "docs-parser/tests/annotations/todo/todo.body.js", "start": 1, "end": 15 } @@ -163,7 +163,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.body.js", + "path": "docs-parser/tests/annotations/todo/todo.body.js", "start": 1, "end": 15 } diff --git a/tests/annotations/todo/todo.header.json b/tests/annotations/todo/todo.header.json index 9cecdc8..6cd623f 100644 --- a/tests/annotations/todo/todo.header.json +++ b/tests/annotations/todo/todo.header.json @@ -24,7 +24,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/todo/todo.header.js", + "path": "docs-parser/tests/annotations/todo/todo.header.js", "start": 1, "end": 7 } diff --git a/tests/annotations/type/type.json b/tests/annotations/type/type.json index a5b8cbf..5c6fbf9 100644 --- a/tests/annotations/type/type.json +++ b/tests/annotations/type/type.json @@ -17,7 +17,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } @@ -41,7 +41,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } @@ -65,7 +65,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } @@ -89,7 +89,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } @@ -113,7 +113,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } @@ -137,7 +137,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } @@ -161,7 +161,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/type/type.js", + "path": "docs-parser/tests/annotations/type/type.js", "start": 1, "end": 18 } diff --git a/tests/annotations/version/version.json b/tests/annotations/version/version.json index 1e27588..526b689 100644 --- a/tests/annotations/version/version.json +++ b/tests/annotations/version/version.json @@ -17,7 +17,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/version/version.js", + "path": "docs-parser/tests/annotations/version/version.js", "start": 1, "end": 13 } @@ -41,7 +41,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/version/version.js", + "path": "docs-parser/tests/annotations/version/version.js", "start": 1, "end": 13 } @@ -65,7 +65,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/version/version.js", + "path": "docs-parser/tests/annotations/version/version.js", "start": 1, "end": 13 } @@ -89,7 +89,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/version/version.js", + "path": "docs-parser/tests/annotations/version/version.js", "start": 1, "end": 13 } @@ -113,7 +113,7 @@ "end": -1 }, "file": { - "path": "docs/tests/annotations/version/version.js", + "path": "docs-parser/tests/annotations/version/version.js", "start": 1, "end": 13 } diff --git a/tests/cases/4-blank-lines-between-code-blocks.json b/tests/cases/4-blank-lines-between-code-blocks.json index 5729ffd..344eaaa 100644 --- a/tests/cases/4-blank-lines-between-code-blocks.json +++ b/tests/cases/4-blank-lines-between-code-blocks.json @@ -34,7 +34,7 @@ "end": 13 }, "file": { - "path": "docs/tests/cases/4-blank-lines-between-code-blocks.scss", + "path": "docs-parser/tests/cases/4-blank-lines-between-code-blocks.scss", "start": 1, "end": 34 } diff --git a/tests/cases/allthethings-js.json b/tests/cases/allthethings-js.json index 638ba40..d82ae58 100644 --- a/tests/cases/allthethings-js.json +++ b/tests/cases/allthethings-js.json @@ -31,7 +31,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/allthethings-js.js", + "path": "docs-parser/tests/cases/allthethings-js.js", "start": 1, "end": 23 } @@ -53,7 +53,7 @@ "end": 23 }, "file": { - "path": "docs/tests/cases/allthethings-js.js", + "path": "docs-parser/tests/cases/allthethings-js.js", "start": 1, "end": 23 } @@ -83,7 +83,7 @@ "end": 16 }, "file": { - "path": "docs/tests/cases/allthethings-js.js", + "path": "docs-parser/tests/cases/allthethings-js.js", "start": 1, "end": 23 } @@ -113,7 +113,7 @@ "end": 22 }, "file": { - "path": "docs/tests/cases/allthethings-js.js", + "path": "docs-parser/tests/cases/allthethings-js.js", "start": 1, "end": 23 } diff --git a/tests/cases/allthethings-scss.json b/tests/cases/allthethings-scss.json index d621a47..deb0022 100644 --- a/tests/cases/allthethings-scss.json +++ b/tests/cases/allthethings-scss.json @@ -43,7 +43,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/allthethings-scss.scss", + "path": "docs-parser/tests/cases/allthethings-scss.scss", "start": 1, "end": 239 } @@ -107,7 +107,7 @@ "end": 239 }, "file": { - "path": "docs/tests/cases/allthethings-scss.scss", + "path": "docs-parser/tests/cases/allthethings-scss.scss", "start": 1, "end": 239 } @@ -146,7 +146,7 @@ "end": 50 }, "file": { - "path": "docs/tests/cases/allthethings-scss.scss", + "path": "docs-parser/tests/cases/allthethings-scss.scss", "start": 1, "end": 239 } @@ -201,7 +201,7 @@ "end": 56 }, "file": { - "path": "docs/tests/cases/allthethings-scss.scss", + "path": "docs-parser/tests/cases/allthethings-scss.scss", "start": 1, "end": 239 } diff --git a/tests/cases/header-comment-only.json b/tests/cases/header-comment-only.json index 4743995..f29e46d 100644 --- a/tests/cases/header-comment-only.json +++ b/tests/cases/header-comment-only.json @@ -27,7 +27,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/header-comment-only.scss", + "path": "docs-parser/tests/cases/header-comment-only.scss", "start": 1, "end": 8 } diff --git a/tests/cases/no-space-between-header-and-body-comments.json b/tests/cases/no-space-between-header-and-body-comments.json index 1fe4bbe..df4ec93 100644 --- a/tests/cases/no-space-between-header-and-body-comments.json +++ b/tests/cases/no-space-between-header-and-body-comments.json @@ -30,7 +30,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", + "path": "docs-parser/tests/cases/no-space-between-header-and-body-comments.scss", "start": 1, "end": 28 } @@ -66,7 +66,7 @@ "end": 27 }, "file": { - "path": "docs/tests/cases/no-space-between-header-and-body-comments.scss", + "path": "docs-parser/tests/cases/no-space-between-header-and-body-comments.scss", "start": 1, "end": 28 } diff --git a/tests/cases/only-body-comments-no-page.json b/tests/cases/only-body-comments-no-page.json index 788eb25..efe9133 100644 --- a/tests/cases/only-body-comments-no-page.json +++ b/tests/cases/only-body-comments-no-page.json @@ -47,7 +47,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-body-comments-no-page.scss", + "path": "docs-parser/tests/cases/only-body-comments-no-page.scss", "start": 1, "end": 21 } @@ -100,7 +100,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-body-comments-no-page.scss", + "path": "docs-parser/tests/cases/only-body-comments-no-page.scss", "start": 1, "end": 21 } diff --git a/tests/cases/only-body-comments.json b/tests/cases/only-body-comments.json index baaabc0..18c81eb 100644 --- a/tests/cases/only-body-comments.json +++ b/tests/cases/only-body-comments.json @@ -55,7 +55,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-body-comments.scss", + "path": "docs-parser/tests/cases/only-body-comments.scss", "start": 1, "end": 19 } @@ -85,7 +85,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-body-comments.scss", + "path": "docs-parser/tests/cases/only-body-comments.scss", "start": 1, "end": 19 } @@ -138,7 +138,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-body-comments.scss", + "path": "docs-parser/tests/cases/only-body-comments.scss", "start": 1, "end": 19 } diff --git a/tests/cases/only-comments.json b/tests/cases/only-comments.json index ecc54a6..3373fc0 100644 --- a/tests/cases/only-comments.json +++ b/tests/cases/only-comments.json @@ -34,7 +34,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-comments.scss", + "path": "docs-parser/tests/cases/only-comments.scss", "start": 1, "end": 27 } @@ -73,7 +73,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-comments.scss", + "path": "docs-parser/tests/cases/only-comments.scss", "start": 1, "end": 27 } @@ -95,7 +95,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/only-comments.scss", + "path": "docs-parser/tests/cases/only-comments.scss", "start": 1, "end": 27 } diff --git a/tests/cases/preserves-blank-lines.json b/tests/cases/preserves-blank-lines.json index e52140c..6ab468f 100644 --- a/tests/cases/preserves-blank-lines.json +++ b/tests/cases/preserves-blank-lines.json @@ -42,7 +42,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/preserves-blank-lines.scss", + "path": "docs-parser/tests/cases/preserves-blank-lines.scss", "start": 1, "end": 13 } diff --git a/tests/cases/single-body-comment-no-code.json b/tests/cases/single-body-comment-no-code.json index 7c11694..022f937 100644 --- a/tests/cases/single-body-comment-no-code.json +++ b/tests/cases/single-body-comment-no-code.json @@ -31,7 +31,7 @@ "end": -1 }, "file": { - "path": "docs/tests/cases/single-body-comment-no-code.scss", + "path": "docs-parser/tests/cases/single-body-comment-no-code.scss", "start": 1, "end": 8 } diff --git a/tests/cases/single-body-comment.json b/tests/cases/single-body-comment.json index 5c792b0..a352ea1 100644 --- a/tests/cases/single-body-comment.json +++ b/tests/cases/single-body-comment.json @@ -48,7 +48,7 @@ "end": 26 }, "file": { - "path": "docs/tests/cases/single-body-comment.scss", + "path": "docs-parser/tests/cases/single-body-comment.scss", "start": 1, "end": 27 } diff --git a/tests/cases/space-between-comment-and-code.json b/tests/cases/space-between-comment-and-code.json index 61eb116..31efc8a 100644 --- a/tests/cases/space-between-comment-and-code.json +++ b/tests/cases/space-between-comment-and-code.json @@ -51,7 +51,7 @@ "end": 27 }, "file": { - "path": "docs/tests/cases/space-between-comment-and-code.scss", + "path": "docs-parser/tests/cases/space-between-comment-and-code.scss", "start": 1, "end": 28 } diff --git a/tests/cases/starts-and-ends-with-spaces.json b/tests/cases/starts-and-ends-with-spaces.json index cb14df9..a70fb7b 100644 --- a/tests/cases/starts-and-ends-with-spaces.json +++ b/tests/cases/starts-and-ends-with-spaces.json @@ -48,7 +48,7 @@ "end": 32 }, "file": { - "path": "docs/tests/cases/starts-and-ends-with-spaces.scss", + "path": "docs-parser/tests/cases/starts-and-ends-with-spaces.scss", "start": 1, "end": 38 } diff --git a/tests/file-types/c++/test.json b/tests/file-types/c++/test.json index 53a63c5..70f3265 100644 --- a/tests/file-types/c++/test.json +++ b/tests/file-types/c++/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/c++/test.c", + "path": "docs-parser/tests/file-types/c++/test.c", "start": 1, "end": 93 } @@ -72,7 +72,7 @@ "end": 32 }, "file": { - "path": "docs/tests/file-types/c++/test.c", + "path": "docs-parser/tests/file-types/c++/test.c", "start": 1, "end": 93 } @@ -94,7 +94,7 @@ "end": 66 }, "file": { - "path": "docs/tests/file-types/c++/test.c", + "path": "docs-parser/tests/file-types/c++/test.c", "start": 1, "end": 93 } @@ -116,7 +116,7 @@ "end": 92 }, "file": { - "path": "docs/tests/file-types/c++/test.c", + "path": "docs-parser/tests/file-types/c++/test.c", "start": 1, "end": 93 } diff --git a/tests/file-types/c/test.json b/tests/file-types/c/test.json index 8a244fd..626fb1c 100644 --- a/tests/file-types/c/test.json +++ b/tests/file-types/c/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/c/test.c", + "path": "docs-parser/tests/file-types/c/test.c", "start": 1, "end": 89 } @@ -72,7 +72,7 @@ "end": 32 }, "file": { - "path": "docs/tests/file-types/c/test.c", + "path": "docs-parser/tests/file-types/c/test.c", "start": 1, "end": 89 } @@ -94,7 +94,7 @@ "end": 62 }, "file": { - "path": "docs/tests/file-types/c/test.c", + "path": "docs-parser/tests/file-types/c/test.c", "start": 1, "end": 89 } @@ -116,7 +116,7 @@ "end": 88 }, "file": { - "path": "docs/tests/file-types/c/test.c", + "path": "docs-parser/tests/file-types/c/test.c", "start": 1, "end": 89 } diff --git a/tests/file-types/coffeescript/test.json b/tests/file-types/coffeescript/test.json index dd8845b..0d046ea 100644 --- a/tests/file-types/coffeescript/test.json +++ b/tests/file-types/coffeescript/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/coffeescript/test.coffee", + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } @@ -72,7 +72,7 @@ "end": 14 }, "file": { - "path": "docs/tests/file-types/coffeescript/test.coffee", + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } @@ -94,7 +94,7 @@ "end": 28 }, "file": { - "path": "docs/tests/file-types/coffeescript/test.coffee", + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } @@ -116,7 +116,7 @@ "end": 39 }, "file": { - "path": "docs/tests/file-types/coffeescript/test.coffee", + "path": "docs-parser/tests/file-types/coffeescript/test.coffee", "start": 1, "end": 40 } diff --git a/tests/file-types/coldfusion/test.json b/tests/file-types/coldfusion/test.json index 25062e2..73afd30 100644 --- a/tests/file-types/coldfusion/test.json +++ b/tests/file-types/coldfusion/test.json @@ -54,7 +54,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/coldfusion/test.cfm", + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } @@ -76,7 +76,7 @@ "end": 16 }, "file": { - "path": "docs/tests/file-types/coldfusion/test.cfm", + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } @@ -98,7 +98,7 @@ "end": 33 }, "file": { - "path": "docs/tests/file-types/coldfusion/test.cfm", + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } @@ -120,7 +120,7 @@ "end": 49 }, "file": { - "path": "docs/tests/file-types/coldfusion/test.cfm", + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } @@ -142,7 +142,7 @@ "end": 60 }, "file": { - "path": "docs/tests/file-types/coldfusion/test.cfm", + "path": "docs-parser/tests/file-types/coldfusion/test.cfm", "start": 1, "end": 61 } diff --git a/tests/file-types/cs/test.json b/tests/file-types/cs/test.json index 51835d8..9cf8b50 100644 --- a/tests/file-types/cs/test.json +++ b/tests/file-types/cs/test.json @@ -51,7 +51,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/cs/test.cs", + "path": "docs-parser/tests/file-types/cs/test.cs", "start": 1, "end": 95 } @@ -73,7 +73,7 @@ "end": 38 }, "file": { - "path": "docs/tests/file-types/cs/test.cs", + "path": "docs-parser/tests/file-types/cs/test.cs", "start": 1, "end": 95 } @@ -95,7 +95,7 @@ "end": 68 }, "file": { - "path": "docs/tests/file-types/cs/test.cs", + "path": "docs-parser/tests/file-types/cs/test.cs", "start": 1, "end": 95 } @@ -117,7 +117,7 @@ "end": 94 }, "file": { - "path": "docs/tests/file-types/cs/test.cs", + "path": "docs-parser/tests/file-types/cs/test.cs", "start": 1, "end": 95 } diff --git a/tests/file-types/css/test.json b/tests/file-types/css/test.json index 510e5b4..35c0b70 100644 --- a/tests/file-types/css/test.json +++ b/tests/file-types/css/test.json @@ -46,7 +46,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/css/test.css", + "path": "docs-parser/tests/file-types/css/test.css", "start": 1, "end": 31 } @@ -68,7 +68,7 @@ "end": 17 }, "file": { - "path": "docs/tests/file-types/css/test.css", + "path": "docs-parser/tests/file-types/css/test.css", "start": 1, "end": 31 } @@ -90,7 +90,7 @@ "end": 31 }, "file": { - "path": "docs/tests/file-types/css/test.css", + "path": "docs-parser/tests/file-types/css/test.css", "start": 1, "end": 31 } diff --git a/tests/file-types/html/test.json b/tests/file-types/html/test.json index 933b2bd..47eb205 100644 --- a/tests/file-types/html/test.json +++ b/tests/file-types/html/test.json @@ -47,7 +47,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/html/test.html", + "path": "docs-parser/tests/file-types/html/test.html", "start": 1, "end": 36 } @@ -69,7 +69,7 @@ "end": 25 }, "file": { - "path": "docs/tests/file-types/html/test.html", + "path": "docs-parser/tests/file-types/html/test.html", "start": 1, "end": 36 } @@ -91,7 +91,7 @@ "end": 33 }, "file": { - "path": "docs/tests/file-types/html/test.html", + "path": "docs-parser/tests/file-types/html/test.html", "start": 1, "end": 36 } diff --git a/tests/file-types/jade/test.json b/tests/file-types/jade/test.json index 9323cb5..b49636d 100644 --- a/tests/file-types/jade/test.json +++ b/tests/file-types/jade/test.json @@ -42,7 +42,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/jade/test.jade", + "path": "docs-parser/tests/file-types/jade/test.jade", "start": 1, "end": 16 } @@ -64,7 +64,7 @@ "end": 15 }, "file": { - "path": "docs/tests/file-types/jade/test.jade", + "path": "docs-parser/tests/file-types/jade/test.jade", "start": 1, "end": 16 } diff --git a/tests/file-types/java/test.json b/tests/file-types/java/test.json index 2a1fe3c..7e82ef2 100644 --- a/tests/file-types/java/test.json +++ b/tests/file-types/java/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/java/test.java", + "path": "docs-parser/tests/file-types/java/test.java", "start": 1, "end": 34 } @@ -72,7 +72,7 @@ "end": 15 }, "file": { - "path": "docs/tests/file-types/java/test.java", + "path": "docs-parser/tests/file-types/java/test.java", "start": 1, "end": 34 } @@ -94,7 +94,7 @@ "end": 24 }, "file": { - "path": "docs/tests/file-types/java/test.java", + "path": "docs-parser/tests/file-types/java/test.java", "start": 1, "end": 34 } @@ -116,7 +116,7 @@ "end": 33 }, "file": { - "path": "docs/tests/file-types/java/test.java", + "path": "docs-parser/tests/file-types/java/test.java", "start": 1, "end": 34 } diff --git a/tests/file-types/js/test.json b/tests/file-types/js/test.json index e36db3a..66c024a 100644 --- a/tests/file-types/js/test.json +++ b/tests/file-types/js/test.json @@ -42,7 +42,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/js/test.js", + "path": "docs-parser/tests/file-types/js/test.js", "start": 1, "end": 28 } @@ -85,7 +85,7 @@ "end": 27 }, "file": { - "path": "docs/tests/file-types/js/test.js", + "path": "docs-parser/tests/file-types/js/test.js", "start": 1, "end": 28 } diff --git a/tests/file-types/less/test.json b/tests/file-types/less/test.json index d216834..a21bad8 100644 --- a/tests/file-types/less/test.json +++ b/tests/file-types/less/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/less/test.less", + "path": "docs-parser/tests/file-types/less/test.less", "start": 1, "end": 59 } @@ -87,7 +87,7 @@ "end": 14 }, "file": { - "path": "docs/tests/file-types/less/test.less", + "path": "docs-parser/tests/file-types/less/test.less", "start": 1, "end": 59 } @@ -121,7 +121,7 @@ "end": 41 }, "file": { - "path": "docs/tests/file-types/less/test.less", + "path": "docs-parser/tests/file-types/less/test.less", "start": 1, "end": 59 } @@ -165,7 +165,7 @@ "end": 58 }, "file": { - "path": "docs/tests/file-types/less/test.less", + "path": "docs-parser/tests/file-types/less/test.less", "start": 1, "end": 59 } diff --git a/tests/file-types/markdown/mark.json b/tests/file-types/markdown/mark.json index 70b5ed6..7889911 100644 --- a/tests/file-types/markdown/mark.json +++ b/tests/file-types/markdown/mark.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mark.mark", + "path": "docs-parser/tests/file-types/markdown/mark.mark", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/markdown.json b/tests/file-types/markdown/markdown.json index 399e9c3..f1d2f61 100644 --- a/tests/file-types/markdown/markdown.json +++ b/tests/file-types/markdown/markdown.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/markdown.markdown", + "path": "docs-parser/tests/file-types/markdown/markdown.markdown", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/md.json b/tests/file-types/markdown/md.json index 94c435c..9375d1c 100644 --- a/tests/file-types/markdown/md.json +++ b/tests/file-types/markdown/md.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/md.md", + "path": "docs-parser/tests/file-types/markdown/md.md", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mdml.json b/tests/file-types/markdown/mdml.json index 801a40c..16ac3c3 100644 --- a/tests/file-types/markdown/mdml.json +++ b/tests/file-types/markdown/mdml.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mdml.mdml", + "path": "docs-parser/tests/file-types/markdown/mdml.mdml", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mdown.json b/tests/file-types/markdown/mdown.json index 79a6be8..eeeb1cc 100644 --- a/tests/file-types/markdown/mdown.json +++ b/tests/file-types/markdown/mdown.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mdown.mdown", + "path": "docs-parser/tests/file-types/markdown/mdown.mdown", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mdtext.json b/tests/file-types/markdown/mdtext.json index ba3d4fd..ad7c10b 100644 --- a/tests/file-types/markdown/mdtext.json +++ b/tests/file-types/markdown/mdtext.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mdtext.mdtext", + "path": "docs-parser/tests/file-types/markdown/mdtext.mdtext", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mdtxt.json b/tests/file-types/markdown/mdtxt.json index c41d58b..54a907a 100644 --- a/tests/file-types/markdown/mdtxt.json +++ b/tests/file-types/markdown/mdtxt.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mdtxt.mdtxt", + "path": "docs-parser/tests/file-types/markdown/mdtxt.mdtxt", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mdwn.json b/tests/file-types/markdown/mdwn.json index 253f621..f5f13ec 100644 --- a/tests/file-types/markdown/mdwn.json +++ b/tests/file-types/markdown/mdwn.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mdwn.mdwn", + "path": "docs-parser/tests/file-types/markdown/mdwn.mdwn", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mkd.json b/tests/file-types/markdown/mkd.json index 86f2c79..0db0d76 100644 --- a/tests/file-types/markdown/mkd.json +++ b/tests/file-types/markdown/mkd.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mkd.mkd", + "path": "docs-parser/tests/file-types/markdown/mkd.mkd", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/mkdn.json b/tests/file-types/markdown/mkdn.json index 76d77d4..d595fda 100644 --- a/tests/file-types/markdown/mkdn.json +++ b/tests/file-types/markdown/mkdn.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/mkdn.mkdn", + "path": "docs-parser/tests/file-types/markdown/mkdn.mkdn", "start": 1, "end": 21 } diff --git a/tests/file-types/markdown/text.json b/tests/file-types/markdown/text.json index 092e484..bf620d2 100644 --- a/tests/file-types/markdown/text.json +++ b/tests/file-types/markdown/text.json @@ -36,7 +36,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/markdown/text.text", + "path": "docs-parser/tests/file-types/markdown/text.text", "start": 1, "end": 21 } diff --git a/tests/file-types/php/test.json b/tests/file-types/php/test.json index bc857fc..c33ed03 100644 --- a/tests/file-types/php/test.json +++ b/tests/file-types/php/test.json @@ -51,7 +51,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/php/test.php", + "path": "docs-parser/tests/file-types/php/test.php", "start": 1, "end": 37 } @@ -73,7 +73,7 @@ "end": 12 }, "file": { - "path": "docs/tests/file-types/php/test.php", + "path": "docs-parser/tests/file-types/php/test.php", "start": 1, "end": 37 } @@ -95,7 +95,7 @@ "end": 25 }, "file": { - "path": "docs/tests/file-types/php/test.php", + "path": "docs-parser/tests/file-types/php/test.php", "start": 1, "end": 37 } @@ -117,7 +117,7 @@ "end": 35 }, "file": { - "path": "docs/tests/file-types/php/test.php", + "path": "docs-parser/tests/file-types/php/test.php", "start": 1, "end": 37 } diff --git a/tests/file-types/python/test.json b/tests/file-types/python/test.json index c0c3b51..50b472f 100644 --- a/tests/file-types/python/test.json +++ b/tests/file-types/python/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/python/test.py", + "path": "docs-parser/tests/file-types/python/test.py", "start": 1, "end": 43 } @@ -72,7 +72,7 @@ "end": 21 }, "file": { - "path": "docs/tests/file-types/python/test.py", + "path": "docs-parser/tests/file-types/python/test.py", "start": 1, "end": 43 } @@ -94,7 +94,7 @@ "end": 29 }, "file": { - "path": "docs/tests/file-types/python/test.py", + "path": "docs-parser/tests/file-types/python/test.py", "start": 1, "end": 43 } @@ -116,7 +116,7 @@ "end": 43 }, "file": { - "path": "docs/tests/file-types/python/test.py", + "path": "docs-parser/tests/file-types/python/test.py", "start": 1, "end": 43 } diff --git a/tests/file-types/ruby/test.json b/tests/file-types/ruby/test.json index 6c57f05..87e4681 100644 --- a/tests/file-types/ruby/test.json +++ b/tests/file-types/ruby/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/ruby/test.rb", + "path": "docs-parser/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } @@ -72,7 +72,7 @@ "end": 12 }, "file": { - "path": "docs/tests/file-types/ruby/test.rb", + "path": "docs-parser/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } @@ -94,7 +94,7 @@ "end": 21 }, "file": { - "path": "docs/tests/file-types/ruby/test.rb", + "path": "docs-parser/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } @@ -116,7 +116,7 @@ "end": 34 }, "file": { - "path": "docs/tests/file-types/ruby/test.rb", + "path": "docs-parser/tests/file-types/ruby/test.rb", "start": 1, "end": 43 } diff --git a/tests/file-types/scss/inline.json b/tests/file-types/scss/inline.json index c233de4..a90c3e7 100644 --- a/tests/file-types/scss/inline.json +++ b/tests/file-types/scss/inline.json @@ -42,7 +42,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/scss/inline.scss", + "path": "docs-parser/tests/file-types/scss/inline.scss", "start": 1, "end": 15 } @@ -68,7 +68,7 @@ "end": 15 }, "file": { - "path": "docs/tests/file-types/scss/inline.scss", + "path": "docs-parser/tests/file-types/scss/inline.scss", "start": 1, "end": 15 } @@ -97,7 +97,7 @@ "end": 12 }, "file": { - "path": "docs/tests/file-types/scss/inline.scss", + "path": "docs-parser/tests/file-types/scss/inline.scss", "start": 1, "end": 15 } @@ -126,7 +126,7 @@ "end": 13 }, "file": { - "path": "docs/tests/file-types/scss/inline.scss", + "path": "docs-parser/tests/file-types/scss/inline.scss", "start": 1, "end": 15 } @@ -155,7 +155,7 @@ "end": 14 }, "file": { - "path": "docs/tests/file-types/scss/inline.scss", + "path": "docs-parser/tests/file-types/scss/inline.scss", "start": 1, "end": 15 } diff --git a/tests/file-types/scss/test.json b/tests/file-types/scss/test.json index f925e2f..57be791 100644 --- a/tests/file-types/scss/test.json +++ b/tests/file-types/scss/test.json @@ -46,7 +46,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/scss/test.scss", + "path": "docs-parser/tests/file-types/scss/test.scss", "start": 1, "end": 39 } @@ -71,7 +71,7 @@ "end": 8 }, "file": { - "path": "docs/tests/file-types/scss/test.scss", + "path": "docs-parser/tests/file-types/scss/test.scss", "start": 1, "end": 39 } @@ -129,7 +129,7 @@ "end": 38 }, "file": { - "path": "docs/tests/file-types/scss/test.scss", + "path": "docs-parser/tests/file-types/scss/test.scss", "start": 1, "end": 39 } diff --git a/tests/file-types/stylus/test.json b/tests/file-types/stylus/test.json index d82f824..951f97f 100644 --- a/tests/file-types/stylus/test.json +++ b/tests/file-types/stylus/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/stylus/test.styl", + "path": "docs-parser/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } @@ -72,7 +72,7 @@ "end": 14 }, "file": { - "path": "docs/tests/file-types/stylus/test.styl", + "path": "docs-parser/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } @@ -94,7 +94,7 @@ "end": 25 }, "file": { - "path": "docs/tests/file-types/stylus/test.styl", + "path": "docs-parser/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } @@ -116,7 +116,7 @@ "end": 34 }, "file": { - "path": "docs/tests/file-types/stylus/test.styl", + "path": "docs-parser/tests/file-types/stylus/test.styl", "start": 1, "end": 37 } diff --git a/tests/file-types/swift/test.json b/tests/file-types/swift/test.json index 26d03bb..a3ef8f0 100644 --- a/tests/file-types/swift/test.json +++ b/tests/file-types/swift/test.json @@ -50,7 +50,7 @@ "end": -1 }, "file": { - "path": "docs/tests/file-types/swift/test.swift", + "path": "docs-parser/tests/file-types/swift/test.swift", "start": 1, "end": 49 } @@ -72,7 +72,7 @@ "end": 20 }, "file": { - "path": "docs/tests/file-types/swift/test.swift", + "path": "docs-parser/tests/file-types/swift/test.swift", "start": 1, "end": 49 } @@ -94,7 +94,7 @@ "end": 31 }, "file": { - "path": "docs/tests/file-types/swift/test.swift", + "path": "docs-parser/tests/file-types/swift/test.swift", "start": 1, "end": 49 } @@ -116,7 +116,7 @@ "end": 48 }, "file": { - "path": "docs/tests/file-types/swift/test.swift", + "path": "docs-parser/tests/file-types/swift/test.swift", "start": 1, "end": 49 }