示例#1
0
def doxygen_refid_to_cpp_name(refid):
    name = refid.attrib["refid"]
    if name.startswith("class") or name.startswith("struct"):
        name = name.removeprefix("class").removeprefix("struct")
        name = doxygen_namespace_to_cpp_namespace(name)
        name_parts = name.split("::")
        # Merging refid and text to avoid bugged names for inner classes
        short_name = refid.text.split("::")
        join_at_index = -1
        if short_name[0] in name_parts:
            join_at_index = name_parts.index(short_name[0],
                                             len(name_parts) - len(short_name))
        return "::".join([*name_parts[:join_at_index], *short_name])
    elif name.startswith("namespace"):
        name = name.removeprefix("namespace")
        name = "_".join(name.split("_")[:-1:])
        name = doxygen_namespace_to_cpp_namespace(name)
        name = name.split("::")
        return "::".join(
            merge_and_remove_duplicates(name,
                                        get_content(refid).split("::")))
    else:
        log.warning(
            f"Unexpected return type '{name}', defaulting as empty string")
        return ""  # raise RuntimeError(f"Unexpected Return Type '{name}'")
示例#2
0
def parse_doxygen_files(path_to_doc, cpp_db):
    doxygen_index = parse_doxygen_index(
        os.path.join(path_to_doc, "docbuild", "xml", "index.xml"))
    log.info("Loading classes info...")
    for currentDir, _, files in os.walk(
            os.path.join(path_to_doc, "docbuild/xml/")):
        for f in sorted(files):
            if any((f.startswith(f"class{item['namespace']}")
                    or f.startswith(f"struct{item['namespace']}"))
                   for item in SOURCE_DIRECTORIES):
                class_filepath = os.path.join(currentDir, f)
                log.debug(f"  Parsing class {class_filepath}")
                tree = etree.parse(class_filepath)
                class_model = parse_class_from_xml(
                    tree.xpath("/doxygen/compounddef")[0], doxygen_index)
                cpp_db.classes["::".join(
                    [class_model.namespace, class_model.name])] = class_model
            elif any(
                    f.startswith(f"namespace{item['namespace']}")
                    for item in SOURCE_DIRECTORIES):
                namespace_filepath = os.path.join(currentDir, f)
                log.debug(f"  Parsing namespace {namespace_filepath}")
                parse_namespace_from_xml(namespace_filepath, cpp_db,
                                         doxygen_index)
            else:
                log.warning(f"Ignoring file {f}")
示例#3
0
def clang_format_files(file_list):
    if CLANG_FORMAT_PATH is not None:
        for path in file_list:
            p = subprocess.Popen(
                [CLANG_FORMAT_PATH, "-i", "-style=file", path],
                cwd=PATH_TO_OBENGINE)
            p.wait()
        return True
    log.warning("clang-format not found, could not format files")
    return False
示例#4
0
def check_obengine_repo(git_dir):
    try:
        repo = git.Repo(git_dir)
    except Exception as e:
        log.warning(f"unable to use repository at '{git_dir}': {e}")
        return False
    return (
        OBENGINE_GIT_URL in repo.remote().urls,
        OBENGINE_GIT_SSH in repo.remote().urls,
    )
示例#5
0
def _check_doxygen():
    try:
        with subprocess.Popen([DOXYGEN_PATH, "--version"],
                              stdout=subprocess.PIPE) as doxygen_exec:
            version = doxygen_exec.stdout.read().decode("utf-8").strip()
            try:
                version = version.split()[0]
                version = semver.VersionInfo.parse(version)
                if version >= semver.VersionInfo(major=1, minor=8, patch=18):
                    return True
                else:
                    return False
            except:
                return False
    except FileNotFoundError as e:
        log.warning(f"doxygen not found at '{DOXYGEN_PATH}' : {e}")
        return False
示例#6
0
def _check_clang_format():
    try:
        with subprocess.Popen([CLANG_FORMAT_PATH, "--version"],
                              stdout=subprocess.PIPE) as clang_format_exec:
            version = clang_format_exec.stdout.read().decode("utf-8").strip()
            try:
                version = version.split()[2]
                if int(version.split(".")[0]) >= 10:
                    return True
                else:
                    return False
            except Exception as e:
                log.warning(
                    f"unable to use clang-format at '{CLANG_FORMAT_PATH}' : {e}"
                )
                return False
    except FileNotFoundError as e:
        log.warning(
            f"unable to find clang-format at '{CLANG_FORMAT_PATH}' : {e}")
        return False