Commits

Kirill Simonov  committed 1ef3e57

htsqldoc: added vsplit directive; other minor fixes.

  • Participants
  • Parent commits 3587cb8

Comments (0)

Files changed (7)

File doc/extensions/htsqldoc.py

         return [query_container, result_container]
 
 
+class VSplitDirective(Directive):
+
+    has_content = True
+
+    def run(self):
+        self.assert_has_content()
+        text = '\n'.join(self.content)
+        node = nodes.container(text, classes=['vsplit'])
+        self.state.nested_parse(self.content, self.content_offset, node)
+        if len(node) != 2:
+            raise self.error("%s directive expects 2 subnodes", self.name)
+        node[0]['classes'].append('vsplit-left')
+        node[1]['classes'].append('vsplit-right')
+        node += nodes.container(classes=['vsplit-clear'])
+        return [node]
+
+
 def load_uri(uri, error=False):
     try:
         headers = { 'Accept': 'application/json' }
 def setup(app):
     app.add_config_value('htsql_server', None, '')
     app.add_directive('htsql', HTSQLDirective)
-    app.add_stylesheet('extra.css')
-    app.add_javascript('extra.js')
+    app.add_directive('vsplit', VSplitDirective)
+    app.add_stylesheet('htsqldoc.css')
+    app.add_javascript('htsqldoc.js')
 
 

File doc/showcase.rst

 HTSQL is a Web Service
 ----------------------
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: text
 
 HTSQL is a Relational Database Gateway
 --------------------------------------
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 HTSQL is an Advanced Query Language
 -----------------------------------
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 
 HTSQL queries typically start with the driving table.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 Output columns are selected with curly brackets ``{}``; the ``:as``
 decorator sets the title.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 
 HTSQL lets you filter results with arbitrary predicates.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 
 Table operations such as sorting and paging are chainable.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 
 In HTSQL, aggregates aren't a reason to run to the DBA.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 HTSQL Makes Dashboarding Easy
 -----------------------------
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: html
 
 
 HTSQL supports complex grouping operations.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 
 
 HTSQL is not limited to tabular output.
 
-.. container:: vsplit
+.. vsplit::
 
    .. sourcecode:: htsql
 

File doc/static/extra.css

-
-div.vsplit:after {
-  visibility: hidden;
-  display: block;
-  font-size: 0;
-  content: " ";
-  clear: both;
-  height: 0;
-}
-
-div.vsplit > *:first-child {
-  width: 45%;
-  float: left;
-  font-size: 95%;
-}
-
-div.vsplit > *:first-child +* {
-  width: 50%;
-  float: right;
-  font-size: 95%;
-}
-
-div.htsql-output {
-  max-height: 10em;
-  overflow: auto;
-  display: none;
-}
-
-div.htsql-toggle {
-  float: right;
-  cursor: pointer
-}
-

File doc/static/extra.js

-
-
-function initToggles() {
-    $('.htsql-input pre').prepend("<div class=\"htsql-toggle\">[+]</div>");
-    $('.htsql-toggle').click(function () {
-        var output = this;
-        if ($(this).text() == '[+]') {
-            $(this).parents('.htsql-input').next('.htsql-output').css('display', 'block');
-            $(this).text('[-]');
-        }
-        else {
-            $(this).parents('.htsql-input').next('.htsql-output').css('display', 'none');
-            $(this).text('[+]');
-        }
-    });
-}
-
-
-$(initToggles);
-
-

File doc/static/htsqldoc.css

+
+.vsplit-left {
+  width: 45%;
+  float: left;
+  font-size: 95%;
+}
+
+.vsplit-right {
+  width: 50%;
+  float: right;
+  font-size: 95%;
+}
+
+.vsplit-clear {
+  clear: both;
+}
+
+div.htsql-input {
+  font-size: 95%;
+}
+
+div.htsql-output {
+  max-height: 10em;
+  overflow: auto;
+  display: none;
+}
+
+div.htsql-toggle {
+  float: right;
+  cursor: pointer
+}
+

File doc/static/htsqldoc.js

+
+
+$(function () {
+    $('.htsql-input pre').prepend("<div class=\"htsql-toggle\">[+]</div>");
+    $('.htsql-toggle').click(function () {
+        var output = this;
+        if ($(this).text() == '[+]') {
+            $(this).parents('.htsql-input').next('.htsql-output').slideDown('fast');
+            $(this).text('[-]');
+        }
+        else {
+            $(this).parents('.htsql-input').next('.htsql-output').slideUp('fast');
+            $(this).text('[+]');
+        }
+    });
+});
+
+

File test/output/pgsql.yaml

                | arthis | art         |                     3 |                     3 |
                | astro  | ns          |                     6 |                     6 |
                | be     | eng         |                     8 |                     8 |
-               | bursar |             |                     0 |                     0 |
+               | bursar |             |                     0 |                       |
                | capmrk | bus         |                     5 |                     5 |
-               | career |             |                     0 |                     0 |
+               | career |             |                     0 |                       |
                | chem   | ns          |                     6 |                     6 |
                | comp   | eng         |                     8 |                     8 |
                | corpfi | bus         |                     5 |                     5 |
                | lang   | la          |                     9 |                     9 |
                | me     | eng         |                     8 |                     8 |
                | mth    | ns          |                     6 |                     6 |
-               | parent |             |                     0 |                     0 |
+               | parent |             |                     0 |                       |
                | phys   | ns          |                     6 |                     6 |
                | pia    | mus         |                     0 |                     0 |
                | poli   | la          |                     9 |                     9 |
               -+-------------------------------------------------------------------------------------------+-
                | name                          | count(department) | this(){count(department)}?name!~'art' |
               -+-------------------------------+-------------------+---------------------------------------+-
-               | School of Art and Design      |                 2 |                                     0 |
+               | School of Art and Design      |                 2 |                                       |
                | School of Business            |                 3 |                                     3 |
                | College of Education          |                 2 |                                     2 |
                | School of Engineering         |                 4 |                                     4 |
-               | School of Arts and Humanities |                 5 |                                     0 |
+               | School of Arts and Humanities |                 5 |                                       |
                | School of Music & Dance       |                 4 |                                     4 |
                | School of Natural Sciences    |                 4 |                                     4 |
                | Public Honorariums            |                 0 |                                     0 |