Explorar el Código

Add documentation for cypress.io

Juan González hace 7 años
padre
commit
d3196c53ed

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

@@ -46,6 +46,7 @@
         'pages/coffeescript',
         'pages/cordova',
         'pages/crystal',
+        'pages/cypress',
         'pages/d',
         'pages/d3',
         'pages/dart',

+ 21 - 0
assets/stylesheets/pages/_cypress.scss

@@ -0,0 +1,21 @@
+._cypress {
+  @extend %simple;
+
+  .note {
+    h1 {
+      margin-left: inherit
+    }
+
+    &.danger {
+      @extend %note-red
+    }
+
+    &.info {
+      @extend %note-blue
+    }
+
+    &.success {
+      @extend %note-green
+    }
+  }
+}

+ 17 - 0
lib/docs/filters/cypress/clean_html.rb

@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Docs
+  class Cypress
+    class CleanHtmlFilter < Filter
+      def call
+        css('.article-edit-link').remove
+        css('#sidebar').remove
+        css('article footer').remove
+        css('#article-toc').remove
+        css('.article-footer-updated').remove
+
+        doc
+      end
+    end
+  end
+end

+ 41 - 0
lib/docs/filters/cypress/entries.rb

@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+module Docs
+  class Cypress
+    class EntriesFilter < Docs::EntriesFilter
+      SECTIONS = %w[
+        commands
+        core-concepts
+        cypress-api
+        events
+        examples
+        getting-started
+        guides
+        overview
+        plugins
+        references
+        utilities
+      ].freeze
+
+      def get_name
+        at_css('h1.article-title').content.strip
+      end
+
+      def get_type
+        path = context[:url].path
+
+        SECTIONS.each do |section|
+          if path.match?("/#{section}/")
+            return section.split('-').map(&:capitalize).join(' ')
+          end
+        end
+      end
+
+      def additional_entries
+        css('.sidebar-li > a').map do |node|
+          [node['href']]
+        end
+      end
+    end
+  end
+end

+ 33 - 0
lib/docs/scrapers/cypress.rb

@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Docs
+  class Cypress < UrlScraper
+    # Follow the instructions on https://github.com/cypress-io/cypress-documentation/blob/develop/CONTRIBUTING.md
+    # to run the cypress documentation server locally in the following URL:
+    # self.base_url = 'http://localhost:2222'
+    self.base_url = 'https://docs.cypress.io'
+
+    self.name = 'Cypress'
+    self.type = 'cypress'
+    self.root_path = '/api/introduction/api.html'
+
+    html_filters.push 'cypress/clean_html', 'cypress/entries'
+
+    options[:root_title] = 'Cypress'
+    options[:container] = '#content'
+
+    options[:include_default_entry] = true
+
+    options[:skip_link] = lambda do |link|
+      href = link.attr(:href)
+
+      EntriesFilter::SECTIONS.none? { |section| href.match?("/#{section}/") }
+    end
+
+    options[:attribution] = <<-HTML
+      © 2018 <a href="https://cypress.io">Cypress.io</a>
+      - Licensed under the
+      <a href="https://github.com/cypress-io/cypress-documentation/blob/develop/LICENSE.md">MIT License</a>.
+    HTML
+  end
+end

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


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


BIN
public/icons/docs/cypress/SOURCE.ico