DraftGeomUtils: Doctstring formatting

Adress vocx-fc's review
This commit is contained in:
alafr
2020-06-15 19:56:47 +02:00
parent 2ae2129383
commit 3186ddd029
4 changed files with 18 additions and 14 deletions

View File

@@ -223,8 +223,8 @@ def getTangent(edge, from_point=None):
def get_referenced_edges(property_value):
""" Returns the Edges referenced by the value of a App:PropertyLink, App::PropertyLinkList,
App::PropertyLinkSub or App::PropertyLinkSubList property. """
"""Return the Edges referenced by the value of a App:PropertyLink, App::PropertyLinkList,
App::PropertyLinkSub or App::PropertyLinkSubList property."""
edges = []
if not isinstance(property_value, list):
property_value = [property_value]

View File

@@ -60,9 +60,11 @@ def precision():
def vec(edge, use_orientation = False):
""" vec(edge[, use_orientation]) or vec(line): returns a vector from an edge or a Part.LineSegment.
If use_orientation is True, it takes into account the edges orientation.
If edge is not straight, you'll get strange results! """
"""Return a vector from an edge or a Part.LineSegment.
If use_orientation is True, it takes into account the edges orientation.
If edge is not straight, you'll get strange results!
"""
if isinstance(edge, Part.Edge):
if edge.Orientation == "Forward" or not use_orientation:
return edge.Vertexes[-1].Point.sub(edge.Vertexes[0].Point)

View File

@@ -436,7 +436,7 @@ def tessellateProjection(shape, seglen):
return Part.makeCompound(newedges)
def get_placement_perpendicular_to_wire(wire):
""" Returns the placement whose base is the wire's first vertex and it's z axis aligned to the wire's tangent. """
"""Return the placement whose base is the wire's first vertex and it's z axis aligned to the wire's tangent."""
pl = FreeCAD.Placement()
if wire.Length > 0.0:
pl.Base = wire.OrderedVertexes[0].Point
@@ -452,9 +452,11 @@ def get_placement_perpendicular_to_wire(wire):
def get_extended_wire(wire, offset_start, offset_end):
""" Returns a wire trimmed (negative offset) or extended (positive offset) at its first vertex, last vertex or both ends.
get_extended_wire(wire, -100.0, 0.0) -> returns a copy of the wire with its first 100 mm removed
get_extended_wire(wire, 0.0, 100.0) -> returns a copy of the wire extended by 100 mm after it's last vertex """
"""Return a wire trimmed (negative offset) or extended (positive offset) at its first vertex, last vertex or both ends.
get_extended_wire(wire, -100.0, 0.0) -> returns a copy of the wire with its first 100 mm removed
get_extended_wire(wire, 0.0, 100.0) -> returns a copy of the wire extended by 100 mm after it's last vertex
"""
if min(offset_start, offset_end, offset_start + offset_end) <= -wire.Length:
FreeCAD.Console.PrintError("debug: get_extended_wire error, wire's length insufficient for trimming.\n")
return wire

View File

@@ -1,4 +1,3 @@
""" Unit test for the DraftGeomUtils module. """
# ***************************************************************************
# * Copyright (c) 2020 Antoine Lafr *
# * *
@@ -21,6 +20,7 @@
# * USA *
# * *
# ***************************************************************************
"""Unit test for the DraftGeomUtils module."""
import unittest
import FreeCAD
@@ -30,14 +30,14 @@ import drafttests.auxiliary as aux
from draftutils.messages import _msg
class TestDraftGeomUtils(unittest.TestCase):
""" Testing the functions in the file DraftGeomUtils.py """
"""Testing the functions in the file DraftGeomUtils.py"""
def setUp(self):
""" Prepare the test. Nothing to do here, DraftGeomUtils doesn't need a document. """
"""Prepare the test. Nothing to do here, DraftGeomUtils doesn't need a document."""
aux.draw_header()
def test_get_extended_wire(self):
""" Test the DraftGeomUtils.get_extended_wire function. """
"""Test the DraftGeomUtils.get_extended_wire function."""
operation = "DraftGeomUtils.get_extended_wire"
_msg(" Test '{}'".format(operation))
@@ -135,7 +135,7 @@ class TestDraftGeomUtils(unittest.TestCase):
_msg(" Test completed, {} subtests run".format(num_subtests))
def tearDown(self):
""" Finish the test. Nothing to do here, DraftGeomUtils doesn't need a document. """
"""Finish the test. Nothing to do here, DraftGeomUtils doesn't need a document."""
pass
# suite = unittest.defaultTestLoader.loadTestsFromTestCase(TestDraftGeomUtils)