You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by rj...@apache.org on 2013/05/20 01:30:07 UTC

svn commit: r1484367 - in /bloodhound/trunk/bloodhound_dashboard/bhdashboard: api.py widgets/templates/widget_doc.html

Author: rjollos
Date: Sun May 19 23:30:07 2013
New Revision: 1484367

URL: http://svn.apache.org/r1484367
Log:
Refs #531: Improved styling and layout of widget documentation. Patch by Olemis.

Modified:
    bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py
    bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_doc.html

Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py?rev=1484367&r1=1484366&r2=1484367&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py (original)
+++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py Sun May 19 23:30:07 2013
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: UTF-8 -*-
+from inspect import isclass
 
 #  Licensed to the Apache Software Foundation (ASF) under one
 #  or more contributor license agreements.  See the NOTICE file
@@ -37,6 +38,7 @@ from trac.resource import get_resource_u
 from trac.util.compat import set
 from trac.util.datefmt import parse_date
 from trac.util.translation import _
+from trac.web.chrome import add_stylesheet
 
 #--------------------------------------
 # Core classes and interfaces
@@ -151,6 +153,7 @@ class DashboardSystem(Component):
         """Render widget considering given options.
         """
         if name == 'WidgetDoc':
+            add_stylesheet(context.req, 'dashboard/css/docs.css')
             widget_name, = self.bind_params(options,
                     self.get_widget_params(name), 'urn')
             if widget_name is not None:
@@ -198,7 +201,8 @@ class DashboardSystem(Component):
     def widget_metadata(self, nm, provider=None):
         """Retrieve widget metadata.
 
-        :param nm:        Widget name
+        :param nm:        Wid
+        get name
         :param provider:  Widget provider. If omitted it will be resolved.
         """
         if provider is None:
@@ -213,9 +217,20 @@ class DashboardSystem(Component):
         """Transform widget metadata into a format suitable to render
         documentation.
         """
+        def plabel(p):
+            v = p.get('type', str)
+            module = getattr(v, '__module__', None)
+            if module in (None, '__builtin__'):
+                return getattr(v, '__name__', None) or v
+            else:
+                # FIXME: Improve e.g. for enum fields
+                if not isclass(v):
+                    v = v.__class__
+                return tag.span(v.__name__, title='in ' + module)
+
         return {
                 'id' : "%s-widget" % (spec['urn'],),
-                'title' : tag.code(spec['urn']),
+                'title' : spec['urn'],
                 'desc' : '\n'.join(l.strip() 
                                    for l in spec['desc'].splitlines()),
                 'sections' : [
@@ -228,7 +243,7 @@ class DashboardSystem(Component):
                                                 l.strip() for l in \
                                                 p.get('desc').splitlines()),
                                         'details' : [
-                                                ('Type', p.get('type', str)),
+                                                ('Type', plabel(p)),
                                                 ('Required', p.get('required',
                                                                    False)),
                                                 ('Default', p.get('default')),
@@ -239,6 +254,7 @@ class DashboardSystem(Component):
                     ]
             }
 
+
     def bind_params(self, options, spec, *params):
         """Extract values for widget arguments from `options` and ensure 
         they are valid and properly formatted.

Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_doc.html
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_doc.html?rev=1484367&r1=1484366&r2=1484367&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_doc.html (original)
+++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_doc.html Sun May 19 23:30:07 2013
@@ -24,29 +24,26 @@
     py:strip="">
 
   <py:for each="item in items">
-    <h3 py:attrs="{ 'id' : item.get('id')}">${item.title}</h3>
+    <h3 py:attrs="{'id': item.get('id')}" class="hblock">${item.title}</h3>
     ${wiki_to_html(context, item.desc)}
     <py:if test="item.sections">
       <py:for each="section in item.sections">
-        <h6>${section.title}</h6>
-        <py:for each="subitem in section.entries">
-          <div class="row">
-            <div class="span2">
-              <span class="label label-inverse">${subitem.caption}</span>
-            </div>
-            <div class="offset2">
-              ${wiki_to_html(context, subitem.summary)}
-            </div>
-          </div>
-          <dl class="dl-horizontal" py:if="subitem.details">
-            <py:for each="row in subitem.details">
-              <py:if test="row[1]">
-                <dt style="line-height: 21px"><span class="label">${row[0]}</span></dt>
-                <dd style="line-height: 21px">${row[1]}</dd>
-              </py:if>
-            </py:for>
-          </dl>
-        </py:for>
+        <div><span class="label label-inverse">${section.title}</span></div>
+        <dl class="dl-horizontal">
+          <py:for each="subitem in section.entries">
+            <dt>${subitem.caption}</dt>
+            <dd>${wiki_to_html(context, subitem.summary)}
+              <p py:if="subitem.details">
+                <py:for each="i, row in enumerate(subitem.details)">
+                  <py:if test="row[1]">
+                    <span class="text-success">${row[0]}</span> :
+                    <span class="muted">${row[1]}</span>
+                  </py:if>
+                </py:for>
+              </p>
+            </dd>
+          </py:for>
+        </dl>
       </py:for>
     </py:if>
   </py:for>