History

Merge pull request #1107 from waldyrious/add-sequelize-documentation

Add Sequelize documentation

Jasper van Merle committed 7 years ago

Commit 5824a4d2 parents 9b63f46 089aa617 files · +126 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. lib/docs/filters/sequelize/clean_html.rb +59 −0
  3. lib/docs/filters/sequelize/entries.rb +33 −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
@@ -711,6 +711,11 @@ credits = [ · 710 unmodified lines
711711 '2010-2018 Christian Johansen',
712712 'BSD',
713713 'https://raw.githubusercontent.com/sinonjs/sinon/master/LICENSE'
714+ ], [
715+ 'Sequelize',
716+ '2014—present Sequelize contributors',
717+ 'MIT',
718+ 'https://raw.githubusercontent.com/sequelize/sequelize/master/LICENSE'
714719 ], [
715720 'Socket.io',
716721 '2014-2015 Automattic',
lib/docs/filters/sequelize/clean_html.rb+59−0
@@ -0,0 +1,59 @@
1+module Docs
2+ class Sequelize
3+ class CleanHtmlFilter < Filter
4+ def call
5+ @doc = at_css('.content')
6+
7+ # Clean up the home page
8+ if root_page? || subpath == "index.html"
9+ # Remove logo
10+ css('.manual-user-index > div > div.logo').remove
11+
12+ # Convert title to proper h1 element
13+ at_css('.manual-user-index > div > div.sequelize').name = 'h1'
14+
15+ # Remove badges (NPM, Travis, test coverage, etc.)
16+ css('.manual-user-index > p:nth-child(4)').remove
17+
18+ # Remove image cards pointing to entries of the manual
19+ 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'
36+ end
37+
38+ # Add syntax highlighting to code blocks
39+ css('pre > code[class^="lang-"]').each do |node|
40+ pre = node.parent
41+ # Convert the existing language definitions to Prism-compatible attributes
42+ pre['data-language'] = 'javascript' if node['class'] == 'lang-js' || node['class'] == 'lang-javascript'
43+ pre['data-language'] = 'json' if node['class'] == 'lang-json'
44+ pre['data-language'] = 'shell' if node['class'] == 'lang-sh' || node['class'] == 'lang-bash'
45+ pre['data-language'] = 'sql' if node['class'] == 'lang-sql'
46+ pre['data-language'] = 'typescript' if node['class'] == 'lang-ts'
47+ end
48+
49+ # Add syntax highlighting to source files
50+ css('pre.raw-source-code').each do |node|
51+ node['data-language'] = 'javascript'
52+ end
53+
54+ # Return the cleaned-up document
55+ doc
56+ end
57+ end
58+ end
59+end
lib/docs/filters/sequelize/entries.rb+33−0
@@ -0,0 +1,33 @@
1+module 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+ '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'
27+ else
28+ 'classes'
29+ end
30+ end
31+ end
32+ end
33+end
lib/docs/scrapers/sequelize.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Sequelize < UrlScraper
3+ self.name = 'Sequelize'
4+ self.slug = 'sequelize'
5+ self.type = 'simple'
6+ self.release = '5.21.1'
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+ # 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/]
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
30+end
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 @@
1+https://github.com/sequelize/sequelize/blob/master/docs/images/logo.png

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t