Skip to content

Commit 6cdc540

Browse files
Merge pull request #626 from AndrewLeedham/master
Option of excluding sub pattern types from the styleguide
2 parents 35ab050 + 6c2da1e commit 6cdc540

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

core/lib/ui_builder.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ var ui_builder = function () {
484484
_.forEach(styleguidePatterns.patternGroups, function (patternTypeObj, patternType) {
485485

486486
var p;
487-
var typePatterns = [];
487+
var typePatterns = [], styleguideTypePatterns = [];
488488
var styleGuideExcludes = patternlab.config.styleGuideExcludes;
489489

490490
_.forOwn(patternTypeObj, function (patternSubtypes, patternSubtype) {
@@ -508,6 +508,19 @@ var ui_builder = function () {
508508
return pat.isDocPattern;
509509
});
510510

511+
//determine if we should omit this subpatterntype completely from the viewall page
512+
var omitPatternType = styleGuideExcludes && styleGuideExcludes.length
513+
&& _.some(styleGuideExcludes, function (exclude) {
514+
return exclude === patternType + '/' + patternSubtype;
515+
});
516+
if (omitPatternType) {
517+
if (patternlab.config.debug) {
518+
console.log('Omitting ' + patternType + '/' + patternSubtype + ' from building a viewall page because its patternSubGroup is specified in styleguideExcludes.');
519+
}
520+
} else {
521+
styleguideTypePatterns = styleguideTypePatterns.concat(subtypePatterns);
522+
}
523+
511524
typePatterns = typePatterns.concat(subtypePatterns);
512525

513526
var viewAllHTML = buildViewAllHTML(patternlab, subtypePatterns, patternPartial);
@@ -544,7 +557,7 @@ var ui_builder = function () {
544557
console.log('Omitting ' + patternType + ' from building a viewall page because its patternGroup is specified in styleguideExcludes.');
545558
}
546559
} else {
547-
patterns = patterns.concat(typePatterns);
560+
patterns = patterns.concat(styleguideTypePatterns);
548561
}
549562
});
550563
return patterns;

0 commit comments

Comments
 (0)