import os import logging import streamlit as st from ..utils.form_documentation import generate_doc from typing import Optional from ..command_handler import CommandHandler class DocumentationHandler(CommandHandler): def __init__(self, commands, successor: Optional["CommandHandler"] = None): super().__init__(successor) self.commands = commands def handle_command(self, command): if command.lower() in self.commands: self.execute_command() else: super().handle_command(command) def execute_command(self): current_dir = os.path.dirname(os.path.realpath(__file__)) path_to_file = generate_doc(path=current_dir) if path_to_file is not None: with st.sidebar: st.download_button('Download doc', path_to_file) st.success("Done", icon="✅") else: logging.error("path_to_file is None")