Added more doc strings and python recommended type checking. py33
authorbenechols-wf <ben.echols@webfilings.com>
Tue, 09 Jul 2013 11:48:13 -0600
branchpy33
changeset 3743 28c74eda3bcc
parent 3742 73fc407f4d7a
child 3744 3fc3de7a46de
Added more doc strings and python recommended type checking.
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/pdfgen/canvas.py
--- a/src/reportlab/pdfbase/pdfdoc.py	Tue Jul 09 11:38:52 2013 -0600
+++ b/src/reportlab/pdfbase/pdfdoc.py	Tue Jul 09 11:48:13 2013 -0600
@@ -1711,7 +1711,12 @@
 
 class HighlightAnnotation(Annotation):
     """
-    HighlightAnnotation adds a highlighted
+    HighlightAnnotation is an annotation that highlights the selected area.
+
+    Rect is the mouseover area that will show the contents.
+
+    QuadPoints is a list of points to highlight, you can have many groups of
+    four QuadPoints to allow highlighting many lines.
     """
     permitted = Annotation.permitted + ("QuadPoints", )
 
@@ -1727,13 +1732,13 @@
         Rect = d["Rect"]
         Quad = d["QuadPoints"]
         Color = d["C"]
-        if type(Rect) is not types.StringType:
+        if not isinstance(Rect, str):
             d["Rect"] = PDFArray(Rect)
-        if type(Quad) is not types.StringType:
+        if not isinstance(Quad, str):
             d["QuadPoints"] = PDFArray(Quad)
-        if type(Color) is not types.StringType:
+        if not isinstance(Color, str):
             d["C"] = PDFArray(Color)
-        d["Contents"] = PDFString(d["Contents"],escape)
+        d["Contents"] = PDFString(d["Contents"], escape)
         return d
 
     def Dict(self):
--- a/src/reportlab/pdfgen/canvas.py	Tue Jul 09 11:38:52 2013 -0600
+++ b/src/reportlab/pdfgen/canvas.py	Tue Jul 09 11:48:13 2013 -0600
@@ -1099,6 +1099,16 @@
 
     def highlightAnnotation(self, contents, Rect, QuadPoints=None, Color=[0.83, 0.89, 0.95], addtopage=1,
                             name=None, relative=0, **kw):
+        """
+        Allows adding of a highlighted annotation.
+
+        Rect: Mouseover area to show contents of annotation
+        QuadPoints: List of four x/y points in counter-clockwise order to highlight areas.
+          You can have multiple groups of four to allow multiple highlighted areas.
+          Is in the format [x1, y1, x2, y2, x3, y3, x4, y4, x1, y1, x2, y2, x3, y3, x4, y4] etc
+          Default is to be area inside of Rect
+        Color: The color of the highlighting.
+        """
         Rect = self._absRect(Rect, relative)
         if not QuadPoints:
             QuadPoints = pdfdoc.rect_to_quad(Rect)