History

cypress: finish scraper and filters

Jasper van Merle committed 7 years ago

Commit 11234ec1 parent f1887bc4 files · +36 −25Browse files

Unified · Split

4 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +6 −0
  2. lib/docs/filters/cypress/clean_html.rb +12 −3
  3. lib/docs/filters/cypress/entries.rb +0 −7
  4. lib/docs/scrapers/cypress.rb +18 −15
assets/javascripts/templates/pages/about_tmpl.coffee+6−0
@@ -202,6 +202,12 @@ credits = [ · 201 unmodified lines
202202 'Apache',
203203 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE'
204204 ], [
205+ 'Cypress',
206+ '2017 Cypress.io',
207+ 'MIT',
208+ 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md'
209+ ],
210+ [
205211 'D',
206212 '1999-2018 The D Language Foundation',
207213 'Boost',
lib/docs/filters/cypress/clean_html.rb+12−3
@@ -4,12 +4,21 @@ module Docs · 3 unmodified lines
44 class Cypress
55 class CleanHtmlFilter < Filter
66 def call
7+ article_div = at_css('#article > div')
8+ @doc = article_div unless article_div.nil?
9+
10+ header = at_css('h1.article-title')
11+ doc.prepend_child(header) unless header.nil?
12+
713 css('.article-edit-link').remove
8− css('#sidebar').remove
9− css('article footer').remove
10− css('#article-toc').remove
14+ css('.article-footer').remove
1115 css('.article-footer-updated').remove
1216
17+ css('pre').each do |node|
18+ node.content = node.content
19+ node['data-language'] = 'javascript'
20+ end
21+
1322 doc
1423 end
1524 end
lib/docs/filters/cypress/entries.rb+0−7
@@ -8,7 +8,6 @@ module Docs · 7 unmodified lines
88 core-concepts
99 cypress-api
1010 events
11− examples
1211 getting-started
1312 guides
1413 overview
@@ -30,12 +29,6 @@ module Docs · 15 unmodified lines
3029 end
3130 end
3231 end
33−
34− def additional_entries
35− css('.sidebar-li > a').map do |node|
36− [node['href']]
37− end
38− end
3932 end
4033 end
4134 end
lib/docs/scrapers/cypress.rb+18−15
@@ -2,32 +2,35 @@ · 1 unmodified line
22
33 module Docs
44 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−
105 self.name = 'Cypress'
116 self.type = 'cypress'
7+ self.release = '3.4.1'
8+ self.base_url = 'https://docs.cypress.io'
129 self.root_path = '/api/api/table-of-contents.html'
10+ self.links = {
11+ home: 'https://www.cypress.io/',
12+ code: 'https://github.com/cypress-io/cypress',
13+ }
1314
14− html_filters.push 'cypress/clean_html', 'cypress/entries'
15+ html_filters.push 'cypress/entries', 'cypress/clean_html'
1516
16− options[:root_title] = 'Cypress'
1717 options[:container] = '#content'
18−
18+ options[:max_image_size] = 300_000
1919 options[:include_default_entry] = true
2020
21− options[:skip_link] = lambda do |link|
21+ options[:skip_patterns] = [/examples\//]
22+ options[:skip_link] = ->(link) {
2223 href = link.attr(:href)
23−
24− EntriesFilter::SECTIONS.none? { |section| href.match?("/#{section}/") }
25− end
24+ href.nil? ? true : EntriesFilter::SECTIONS.none? { |section| href.match?("/#{section}/") }
25+ }
2626
2727 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>.
28+ &copy; 2017 Cypress.io<br>
29+ Licensed under the MIT License.
3130 HTML
31+
32+ def get_latest_version(opts)
33+ get_latest_github_release('cypress-io', 'cypress', opts)
34+ end
3235 end
3336 end