History

Add Sequelize documentation

Waldir Pimenta committed 7 years ago

Commit 2bdf3a01 parent dd0cc077 files · +93 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. lib/docs/filters/sequelize/clean_html.rb +33 −0
  3. lib/docs/filters/sequelize/entries.rb +26 −0
  4. lib/docs/scrapers/sequelize.rb +30 −0
  5. public/icons/docs/sequelize/16.png +0 −0
  6. public/icons/docs/sequelize/16@2x.png +0 −0
  7. public/icons/docs/sequelize/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -701,6 +701,11 @@ credits = [ · 700 unmodified lines
701 '2010-2018 Christian Johansen',701 '2010-2018 Christian Johansen',
702 'BSD',702 'BSD',
703 'https://raw.githubusercontent.com/sinonjs/sinon/master/LICENSE'703 'https://raw.githubusercontent.com/sinonjs/sinon/master/LICENSE'
704 ], [
705 'Sequelize',
706 '2014—present Sequelize contributors',
707 'MIT',
708 'https://raw.githubusercontent.com/sequelize/sequelize/master/LICENSE'
704 ], [709 ], [
705 'Socket.io',710 'Socket.io',
706 '2014-2015 Automattic',711 '2014-2015 Automattic',
lib/docs/filters/sequelize/clean_html.rb+33−0
@@ -0,0 +1,33 @@
1module Docs
2 class Sequelize
3 class CleanHtmlFilter < Filter
4 def call
5 # Clean up the home page
6 if root_page?
7 # Remove logo
8 css('.manual-user-index > div > div.logo').remove
9 # Convert title to proper H1 element
10 at_css('.manual-user-index > div > div.sequelize').name = 'h1'
11 # Remove badges (NPM, Travis, test coverage, etc.)
12 css('.manual-user-index > p:nth-child(4)').remove
13 # Remove image cards pointing to entries of the manual
14 css('.manual-cards').remove
15 end
16
17 # Add syntax highlighting to code blocks
18 css('pre > code[class^="lang-"]').each do |node|
19 pre = node.parent
20 # Convert the existing language definitions to Prism-compatible attributes
21 pre['data-language'] = 'javascript' if node['class'] == 'lang-js' || node['class'] == 'lang-javascript'
22 pre['data-language'] = 'json' if node['class'] == 'lang-json'
23 pre['data-language'] = 'shell' if node['class'] == 'lang-sh' || node['class'] == 'lang-bash'
24 pre['data-language'] = 'sql' if node['class'] == 'lang-sql'
25 pre['data-language'] = 'typescript' if node['class'] == 'lang-ts'
26 end
27
28 # Return the cleaned-up document
29 doc
30 end
31 end
32 end
33end
lib/docs/filters/sequelize/entries.rb+26−0
@@ -0,0 +1,26 @@
1module Docs
2 class Sequelize
3 class EntriesFilter < Docs::EntriesFilter
4 # Use the main title as the page name
5 def get_name
6 at_css('h1').text
7 end
8
9 # Assign the pages to main categories
10 def get_type
11 if path.start_with?('manual/')
12 type = 'Manual'
13 elsif path.start_with?('file/lib/')
14 type = 'Source files'
15 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'
20 end
21
22 type
23 end
24 end
25 end
26end
lib/docs/scrapers/sequelize.rb+30−0
@@ -0,0 +1,30 @@
1module Docs
2 class Sequelize < UrlScraper
3 self.name = 'Sequelize'
4 self.slug = 'sequelize'
5 self.type = 'simple'
6 self.release = '5.19.6'
7 self.base_url = 'https://sequelize.org/master/'
8 self.links = {
9 home: 'https://sequelize.org/',
10 code: 'https://github.com/sequelize/sequelize/'
11 }
12
13 # List of content filters (to be applied sequentially)
14 html_filters.push 'sequelize/entries', 'sequelize/clean_html'
15
16 # Wrapper element that holds the main content
17 options[:container] = '.content'
18
19 # License information that appears appears at the bottom of the entry page
20 options[:attribution] = <<-HTML
21 Copyright &copy; 2014&ndash;present Sequelize contributors<br>
22 Licensed under the MIT License.
23 HTML
24
25 # Method to fetch the most recent version of the project
26 def get_latest_version(opts)
27 get_npm_version('sequelize', opts)
28 end
29 end
30end
public/icons/docs/sequelize/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/sequelize/SOURCE+1−0
@@ -0,0 +1 @@
1https://github.com/sequelize/sequelize/blob/master/docs/images/logo.png