UNPKG

1.31 kBJavaScriptView Raw
1/**
2 @overview
3 @author Michael Mathews <micmath@gmail.com>
4 @license Apache License 2.0 - See file 'LICENSE.md' in this project.
5 */
6
7/**
8 @module jsdoc/config
9 */
10'use strict';
11
12function mergeRecurse(target, source) {
13 Object.keys(source).forEach(function(p) {
14 if ( source[p].constructor === Object ) {
15 if ( !target[p] ) { target[p] = {}; }
16 mergeRecurse(target[p], source[p]);
17 }
18 else {
19 target[p] = source[p];
20 }
21 });
22
23 return target;
24}
25
26// required config values, override these defaults in your config.json if necessary
27var defaults = {
28 tags: {
29 allowUnknownTags: true,
30 dictionaries: ['jsdoc', 'closure']
31 },
32 templates: {
33 monospaceLinks: false,
34 cleverLinks: false
35 },
36 source: {
37 includePattern: '.+\\.js(doc)?$',
38 excludePattern: ''
39 },
40 plugins: []
41};
42
43/**
44 @class
45 @classdesc Represents a JSDoc application configuration.
46 @param {string} [json] - The contents of config.json.
47 */
48function Config(json) {
49 json = JSON.parse( (json || '{}') );
50 this._config = mergeRecurse(defaults, json);
51}
52
53module.exports = Config;
54
55/**
56 Get the merged configuration values.
57 */
58Config.prototype.get = function() {
59 return this._config;
60};