1
0
Thibaut Courouble 8 жил өмнө
parent
commit
f0125e55ae

BIN
assets/images/docs-2.png


BIN
assets/images/docs-2@2x.png


+ 3 - 0
assets/javascripts/news.json

@@ -1,5 +1,8 @@
 [
   [
+    "2017-06-04",
+    "New documentation: <a href=\"/pug/\">Pug</a>"
+  ], [
     "2017-05-14",
     "New documentations: <a href=\"/jest/\">Jest</a>, <a href=\"/jasmine/\">Jasmine</a> and <a href=\"/liquid/\">Liquid</a>"
   ], [

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

@@ -76,6 +76,7 @@
         'pages/php',
         'pages/phpunit',
         'pages/postgres',
+        'pages/pug',
         'pages/ramda',
         'pages/rdoc',
         'pages/react',

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

@@ -76,6 +76,7 @@
         'pages/php',
         'pages/phpunit',
         'pages/postgres',
+        'pages/pug',
         'pages/ramda',
         'pages/rdoc',
         'pages/react',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -172,3 +172,4 @@
 ._icon-angular:before       { background-position: -8rem -1rem; @extend %doc-icon-2; }
 ._icon-love:before          { background-position: -9rem -1rem; @extend %doc-icon-2; }
 ._icon-jasmine:before       { background-position: 0 -2rem; @extend %doc-icon-2; }
+._icon-pug:before           { background-position: -1rem -2rem; @extend %doc-icon-2; }

+ 9 - 0
assets/stylesheets/pages/_pug.scss

@@ -0,0 +1,9 @@
+._pug {
+  @extend %simple;
+
+  .alert { @extend %note; }
+  .alert-danger { @extend %note-orange; }
+  .alert h6 { margin-top: .25rem; }
+
+  h4 > code { @extend %label; }
+}

+ 30 - 0
lib/docs/filters/pug/clean_html.rb

@@ -0,0 +1,30 @@
+module Docs
+  class Pug
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.main')
+
+        at_css('h1').content = 'Pug Documentation' if root_page?
+
+        if slug == 'api/reference'
+          at_css('.alert-info').remove
+        end
+
+        css('.header-anchor').remove
+
+        css('.preview-wrapper').each do |node|
+          node.css('pre').each do |n|
+            node.before(n)
+          end
+          node.remove
+        end
+
+        css('pre').each do |node|
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 27 - 0
lib/docs/filters/pug/entries.rb

@@ -0,0 +1,27 @@
+module Docs
+  class Pug
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content
+      end
+
+      def get_type
+        if subpath.start_with?('language')
+          'Language'
+        elsif subpath.start_with?('api')
+          'API'
+        end
+      end
+
+      def additional_entries
+        return [] unless slug == 'api/reference'
+
+        css('h3').each_with_object [] do |node, entries|
+          name = node.content
+          name.sub! %r{\(.*\)}, '()'
+          entries << [name, node['id']]
+        end
+      end
+    end
+  end
+end

+ 28 - 0
lib/docs/scrapers/pug.rb

@@ -0,0 +1,28 @@
+module Docs
+  class Pug < UrlScraper
+    self.type = 'pug'
+    self.base_url = 'https://pugjs.org/'
+    self.root_path = 'api/getting-started.html'
+    self.release = '2.0.0-rc.2'
+    self.links = {
+      home: 'https://pugjs.org/',
+      code: 'https://github.com/pugjs/pug'
+    }
+
+    html_filters.push 'pug/clean_html', 'pug/entries'
+
+    options[:container] = 'body > .container'
+
+    options[:attribution] = <<-HTML
+      &copy; Pug authors<br>
+      Licensed under the MIT license.
+    HTML
+
+    private
+
+    def parse(response) # Hook here because Nokogori removes whitespace from textareas
+      response.body.gsub! %r{<textarea\ [^>]*>([\W\w]+?)</textarea>}, '<pre>\1</pre>'
+      super
+    end
+  end
+end

BIN
public/icons/docs/pug/16.png


BIN
public/icons/docs/pug/16@2x.png


+ 1 - 0
public/icons/docs/pug/SOURCE

@@ -0,0 +1 @@
+https://github.com/pugjs/pug-www/blob/master/htdocs/images/logo.svg