Commits

Kirill Simonov committed 941a35e

Updated `htrafdemo` extension to use `sphinxcontrib` namespace package.

  • Participants
  • Parent commits d312f5a

Comments (0)

Files changed (8)

 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.ifconfig',
-              'sphinxext_htsqldoc', 'sphinxext_htrafdemo']
+              'sphinxcontrib.htsqldoc', 'sphinxcontrib.htrafdemo']
 
 # The default URL of an HTSQL service.
 htsql_server = 'http://demo.htsql.org'

doc/extensions/sphinxcontrib/__init__.py

+__import__('pkg_resources').declare_namespace(__name__)

doc/extensions/sphinxcontrib/htrafdemo/__init__.py

+
+from docutils import nodes
+from docutils.parsers.rst import Directive, directives
+from sphinx.util.osutil import copyfile
+
+from urllib import urlopen
+import os.path
+
+
+JQUERY_URL = "http://code.jquery.com/jquery-1.5.2.min.js"
+
+
+class DemoDirective(Directive):
+
+    has_content = True
+    option_spec = {
+            'source': directives.flag,
+            'hide': directives.flag,
+    }
+
+    def run(self):
+        wrapper = nodes.compound(classes=['demo-block'])
+        data = "\n".join(self.content)
+        demo = nodes.raw(data, data,
+                         format='html',
+                         classes=['demo-area'])
+        source = nodes.literal_block(data, data,
+                                     language='html',
+                                     classes=['demo-source'])
+        switch = nodes.literal(classes=['demo-switch'])
+        if 'source' not in self.options:
+            if 'hide' not in self.options:
+                switch += nodes.Text("[- view source]")
+            else:
+                switch += nodes.Text("[+ view source]")
+                source['classes'].append('demo-hide')
+            wrapper += demo
+            wrapper += switch
+            wrapper += source
+        else:
+            if 'hide' not in self.options:
+                switch += nodes.Text("[- view demo]")
+            else:
+                switch += nodes.Text("[+ view demo]")
+                demo['classes'].append('demo-hide')
+            wrapper += source
+            wrapper += switch
+            wrapper += demo
+        return [wrapper]
+
+
+def copy_static(app, exception):
+    if app.builder.name != 'html' or exception:
+        return
+    src_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static')
+    dst_dir = os.path.join(app.builder.outdir, '_static')
+    for filename in os.listdir(src_dir):
+        src = os.path.join(src_dir, filename)
+        if not os.path.isfile(src):
+            continue
+        dst = os.path.join(dst_dir, filename)
+        copyfile(src, dst)
+    data = urlopen(JQUERY_URL).read()
+    open(os.path.join(dst_dir, 'jquery.js'), 'w').write(data)
+
+
+def setup(app):
+    app.add_directive('demo', DemoDirective)
+    app.connect('build-finished', copy_static)
+    app.add_stylesheet('htrafdemo.css')
+    app.add_javascript('htrafdemo.js')
+
+

doc/extensions/sphinxcontrib/htrafdemo/static/htrafdemo.css

+
+div.demo-block {
+  margin: 1em 0 0;
+}
+
+div.demo-block tt.demo-switch {
+  cursor: pointer;
+  font-size: 95%;
+  background-color: inherit;
+}
+
+div.demo-block div.demo-area {
+/*  background-color: yellow; */
+}
+
+/* div.demo-block div.demo-source {
+  display: none;
+}*/
+
+div.demo-block div.demo-hide {
+  display: none;
+}
+
+div.body .demo-area h3 {
+  margin: 1em 0 0;
+  padding: 0;
+  font-family: inherit;
+  font-weight: bold;
+  font-size: 105%;
+  color: #900;
+  background: transparent;
+  border: none;
+}
+
+div.body .demo-area em.htraf,
+div.body .demo-area strong.htraf {
+  color: #369;
+}
+
+div.body .demo-area table.htraf {
+	border-collapse: collapse;
+	border-spacing: 0;
+  border-left: 2px solid #ddd;
+  border-right: 2px solid #ddd;
+  border-bottom: 2px solid #ddd;
+}
+
+div.body .demo-area table.htraf th,
+div.body .demo-area table td {
+  padding: 4px 6px;
+  font-size: 90%;
+  vertical-align: top;
+}
+
+div.body .demo-area table.htraf th {
+  background: #ddd;
+  font-weight: bold;
+  color: #555;
+}
+
+div.body .demo-area table.htraf td {
+  border-right: 1px solid #ddd;
+  border-bottom: 1px solid #ddd;
+}
+
+div.body .demo-area ul.htraf,
+div.body .demo-area ol.htraf,
+div.body .demo-area dl.htraf {
+  border-left: 6px solid #ddd;
+  padding-left: 0.5em;
+}
+
+div.body .demo-area ul.htraf li,
+div.body .demo-area ol.htraf li,
+div.body .demo-area dl.htraf dt {
+  margin: 0;
+  list-style-position: inside;
+}
+
+div.body .demo-area dl.htraf dd {
+  margin: 0 0 0 1em;
+}
+
+div.body .demo-area .htraf-hover {
+  background: #f6ddaf;
+}
+
+div.body .demo-area .htraf-selected {
+  background: #ffa43f;
+}
+

doc/extensions/sphinxcontrib/htrafdemo/static/htrafdemo.js

+
+
+
+$(function () {
+    $('.demo-switch').click(function () {
+        var text = $(this).text()
+        if (text == '[+ view source]') {
+            $(this).next('.demo-source').slideDown('fast');
+            $(this).text('[- view source]');
+        }
+        else if (text == '[- view source]') {
+            $(this).next('.demo-source').slideUp('fast');
+            $(this).text('[+ view source]');
+        }
+        else if (text == '[+ view demo]') {
+            $(this).next('.demo-area').slideDown('fast');
+            $(this).text('[- view demo]');
+        }
+        else if (text == '[- view demo]') {
+            $(this).next('.demo-area').slideUp('fast');
+            $(this).text('[+ view demo]');
+        }
+    });
+});
+
+

doc/extensions/sphinxext_htrafdemo/__init__.py

-
-from docutils import nodes
-from docutils.parsers.rst import Directive, directives
-from sphinx.util.osutil import copyfile
-
-from urllib import urlopen
-import os.path
-
-
-JQUERY_URL = "http://code.jquery.com/jquery-1.5.2.min.js"
-
-
-class DemoDirective(Directive):
-
-    has_content = True
-    option_spec = {
-            'source': directives.flag,
-            'hide': directives.flag,
-    }
-
-    def run(self):
-        wrapper = nodes.compound(classes=['demo-block'])
-        data = "\n".join(self.content)
-        demo = nodes.raw(data, data,
-                         format='html',
-                         classes=['demo-area'])
-        source = nodes.literal_block(data, data,
-                                     language='html',
-                                     classes=['demo-source'])
-        switch = nodes.literal(classes=['demo-switch'])
-        if 'source' not in self.options:
-            if 'hide' not in self.options:
-                switch += nodes.Text("[- view source]")
-            else:
-                switch += nodes.Text("[+ view source]")
-                source['classes'].append('demo-hide')
-            wrapper += demo
-            wrapper += switch
-            wrapper += source
-        else:
-            if 'hide' not in self.options:
-                switch += nodes.Text("[- view demo]")
-            else:
-                switch += nodes.Text("[+ view demo]")
-                demo['classes'].append('demo-hide')
-            wrapper += source
-            wrapper += switch
-            wrapper += demo
-        return [wrapper]
-
-
-def copy_static(app, exception):
-    if app.builder.name != 'html' or exception:
-        return
-    src_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static')
-    dst_dir = os.path.join(app.builder.outdir, '_static')
-    for filename in os.listdir(src_dir):
-        src = os.path.join(src_dir, filename)
-        if not os.path.isfile(src):
-            continue
-        dst = os.path.join(dst_dir, filename)
-        copyfile(src, dst)
-    data = urlopen(JQUERY_URL).read()
-    open(os.path.join(dst_dir, 'jquery.js'), 'w').write(data)
-
-
-def setup(app):
-    app.add_directive('demo', DemoDirective)
-    app.connect('build-finished', copy_static)
-    app.add_stylesheet('htrafdemo.css')
-    app.add_javascript('htrafdemo.js')
-
-

doc/extensions/sphinxext_htrafdemo/static/htrafdemo.css

-
-div.demo-block {
-  margin: 1em 0 0;
-}
-
-div.demo-block tt.demo-switch {
-  cursor: pointer;
-  font-size: 95%;
-  background-color: inherit;
-}
-
-div.demo-block div.demo-area {
-/*  background-color: yellow; */
-}
-
-/* div.demo-block div.demo-source {
-  display: none;
-}*/
-
-div.demo-block div.demo-hide {
-  display: none;
-}
-
-div.body .demo-area h3 {
-  margin: 1em 0 0;
-  padding: 0;
-  font-family: inherit;
-  font-weight: bold;
-  font-size: 105%;
-  color: #900;
-  background: transparent;
-  border: none;
-}
-
-div.body .demo-area em.htraf,
-div.body .demo-area strong.htraf {
-  color: #369;
-}
-
-div.body .demo-area table.htraf {
-	border-collapse: collapse;
-	border-spacing: 0;
-  border-left: 2px solid #ddd;
-  border-right: 2px solid #ddd;
-  border-bottom: 2px solid #ddd;
-}
-
-div.body .demo-area table.htraf th,
-div.body .demo-area table td {
-  padding: 4px 6px;
-  font-size: 90%;
-  vertical-align: top;
-}
-
-div.body .demo-area table.htraf th {
-  background: #ddd;
-  font-weight: bold;
-  color: #555;
-}
-
-div.body .demo-area table.htraf td {
-  border-right: 1px solid #ddd;
-  border-bottom: 1px solid #ddd;
-}
-
-div.body .demo-area ul.htraf,
-div.body .demo-area ol.htraf,
-div.body .demo-area dl.htraf {
-  border-left: 6px solid #ddd;
-  padding-left: 0.5em;
-}
-
-div.body .demo-area ul.htraf li,
-div.body .demo-area ol.htraf li,
-div.body .demo-area dl.htraf dt {
-  margin: 0;
-  list-style-position: inside;
-}
-
-div.body .demo-area dl.htraf dd {
-  margin: 0 0 0 1em;
-}
-
-div.body .demo-area .htraf-hover {
-  background: #f6ddaf;
-}
-
-div.body .demo-area .htraf-selected {
-  background: #ffa43f;
-}
-

doc/extensions/sphinxext_htrafdemo/static/htrafdemo.js

-
-
-
-$(function () {
-    $('.demo-switch').click(function () {
-        var text = $(this).text()
-        if (text == '[+ view source]') {
-            $(this).next('.demo-source').slideDown('fast');
-            $(this).text('[- view source]');
-        }
-        else if (text == '[- view source]') {
-            $(this).next('.demo-source').slideUp('fast');
-            $(this).text('[+ view source]');
-        }
-        else if (text == '[+ view demo]') {
-            $(this).next('.demo-area').slideDown('fast');
-            $(this).text('[- view demo]');
-        }
-        else if (text == '[- view demo]') {
-            $(this).next('.demo-area').slideUp('fast');
-            $(this).text('[+ view demo]');
-        }
-    });
-});
-
-