Browse Source

Updated comments in Models

Converted doxygen style comments to reStructuredText style in the files
 found in Cura/cura/Model directory recursively  using the script
dox_2_rst.py (provided in the Uranium repo). Comments were manually
 checked and changed if needed.

 Note: dox_2rst.py struggles with decorated functions.
Jelle Spijker 4 years ago
parent
commit
120541a8db

+ 36 - 24
cura/Machines/ContainerNode.py

@@ -9,47 +9,59 @@ from UM.Logger import Logger
 from UM.Settings.InstanceContainer import InstanceContainer
 
 
-##  A node in the container tree. It represents one container.
-#
-#   The container it represents is referenced by its container_id. During normal
-#   use of the tree, this container is not constructed. Only when parts of the
-#   tree need to get loaded in the container stack should it get constructed.
 class ContainerNode:
-    ##  Creates a new node for the container tree.
-    #   \param container_id The ID of the container that this node should
-    #   represent.
+    """A node in the container tree. It represents one container.
+    
+    The container it represents is referenced by its container_id. During normal use of the tree, this container is
+    not constructed. Only when parts of the tree need to get loaded in the container stack should it get constructed.
+    """
+
     def __init__(self, container_id: str) -> None:
+        """Creates a new node for the container tree.
+        
+        :param container_id: The ID of the container that this node should represent.
+        """
+
         self.container_id = container_id
         self._container = None  # type: Optional[InstanceContainer]
         self.children_map = {}  # type: Dict[str, ContainerNode]  # Mapping from container ID to container node.
 
-    ##  Gets the metadata of the container that this node represents.
-    #   Getting the metadata from the container directly is about 10x as fast.
-    #   \return The metadata of the container in this node.
     def getMetadata(self) -> Dict[str, Any]:
+        """Gets the metadata of the container that this node represents.
+        
+        Getting the metadata from the container directly is about 10x as fast.
+
+        :return: The metadata of the container in this node.
+        """
+
         return ContainerRegistry.getInstance().findContainersMetadata(id = self.container_id)[0]
 
-    ##  Get an entry from the metadata of the container that this node contains.
-    #
-    #   This is just a convenience function.
-    #   \param entry The metadata entry key to return.
-    #   \param default If the metadata is not present or the container is not
-    #   found, the value of this default is returned.
-    #   \return The value of the metadata entry, or the default if it was not
-    #   present.
     def getMetaDataEntry(self, entry: str, default: Any = None) -> Any:
+        """Get an entry from the metadata of the container that this node contains.
+        
+        This is just a convenience function.
+
+        :param entry: The metadata entry key to return.
+        :param default: If the metadata is not present or the container is not found, the value of this default is
+        returned.
+
+        :return: The value of the metadata entry, or the default if it was not present.
+        """
+
         container_metadata = ContainerRegistry.getInstance().findContainersMetadata(id = self.container_id)
         if len(container_metadata) == 0:
             return default
         return container_metadata[0].get(entry, default)
 
-    ##  The container that this node's container ID refers to.
-    #
-    #   This can be used to finally instantiate the container in order to put it
-    #   in the container stack.
-    #   \return A container.
     @property
     def container(self) -> Optional[InstanceContainer]:
+        """The container that this node's container ID refers to.
+        
+        This can be used to finally instantiate the container in order to put it in the container stack.
+
+        :return: A container.
+        """
+
         if not self._container:
             container_list = ContainerRegistry.getInstance().findInstanceContainers(id = self.container_id)
             if len(container_list) == 0:

+ 87 - 61
cura/Machines/ContainerTree.py

@@ -19,17 +19,16 @@ if TYPE_CHECKING:
     from UM.Settings.ContainerStack import ContainerStack
 
 
-##  This class contains a look-up tree for which containers are available at
-#   which stages of configuration.
-#
-#   The tree starts at the machine definitions. For every distinct definition
-#   there will be one machine node here.
-#
-#   All of the fallbacks for material choices, quality choices, etc. should be
-#   encoded in this tree. There must always be at least one child node (for
-#   nodes that have children) but that child node may be a node representing the
-#   empty instance container.
 class ContainerTree:
+    """This class contains a look-up tree for which containers are available at which stages of configuration.
+    
+    The tree starts at the machine definitions. For every distinct definition there will be one machine node here.
+    
+    All of the fallbacks for material choices, quality choices, etc. should be encoded in this tree. There must
+    always be at least one child node (for nodes that have children) but that child node may be a node representing
+    the empty instance container.
+    """
+
     __instance = None  # type: Optional["ContainerTree"]
 
     @classmethod
@@ -43,13 +42,15 @@ class ContainerTree:
         self.materialsChanged = Signal()  # Emitted when any of the material nodes in the tree got changed.
         cura.CuraApplication.CuraApplication.getInstance().initializationFinished.connect(self._onStartupFinished)  # Start the background task to load more machine nodes after start-up is completed.
 
-    ##  Get the quality groups available for the currently activated printer.
-    #
-    #   This contains all quality groups, enabled or disabled. To check whether
-    #   the quality group can be activated, test for the
-    #   ``QualityGroup.is_available`` property.
-    #   \return For every quality type, one quality group.
     def getCurrentQualityGroups(self) -> Dict[str, "QualityGroup"]:
+        """Get the quality groups available for the currently activated printer.
+        
+        This contains all quality groups, enabled or disabled. To check whether the quality group can be activated,
+        test for the ``QualityGroup.is_available`` property.
+
+        :return: For every quality type, one quality group.
+        """
+
         global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
         if global_stack is None:
             return {}
@@ -58,14 +59,15 @@ class ContainerTree:
         extruder_enabled = [extruder.isEnabled for extruder in global_stack.extruderList]
         return self.machines[global_stack.definition.getId()].getQualityGroups(variant_names, material_bases, extruder_enabled)
 
-    ##  Get the quality changes groups available for the currently activated
-    #   printer.
-    #
-    #   This contains all quality changes groups, enabled or disabled. To check
-    #   whether the quality changes group can be activated, test for the
-    #   ``QualityChangesGroup.is_available`` property.
-    #   \return A list of all quality changes groups.
     def getCurrentQualityChangesGroups(self) -> List["QualityChangesGroup"]:
+        """Get the quality changes groups available for the currently activated printer.
+        
+        This contains all quality changes groups, enabled or disabled. To check whether the quality changes group can
+        be activated, test for the ``QualityChangesGroup.is_available`` property.
+
+        :return: A list of all quality changes groups.
+        """
+
         global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
         if global_stack is None:
             return []
@@ -74,31 +76,43 @@ class ContainerTree:
         extruder_enabled = [extruder.isEnabled for extruder in global_stack.extruderList]
         return self.machines[global_stack.definition.getId()].getQualityChangesGroups(variant_names, material_bases, extruder_enabled)
 
-    ##  Ran after completely starting up the application.
     def _onStartupFinished(self) -> None:
+        """Ran after completely starting up the application."""
+
         currently_added = ContainerRegistry.getInstance().findContainerStacks()  # Find all currently added global stacks.
         JobQueue.getInstance().add(self._MachineNodeLoadJob(self, currently_added))
 
-    ##  Dictionary-like object that contains the machines.
-    #
-    #   This handles the lazy loading of MachineNodes.
     class _MachineNodeMap:
+        """Dictionary-like object that contains the machines.
+        
+        This handles the lazy loading of MachineNodes.
+        """
+
         def __init__(self) -> None:
             self._machines = {}  # type: Dict[str, MachineNode]
 
-        ##  Returns whether a printer with a certain definition ID exists. This
-        #   is regardless of whether or not the printer is loaded yet.
-        #   \param definition_id The definition to look for.
-        #   \return Whether or not a printer definition exists with that name.
         def __contains__(self, definition_id: str) -> bool:
+            """Returns whether a printer with a certain definition ID exists.
+
+            This is regardless of whether or not the printer is loaded yet.
+
+            :param definition_id: The definition to look for.
+
+            :return: Whether or not a printer definition exists with that name.
+            """
+
             return len(ContainerRegistry.getInstance().findContainersMetadata(id = definition_id)) > 0
 
-        ##  Returns a machine node for the specified definition ID.
-        #
-        #   If the machine node wasn't loaded yet, this will load it lazily.
-        #   \param definition_id The definition to look for.
-        #   \return A machine node for that definition.
         def __getitem__(self, definition_id: str) -> MachineNode:
+            """Returns a machine node for the specified definition ID.
+            
+            If the machine node wasn't loaded yet, this will load it lazily.
+
+            :param definition_id: The definition to look for.
+
+            :return: A machine node for that definition.
+            """
+
             if definition_id not in self._machines:
                 start_time = time.time()
                 self._machines[definition_id] = MachineNode(definition_id)
@@ -106,46 +120,58 @@ class ContainerTree:
                 Logger.log("d", "Adding container tree for {definition_id} took {duration} seconds.".format(definition_id = definition_id, duration = time.time() - start_time))
             return self._machines[definition_id]
 
-        ##  Gets a machine node for the specified definition ID, with default.
-        #
-        #   The default is returned if there is no definition with the specified
-        #   ID. If the machine node wasn't loaded yet, this will load it lazily.
-        #   \param definition_id The definition to look for.
-        #   \param default The machine node to return if there is no machine
-        #   with that definition (can be ``None`` optionally or if not
-        #   provided).
-        #   \return A machine node for that definition, or the default if there
-        #   is no definition with the provided definition_id.
         def get(self, definition_id: str, default: Optional[MachineNode] = None) -> Optional[MachineNode]:
+            """Gets a machine node for the specified definition ID, with default.
+            
+            The default is returned if there is no definition with the specified ID. If the machine node wasn't
+            loaded yet, this will load it lazily.
+
+            :param definition_id: The definition to look for.
+            :param default: The machine node to return if there is no machine with that definition (can be ``None``
+            optionally or if not provided).
+
+            :return: A machine node for that definition, or the default if there is no definition with the provided
+            definition_id.
+            """
+
             if definition_id not in self:
                 return default
             return self[definition_id]
 
-        ##  Returns whether we've already cached this definition's node.
-        #   \param definition_id The definition that we may have cached.
-        #   \return ``True`` if it's cached.
         def is_loaded(self, definition_id: str) -> bool:
+            """Returns whether we've already cached this definition's node.
+            
+            :param definition_id: The definition that we may have cached.
+
+            :return: ``True`` if it's cached.
+            """
+
             return definition_id in self._machines
 
-    ##  Pre-loads all currently added printers as a background task so that
-    #   switching printers in the interface is faster.
     class _MachineNodeLoadJob(Job):
-        ##  Creates a new background task.
-        #   \param tree_root The container tree instance. This cannot be
-        #   obtained through the singleton static function since the instance
-        #   may not yet be constructed completely.
-        #   \param container_stacks All of the stacks to pre-load the container
-        #   trees for. This needs to be provided from here because the stacks
-        #   need to be constructed on the main thread because they are QObject.
+        """Pre-loads all currently added printers as a background task so that switching printers in the interface is
+        faster.
+        """
+
         def __init__(self, tree_root: "ContainerTree", container_stacks: List["ContainerStack"]) -> None:
+            """Creates a new background task.
+            
+            :param tree_root: The container tree instance. This cannot be obtained through the singleton static
+            function since the instance may not yet be constructed completely.
+            :param container_stacks: All of the stacks to pre-load the container trees for. This needs to be provided
+            from here because the stacks need to be constructed on the main thread because they are QObject.
+            """
+
             self.tree_root = tree_root
             self.container_stacks = container_stacks
             super().__init__()
 
-        ##  Starts the background task.
-        #
-        #   The ``JobQueue`` will schedule this on a different thread.
         def run(self) -> None:
+            """Starts the background task.
+            
+            The ``JobQueue`` will schedule this on a different thread.
+            """
+
             for stack in self.container_stacks:  # Load all currently-added containers.
                 if not isinstance(stack, GlobalStack):
                     continue

+ 5 - 3
cura/Machines/IntentNode.py

@@ -11,10 +11,12 @@ if TYPE_CHECKING:
     from cura.Machines.QualityNode import QualityNode
 
 
-##  This class represents an intent profile in the container tree.
-#
-#   This class has no more subnodes.
 class IntentNode(ContainerNode):
+    """This class represents an intent profile in the container tree.
+    
+    This class has no more subnodes.
+    """
+
     def __init__(self, container_id: str, quality: "QualityNode") -> None:
         super().__init__(container_id)
         self.quality = quality

+ 28 - 15
cura/Machines/MachineErrorChecker.py

@@ -13,16 +13,16 @@ from UM.Settings.SettingDefinition import SettingDefinition
 from UM.Settings.Validator import ValidatorState
 
 import cura.CuraApplication
-#
-# This class performs setting error checks for the currently active machine.
-#
-# The whole error checking process is pretty heavy which can take ~0.5 secs, so it can cause GUI to lag.
-# The idea here is to split the whole error check into small tasks, each of which only checks a single setting key
-# in a stack. According to my profiling results, the maximal runtime for such a sub-task is <0.03 secs, which should
-# be good enough. Moreover, if any changes happened to the machine, we can cancel the check in progress without wait
-# for it to finish the complete work.
-#
+
 class MachineErrorChecker(QObject):
+    """This class performs setting error checks for the currently active machine.
+
+    The whole error checking process is pretty heavy which can take ~0.5 secs, so it can cause GUI to lag. The idea
+    here is to split the whole error check into small tasks, each of which only checks a single setting key in a
+    stack. According to my profiling results, the maximal runtime for such a sub-task is <0.03 secs, which should be
+    good enough. Moreover, if any changes happened to the machine, we can cancel the check in progress without wait
+    for it to finish the complete work.
+    """
 
     def __init__(self, parent: Optional[QObject] = None) -> None:
         super().__init__(parent)
@@ -92,24 +92,37 @@ class MachineErrorChecker(QObject):
     def needToWaitForResult(self) -> bool:
         return self._need_to_check or self._check_in_progress
 
-    #   Start the error check for property changed
-    #   this is seperate from the startErrorCheck because it ignores a number property types
     def startErrorCheckPropertyChanged(self, key: str, property_name: str) -> None:
+        """Start the error check for property changed
+
+        this is seperate from the startErrorCheck because it ignores a number property types
+
+        :param key:
+        :param property_name:
+        """
+
         if property_name != "value":
             return
         self.startErrorCheck()
 
-    # Starts the error check timer to schedule a new error check.
     def startErrorCheck(self, *args: Any) -> None:
+        """Starts the error check timer to schedule a new error check.
+
+        :param args:
+        """
+
         if not self._check_in_progress:
             self._need_to_check = True
             self.needToWaitForResultChanged.emit()
         self._error_check_timer.start()
 
-    # This function is called by the timer to reschedule a new error check.
-    # If there is no check in progress, it will start a new one. If there is any, it sets the "_need_to_check" flag
-    # to notify the current check to stop and start a new one.
     def _rescheduleCheck(self) -> None:
+        """This function is called by the timer to reschedule a new error check.
+
+        If there is no check in progress, it will start a new one. If there is any, it sets the "_need_to_check" flag
+        to notify the current check to stop and start a new one.
+        """
+
         if self._check_in_progress and not self._need_to_check:
             self._need_to_check = True
             self.needToWaitForResultChanged.emit()

+ 46 - 44
cura/Machines/MachineNode.py

@@ -17,10 +17,12 @@ from cura.Machines.VariantNode import VariantNode
 import UM.FlameProfiler
 
 
-##  This class represents a machine in the container tree.
-#
-#   The subnodes of these nodes are variants.
 class MachineNode(ContainerNode):
+    """This class represents a machine in the container tree.
+    
+    The subnodes of these nodes are variants.
+    """
+
     def __init__(self, container_id: str) -> None:
         super().__init__(container_id)
         self.variants = {}  # type: Dict[str, VariantNode] # Mapping variant names to their nodes.
@@ -47,20 +49,21 @@ class MachineNode(ContainerNode):
 
         self._loadAll()
 
-    ##  Get the available quality groups for this machine.
-    #
-    #   This returns all quality groups, regardless of whether they are
-    #   available to the combination of extruders or not. On the resulting
-    #   quality groups, the is_available property is set to indicate whether the
-    #   quality group can be selected according to the combination of extruders
-    #   in the parameters.
-    #   \param variant_names The names of the variants loaded in each extruder.
-    #   \param material_bases The base file names of the materials loaded in
-    #   each extruder.
-    #   \param extruder_enabled Whether or not the extruders are enabled. This
-    #   allows the function to set the is_available properly.
-    #   \return For each available quality type, a QualityGroup instance.
     def getQualityGroups(self, variant_names: List[str], material_bases: List[str], extruder_enabled: List[bool]) -> Dict[str, QualityGroup]:
+        """Get the available quality groups for this machine.
+        
+        This returns all quality groups, regardless of whether they are available to the combination of extruders or
+        not. On the resulting quality groups, the is_available property is set to indicate whether the quality group
+        can be selected according to the combination of extruders in the parameters.
+
+        :param variant_names: The names of the variants loaded in each extruder.
+        :param material_bases: The base file names of the materials loaded in each extruder.
+        :param extruder_enabled: Whether or not the extruders are enabled. This allows the function to set the
+        is_available properly.
+
+        :return: For each available quality type, a QualityGroup instance.
+        """
+
         if len(variant_names) != len(material_bases) or len(variant_names) != len(extruder_enabled):
             Logger.log("e", "The number of extruders in the list of variants (" + str(len(variant_names)) + ") is not equal to the number of extruders in the list of materials (" + str(len(material_bases)) + ") or the list of enabled extruders (" + str(len(extruder_enabled)) + ").")
             return {}
@@ -98,28 +101,26 @@ class MachineNode(ContainerNode):
             quality_groups[quality_type].is_available = True
         return quality_groups
 
-    ##  Returns all of the quality changes groups available to this printer.
-    #
-    #   The quality changes groups store which quality type and intent category
-    #   they were made for, but not which material and nozzle. Instead for the
-    #   quality type and intent category, the quality changes will always be
-    #   available but change the quality type and intent category when
-    #   activated.
-    #
-    #   The quality changes group does depend on the printer: Which quality
-    #   definition is used.
-    #
-    #   The quality changes groups that are available do depend on the quality
-    #   types that are available, so it must still be known which extruders are
-    #   enabled and which materials and variants are loaded in them. This allows
-    #   setting the correct is_available flag.
-    #   \param variant_names The names of the variants loaded in each extruder.
-    #   \param material_bases The base file names of the materials loaded in
-    #   each extruder.
-    #   \param extruder_enabled For each extruder whether or not they are
-    #   enabled.
-    #   \return List of all quality changes groups for the printer.
     def getQualityChangesGroups(self, variant_names: List[str], material_bases: List[str], extruder_enabled: List[bool]) -> List[QualityChangesGroup]:
+        """Returns all of the quality changes groups available to this printer.
+        
+        The quality changes groups store which quality type and intent category they were made for, but not which
+        material and nozzle. Instead for the quality type and intent category, the quality changes will always be
+        available but change the quality type and intent category when activated.
+        
+        The quality changes group does depend on the printer: Which quality definition is used.
+        
+        The quality changes groups that are available do depend on the quality types that are available, so it must
+        still be known which extruders are enabled and which materials and variants are loaded in them. This allows
+        setting the correct is_available flag.
+
+        :param variant_names: The names of the variants loaded in each extruder.
+        :param material_bases: The base file names of the materials loaded in each extruder.
+        :param extruder_enabled: For each extruder whether or not they are enabled.
+
+        :return: List of all quality changes groups for the printer.
+        """
+
         machine_quality_changes = ContainerRegistry.getInstance().findContainersMetadata(type = "quality_changes", definition = self.quality_definition)  # All quality changes for each extruder.
 
         groups_by_name = {}  #type: Dict[str, QualityChangesGroup]  # Group quality changes profiles by their display name. The display name must be unique for quality changes. This finds profiles that belong together in a group.
@@ -147,18 +148,19 @@ class MachineNode(ContainerNode):
 
         return list(groups_by_name.values())
 
-    ##  Gets the preferred global quality node, going by the preferred quality
-    #   type.
-    #
-    #   If the preferred global quality is not in there, an arbitrary global
-    #   quality is taken.
-    #   If there are no global qualities, an empty quality is returned.
     def preferredGlobalQuality(self) -> "QualityNode":
+        """Gets the preferred global quality node, going by the preferred quality type.
+        
+        If the preferred global quality is not in there, an arbitrary global quality is taken. If there are no global
+        qualities, an empty quality is returned.
+        """
+
         return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
 
-    ##  (Re)loads all variants under this printer.
     @UM.FlameProfiler.profile
     def _loadAll(self) -> None:
+        """(Re)loads all variants under this printer."""
+
         container_registry = ContainerRegistry.getInstance()
         if not self.has_variants:
             self.variants["empty"] = VariantNode("empty_variant", machine = self)

+ 14 - 11
cura/Machines/MaterialGroup.py

@@ -7,18 +7,21 @@ if TYPE_CHECKING:
     from cura.Machines.MaterialNode import MaterialNode
 
 
-## A MaterialGroup represents a group of material InstanceContainers that are derived from a single material profile.
-# The main InstanceContainer which has the ID of the material profile file name is called the "root_material". For
-# example: "generic_abs" is the root material (ID) of "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4",
-# and "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4" are derived materials of "generic_abs".
-#
-# Using "generic_abs" as an example, the MaterialGroup for "generic_abs" will contain the following information:
-#  - name: "generic_abs", root_material_id
-#  - root_material_node: MaterialNode of "generic_abs"
-#  - derived_material_node_list: A list of MaterialNodes that are derived from "generic_abs",
-#                                so "generic_abs_ultimaker3", "generic_abs_ultimaker3_AA_0.4", etc.
-#
 class MaterialGroup:
+    """A MaterialGroup represents a group of material InstanceContainers that are derived from a single material profile.
+    
+    The main InstanceContainer which has the ID of the material profile file name is called the "root_material". For
+    example: "generic_abs" is the root material (ID) of "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4",
+    and "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4" are derived materials of "generic_abs".
+    
+    Using "generic_abs" as an example, the MaterialGroup for "generic_abs" will contain the following information:
+        - name: "generic_abs", root_material_id
+        - root_material_node: MaterialNode of "generic_abs"
+        - derived_material_node_list: A list of MaterialNodes that are derived from "generic_abs", so
+        "generic_abs_ultimaker3", "generic_abs_ultimaker3_AA_0.4", etc.
+    
+    """
+
     __slots__ = ("name", "is_read_only", "root_material_node", "derived_material_node_list")
 
     def __init__(self, name: str, root_material_node: "MaterialNode") -> None:

+ 28 - 21
cura/Machines/MaterialNode.py

@@ -15,10 +15,12 @@ if TYPE_CHECKING:
     from cura.Machines.VariantNode import VariantNode
 
 
-##  Represents a material in the container tree.
-#
-#   Its subcontainers are quality profiles.
 class MaterialNode(ContainerNode):
+    """Represents a material in the container tree.
+    
+    Its subcontainers are quality profiles.
+    """
+
     def __init__(self, container_id: str, variant: "VariantNode") -> None:
         super().__init__(container_id)
         self.variant = variant
@@ -34,16 +36,16 @@ class MaterialNode(ContainerNode):
         container_registry.containerRemoved.connect(self._onRemoved)
         container_registry.containerMetaDataChanged.connect(self._onMetadataChanged)
 
-    ##  Finds the preferred quality for this printer with this material and this
-    #   variant loaded.
-    #
-    #   If the preferred quality is not available, an arbitrary quality is
-    #   returned. If there is a configuration mistake (like a typo in the
-    #   preferred quality) this returns a random available quality. If there are
-    #   no available qualities, this will return the empty quality node.
-    #   \return The node for the preferred quality, or any arbitrary quality if
-    #   there is no match.
     def preferredQuality(self) -> QualityNode:
+        """Finds the preferred quality for this printer with this material and this variant loaded.
+        
+        If the preferred quality is not available, an arbitrary quality is returned. If there is a configuration
+        mistake (like a typo in the preferred quality) this returns a random available quality. If there are no
+        available qualities, this will return the empty quality node.
+
+        :return: The node for the preferred quality, or any arbitrary quality if there is no match.
+        """
+
         for quality_id, quality_node in self.qualities.items():
             if self.variant.machine.preferred_quality_type == quality_node.quality_type:
                 return quality_node
@@ -107,10 +109,13 @@ class MaterialNode(ContainerNode):
         if not self.qualities:
             self.qualities["empty_quality"] = QualityNode("empty_quality", parent = self)
 
-    ##  Triggered when any container is removed, but only handles it when the
-    #   container is removed that this node represents.
-    #   \param container The container that was allegedly removed.
     def _onRemoved(self, container: ContainerInterface) -> None:
+        """Triggered when any container is removed, but only handles it when the container is removed that this node
+        represents.
+
+        :param container: The container that was allegedly removed.
+        """
+
         if container.getId() == self.container_id:
             # Remove myself from my parent.
             if self.base_file in self.variant.materials:
@@ -119,13 +124,15 @@ class MaterialNode(ContainerNode):
                     self.variant.materials["empty_material"] = MaterialNode("empty_material", variant = self.variant)
             self.materialChanged.emit(self)
 
-    ##  Triggered when any metadata changed in any container, but only handles
-    #   it when the metadata of this node is changed.
-    #   \param container The container whose metadata changed.
-    #   \param kwargs Key-word arguments provided when changing the metadata.
-    #   These are ignored. As far as I know they are never provided to this
-    #   call.
     def _onMetadataChanged(self, container: ContainerInterface, **kwargs: Any) -> None:
+        """Triggered when any metadata changed in any container, but only handles it when the metadata of this node is
+        changed.
+
+        :param container: The container whose metadata changed.
+        :param kwargs: Key-word arguments provided when changing the metadata. These are ignored. As far as I know they
+        are never provided to this call.
+        """
+
         if container.getId() != self.container_id:
             return
 

+ 22 - 15
cura/Machines/Models/BaseMaterialsModel.py

@@ -13,11 +13,13 @@ from cura.Machines.ContainerTree import ContainerTree
 from cura.Machines.MaterialNode import MaterialNode
 from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
 
-## This is the base model class for GenericMaterialsModel and MaterialBrandsModel.
-#  Those 2 models are used by the material drop down menu to show generic materials and branded materials separately.
-#  The extruder position defined here is being used to bound a menu to the correct extruder. This is used in the top
-#  bar menu "Settings" -> "Extruder nr" -> "Material" -> this menu
 class BaseMaterialsModel(ListModel):
+    """This is the base model class for GenericMaterialsModel and MaterialBrandsModel.
+    
+    Those 2 models are used by the material drop down menu to show generic materials and branded materials
+    separately. The extruder position defined here is being used to bound a menu to the correct extruder. This is
+    used in the top bar menu "Settings" -> "Extruder nr" -> "Material" -> this menu
+    """
 
     extruderPositionChanged = pyqtSignal()
     enabledChanged = pyqtSignal()
@@ -121,10 +123,13 @@ class BaseMaterialsModel(ListModel):
     def enabled(self):
         return self._enabled
 
-    ##  Triggered when a list of materials changed somewhere in the container
-    #   tree. This change may trigger an _update() call when the materials
-    #   changed for the configuration that this model is looking for.
     def _materialsListChanged(self, material: MaterialNode) -> None:
+        """Triggered when a list of materials changed somewhere in the container
+        
+        tree. This change may trigger an _update() call when the materials changed for the configuration that this
+        model is looking for.
+        """
+
         if self._extruder_stack is None:
             return
         if material.variant.container_id != self._extruder_stack.variant.getId():
@@ -136,14 +141,15 @@ class BaseMaterialsModel(ListModel):
             return
         self._onChanged()
 
-    ##  Triggered when the list of favorite materials is changed.
     def _favoritesChanged(self, material_base_file: str) -> None:
+        """Triggered when the list of favorite materials is changed."""
+
         if material_base_file in self._available_materials:
             self._onChanged()
 
-    ##  This is an abstract method that needs to be implemented by the specific
-    #   models themselves.
     def _update(self):
+        """This is an abstract method that needs to be implemented by the specific models themselves. """
+
         self._favorite_ids = set(cura.CuraApplication.CuraApplication.getInstance().getPreferences().getValue("cura/favorite_materials").split(";"))
 
         # Update the available materials (ContainerNode) for the current active machine and extruder setup.
@@ -163,10 +169,10 @@ class BaseMaterialsModel(ListModel):
         approximate_material_diameter = extruder_stack.getApproximateMaterialDiameter()
         self._available_materials = {key: material for key, material in materials.items() if float(material.getMetaDataEntry("approximate_diameter", -1)) == approximate_material_diameter}
 
-    ## This method is used by all material models in the beginning of the
-    #  _update() method in order to prevent errors. It's the same in all models
-    #  so it's placed here for easy access.
     def _canUpdate(self):
+        """This method is used by all material models in the beginning of the _update() method in order to prevent
+        errors. It's the same in all models so it's placed here for easy access. """
+
         global_stack = self._machine_manager.activeMachine
         if global_stack is None or not self._enabled:
             return False
@@ -177,9 +183,10 @@ class BaseMaterialsModel(ListModel):
 
         return True
 
-    ## This is another convenience function which is shared by all material
-    #  models so it's put here to avoid having so much duplicated code.
     def _createMaterialItem(self, root_material_id, container_node):
+        """This is another convenience function which is shared by all material models so it's put here to avoid having
+         so much duplicated code. """
+
         metadata_list = CuraContainerRegistry.getInstance().findContainersMetadata(id = container_node.container_id)
         if not metadata_list:
             return None

+ 1 - 2
cura/Machines/Models/CustomQualityProfilesDropDownMenuModel.py

@@ -14,9 +14,8 @@ if TYPE_CHECKING:
     from UM.Settings.Interfaces import ContainerInterface
 
 
-##  This model is used for the custom profile items in the profile drop down
-#   menu.
 class CustomQualityProfilesDropDownMenuModel(QualityProfilesDropDownMenuModel):
+    """This model is used for the custom profile items in the profile drop down menu."""
 
     def __init__(self, parent: Optional["QObject"] = None) -> None:
         super().__init__(parent)

+ 16 - 10
cura/Machines/Models/DiscoveredCloudPrintersModel.py

@@ -9,9 +9,9 @@ if TYPE_CHECKING:
 
 
 class DiscoveredCloudPrintersModel(ListModel):
-    """
-    Model used to inform the application about newly added cloud printers, which are discovered from the user's account
-    """
+    """Model used to inform the application about newly added cloud printers, which are discovered from the user's
+     account """
+
     DeviceKeyRole = Qt.UserRole + 1
     DeviceNameRole = Qt.UserRole + 2
     DeviceTypeRole = Qt.UserRole + 3
@@ -31,18 +31,24 @@ class DiscoveredCloudPrintersModel(ListModel):
         self._application = application  # type: CuraApplication
 
     def addDiscoveredCloudPrinters(self, new_devices: List[Dict[str, str]]) -> None:
-        """
-        Adds all the newly discovered cloud printers into the DiscoveredCloudPrintersModel.
+        """Adds all the newly discovered cloud printers into the DiscoveredCloudPrintersModel.
+
+        Example new_devices entry:
+
+        .. code-block:: python
 
-        :param new_devices: List of dictionaries which contain information about added cloud printers. Example:
         {
             "key": "YjW8pwGYcaUvaa0YgVyWeFkX3z",
             "name": "NG 001",
             "machine_type": "Ultimaker S5",
             "firmware_version": "5.5.12.202001"
         }
+
+        :param new_devices: List of dictionaries which contain information about added cloud printers.
+
         :return: None
         """
+
         self._discovered_cloud_printers_list.extend(new_devices)
         self._update()
 
@@ -51,21 +57,21 @@ class DiscoveredCloudPrintersModel(ListModel):
 
     @pyqtSlot()
     def clear(self) -> None:
-        """
-        Clears the contents of the DiscoveredCloudPrintersModel.
+        """Clears the contents of the DiscoveredCloudPrintersModel.
 
         :return: None
         """
+
         self._discovered_cloud_printers_list = []
         self._update()
         self.cloudPrintersDetectedChanged.emit(False)
 
     def _update(self) -> None:
-        """
-        Sorts the newly discovered cloud printers by name and then updates the ListModel.
+        """Sorts the newly discovered cloud printers by name and then updates the ListModel.
 
         :return: None
         """
+
         items = self._discovered_cloud_printers_list[:]
         items.sort(key = lambda k: k["name"])
         self.setItems(items)

Some files were not shown because too many files changed in this diff