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
2 class Sequelize2 class Sequelize
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('.content')
6
5 # Clean up the home page7 # Clean up the home page
6 if root_page?8 if root_page? || subpath == "index.html"
7 # Remove logo9 # Remove logo
8 css('.manual-user-index > div > div.logo').remove10 css('.manual-user-index > div > div.logo').remove
9 # Convert title to proper H1 element11
12 # Convert title to proper h1 element
10 at_css('.manual-user-index > div > div.sequelize').name = 'h1'13 at_css('.manual-user-index > div > div.sequelize').name = 'h1'
14
11 # Remove badges (NPM, Travis, test coverage, etc.)15 # Remove badges (NPM, Travis, test coverage, etc.)
12 css('.manual-user-index > p:nth-child(4)').remove16 css('.manual-user-index > p:nth-child(4)').remove
17
13 # Remove image cards pointing to entries of the manual18 # Remove image cards pointing to entries of the manual
14 css('.manual-cards').remove19 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'
15 end36 end
16 37
17 # Add syntax highlighting to code blocks38 # Add syntax highlighting to code blocks
lib/docs/filters/sequelize/entries.rb+16−9
@@ -9,17 +9,24 @@ module Docs · 8 unmodified lines
9 # Assign the pages to main categories9 # Assign the pages to main categories
10 def get_type10 def get_type
11 if path.start_with?('manual/')11 if path.start_with?('manual/')
12 type = 'Manual'12 'Manual'
13 elsif path.start_with?('file/lib/')13 elsif path.include?('lib/data-types')
14 type = 'Source files'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'
15 else27 else
16 # API Reference pages. The `path` for most of these starts with 'class/lib/',28 'classes'
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'
20 end29 end
21
22 type
23 end30 end
24 end31 end
25 end32 end
lib/docs/scrapers/sequelize.rb+4−4
@@ -3,18 +3,18 @@ module Docs · 2 unmodified lines
3 self.name = 'Sequelize'3 self.name = 'Sequelize'
4 self.slug = 'sequelize'4 self.slug = 'sequelize'
5 self.type = 'simple'5 self.type = 'simple'
6 self.release = '5.19.6'6 self.release = '5.21.1'
7 self.base_url = 'https://sequelize.org/master/'7 self.base_url = 'https://sequelize.org/master/'
8 self.links = {8 self.links = {
9 home: 'https://sequelize.org/',9 home: 'https://sequelize.org/',
10 code: 'https://github.com/sequelize/sequelize/'10 code: 'https://github.com/sequelize/sequelize'
11 }11 }
12 12
13 # List of content filters (to be applied sequentially)13 # List of content filters (to be applied sequentially)
14 html_filters.push 'sequelize/entries', 'sequelize/clean_html'14 html_filters.push 'sequelize/entries', 'sequelize/clean_html'
15 15
16 # Wrapper element that holds the main content16 # Skip the source files, the license page and the "Who's using Sequelize" page
17 options[:container] = '.content'17 options[:skip_patterns] = [/\.js\.html/, /manual\/legal\.html/, /manual\/whos-using\.html/]
18 18
19 # License information that appears appears at the bottom of the entry page19 # License information that appears appears at the bottom of the entry page
20 options[:attribution] = <<-HTML20 options[:attribution] = <<-HTML