Improve IDS static HTML reporter to report list of prohibited entities (they aren't passes or fails, just prohibited applicability)

This commit is contained in:
Dion Moult
2026-01-22 11:18:35 +11:00
parent 84d55d8969
commit 4c47eb573a
2 changed files with 63 additions and 1 deletions
+24
View File
@@ -85,6 +85,7 @@ class ResultsSpecification(TypedDict):
total_applicable: int
total_applicable_pass: int
total_applicable_fail: int
applicable_entities: list[ResultsEntity]
percent_applicable_pass: ResultsPercent
total_checks: int
total_checks_pass: int
@@ -383,6 +384,7 @@ class Json(Reporter):
total_applicable=total_applicable,
total_applicable_pass=total_applicable_pass,
total_applicable_fail=total_applicable - total_applicable_pass,
applicable_entities=self.report_applicable_entities(specification),
percent_applicable_pass=percent_applicable_pass,
total_checks=total_checks,
total_checks_pass=total_checks_pass,
@@ -393,6 +395,24 @@ class Json(Reporter):
requirements=requirements,
)
def report_applicable_entities(self, specification: Specification) -> list[ResultsEntity]:
return [
ResultsEntity(
{
"element": e,
"element_type": ifcopenshell.util.element.get_type(e),
"class": e.is_a(),
"predefined_type": ifcopenshell.util.element.get_predefined_type(e),
"name": getattr(e, "Name", None),
"description": getattr(e, "Description", None),
"id": e.id(),
"global_id": getattr(e, "GlobalId", None),
"tag": getattr(e, "Tag", None),
}
)
for e in specification.applicable_entities
]
def report_passed_entities(self, requirement: Facet) -> list[ResultsEntity]:
return [
ResultsEntity(
@@ -459,6 +479,10 @@ class Html(Json):
spec["is_prohibited"] = spec["cardinality"] == "prohibited"
spec["cardinality"] = spec["cardinality"].capitalize()
spec["has_requirements"] = bool(spec["requirements"])
total_applicable_entities = len(spec["applicable_entities"])
spec["applicable_entities"] = self.limit_entities(spec["applicable_entities"])
spec["has_omitted_applicable"] = total_applicable_entities > self.entity_limit
spec["total_omitted_applicable"] = total_applicable_entities - self.entity_limit
for requirement in spec["requirements"]:
total_passed_entities = len(requirement["passed_entities"])
total_failed_entities = len(requirement["failed_entities"])
+39 -1
View File
@@ -152,7 +152,6 @@
<p>
<strong>Requirements</strong>
</p>
{{/has_requirements}}
<ol>
{{#requirements}}
<li class="{{^total_checks}}skipped{{/total_checks}}{{#total_checks}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/total_checks}}">
@@ -252,6 +251,45 @@
</li>
{{/requirements}}
</ol>
{{/has_requirements}}
{{#is_prohibited}}
{{#total_applicable}}
<table class="fail">
<thead>
<tr>
<th>Class</th>
<th>PredefinedType</th>
<th>Name</th>
<th>Description</th>
<th>GlobalId</th>
<th>Tag</th>
</tr>
</thead>
<tbody>
{{#applicable_entities}}
<tr>
<td>{{class}}</td>
<td>{{predefined_type}}</td>
<td>{{name}}</td>
<td>{{description}}</td>
<td>{{global_id}}</td>
<td>{{tag}}</td>
</tr>
{{#extra_of_type}}
<tr>
<td colspan="7">... {{extra_of_type}} more of the same element type ({{type_name}} with Tag {{type_tag}} and GlobalId {{type_global_id}}) not shown ...</td>
</tr>
{{/extra_of_type}}
{{/applicable_entities}}
{{#has_omitted_applicable}}
<tr>
<td colspan="7"> ... {{total_omitted_applicable}} more failing elements not shown out of {{total_applicable}} total ...</td>
</tr>
{{/has_omitted_applicable}}
</tbody>
</table>
{{/total_applicable}}
{{/is_prohibited}}
</div>
</section>
{{/specifications}}