1
0
Эх сурвалжийг харах

Improve jq examples: simplify HTML, add %pre CSS

Cimbali 4 жил өмнө
parent
commit
7269d5431f

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -67,6 +67,7 @@
         'pages/haproxy',
         'pages/haskell',
         'pages/jekyll',
+        'pages/jq',
         'pages/jquery',
         'pages/julia',
         'pages/knockout',

+ 26 - 0
assets/stylesheets/pages/_jq.scss

@@ -0,0 +1,26 @@
+._jq {
+  @extend %simple;
+
+  .manual-example table {
+	  border: none;
+
+	  & td {
+		  @extend %pre;
+		  &.jqprogram { font-weight: bold; }
+		  border: none;
+	  }
+
+	  & th {
+		  color: var(--textColor);
+		  background: var(--contentBackground);
+		  text-align: right;
+		  border: none;
+	  }
+
+	  & tr:not(:first-child) th:not(:empty) {
+		  &, & + td {
+			  border-top: 1px solid var(--boxBorder);
+		  }
+	  }
+  }
+}

+ 13 - 1
lib/docs/filters/jq/clean_html.rb

@@ -2,7 +2,19 @@ module Docs
   class Jq
     class CleanHtmlFilter < Filter
       def call
-        at_css('div#manualcontent')
+        content = at_css('div#manualcontent')
+
+        css('.manual-example').each do |node|
+          container = node.parent
+          example_header = doc.document.create_element('h4')
+          example_header.content = container.at_css('a[data-toggle="collapse"]').content
+          node.children.before(example_header)
+
+          node.remove_class('collapse')
+          container.replace(node)
+        end
+
+        content
       end
     end
   end

+ 1 - 1
lib/docs/scrapers/jq.rb

@@ -2,7 +2,7 @@ module Docs
   class Jq < UrlScraper
     self.name = 'jq'
     self.slug = 'jq'
-    self.type = 'simple'
+    self.type = 'jq'
     self.release = '1.6'
     self.links = {
       home: 'https://stedolan.github.io/jq/'