Repository: Avaiga/taipy
File: taipy/common/config/__init__.py (Python)

Code before:
        with open("config_doc.txt", "a") as f:
            from inspect import signature

            # Add the documentation for configure methods
            for exposed_configuration_method, configuration_method in configuration_methods:
                annotation = "    @staticmethod\n"
                sign = "    def " + exposed_configuration_method + str(signature(configuration_method)) + ":\n"
                doc = '        """' + configuration_method.__doc__ + '"""\n'
                content = "        pass\n\n"
                f.write(annotation + sign + doc + content)

            # Add the documentation for the attribute
            annotation = "    @property\n"
            sign = f"    def {attr_name} (self) -> {section.__name__}:\n"
            if issubclass(section, UniqueSection):
                doc = f'        """The configured {section.__name__} section."""\n'
            elif issubclass(section, Section):
                doc = f'        """The configured {section.__name__} sections ."""\n'
            else:
                print(f" ERROR - Invalid section class: {section.__name__}")  # noqa: T201
                return
            content = "        pass\n\n"
            f.write(annotation + sign + doc + content)


def _config_doc_for_config_section(func):
    def func_with_doc(section, attribute_name, default, configuration_methods, add_to_unconflicted_sections=False):
        __write_func_to_doc(section, attribute_name, configuration_methods)
        return func(section, attribute_name, default, configuration_methods, add_to_unconflicted_sections)

    return func_with_doc


def _config_doc_for_config_method(func):
    def func_with_doc(section, attribute_name, configuration_methods):
        __write_func_to_doc(section, attribute_name, configuration_methods)
        return func(attribute_name, configuration_methods)

    return func_with_doc


@_config_doc_for_config_section
def _inject_section(
    section_clazz,
    attribute_name: str,
    default: Section,
    configuration_methods: List[tuple],
    add_to_unconflicted_sections: bool = False,
):
    Config._register_default(default)


Review comment (suggestion):
```suggestion
def _config_doc_for_section(func):
```

Code after:
    if os.environ.get("GENERATING_TAIPY_DOC", None) and os.environ["GENERATING_TAIPY_DOC"] == "true":
        with open("config_doc.txt", "a") as f:
            from inspect import signature

            # Add the documentation for configure methods
            for exposed_configuration_method, configuration_method in configuration_methods:
                annotation = "    @staticmethod\n"
                sign = "    def " + exposed_configuration_method + str(signature(configuration_method)) + ":\n"
                doc = '        """' + configuration_method.__doc__ + '"""\n'
                content = "        pass\n\n"
                f.write(annotation + sign + doc + content)


def __write_section_to_doc(section, attr_name):
    if os.environ.get("GENERATING_TAIPY_DOC", None) and os.environ["GENERATING_TAIPY_DOC"] == "true":
        with open("config_doc.txt", "a") as f:
            # Add the documentation for the attribute
            annotation = "    @property\n"
            sign = f"    def {attr_name} (self) -> {section.__name__}:\n"
            if issubclass(section, UniqueSection):
                doc = f'        """The configured {section.__name__} section."""\n'
            elif issubclass(section, Section):
                doc = f'        """The configured {section.__name__} sections ."""\n'
            else:
                print(f" ERROR - Invalid section class: {section.__name__}")  # noqa: T201
                return
            content = "        pass\n\n"
            f.write(annotation + sign + doc + content)


def _config_doc_for_section(func):
    def func_with_doc(section, attribute_name, default, configuration_methods, add_to_unconflicted_sections=False):
        __write_section_to_doc(section, attribute_name)
        __write_method_to_doc(configuration_methods)
        return func(section, attribute_name, default, configuration_methods, add_to_unconflicted_sections)

    return func_with_doc


def _config_doc_for_method(func):
    def func_with_doc(configuration_methods):
        __write_method_to_doc(configuration_methods)
        return func(configuration_methods)

    return func_with_doc


@_config_doc_for_section
def _inject_section(
    section_clazz,
    attribute_name: str,