Skip to content

Commit

Permalink
Merge ab89646 into 81ec9e3
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalduez committed Mar 22, 2015
2 parents 81ec9e3 + ab89646 commit b6ab10a
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 136 deletions.
42 changes: 42 additions & 0 deletions .eslintrc
@@ -0,0 +1,42 @@
parser: "babel-eslint"

env:
node: true
mocha: true

ecmaFeatures:
arrowFunctions: true
blockBindings: true
classes: true
defaultParams: true
destructuring: true
forOf: true
modules: true
objectLiteralComputedProperties: true
objectLiteralDuplicateProperties: true
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
templateStrings: true
restParams: true
spread: true
superInFunctions: true

rules:
no-global-strict: 0
strict: 1
no-undef: 1
no-use-before-define: 0
consistent-return: 0
comma-dangle: "always-multiline"
no-process-exit: 0

quotes: [2, "single"]
indent: [2, 2]
no-mixed-spaces-and-tabs: [1, "smart-tabs"]
no-spaced-func: 1
space-after-keywords: [1, "always"]
space-before-function-parentheses: {"anonymous": "always", "named": "never"}
space-before-function-paren: {"anonymous": "always", "named": "never"}
space-before-blocks: "always"
space-in-brackets: "always"
no-underscore-dangle: 0
30 changes: 0 additions & 30 deletions .jshintrc

This file was deleted.

29 changes: 0 additions & 29 deletions .jshintrc.yaml

This file was deleted.

7 changes: 2 additions & 5 deletions Makefile
Expand Up @@ -13,11 +13,8 @@ dist:
# Code quality
# ============

lint: .jshintrc
$(BIN)jshint --verbose bin/sassdoc index.js src test

.jshintrc: .jshintrc.yaml
$(BIN)js-yaml $< > $@
lint:
$(BIN)eslint bin/sassdoc index.js src test

test: test/data/expected.stream.json dist
$(BIN)mocha test/**/*.test.js
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -102,8 +102,10 @@
},
"devDependencies": {
"babel": "4.6.*",
"babel-eslint": "^2.0.2",
"coveralls": "^2.11.2",
"dateformat": "^1.0.11",
"eslint": "^0.17.1",
"istanbul": "^0.3.5",
"jsesc": "^0.5.0",
"jshint": "^2.6.3",
Expand Down
12 changes: 6 additions & 6 deletions src/annotation/annotations/example.js
Expand Up @@ -14,7 +14,7 @@ export default function example() {
name: 'example',

parse(text) {
let example = {
let instance = {
type: 'scss', // Default to `scss`.
code: text,
};
Expand All @@ -24,17 +24,17 @@ export default function example() {

if (optionalType.trim().length !== 0) {
let typeDesc = descRegEx.exec(optionalType);
example.type = typeDesc[1];
instance.type = typeDesc[1];
if (typeDesc[2].length !== 0) {
example.description = typeDesc[2];
instance.description = typeDesc[2];
}
example.code = text.substr(optionalType.length + 1); // Remove the type
instance.code = text.substr(optionalType.length + 1); // Remove the type
}

// Remove all leading/trailing line breaks.
example.code = example.code.replace(/^\n|\n$/g, '');
instance.code = instance.code.replace(/^\n|\n$/g, '');

return example;
return instance;
},
};
}
6 changes: 3 additions & 3 deletions src/annotation/annotations/require.js
Expand Up @@ -60,7 +60,7 @@ export default function (env) {

let functions = searchForMatches(
item.context.code,
new RegExp('(@include)?\\s*([a-z0-9_-]+)\\s*\\(','ig'), // Literal destorys Syntax
new RegExp('(@include)?\\s*([a-z0-9_-]+)\\s*\\(', 'ig'), // Literal destorys Syntax
isAnnotatedByHand.bind(null, handWritten, 'function'),
2 // Get the second matching group instead of 1
);
Expand Down Expand Up @@ -187,12 +187,12 @@ function isAnnotatedByHand(handWritten, type, name) {
return false;
}

function searchForMatches(code, regex, isAnnotatedByHand, id = 1) {
function searchForMatches(code, regex, isAnnotatedByHandProxy, id = 1) {
let match;
let matches = [];

while ((match = regex.exec(code))) {
if (!isAnnotatedByHand(match[id]) && (id <= 1 || match[id-1] === undefined)) {
if (!isAnnotatedByHandProxy(match[id]) && (id <= 1 || match[id-1] === undefined)) {
matches.push(match[id]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/environment.js
Expand Up @@ -225,7 +225,7 @@ export default class Environment extends EventEmitter {

if (typeof this.theme !== 'function') {
this.emit('error', new errors.SassDocError(
`Given theme is ${str(this.theme)}, expected ${str(str)}.`
`Given theme is ${str(this.theme)}, expected ${str(str)}.` // eslint-disable-line comma-spacing
));

return this.defaultTheme();
Expand Down
52 changes: 18 additions & 34 deletions src/sassdoc.js
Expand Up @@ -9,12 +9,12 @@ import exclude from './exclude';
import recurse from './recurse';

import fs from 'fs';
import path from 'path'; // jshint ignore:line
import difference from 'lodash.difference'; // jshint ignore:line
import path from 'path';
import difference from 'lodash.difference';
import safeWipe from 'safe-wipe';
import vfs from 'vinyl-fs';
import converter from 'sass-convert';
import pipe from 'multipipe'; // jshint ignore:line
import pipe from 'multipipe';
import through from 'through2';
const mkdir = denodeify(require('mkdirp'));

Expand Down Expand Up @@ -81,13 +81,13 @@ function ensureLogger(config) {
* @see srcEnv
*/
export default function sassdoc(...args) {
return srcEnv(documentize, stream)(...args); // jshint ignore:line
return srcEnv(documentize, stream)(...args);

/**
* Safely wipe and re-create the destination directory.
* @return {Promise}
*/
function refresh(env) { // jshint ignore:line
function refresh(env) {
return safeWipe(env.dest, {
force: true,
parent: is.string(env.src) || is.array(env.src) ? g2b(env.src) : null,
Expand All @@ -107,7 +107,7 @@ export default function sassdoc(...args) {
* Render theme with parsed data context.
* @return {Promise}
*/
function theme(env) { // jshint ignore:line
function theme(env) {
let promise = env.theme(env.dest, env);

if (!is.promise(promise)) {
Expand All @@ -126,9 +126,7 @@ export default function sassdoc(...args) {
* Execute full SassDoc sequence from a source directory.
* @return {Promise}
*/
async function documentize(env) { // jshint ignore:line
/* jshint ignore:start */

async function documentize(env) {
init(env);
let data = await baseDocumentize(env);

Expand All @@ -142,8 +140,6 @@ export default function sassdoc(...args) {
}

return data;

/* jshint ignore:end */
}

/**
Expand All @@ -161,8 +157,6 @@ export default function sassdoc(...args) {
onEmpty(data, env);
});

/* jshint ignore:start */

/**
* Returned Promise await the full sequence,
* instead of just the parsing step.
Expand Down Expand Up @@ -190,8 +184,6 @@ export default function sassdoc(...args) {

});

/* jshint ignore:end */

return filter;
}
}
Expand All @@ -203,8 +195,7 @@ export default function sassdoc(...args) {
* @return {Promise | Stream}
* @see srcEnv
*/
export function parse(...args) { // jshint ignore:line
/* jshint ignore:start */
export function parse(...args) {

return srcEnv(documentize, stream)(...args);

Expand All @@ -217,30 +208,28 @@ export function parse(...args) { // jshint ignore:line
return data;
}

/* jshint ignore:end */

/**
* Don't pass files through, but pass final data at the end.
* @return {Stream}
*/
function stream(env) { // jshint ignore:line
let parse = parseFilter(env);
function stream(env) {
let parseStream = parseFilter(env);

let filter = through.obj((file, enc, cb) => cb(), function (cb) {
parse.promise.then(data => {
parseStream.promise.then(data => {
this.push(data);
cb();
}, cb);
});

return pipe(parse, filter);
return pipe(parseStream, filter);
}
}

/**
* Source directory fetching and parsing.
*/
async function baseDocumentize(env) { // jshint ignore:line
async function baseDocumentize(env) {
let filter = parseFilter(env);

filter.promise
Expand All @@ -259,21 +248,18 @@ async function baseDocumentize(env) { // jshint ignore:line
});
});

let streams = [ // jshint ignore:line
let streams = [
vfs.src(env.src),
recurse(),
exclude(env.exclude || []),
converter({ from: 'sass', to: 'scss' }),
filter
];

/* jshint ignore:start */

let pipeline = () => {
return new Promise((resolve, reject) => {
pipe(...streams, err => {
err ? reject(err) : resolve();
})
pipe(...streams, err =>
err ? reject(err) : resolve())
.resume(); // Drain.
});
};
Expand All @@ -286,8 +272,6 @@ async function baseDocumentize(env) { // jshint ignore:line
}

return env.data;

/* jshint ignore:end */
}

/**
Expand Down Expand Up @@ -367,15 +351,15 @@ function onEmpty(data, env) {
* Init timer.
* @param {Object} env
*/
function init(env) { // jshint ignore:line
function init(env) {
env.logger.time('SassDoc');
}

/**
* Log final success message.
* @param {Object} env
*/
function okay(env) { // jshint ignore:line
function okay(env) {
env.logger.log('Process over. Everything okay!');
env.logger.timeEnd('SassDoc', '%s completed after %dms');
}
11 changes: 2 additions & 9 deletions test/annotations/content.test.js
Expand Up @@ -11,16 +11,9 @@ describe('#content', function () {
assert.deepEqual(content.parse('\nTest\n\nTest\t'), 'Test\n\nTest');
});

it('should add @content to all items that contain it in item.context.code', function(){
it('should add @content to all items that contain it in item.context.code', function () {

assert.deepEqual(
content.autofill({
context : {
code : '@content'
}
}),
''
);
assert.deepEqual(content.autofill({ context: { code: '@content' }}), '');

});
});

0 comments on commit b6ab10a

Please sign in to comment.