import os
import sys

# from PyQt6 import Webview
from PyQt6.QtWidgets import QApplication, QMainWindow, QTabWidget

documentation_path = "docs"


class DocumentationViewer(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Documentation Viewer")
        self.setGeometry(100, 100, 800, 600)

        self.tabs = QTabWidget()
        self.setCentralWidget(self.tabs)

        self.set_documentation_tabs()

    def set_documentation_tabs(self):
        files = [
            os.path.join(documentation_path, file)
            for file in os.listdir(documentation_path)
            if file.endswith(".html")
        ]
        for file in files:
            with open(file, "r") as f:
                html_content = f.read()
                tab_name = os.path.basename(file).split(".")[0]
                self.load_documentation(tab_name, html_content)

    def load_documentation(
        self,
        tab_name="Documentation",
        html_content="<h1>Documentation</h1><p>Your HTML documentation content goes here.</p>",
    ):
        # open documentation
        name = tab_name


if __name__ == "__main__":
    app = QApplication(sys.argv)
    viewer = DocumentationViewer()
    viewer.show()
    sys.exit(app.exec())
