Skip to content

Commit d4b7274

Browse files
committed
fix(doc-coverage): ignore private, handle constructor
fix #122
1 parent 34e807b commit d4b7274

File tree

2 files changed

+99
-18
lines changed

2 files changed

+99
-18
lines changed

src/app/application.ts

Lines changed: 97 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -582,33 +582,55 @@ export class Application {
582582
let cl:any = {
583583
filePath: component.file,
584584
type: component.type,
585+
linktype: component.type,
585586
name: component.name
586587
},
587588
totalStatementDocumented = 0,
588589
totalStatements = component.propertiesClass.length + component.methodsClass.length + component.inputsClass.length + component.outputsClass.length + 1; // +1 for component decorator comment
590+
591+
if (component.constructorObj) {
592+
totalStatements += 1;
593+
if (component.constructorObj.description !== '') {
594+
totalStatementDocumented += 1;
595+
}
596+
}
597+
if (component.description !== '') {
598+
totalStatementDocumented += 1;
599+
}
600+
589601
_.forEach(component.propertiesClass, (property) => {
590-
if(property.description !== '') {
602+
if (property.modifierKind === 111) { // Doesn't handle private for coverage
603+
totalStatements -= 1;
604+
}
605+
if(property.description !== '' && property.modifierKind !== 111) {
591606
totalStatementDocumented += 1;
592607
}
593608
});
594609
_.forEach(component.methodsClass, (method) => {
595-
if(method.description !== '') {
610+
if (method.modifierKind === 111) { // Doesn't handle private for coverage
611+
totalStatements -= 1;
612+
}
613+
if(method.description !== '' && method.modifierKind !== 111) {
596614
totalStatementDocumented += 1;
597615
}
598616
});
599617
_.forEach(component.inputsClass, (input) => {
600-
if(input.description !== '') {
618+
if (input.modifierKind === 111) { // Doesn't handle private for coverage
619+
totalStatements -= 1;
620+
}
621+
if(input.description !== '' && input.modifierKind !== 111) {
601622
totalStatementDocumented += 1;
602623
}
603624
});
604625
_.forEach(component.outputsClass, (output) => {
605-
if(output.description !== '') {
626+
if (output.modifierKind === 111) { // Doesn't handle private for coverage
627+
totalStatements -= 1;
628+
}
629+
if(output.description !== '' && output.modifierKind !== 111) {
606630
totalStatementDocumented += 1;
607631
}
608632
});
609-
if (component.description !== '') {
610-
totalStatementDocumented += 1;
611-
}
633+
612634
cl.coveragePercent = Math.floor((totalStatementDocumented / totalStatements) * 100);
613635
if(totalStatements === 0) {
614636
cl.coveragePercent = 0;
@@ -626,20 +648,39 @@ export class Application {
626648
let cl:any = {
627649
filePath: classe.file,
628650
type: 'class',
651+
linktype: 'classe',
629652
name: classe.name
630653
},
631654
totalStatementDocumented = 0,
632-
totalStatements = classe.properties.length + classe.methods.length;
655+
totalStatements = classe.properties.length + classe.methods.length + 1; // +1 for class itself
656+
657+
if (classe.constructorObj) {
658+
totalStatements += 1;
659+
if (classe.constructorObj.description !== '') {
660+
totalStatementDocumented += 1;
661+
}
662+
}
663+
if (classe.description !== '') {
664+
totalStatementDocumented += 1;
665+
}
666+
633667
_.forEach(classe.properties, (property) => {
634-
if(property.description !== '') {
668+
if (property.modifierKind === 111) { // Doesn't handle private for coverage
669+
totalStatements -= 1;
670+
}
671+
if(property.description !== '' && property.modifierKind !== 111) {
635672
totalStatementDocumented += 1;
636673
}
637674
});
638675
_.forEach(classe.methods, (method) => {
639-
if(method.description !== '') {
676+
if (method.modifierKind === 111) { // Doesn't handle private for coverage
677+
totalStatements -= 1;
678+
}
679+
if(method.description !== '' && method.modifierKind !== 111) {
640680
totalStatementDocumented += 1;
641681
}
642682
});
683+
643684
cl.coveragePercent = Math.floor((totalStatementDocumented / totalStatements) * 100);
644685
if(totalStatements === 0) {
645686
cl.coveragePercent = 0;
@@ -657,20 +698,39 @@ export class Application {
657698
let cl:any = {
658699
filePath: injectable.file,
659700
type: injectable.type,
701+
linktype: injectable.type,
660702
name: injectable.name
661703
},
662704
totalStatementDocumented = 0,
663-
totalStatements = injectable.properties.length + injectable.methods.length;
705+
totalStatements = injectable.properties.length + injectable.methods.length + 1; // +1 for injectable itself
706+
707+
if (injectable.constructorObj) {
708+
totalStatements += 1;
709+
if (injectable.constructorObj.description !== '') {
710+
totalStatementDocumented += 1;
711+
}
712+
}
713+
if (injectable.description !== '') {
714+
totalStatementDocumented += 1;
715+
}
716+
664717
_.forEach(injectable.properties, (property) => {
665-
if(property.description !== '') {
718+
if (property.modifierKind === 111) { // Doesn't handle private for coverage
719+
totalStatements -= 1;
720+
}
721+
if(property.description !== '' && property.modifierKind !== 111) {
666722
totalStatementDocumented += 1;
667723
}
668724
});
669725
_.forEach(injectable.methods, (method) => {
670-
if(method.description !== '') {
726+
if (method.modifierKind === 111) { // Doesn't handle private for coverage
727+
totalStatements -= 1;
728+
}
729+
if(method.description !== '' && method.modifierKind !== 111) {
671730
totalStatementDocumented += 1;
672731
}
673732
});
733+
674734
cl.coveragePercent = Math.floor((totalStatementDocumented / totalStatements) * 100);
675735
if(totalStatements === 0) {
676736
cl.coveragePercent = 0;
@@ -688,20 +748,39 @@ export class Application {
688748
let cl:any = {
689749
filePath: inter.file,
690750
type: inter.type,
751+
linktype: inter.type,
691752
name: inter.name
692753
},
693754
totalStatementDocumented = 0,
694-
totalStatements = inter.properties.length + inter.methods.length;
755+
totalStatements = inter.properties.length + inter.methods.length + 1; // +1 for interface itself
756+
757+
if (inter.constructorObj) {
758+
totalStatements += 1;
759+
if (inter.constructorObj.description !== '') {
760+
totalStatementDocumented += 1;
761+
}
762+
}
763+
if (inter.description !== '') {
764+
totalStatementDocumented += 1;
765+
}
766+
695767
_.forEach(inter.properties, (property) => {
696-
if(property.description !== '') {
768+
if (property.modifierKind === 111) { // Doesn't handle private for coverage
769+
totalStatements -= 1;
770+
}
771+
if(property.description !== '' && property.modifierKind !== 111) {
697772
totalStatementDocumented += 1;
698773
}
699774
});
700775
_.forEach(inter.methods, (method) => {
701-
if(method.description !== '') {
776+
if (method.modifierKind === 111) { // Doesn't handle private for coverage
777+
totalStatements -= 1;
778+
}
779+
if(method.description !== '' && method.modifierKind !== 111) {
702780
totalStatementDocumented += 1;
703781
}
704782
});
783+
705784
cl.coveragePercent = Math.floor((totalStatementDocumented / totalStatements) * 100);
706785
if(totalStatements === 0) {
707786
cl.coveragePercent = 0;
@@ -715,13 +794,15 @@ export class Application {
715794
let cl:any = {
716795
filePath: pipe.file,
717796
type: pipe.type,
797+
linktype: pipe.type,
718798
name: pipe.name
719799
},
720800
totalStatementDocumented = 0,
721801
totalStatements = 1;
722802
if (pipe.description !== '') {
723803
totalStatementDocumented += 1;
724804
}
805+
725806
cl.coveragePercent = Math.floor((totalStatementDocumented / totalStatements) * 100);
726807
cl.coverageCount = totalStatementDocumented + '/' + totalStatements;
727808
cl.status = getStatus(cl.coveragePercent);

src/templates/partials/coverage-report.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ol class="breadcrumb">
2-
<li>Documentation coverage</li>
2+
<li>Documentation coverage</li>
33
</ol>
44

55
<div class="coverage-badge">
@@ -20,7 +20,7 @@
2020
{{#each files}}
2121
<tr class="{{status}}">
2222
<td>
23-
<a href="./{{type}}s/{{name}}.html">{{filePath}}</a>
23+
<a href="./{{linktype}}s/{{name}}.html">{{filePath}}</a>
2424
</td>
2525
<td>
2626
{{type}}

0 commit comments

Comments
 (0)