This repository has been archived by the owner on Nov 17, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3adb1f1
commit 577957b
Showing
27 changed files
with
2,295 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.DS_STORE | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- 6 | ||
before_script: | ||
- npm install -g gulp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# livingstyleguides | ||
livingstyleguides [![Build Status](https://travis-ci.org/Instadoc/livingstyleguides.svg?branch=master)](https://travis-ci.org/Instadoc/livingstyleguides) | ||
================= | ||
Documentation extractor for living style guides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var gulp = require('gulp'); | ||
var mocha = require('gulp-mocha'); | ||
|
||
gulp.task('test', function () { | ||
return gulp.src('test/**/*test.js', { read: false }) | ||
.pipe(mocha({ reporter: 'spec' })); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var rfr = require('rfr'); | ||
var Parser = rfr('src/parser'); | ||
|
||
module.exports = new Parser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "livingstyleguides", | ||
"version": "0.0.0", | ||
"description": "Documentation extractor for living style guides", | ||
"keywords": [ | ||
"livingstyleguide", | ||
"living style guide", | ||
"style guide", | ||
"component library", | ||
"design pattern" | ||
], | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "gulp test" | ||
}, | ||
"homepage": "https://github.com/Instadoc/livingstyleguides", | ||
"repository": "https://github.com/Instadoc/livingstyleguides.git", | ||
"bugs": { | ||
"url": "https://github.com/Instadoc/livingstyleguides/issues" | ||
}, | ||
"author": "Mike Petrovich <michael.c.petrovich@gmail.com>", | ||
"license": "MIT", | ||
"bundleDependencies": [ | ||
"rfr" | ||
], | ||
"dependencies": { | ||
"gray-matter": "^2.1.1", | ||
"lodash": "^4.17.2", | ||
"rfr": "^1.2.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"gulp": "^3.8.10", | ||
"gulp-mocha": "^2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
var _ = require('lodash'); | ||
|
||
/** | ||
* @constructs | ||
*/ | ||
function Doc() {} | ||
|
||
/* --------------------------------------------------------------------- | ||
* Public | ||
* --------------------------------------------------------------------- */ | ||
|
||
/** | ||
* @static | ||
* @param {Array} docs | ||
* @return {Array} | ||
*/ | ||
Doc.merge = function(docs) { | ||
var docsGroupedByName = _.groupBy(docs, 'name'); | ||
|
||
var docsMerged = _.map(docsGroupedByName, function(docsToMerge) { | ||
var docMerged = new Doc(); | ||
|
||
_.forEach(docsToMerge, function(doc) { | ||
docMerged.import(doc); | ||
}); | ||
|
||
return docMerged; | ||
}); | ||
|
||
return docsMerged; | ||
}; | ||
|
||
/** | ||
* @return {String} | ||
*/ | ||
Doc.prototype.getName = function() { | ||
return this.name; | ||
}; | ||
|
||
/** | ||
* @param {String} name | ||
*/ | ||
Doc.prototype.setName = function(name) { | ||
this.name = name; | ||
}; | ||
|
||
/** | ||
* @return {String} | ||
*/ | ||
Doc.prototype.getCategory = function() { | ||
return this.category; | ||
}; | ||
|
||
/** | ||
* @param {String} category | ||
*/ | ||
Doc.prototype.setCategory = function(category) { | ||
this.category = category; | ||
}; | ||
|
||
/** | ||
* @return {String} | ||
*/ | ||
Doc.prototype.getDescription = function() { | ||
return this.description; | ||
}; | ||
|
||
/** | ||
* @param {String} description | ||
*/ | ||
Doc.prototype.setDescription = function(description) { | ||
this.description = description; | ||
}; | ||
|
||
/** | ||
* @return {Object} | ||
*/ | ||
Doc.prototype.getExamples = function() { | ||
return this.examples || {}; | ||
}; | ||
|
||
/** | ||
* @param {String} name | ||
* @param {Array.<Object>} codeBlocks | ||
* @param {String} codeBlocks[i].syntax | ||
* @param {String} codeBlocks[i].code | ||
* @param {Boolean} [codeBlocks[i].hidden] | ||
* @param {Object} [options] | ||
* @param {Number} [options.height] | ||
*/ | ||
Doc.prototype.addExample = function(name, codeBlocks, options) { | ||
this.examples = this.examples || {}; | ||
this.examples[name] = { | ||
codeBlocks: codeBlocks, | ||
options: options || {}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @return {Object} Set of key-value pairs | ||
*/ | ||
Doc.prototype.getMeta = function() { | ||
return this.meta || {}; | ||
}; | ||
|
||
/** | ||
* @param {String} key | ||
* @param {*} value | ||
*/ | ||
Doc.prototype.addMeta = function(key, value) { | ||
this.meta = this.meta || {}; | ||
|
||
if (this.meta[key]) { | ||
this.meta[key].push(value); | ||
} | ||
else { | ||
this.meta[key] = [value]; | ||
} | ||
}; | ||
|
||
/** | ||
* @return {String} | ||
*/ | ||
Doc.prototype.getSource = function() { | ||
return this.source; | ||
}; | ||
|
||
/** | ||
* @param {String} source | ||
*/ | ||
Doc.prototype.setSource = function(source) { | ||
this.source = source; | ||
}; | ||
|
||
/** | ||
* @return {String} | ||
*/ | ||
Doc.prototype.getFilepath = function() { | ||
return this.filepath; | ||
}; | ||
|
||
/** | ||
* @param {String} filepath | ||
*/ | ||
Doc.prototype.setFilepath = function(filepath) { | ||
this.filepath = filepath; | ||
}; | ||
|
||
/** | ||
* @param {Doc} doc | ||
*/ | ||
Doc.prototype.import = function(doc) { | ||
var self = this; | ||
|
||
this.name = doc.name; | ||
this.category = doc.category || this.category; | ||
this.source = doc.source || this.source; | ||
this.filepath = doc.filepath || this.filepath; | ||
|
||
if (doc.description) { | ||
var description = this.description ? this.description + '\n\n' : ''; | ||
this.description = description + doc.description; | ||
} | ||
|
||
_.each(doc.getExamples(), function(example, name) { | ||
self.addExample(name, example.codeBlocks, example.options); | ||
}); | ||
_.each(doc.getMeta(), function(meta, key) { | ||
_.each(meta, function(value) { | ||
self.addMeta(key, value); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = Doc; |
Oops, something went wrong.