Manfred Moitzi avatar Manfred Moitzi committed 80115df

added docs for the style element; edit other docs

Comments (0)

Files changed (6)

doc/classes/drawing.rst

 
    `string` should be valid for :func:`open`.
 
+.. attribute:: Drawing.defs
+
+   SVG defs section - as :class:`~svgwrite.container.Defs` object.
+
 Methods
 -------
 
 Factory Methods
 ---------------
 
-.. method:: Drawing.line(start=(0, 0), end=(0, 0), attribs=None, \*\*extra)
+.. method:: Drawing.line(start=(0, 0), end=(0, 0), \*\*extra)
 
    Create a :class:`svgwrite.shapes.Line` object.
 
-.. method:: Drawing.rect(insert=(0, 0), size=(1, 1), rx=None, ry=None, attribs=None, \*\*extra)
+.. method:: Drawing.rect(insert=(0, 0), size=(1, 1), rx=None, ry=None, \*\*extra)
 
    Create a :class:`svgwrite.shapes.Rect` object.
 
-.. method:: Drawing.circle(center=(0, 0), r=1, attribs=None, \*\*extra)
+.. method:: Drawing.circle(center=(0, 0), r=1, \*\*extra)
 
    Create a :class:`svgwrite.shapes.Circle` object.
 
-.. method:: Drawing.ellipse(center=(0, 0), r=(1, 1), attribs=None, \*\*extra)
+.. method:: Drawing.ellipse(center=(0, 0), r=(1, 1), \*\*extra)
 
    Create a :class:`svgwrite.shapes.Ellipse` object.
 
-.. method:: Drawing.polyline(points=[], attribs=None, \*\*extra)
+.. method:: Drawing.polyline(points=[], \*\*extra)
 
    Create a :class:`svgwrite.shapes.Polyline` object.
 
-.. method:: Drawing.polygon(points=[], attribs=None, \*\*extra)
+.. method:: Drawing.polygon(points=[], \*\*extra)
 
    Create a :class:`svgwrite.shapes.Polygon` object.
 
-.. method:: Drawing.text(text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[], attribs=None, \*\*extra)
+.. method:: Drawing.text(text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[], \*\*extra)
 
    Create a :class:`svgwrite.text.Text` object.
 
-.. method:: Drawing.tspan(text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[], attribs=None, \*\*extra)
+.. method:: Drawing.tspan(text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[], \*\*extra)
 
    Create a :class:`svgwrite.text.TSpan` object.
 
-.. method:: Drawing.tref(element, attribs=None, \*\*extra)
+.. method:: Drawing.tref(element, \*\*extra)
 
    Create a :class:`svgwrite.text.TRef` object.
 
-.. method:: Drawing.textPath(path, text, startOffset=None, method='align', spacing='exact', attribs=None, \*\*extra)
+.. method:: Drawing.textPath(path, text, startOffset=None, method='align', spacing='exact', \*\*extra)
 
    Create a :class:`svgwrite.text.TextPath` object.
 
-.. method:: Drawing.textArea(text=None, insert=None, size=None, attribs={}, \*\*extra)
+.. method:: Drawing.textArea(text=None, insert=None, size=None, \*\*extra)
 
    Create a :class:`svgwrite.text.TextArea` object.
 
-.. method:: Drawing.path(d=None, attribs=None, \*\*extra)
+.. method:: Drawing.path(d=None, \*\*extra)
 
    Create a :class:`svgwrite.path.Path` object.
 
-.. method:: Drawing.image(href, insert=None, size=None, attribs=None, \*\*extra)
+.. method:: Drawing.image(href, insert=None, size=None, \*\*extra)
 
    Create a :class:`svgwrite.image.Image` object.
 
-.. method:: Drawing.g(attribs=None, \*\*extra)
+.. method:: Drawing.g(\*\*extra)
 
    Create a :class:`svgwrite.container.Group` object.
 
-.. method:: Drawing.defs(attribs=None, \*\*extra)
-
-   Create a :class:`svgwrite.container.Defs` object.
-
-.. method:: Drawing.symbol(attribs=None, \*\*extra)
+.. method:: Drawing.symbol(\*\*extra)
 
    Create a :class:`svgwrite.container.Symbol` object.
 
-.. method:: Drawing.svg(insert=None, size=None, attribs=None, \*\*extra)
+.. method:: Drawing.svg(insert=None, size=None, \*\*extra)
 
    Create a :class:`svgwrite.container.SVG` object.
 
-.. method:: Drawing.use(href, insert=None, size=None, attribs=None, \*\*extra)
+.. method:: Drawing.use(href, insert=None, size=None, \*\*extra)
 
    Create a :class:`svgwrite.container.Use` object.
 
-.. method:: Drawing.a(href, target='_blank', attribs=None, \*\*extra)
+.. method:: Drawing.a(href, target='_blank', \*\*extra)
 
    Create a :class:`svgwrite.container.Hyperlink` object.
 
-.. method:: Drawing.marker(insert=None, size=None, orient=None, attribs=None, \*\*extra)
+.. method:: Drawing.marker(insert=None, size=None, orient=None, \*\*extra)
 
    Create a :class:`svgwrite.container.Marker` object.
 
-.. method:: Drawing.linearGradient(start=None, end=None, inherit=None, attribs=None, \*\*extra)
+.. method:: Drawing.script(href=None, content='', \*\*extra)
+
+   Create a :class:`svgwrite.container.Script` object.
+
+.. method:: Drawing.style(content='', \*\*extra)
+
+   Create a :class:`svgwrite.container.Style` object.
+
+.. method:: Drawing.linearGradient(start=None, end=None, inherit=None, \*\*extra)
 
    Create a :class:`svgwrite.gradients.LinearGradient` object.
 
-.. method:: Drawing.radialGradient(center=None, r=None, focal=None, inherit=None, attribs=None, \*\*extra)
+.. method:: Drawing.radialGradient(center=None, r=None, focal=None, inherit=None, \*\*extra)
 
    Create a :class:`svgwrite.gradients.RadialGradient` object.
 

doc/classes/script.rst

 Script
-=========
+======
 
-The **script** element indicate links to a client-side language.
+The *script* element indicate links to a client-side language.
 
 .. autoclass:: svgwrite.container.Script
 
 
 .. automethod:: svgwrite.container.Script.__init__
 
+.. automethod:: svgwrite.container.Script.append
+
+Best place for the *script* element is the *defs* attribute of the
+:class:`~svgwrite.drawing.Drawing` class::
+
+    drawing.defs.add(drawing.script('script-content'))
+
 Parent Classes
 --------------
 
 * :class:`svgwrite.base.BaseElement`
-* :class:`svgwrite.mixins.Presentation`
 
 SVG Attributes
 --------------

doc/classes/style.rst

+Style
+=====
+
+Internal Stylesheets
+
+.. autoclass:: svgwrite.container.Style
+
+.. seealso:: http://www.w3.org/TR/SVG/styling.html#StyleElement
+
+.. automethod:: svgwrite.container.Style.__init__
+
+.. automethod:: svgwrite.container.Style.append
+
+Best place for the *style* element is the *defs* attribute of the
+:class:`~svgwrite.drawing.Drawing` class::
+
+    drawing.defs.add(drawing.style('stylesheet-content'))
+
+Parent Classes
+--------------
+
+* :class:`svgwrite.base.BaseElement`
+
+SVG Attributes
+--------------
+
+* **type** -- `string`
+
+  default is ``'text/css'``
+
+* **title** -- `string`
+
+  (For compatibility with HTML 4.) This attribute specifies an advisory
+  title for the ‘style’ element.
+
+* **media** -- `string`
+
+  This attribute specifies the intended destination medium for style information.
+  It may be a single media descriptor or a comma-separated list.
+  The default value for this attribute is ``'all'``.
+
+Standard SVG Attributes
+-----------------------
+
+* :doc:`Core Attributes </attributes/core>`
+* :doc:`Conditional Processing Attributes </attributes/conditional_processing>`
+* :doc:`Graphical Event Attributes </attributes/graphical_event>`
+* :doc:`Presentation Attributes </attributes/presentation>`
+* :doc:`XLink Attributes </attributes/xlink>`
    classes/use
    classes/hyperlink
    classes/script
+   classes/style
 
 Graphical Objects
 -----------------

svgwrite/container.py

     within the SVG file by catching events or adding the mouseover/mousedown/
     mouseup elements to the markup.
 
-    usage: drawing.defs.add(drawing.script(...))
     """
 
     elementname = 'script'
         return xml
 
     def append(self, content):
+        """ Append content to the existing element-content. """
         self._content += content
 
 class Style(Script):
-    """
-    Create an inline stylesheet.
+    """ The *style* element allows style sheets to be embedded directly within
+    SVG content. SVG's *style* element has the same attributes as the
+    corresponding element in HTML.
 
-    usage: drawing.defs.add(drawing.style(...))
     """
     elementname = 'style'
     def __init__(self, content="", **extra):
         """
-        :param string content: stylsheet content
+        :param string content: stylesheet content
         """
         super(Style, self).__init__(content=content, **extra)
         self['type'] = "text/css"

svgwrite/drawing.py

 # Copyright (C) 2010, Manfred Moitzi
 # License: GPLv3
 """
-The **Drawing** object is the overall container for all SVG
+The *Drawing* object is the overall container for all SVG
 elements. It provides the methods to store the drawing into a file or a
 file-like object. If you want to use stylesheets, the reference links
 to this stylesheets were also stored (`add_stylesheet`)
-in the **Drawing** object.
+in the *Drawing* object.
 
 set/get SVG attributes::
 
     element['attribute'] = value
     value = element['attribute']
 
-.. seealso:: :ref:`Common SVG Attributes <Common-SVG-Attributes>`
+The Drawing object also includes a defs section, add elements to the defs
+section by::
+
+    drawing.defs.add(element)
 
 """
 from __future__ import unicode_literals
 from svgwrite.elementfactory import ElementFactory
 
 class Drawing(SVG, ElementFactory):
-    """ This is the SVG drawing represented by the top level **svg** element.
+    """ This is the SVG drawing represented by the top level *svg* element.
 
     A drawing consists of any number of SVG elements contained within the drawing
-    element, stored in the **elements** attribute.
+    element, stored in the *elements* attribute.
 
     A drawing can range from an empty drawing (i.e., no content inside of the drawing),
-    to a very simple drawing containing a single SVG element such as a **rect**,
+    to a very simple drawing containing a single SVG element such as a *rect*,
     to a complex, deeply nested collection of container elements and graphics elements.
     """
     def __init__(self, filename="noname.svg", size=('100%', '100%'), **extra):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.