History

sequelize: finish scraper and filters

Jasper van Merle committed 7 years ago

Commit 089aa611 parent 0631b3f3 files · +43 −15Browse files

Unified · Split

3 files
  1. lib/docs/filters/sequelize/clean_html.rb +23 −2
  2. lib/docs/filters/sequelize/entries.rb +16 −9
  3. lib/docs/scrapers/sequelize.rb +4 −4
lib/docs/filters/sequelize/clean_html.rb+23−2
@@ -2,16 +2,37 @@ module Docs · 1 unmodified line
22 class Sequelize
33 class CleanHtmlFilter < Filter
44 def call
5+ @doc = at_css('.content')
6+
57 # Clean up the home page
6− if root_page?
8+ if root_page? || subpath == "index.html"
79 # Remove logo
810 css('.manual-user-index > div > div.logo').remove
9− # Convert title to proper H1 element
11+
12+ # Convert title to proper h1 element
1013 at_css('.manual-user-index > div > div.sequelize').name = 'h1'
14+
1115 # Remove badges (NPM, Travis, test coverage, etc.)
1216 css('.manual-user-index > p:nth-child(4)').remove
17+
1318 # Remove image cards pointing to entries of the manual
1419 css('.manual-cards').remove
20+
21+ # Pull the header out of it's container
22+ header = at_css('h1')
23+ header.parent.parent.parent.add_previous_sibling header
24+ else
25+ # Pull the header out of it's container
26+ header = at_css('h1')
27+ header.parent.add_previous_sibling header
28+ end
29+
30+ # Remove header notice
31+ css('.header-notice').remove
32+
33+ # Change td in thead to th
34+ css('table > thead > tr > td').each do |node|
35+ node.name = 'th'
1536 end
1637
1738 # Add syntax highlighting to code blocks
lib/docs/filters/sequelize/entries.rb+16−9
@@ -9,17 +9,24 @@ module Docs · 8 unmodified lines
99 # Assign the pages to main categories
1010 def get_type
1111 if path.start_with?('manual/')
12− type = 'Manual'
13− elsif path.start_with?('file/lib/')
14− type = 'Source files'
12+ 'Manual'
13+ elsif path.include?('lib/data-types')
14+ 'datatypes'
15+ elsif path.include?('lib/errors/validation')
16+ 'errors/validation'
17+ elsif path.include?('lib/errors/database')
18+ 'errors/database'
19+ elsif path.include?('lib/errors/connection')
20+ 'errors/connection'
21+ elsif path.include?('lib/errors')
22+ 'errors'
23+ elsif path.include?('lib/associations')
24+ 'associations'
25+ elsif path.include?('master/variable')
26+ 'variables'
1527 else
16− # API Reference pages. The `path` for most of these starts with 'class/lib/',
17− # but there's also 'variable/index' (pseudo-classes), and 'identifiers' (the main index)
18− # so we use an unqualified `else` as a catch-all.
19− type = 'Reference'
28+ 'classes'
2029 end
21−
22− type
2330 end
2431 end
2532 end
lib/docs/scrapers/sequelize.rb+4−4
@@ -3,18 +3,18 @@ module Docs · 2 unmodified lines
33 self.name = 'Sequelize'
44 self.slug = 'sequelize'
55 self.type = 'simple'
6− self.release = '5.19.6'
6+ self.release = '5.21.1'
77 self.base_url = 'https://sequelize.org/master/'
88 self.links = {
99 home: 'https://sequelize.org/',
10− code: 'https://github.com/sequelize/sequelize/'
10+ code: 'https://github.com/sequelize/sequelize'
1111 }
1212
1313 # List of content filters (to be applied sequentially)
1414 html_filters.push 'sequelize/entries', 'sequelize/clean_html'
1515
16− # Wrapper element that holds the main content
17− options[:container] = '.content'
16+ # Skip the source files, the license page and the "Who's using Sequelize" page
17+ options[:skip_patterns] = [/\.js\.html/, /manual\/legal\.html/, /manual\/whos-using\.html/]
1818
1919 # License information that appears appears at the bottom of the entry page
2020 options[:attribution] = <<-HTML