Peter Ward avatar Peter Ward committed ff0252c

write calling code, start on themes

Comments (0)

Files changed (2)

docs/fake/shinypress/theme.py

+class Theme(object):
+    """
+    Describes how the handlers should render their content.
+    """
+    @classmethod
+    def from_json(cls, f):
+        """
+        Load a theme specification from a JSON file.
+
+        :param f: file object
+        """
+
+    def get_block_size(self, template, block):
+        """
+        Get the size of the given block in the named template.
+
+        :param template: name of the template
+        :param block: name of the block
+        :rtype: (width, height) tuple
+        """
+        pass
+
 
 This section describes the interaction between handlers and themes.
 
+Usage
+~~~~~
+
+To render multiple handlers:
+
+.. code-block:: python
+
+    import cairo
+
+    from shinypress.theme import Theme
+
+    with open('my-theme.json', 'rb') as f:
+        theme = Theme.from_json(f)
+
+    surf = cairo.PDFSurface('slides.pdf', 1024, 768)
+    ctx = cairo.Context(surf)
+
+    for handler in handlers:
+        slide_layouts = handler.layout(theme)
+        for template, blocks in slide_layouts:
+            theme.render(template, blocks)
+            surf.show_page()
+
 Handlers
 ~~~~~~~~
 
 Themes
 ~~~~~~
+
+Themes are responsible for deciding where the handlers should draw their blocks.
+
+.. automodule:: shinypress.theme
+    :members:
+
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.