MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / extract_docs

Function extract_docs

src/ifcpatch/ifcpatch/__init__.py:153–174  ·  view source on GitHub ↗

Extract class docstrings and method arguments :param submodule_name: Submodule from which to extract the class :param cls_name: Class from which to extract the docstring and method arguments :param method_name: Class Method name from which to extract arguments :param boilerplate_arg

(
    submodule_name: str, cls_name: str, method_name: str = "__init__", boilerplate_args: Optional[Sequence[str]] = None
)

Source from the content-addressed store, hash-verified

151
152
153def extract_docs(
154 submodule_name: str, cls_name: str, method_name: str = "__init__", boilerplate_args: Optional[Sequence[str]] = None
155) -> Union["PatcherDoc", None]:
156 """Extract class docstrings and method arguments
157
158 :param submodule_name: Submodule from which to extract the class
159 :param cls_name: Class from which to extract the docstring and method arguments
160 :param method_name: Class Method name from which to extract arguments
161 :param boilerplate_args: String iterable containing arguments that shall not be parsed
162 """
163 spec = importlib.util.spec_from_file_location(
164 submodule_name, f"{os.path.dirname(inspect.getabsfile(inspect.currentframe()))}/recipes/{submodule_name}.py"
165 )
166 submodule = importlib.util.module_from_spec(spec)
167 try:
168 spec.loader.exec_module(submodule)
169 try:
170 return _extract_docs(getattr(submodule, cls_name), method_name, boilerplate_args)
171 except AttributeError as e:
172 print(e)
173 except ModuleNotFoundError as e:
174 print(f"Error : IFCPatch {str(submodule)} could not load because : {str(e)}")
175
176
177class PatcherDoc(TypedDict):

Callers

nothing calls this directly

Calls 2

_extract_docsFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected