浏览代码

function description formatting

Dan Cech 8 年之前
父节点
当前提交
3ddb65fc8b

+ 10 - 1
public/app/plugins/datasource/graphite/datasource.ts

@@ -444,9 +444,18 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
             return;
           }
 
+          var description = funcDef.description;
+          if (description) {
+            // tidy up some pydoc syntax that rst2html can't handle
+            description = description
+              .replace(/:py:func:`(.+)( <[^>]*>)?`/g, '``$1``')
+              .replace(/.. seealso:: /g, 'See also: ')
+              .replace(/.. code-block *:: *none/g, '.. code-block::');
+          }
+
           var func = {
             name: funcDef.name,
-            description: funcDef.description,
+            description: description,
             category: funcDef.group,
             params: [],
             defaultParams: [],

+ 2 - 1
public/app/plugins/datasource/graphite/func_editor.js

@@ -264,7 +264,8 @@ function (angular, _, $, rst2html) {
                   popoverSrv.show({
                     element: e.target,
                     position: 'bottom left',
-                    template: '<div><h4>' + funcDef.name + '</h4>' + rst2html(funcDef.description) + '</div>',
+                    classNames: 'drop-popover drop-function-def',
+                    template: '<div style="overflow:auto;max-height:30rem;"><h4>' + funcDef.name + '</h4>' + rst2html(funcDef.description) + '</div>',
                     openOn: 'click',
                   });
                 } else {

+ 33 - 2
public/sass/components/_query_editor.scss

@@ -89,7 +89,7 @@
   }
 }
 
-input[type="text"].tight-form-func-param {
+input[type='text'].tight-form-func-param {
   background: transparent;
   border: none;
   margin: 0;
@@ -129,7 +129,7 @@ input[type="text"].tight-form-func-param {
   }
 }
 
-input[type="text"].tight-form-func-param {
+input[type='text'].tight-form-func-param {
   font-size: 0.875rem;
   background: transparent;
   border: none;
@@ -177,3 +177,34 @@ input[type="text"].tight-form-func-param {
 .query-troubleshooter__body {
   padding: $spacer 0;
 }
+
+.rst-text::before {
+  content: ' ';
+}
+
+.rst-unknown.rst-directive {
+  font-family: monospace;
+  margin-bottom: 1rem;
+}
+
+.rst-interpreted_text {
+  font-family: monospace;
+  display: inline;
+}
+
+.rst-bullet-list {
+  padding-left: 1.5rem;
+  margin-bottom: 1rem;
+}
+
+.rst-paragraph:last-child {
+  margin-bottom: 0;
+}
+
+.drop-element.drop-popover.drop-function-def .drop-content {
+  max-width: 30rem;
+}
+
+.rst-literal-block .rst-text {
+  display: block;
+}