History

Add documentation for cypress.io

Juan González committed 8 years ago

Commit d3196c51 parent e8d52c98 files · +110 −-3Browse files

Unified · Split

8 files
  1. assets/stylesheets/application.css.scss +1 −0
  2. assets/stylesheets/pages/_cypress.scss +21 −0
  3. lib/docs/filters/cypress/clean_html.rb +17 −0
  4. lib/docs/filters/cypress/entries.rb +41 −0
  5. lib/docs/scrapers/cypress.rb +33 −0
  6. public/icons/docs/cypress/16.png +0 −0
  7. public/icons/docs/cypress/16@2x.png +0 −0
  8. public/icons/docs/cypress/SOURCE.ico +0 −0
assets/stylesheets/application.css.scss+1−0
@@ -46,6 +46,7 @@ · 45 unmodified lines
4646 'pages/coffeescript',
4747 'pages/cordova',
4848 'pages/crystal',
49+ 'pages/cypress',
4950 'pages/d',
5051 'pages/d3',
5152 'pages/dart',
assets/stylesheets/pages/_cypress.scss+21−0
@@ -0,0 +1,21 @@
1+._cypress {
2+ @extend %simple;
3+
4+ .note {
5+ h1 {
6+ margin-left: inherit
7+ }
8+
9+ &.danger {
10+ @extend %note-red
11+ }
12+
13+ &.info {
14+ @extend %note-blue
15+ }
16+
17+ &.success {
18+ @extend %note-green
19+ }
20+ }
21+}
lib/docs/filters/cypress/clean_html.rb+17−0
@@ -0,0 +1,17 @@
1+# frozen_string_literal: true
2+
3+module Docs
4+ class Cypress
5+ class CleanHtmlFilter < Filter
6+ def call
7+ css('.article-edit-link').remove
8+ css('#sidebar').remove
9+ css('article footer').remove
10+ css('#article-toc').remove
11+ css('.article-footer-updated').remove
12+
13+ doc
14+ end
15+ end
16+ end
17+end
lib/docs/filters/cypress/entries.rb+41−0
@@ -0,0 +1,41 @@
1+# frozen_string_literal: true
2+
3+module Docs
4+ class Cypress
5+ class EntriesFilter < Docs::EntriesFilter
6+ SECTIONS = %w[
7+ commands
8+ core-concepts
9+ cypress-api
10+ events
11+ examples
12+ getting-started
13+ guides
14+ overview
15+ plugins
16+ references
17+ utilities
18+ ].freeze
19+
20+ def get_name
21+ at_css('h1.article-title').content.strip
22+ end
23+
24+ def get_type
25+ path = context[:url].path
26+
27+ SECTIONS.each do |section|
28+ if path.match?("/#{section}/")
29+ return section.split('-').map(&:capitalize).join(' ')
30+ end
31+ end
32+ end
33+
34+ def additional_entries
35+ css('.sidebar-li > a').map do |node|
36+ [node['href']]
37+ end
38+ end
39+ end
40+ end
41+end
lib/docs/scrapers/cypress.rb+33−0
@@ -0,0 +1,33 @@
1+# frozen_string_literal: true
2+
3+module Docs
4+ class Cypress < UrlScraper
5+ # Follow the instructions on https://github.com/cypress-io/cypress-documentation/blob/develop/CONTRIBUTING.md
6+ # to run the cypress documentation server locally in the following URL:
7+ # self.base_url = 'http://localhost:2222'
8+ self.base_url = 'https://docs.cypress.io'
9+
10+ self.name = 'Cypress'
11+ self.type = 'cypress'
12+ self.root_path = '/api/introduction/api.html'
13+
14+ html_filters.push 'cypress/clean_html', 'cypress/entries'
15+
16+ options[:root_title] = 'Cypress'
17+ options[:container] = '#content'
18+
19+ options[:include_default_entry] = true
20+
21+ options[:skip_link] = lambda do |link|
22+ href = link.attr(:href)
23+
24+ EntriesFilter::SECTIONS.none? { |section| href.match?("/#{section}/") }
25+ end
26+
27+ options[:attribution] = <<-HTML
28+ © 2018 <a href="https://cypress.io">Cypress.io</a>
29+ - Licensed under the
30+ <a href="https://github.com/cypress-io/cypress-documentation/blob/develop/LICENSE.md">MIT License</a>.
31+ HTML
32+ end
33+end
public/icons/docs/cypress/16.png+0−0

Binary file not shown.

public/icons/docs/cypress/16@2x.png+0−0

Binary file not shown.

public/icons/docs/cypress/SOURCE.ico+0−0

Binary file not shown.