mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1107 from waldyrious/add-sequelize-documentation
Add Sequelize documentation
This commit is contained in:
commit
5824a4dced
7 changed files with 128 additions and 0 deletions
|
@ -711,6 +711,11 @@ credits = [
|
|||
'2010-2018 Christian Johansen',
|
||||
'BSD',
|
||||
'https://raw.githubusercontent.com/sinonjs/sinon/master/LICENSE'
|
||||
], [
|
||||
'Sequelize',
|
||||
'2014—present Sequelize contributors',
|
||||
'MIT',
|
||||
'https://raw.githubusercontent.com/sequelize/sequelize/master/LICENSE'
|
||||
], [
|
||||
'Socket.io',
|
||||
'2014-2015 Automattic',
|
||||
|
|
59
lib/docs/filters/sequelize/clean_html.rb
Normal file
59
lib/docs/filters/sequelize/clean_html.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
module Docs
|
||||
class Sequelize
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('.content')
|
||||
|
||||
# Clean up the home page
|
||||
if root_page? || subpath == "index.html"
|
||||
# Remove logo
|
||||
css('.manual-user-index > div > div.logo').remove
|
||||
|
||||
# Convert title to proper h1 element
|
||||
at_css('.manual-user-index > div > div.sequelize').name = 'h1'
|
||||
|
||||
# Remove badges (NPM, Travis, test coverage, etc.)
|
||||
css('.manual-user-index > p:nth-child(4)').remove
|
||||
|
||||
# Remove image cards pointing to entries of the manual
|
||||
css('.manual-cards').remove
|
||||
|
||||
# Pull the header out of it's container
|
||||
header = at_css('h1')
|
||||
header.parent.parent.parent.add_previous_sibling header
|
||||
else
|
||||
# Pull the header out of it's container
|
||||
header = at_css('h1')
|
||||
header.parent.add_previous_sibling header
|
||||
end
|
||||
|
||||
# Remove header notice
|
||||
css('.header-notice').remove
|
||||
|
||||
# Change td in thead to th
|
||||
css('table > thead > tr > td').each do |node|
|
||||
node.name = 'th'
|
||||
end
|
||||
|
||||
# Add syntax highlighting to code blocks
|
||||
css('pre > code[class^="lang-"]').each do |node|
|
||||
pre = node.parent
|
||||
# Convert the existing language definitions to Prism-compatible attributes
|
||||
pre['data-language'] = 'javascript' if node['class'] == 'lang-js' || node['class'] == 'lang-javascript'
|
||||
pre['data-language'] = 'json' if node['class'] == 'lang-json'
|
||||
pre['data-language'] = 'shell' if node['class'] == 'lang-sh' || node['class'] == 'lang-bash'
|
||||
pre['data-language'] = 'sql' if node['class'] == 'lang-sql'
|
||||
pre['data-language'] = 'typescript' if node['class'] == 'lang-ts'
|
||||
end
|
||||
|
||||
# Add syntax highlighting to source files
|
||||
css('pre.raw-source-code').each do |node|
|
||||
node['data-language'] = 'javascript'
|
||||
end
|
||||
|
||||
# Return the cleaned-up document
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
lib/docs/filters/sequelize/entries.rb
Normal file
33
lib/docs/filters/sequelize/entries.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Docs
|
||||
class Sequelize
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
# Use the main title as the page name
|
||||
def get_name
|
||||
at_css('h1').text
|
||||
end
|
||||
|
||||
# Assign the pages to main categories
|
||||
def get_type
|
||||
if path.start_with?('manual/')
|
||||
'Manual'
|
||||
elsif path.include?('lib/data-types')
|
||||
'datatypes'
|
||||
elsif path.include?('lib/errors/validation')
|
||||
'errors/validation'
|
||||
elsif path.include?('lib/errors/database')
|
||||
'errors/database'
|
||||
elsif path.include?('lib/errors/connection')
|
||||
'errors/connection'
|
||||
elsif path.include?('lib/errors')
|
||||
'errors'
|
||||
elsif path.include?('lib/associations')
|
||||
'associations'
|
||||
elsif path.include?('master/variable')
|
||||
'variables'
|
||||
else
|
||||
'classes'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
lib/docs/scrapers/sequelize.rb
Normal file
30
lib/docs/scrapers/sequelize.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Docs
|
||||
class Sequelize < UrlScraper
|
||||
self.name = 'Sequelize'
|
||||
self.slug = 'sequelize'
|
||||
self.type = 'simple'
|
||||
self.release = '5.21.1'
|
||||
self.base_url = 'https://sequelize.org/master/'
|
||||
self.links = {
|
||||
home: 'https://sequelize.org/',
|
||||
code: 'https://github.com/sequelize/sequelize'
|
||||
}
|
||||
|
||||
# List of content filters (to be applied sequentially)
|
||||
html_filters.push 'sequelize/entries', 'sequelize/clean_html'
|
||||
|
||||
# Skip the source files, the license page and the "Who's using Sequelize" page
|
||||
options[:skip_patterns] = [/\.js\.html/, /manual\/legal\.html/, /manual\/whos-using\.html/]
|
||||
|
||||
# License information that appears appears at the bottom of the entry page
|
||||
options[:attribution] = <<-HTML
|
||||
Copyright © 2014–present Sequelize contributors<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
|
||||
# Method to fetch the most recent version of the project
|
||||
def get_latest_version(opts)
|
||||
get_npm_version('sequelize', opts)
|
||||
end
|
||||
end
|
||||
end
|
BIN
public/icons/docs/sequelize/16.png
Normal file
BIN
public/icons/docs/sequelize/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
public/icons/docs/sequelize/16@2x.png
Normal file
BIN
public/icons/docs/sequelize/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
1
public/icons/docs/sequelize/SOURCE
Normal file
1
public/icons/docs/sequelize/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://github.com/sequelize/sequelize/blob/master/docs/images/logo.png
|
Loading…
Reference in a new issue