diff --git a/lib/resources/js/controllers/index.js b/lib/resources/js/controllers/index.js
index 0c5ac8f..4f751af 100755
--- a/lib/resources/js/controllers/index.js
+++ b/lib/resources/js/controllers/index.js
@@ -123,19 +123,21 @@ angular.module('docular.controllers', [
if(!documentationItem) {
$scope.isIndex = true;
} else {
- sourceService.fetchSourceFile(documentationItem.file).then(function (resp) {
- var fileType = fileType ? documentationItem.file.match(/[A-Za-z0-9]+$/) : null;
- if(fileType && fileType.length == 1) {
- fileType = fileType[0];
- } else {
- fileType = null;
- }
- $scope.source = {
- content: resp.data,
- fileType: fileType
- }
- console.log($scope.source);
- });
+ if (documentationItem.showSource) {
+ sourceService.fetchSourceFile(documentationItem.file).then(function (resp) {
+ var fileType = fileType ? documentationItem.file.match(/[A-Za-z0-9]+$/) : null;
+ if(fileType && fileType.length == 1) {
+ fileType = fileType[0];
+ } else {
+ fileType = null;
+ }
+ $scope.source = {
+ content: resp.data,
+ fileType: fileType
+ }
+ console.log($scope.source);
+ });
+ }
$scope.includeUrl = 'resources/plugins/' + documentationItem.handler + '/documentationPartial.html';
}
diff --git a/lib/resources/templates/index_page.html b/lib/resources/templates/index_page.html
index e6ed8f9..2e04e5b 100755
--- a/lib/resources/templates/index_page.html
+++ b/lib/resources/templates/index_page.html
@@ -43,7 +43,7 @@
-
+
diff --git a/lib/scripts/core/generator.js b/lib/scripts/core/generator.js
index daa2f85..5976334 100755
--- a/lib/scripts/core/generator.js
+++ b/lib/scripts/core/generator.js
@@ -125,11 +125,20 @@ var Generator = Group.extend({
fs.writeFileSync(baseFolder + '/site.json', JSON.stringify(docs, null, 4));
fs.writeFileSync(baseFolder + '/structure.json', JSON.stringify(structure, null, 4));
- fse.ensureDirSync(baseFolder + '/sources/');
+ var bSourcesFolderCreated = false;
+
for (var i = 0, l = docs.length; i < l; i++) {
- if (docs[i].file) {
+ if (docs[i].file && docs[i].showSource) {
+
+ //We only create the sources folder if it's needed by at least one file
+ if (!bSourcesFolderCreated) {
+ bSourcesFolderCreated = true;
+ fse.ensureDirSync(baseFolder + '/sources/');
+ }
+
fse.ensureFileSync(baseFolder + '/sources/' + docs[i].file);
fse.copySync(docs[i].file, baseFolder + '/sources/' + docs[i].file);
+
}
}
diff --git a/lib/scripts/core/group.js b/lib/scripts/core/group.js
index b7f75e1..a4f9320 100755
--- a/lib/scripts/core/group.js
+++ b/lib/scripts/core/group.js
@@ -75,18 +75,20 @@ var Group = Class.extend({
return paths.reverse().join('/');
},
- setupGroups: function () {
+ setupGroups: function (parentConfig) {
+ // The root group isn't called with a parentConfig so we set default value of bShowSource at this point
+ var _parentConfig = parentConfig || {showSource : false};
var groups = this.option('groups');
var self = this;
this._groups = [];
if(!groups) { return; }
for(var i = 0, l = groups.length; i < l; i++) {
- var config = Group.normalizeConfig(groups[i]);
+ var config = Group.normalizeConfig(groups[i], _parentConfig);
this.emit('ProcessGroupConfig', config);
var group = new Group(config, {
registry: this.registry
});
- group.setupGroups();
+ group.setupGroups(config);
this.events.forEach(function (evt) {
group.on(evt, function () {
self.emit.apply(self, [evt].concat(Array.prototype.slice.apply(arguments)));
@@ -193,6 +195,7 @@ var Group = Class.extend({
var promises = [];
var self = this;
var files = this.option('files') || [];
+ var showSource = this.option('showSource');
this.docs = [];
files.forEach(function (fileName) {
@@ -207,6 +210,7 @@ var Group = Class.extend({
}
docPromise.then(function (docModel) {
docModel.setPath(paths);
+ docModel.data.showSource = showSource;
self.docs.push(docModel);
docModel.groupId = self.internalGroupId;
self.files[fileName].docs.push(docModel);
@@ -222,12 +226,13 @@ var Group = Class.extend({
buildRegistry: function () {
this.docs.forEach(function (doc) {
- this.registry.addItem(doc.id, doc);
+ this.registry.addItem(doc.id, doc);
}.bind(this));
+
return this.runRecursively('buildRegistry');
}
}, {
- normalizeConfig: function (groupData) {
+ normalizeConfig: function (groupData, parentGroupData) {
/*
* Backwards compatibility
*/
@@ -237,6 +242,10 @@ var Group = Class.extend({
if(!groupData.groupIcon) {
groupData.groupIcon = 'code';
}
+ // If we don't explicitly set showSource, we inherit from parent
+ if (typeof(groupData.showSource) !== 'boolean') {
+ groupData.showSource = parentGroupData.showSource;
+ }
return groupData;
}