forked from codeclimate/codeclimate-eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.js
40 lines (29 loc) · 1.06 KB
/
docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @fileoverview Providing easy access to rule documentation
*/
'use strict';
var fs = require('fs')
, path = require('path');
//------------------------------------------------------------------------------
// Privates
//------------------------------------------------------------------------------
var docs = Object.create(null);
function load() {
var docsDir = path.join(__dirname, '/docs/rules');
fs.readdirSync(docsDir).forEach(function(file) {
var content = fs.readFileSync(docsDir + '/' + file, 'utf8');
// Remove the .md extension from the filename
docs[file.slice(0, -3)] = content;
});
}
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
exports.get = function(ruleId) {
return docs[ruleId];
};
//------------------------------------------------------------------------------
// Initialization
//------------------------------------------------------------------------------
// loads existing docs
load();