[devdocsgjs/main: 785/1867] cypress: finish scraper and filters
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 785/1867] cypress: finish scraper and filters
- Date: Fri, 19 Nov 2021 23:47:29 +0000 (UTC)
commit 11234ecb454ff837ca1b3fa18ae338cb0793df54
Author: Jasper van Merle <jaspervmerle gmail com>
Date: Mon Aug 12 02:02:16 2019 +0200
cypress: finish scraper and filters
.../javascripts/templates/pages/about_tmpl.coffee | 6 ++++
lib/docs/filters/cypress/clean_html.rb | 15 ++++++++--
lib/docs/filters/cypress/entries.rb | 7 -----
lib/docs/scrapers/cypress.rb | 33 ++++++++++++----------
4 files changed, 36 insertions(+), 25 deletions(-)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 37d14eea..5e9dc6cc 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -202,6 +202,12 @@ credits = [
'Apache',
'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE'
], [
+ 'Cypress',
+ '2017 Cypress.io',
+ 'MIT',
+ 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md'
+ ],
+ [
'D',
'1999-2018 The D Language Foundation',
'Boost',
diff --git a/lib/docs/filters/cypress/clean_html.rb b/lib/docs/filters/cypress/clean_html.rb
index 6a36d24c..9b93b313 100644
--- a/lib/docs/filters/cypress/clean_html.rb
+++ b/lib/docs/filters/cypress/clean_html.rb
@@ -4,12 +4,21 @@ module Docs
class Cypress
class CleanHtmlFilter < Filter
def call
+ article_div = at_css('#article > div')
+ @doc = article_div unless article_div.nil?
+
+ header = at_css('h1.article-title')
+ doc.prepend_child(header) unless header.nil?
+
css('.article-edit-link').remove
- css('#sidebar').remove
- css('article footer').remove
- css('#article-toc').remove
+ css('.article-footer').remove
css('.article-footer-updated').remove
+ css('pre').each do |node|
+ node.content = node.content
+ node['data-language'] = 'javascript'
+ end
+
doc
end
end
diff --git a/lib/docs/filters/cypress/entries.rb b/lib/docs/filters/cypress/entries.rb
index a854acd7..664f4da7 100644
--- a/lib/docs/filters/cypress/entries.rb
+++ b/lib/docs/filters/cypress/entries.rb
@@ -8,7 +8,6 @@ module Docs
core-concepts
cypress-api
events
- examples
getting-started
guides
overview
@@ -30,12 +29,6 @@ module Docs
end
end
end
-
- def additional_entries
- css('.sidebar-li > a').map do |node|
- [node['href']]
- end
- end
end
end
end
diff --git a/lib/docs/scrapers/cypress.rb b/lib/docs/scrapers/cypress.rb
index e5433b22..56380630 100644
--- a/lib/docs/scrapers/cypress.rb
+++ b/lib/docs/scrapers/cypress.rb
@@ -2,32 +2,35 @@
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.release = '3.4.1'
+ self.base_url = 'https://docs.cypress.io'
self.root_path = '/api/api/table-of-contents.html'
+ self.links = {
+ home: 'https://www.cypress.io/',
+ code: 'https://github.com/cypress-io/cypress',
+ }
- html_filters.push 'cypress/clean_html', 'cypress/entries'
+ html_filters.push 'cypress/entries', 'cypress/clean_html'
- options[:root_title] = 'Cypress'
options[:container] = '#content'
-
+ options[:max_image_size] = 300_000
options[:include_default_entry] = true
- options[:skip_link] = lambda do |link|
+ options[:skip_patterns] = [/examples\//]
+ options[:skip_link] = ->(link) {
href = link.attr(:href)
-
- EntriesFilter::SECTIONS.none? { |section| href.match?("/#{section}/") }
- end
+ href.nil? ? true : EntriesFilter::SECTIONS.none? { |section| href.match?("/#{section}/") }
+ }
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>.
+ © 2017 Cypress.io<br>
+ Licensed under the MIT License.
HTML
+
+ def get_latest_version(opts)
+ get_latest_github_release('cypress-io', 'cypress', opts)
+ end
end
end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]