File size: 943 Bytes
d5436e0
2e48544
 
d5436e0
 
2e48544
a2756cf
 
 
2e48544
a2756cf
d5436e0
a2756cf
 
 
 
 
2e48544
a2756cf
 
 
 
d5436e0
 
2e48544
 
d5436e0
 
 
2e48544
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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")