diff --git a/src/ifcopenshell-python/ifcopenshell/util/ifc4x3dev_scrape_data_for_docs.py b/src/ifcopenshell-python/ifcopenshell/util/ifc4x3dev_scrape_data_for_docs.py index 5daf2b5f46..93fd6a15c8 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/ifc4x3dev_scrape_data_for_docs.py +++ b/src/ifcopenshell-python/ifcopenshell/util/ifc4x3dev_scrape_data_for_docs.py @@ -31,7 +31,7 @@ import json import ifcopenshell from collections import Counter from bs4 import BeautifulSoup -from typing import Any +from typing import Any, Union # Hacky modified functions from server.py to make parser work @@ -128,9 +128,19 @@ def get_attributes_keep_md(resource, builder): # ------------------------- +# Temporary fix for https://github.com/buildingSMART/IFC4.3.x-development/issues/754. +_original_get_resource_path = get_resource_path +def get_resource_path(resource: str, abort_on_error=False) -> Union[str, None]: + md = _original_get_resource_path(resource, abort_on_error) + if md and resource == "IfcURIReference": + md = md.replace("IfcMeasureResource", "IfcExternalReferenceResource") + return md + def get_description_json(resource: str) -> str: md = get_resource_path(resource, abort_on_error=False) + if not md: + raise Exception(f"No resource path found for '{resource}'.") mdc = open(md, "r", encoding="utf-8").read() description = get_definition_from_md(resource, mdc) return description @@ -150,6 +160,8 @@ def get_attributes_json(resource): def get_predefined_type_values_json(resource): md = get_resource_path(resource, abort_on_error=False) + if not md: + raise Exception(f"No resource path found for '{resource}'.") mdc = open(md, "r", encoding="utf-8").read() return get_type_values(resource, mdc)["schema_values"] @@ -164,6 +176,7 @@ def save_entities_data(entities: list[str]) -> None: except Exception as e: md = get_resource_path(entity, abort_on_error=False) if md: + print(f"server returned markdown file path ('{md}') but there was some other parsing error, see below.") raise e print( f"WARNING. Cannot find resource path for `{entity}` in DEV DOCUMENTATION even though it's present in ifcopenshell schema. It will be skipped."