# Copyright (c) 2018-2021, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#

from .doc_page import DocPage
from omni.kit.documentation.builder import DocumentationBuilderMd
from omni.kit.documentation.builder import DocumentationBuilderPage


class MdDoc(DocPage):
    def __init__(self, extension_path, md: DocumentationBuilderMd):
        super().__init__(extension_path)
        self.__md = md
        self.__page = None

    def clean(self):
        """Should be called when the extesion us unloaded or reloaded"""
        if self.__page:
            self.__page.destroy()
            self.__page = None

    def create_doc(self, navigate_to=None):
        """Issue the UI"""
        self.__page = DocumentationBuilderPage(self.__md, navigate_to)
