<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dockWidget(self, widget, title, area):
 """ Adds a widget as a docked widget. Returns the added dockWidget """

        assert widget.parent() is None, "Widget already has a parent"

        dockWidget = QtWidgets.QDockWidget(title, parent=self)
        dockWidget.setObjectName("dock_" + string_to_identifier(title))
        dockWidget.setWidget(widget)

        # Prevent parent context menu (with e.g. 'set inspector" option) to be displayed.
        dockWidget.setContextMenuPolicy(Qt.PreventContextMenu)

        self.addDockWidget(area, dockWidget)
        self.viewMenu.addAction(dockWidget.toggleViewAction())
        return dockWidget