mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 16:43:00 +00:00
ifc4x3 docs - temporary fix for issue upstream
see https://github.com/buildingSMART/IFC4.3.x-development/issues/754
This commit is contained in:
@@ -31,7 +31,7 @@ import json
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from typing import Any
|
from typing import Any, Union
|
||||||
|
|
||||||
|
|
||||||
# Hacky modified functions from server.py to make parser work
|
# 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:
|
def get_description_json(resource: str) -> str:
|
||||||
md = get_resource_path(resource, abort_on_error=False)
|
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()
|
mdc = open(md, "r", encoding="utf-8").read()
|
||||||
description = get_definition_from_md(resource, mdc)
|
description = get_definition_from_md(resource, mdc)
|
||||||
return description
|
return description
|
||||||
@@ -150,6 +160,8 @@ def get_attributes_json(resource):
|
|||||||
|
|
||||||
def get_predefined_type_values_json(resource):
|
def get_predefined_type_values_json(resource):
|
||||||
md = get_resource_path(resource, abort_on_error=False)
|
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()
|
mdc = open(md, "r", encoding="utf-8").read()
|
||||||
return get_type_values(resource, mdc)["schema_values"]
|
return get_type_values(resource, mdc)["schema_values"]
|
||||||
|
|
||||||
@@ -164,6 +176,7 @@ def save_entities_data(entities: list[str]) -> None:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
md = get_resource_path(entity, abort_on_error=False)
|
md = get_resource_path(entity, abort_on_error=False)
|
||||||
if md:
|
if md:
|
||||||
|
print(f"server returned markdown file path ('{md}') but there was some other parsing error, see below.")
|
||||||
raise e
|
raise e
|
||||||
print(
|
print(
|
||||||
f"WARNING. Cannot find resource path for `{entity}` in DEV DOCUMENTATION even though it's present in ifcopenshell schema. It will be skipped."
|
f"WARNING. Cannot find resource path for `{entity}` in DEV DOCUMENTATION even though it's present in ifcopenshell schema. It will be skipped."
|
||||||
|
|||||||
Reference in New Issue
Block a user