PluginDocumentationSets.py

Sat, 23 Dec 2023 16:13:31 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Dec 2023 16:13:31 +0100
branch
eric7
changeset 86
812d4cf28c23
parent 85
8bdcb62db996
child 98
bab4585d9d63
permissions
-rw-r--r--

Converted some source code documentation to the new style.

# -*- coding: utf-8 -*-

# Copyright (c) 2016 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the QtHelp documentation provider plug-in.
"""

import glob
import os

from PyQt6.QtCore import QObject

# Start-Of-Header
name = "Documentation Sets"
author = "Detlev Offenbach <detlev@die-offenbachs.de>"
autoactivate = True
deactivateable = True
version = "10.0.0"
className = "PluginDocumentationSets"
packageName = "DocumentationSets"
shortDescription = "Documentation sets in QtHelp format (*.qch)"
longDescription = (
    """This plug-in provides an interface to additional documentation sets"""
    """ in QtHelp format (*.qch) for registration with the eric help/web"""
    """ browser or Qt Assistant."""
)
needsRestart = False
pyqtApi = 2
# End-Of-Header

error = ""


def helpFiles():
    """
    Module function to return the documentation sets provided by this plug-in.

    @return dictionary with documentation set type as key and list of
        documentation files as values
    @rtype dict (key: str, value: list of str)
    """
    documentationSets = {}
    documentationSetsDir = os.path.join(os.path.dirname(__file__), "DocumentationSets")
    if os.path.isdir(documentationSetsDir):
        documentationTypes = [
            d
            for d in os.listdir(documentationSetsDir)
            if os.path.isdir(os.path.join(documentationSetsDir, d))
        ]
        for documentationType in documentationTypes:
            documentationSets[documentationType] = glob.glob(
                os.path.join(documentationSetsDir, documentationType, "*.qch")
            )

    return documentationSets


class PluginDocumentationSets(QObject):
    """
    Class implementing the QtHelp documentation provider plug-in.
    """

    def __init__(self, ui):
        """
        Constructor

        @param ui reference to the user interface object
        @type UserInterface
        """
        super().__init__(ui)
        self.__ui = ui

    def activate(self):
        """
        Public method to activate this plugin.

        @return tuple of None and activation status
        @rtype bool
        """
        global error
        error = ""  # clear previous error

        return None, True

    def deactivate(self):
        """
        Public method to deactivate this plugin.
        """
        pass

#
# eflag: noqa = U200

eric ide

mercurial