Commits

Kirill Simonov  committed 38349cb

Enchance the htsql ReST directive.

Allow to optionally specify the query in the directive body.

  • Participants
  • Parent commits 6f4ee3c

Comments (0)

Files changed (1)

File doc/extensions/htsqldoc.py

 
 
 class HTSQLDirective(Directive):
-    required_arguments = 1
+    optional_arguments = 1
+    has_content = True
     final_argument_whitespace = True
     option_spec = {
             'plain': directives.flag,
 
     def run(self):
         env = self.state.document.settings.env
-        query = " ".join(line.strip()
-                         for line in self.arguments[0].split("\n"))
+        if self.arguments:
+            if self.content:
+                raise self.error("duplicate query")
+            query = " ".join(line.strip()
+                             for line in self.arguments[0].split("\n"))
+        elif self.content:
+            query = "\n".join(self.content)
+        else:
+            raise self.error("no query")
         query_node = nodes.literal_block(query, query)
         query_node['language'] = 'htsql'
         if not env.config.htsql_server: