Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/test_uml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pathlib import Path

from docs.uml import PlantUMLNetwork, build_network


def test_network_build() -> None:
"""
This test is only for debugging purposes.
"""
project_root_dir = Path(__file__).parent.parent
module_dir = project_root_dir / "src/bo4e"
_network, _namespaces_to_parse = build_network(module_dir, PlantUMLNetwork)
8 changes: 8 additions & 0 deletions docs/uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import subprocess
from abc import ABCMeta, abstractmethod
from pathlib import Path
from re import Pattern
from typing import Any, Dict, List, Optional, Tuple, Type, cast

import networkx as nx # type: ignore[import]
import requests # type: ignore[import]

# pylint: disable=no-name-in-module
from pydantic import ConstrainedStr
from pydantic.fields import (
MAPPING_LIKE_SHAPES,
SHAPE_GENERIC,
Expand Down Expand Up @@ -251,6 +253,12 @@ def model_field_str(model_field: ModelField, card: Optional[Cardinality] = None)
elif model_field.shape not in (SHAPE_SINGLETON, SHAPE_LIST):
result_str = SHAPE_NAME_LOOKUP[model_field.shape].format(result_str)

if isinstance(model_field.outer_type_, type) and issubclass(model_field.outer_type_, ConstrainedStr):
if isinstance(model_field.outer_type_.regex, Pattern):
result_str = f"str<{model_field.outer_type_.regex.pattern}>"
elif isinstance(model_field.outer_type_.regex, str):
result_str = f"str<{model_field.outer_type_.regex}>"

assert card is not None
return f"{result_str} [{_UMLNetworkABC.get_cardinality_string(card)}]"

Expand Down