mirror of https://github.com/freeCodeCamp/devdocs
parent
be13903319
commit
0c8ca4e5fa
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 136 KiB |
@ -0,0 +1,17 @@
|
||||
#= require views/pages/simple
|
||||
|
||||
class app.views.SqlitePage extends app.views.SimplePage
|
||||
@events:
|
||||
click: 'onClick'
|
||||
|
||||
onClick: (event) =>
|
||||
return unless id = event.target.getAttribute('data-toggle')
|
||||
return unless el = @find("##{id}")
|
||||
$.stopEvent(event)
|
||||
if el.style.display == 'none'
|
||||
el.style.display = 'block'
|
||||
event.target.textContent = 'hide'
|
||||
else
|
||||
el.style.display = 'none'
|
||||
event.target.textContent = 'show'
|
||||
return
|
@ -0,0 +1,6 @@
|
||||
._sqlite {
|
||||
@extend %simple;
|
||||
|
||||
dt { @extend %block-label, %label-blue; }
|
||||
.todo { @extend %note, %note-red; }
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
module Docs
|
||||
class Sqlite
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
at_css('.nosearch').remove
|
||||
|
||||
css('.rightsidebar', 'hr', '.sh_mark', '.fancy_toc > a', '.fancy_toc_mark', 'h[style*="none"]',
|
||||
'a[href$="intro.html"] > h2', 'a[href$="intro"] > h2', '#document_title + #toc_header',
|
||||
'#document_title ~ #toc').remove
|
||||
|
||||
css('.fancy_title', '> h2[align=center]', '#document_title').each do |node|
|
||||
node.name = 'h1'
|
||||
end
|
||||
|
||||
unless at_css('h1')
|
||||
if at_css('h2').content == context[:html_title]
|
||||
at_css('h2').name = 'h1'
|
||||
else
|
||||
doc.child.before("<h1>#{context[:html_title]}</h1>")
|
||||
end
|
||||
end
|
||||
|
||||
if root_page?
|
||||
at_css('h1').content = 'SQLite Documentation'
|
||||
end
|
||||
|
||||
css('.codeblock', '.fancy', '.nosearch', '.optab > blockquote', '.optab').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('blockquote').each do |node|
|
||||
next unless node.at_css('b')
|
||||
node.name = 'pre'
|
||||
node.inner_html = node.inner_html.gsub('<br>', "\n")
|
||||
end
|
||||
|
||||
css('.todo').each do |node|
|
||||
node.inner_html = "TODO: #{node.inner_html}"
|
||||
end
|
||||
|
||||
css('blockquote > pre', 'a > h1', 'a > h2', 'center > table', 'ul > ul').each do |node|
|
||||
node.parent.before(node.parent.children).remove
|
||||
end
|
||||
|
||||
css('table > tr:first-child:last-child > td:first-child:last-child > pre',
|
||||
'table > tr:first-child:last-child > td:first-child:last-child > ul').each do |node|
|
||||
node.ancestors('table').first.replace(node)
|
||||
end
|
||||
|
||||
css('a[name]').each do |node|
|
||||
if node.next_element
|
||||
if node.next_element['id']
|
||||
node.next_element.next_element['id'] ||= node['name']
|
||||
else
|
||||
node.next_element['id'] = node['name']
|
||||
end
|
||||
else
|
||||
node.parent['id'] ||= node['name']
|
||||
end
|
||||
node.remove
|
||||
end
|
||||
|
||||
unless at_css('h2')
|
||||
css('h1 ~ h1').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
end
|
||||
|
||||
css('tt').each do |node|
|
||||
node.name = 'code'
|
||||
end
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
node['data-language'] = 'sql'
|
||||
end
|
||||
|
||||
css('button[onclick]').each do |node|
|
||||
node['class'] = '_btn'
|
||||
node['data-toggle'] = node['onclick'][/hideorshow\("\w+","(\w+)"\)/, 1]
|
||||
node.remove_attribute('onclick')
|
||||
end
|
||||
|
||||
css('*[align]').remove_attr('align')
|
||||
css('*[style]:not(.imgcontainer)').remove_attr('style')
|
||||
css('table[border]').remove_attr('border')
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,42 @@
|
||||
module Docs
|
||||
class Sqlite
|
||||
class CleanJsTablesFilter < Filter
|
||||
def call
|
||||
css('table[id]:empty + script').each do |node|
|
||||
json_list = JSON.parse(node.inner_html[/\[.+?\]/m])
|
||||
list = '<ul>'
|
||||
json_list.each do |item|
|
||||
list << '<li>'
|
||||
|
||||
unless item['u'].blank? || item['s'] == 2
|
||||
list << %(<a href="#{item['u']}">)
|
||||
link = true
|
||||
end
|
||||
|
||||
if item['s'] == 2 || item['s'] == 3
|
||||
list << "<s>#{item['x']}</s>"
|
||||
else
|
||||
list << item['x']
|
||||
end
|
||||
|
||||
list << '</a>' if link
|
||||
|
||||
if item['s'] == 1
|
||||
list << ' <small><i>(exp)</i></small>'
|
||||
elsif item['s'] == 3
|
||||
list << '¹'
|
||||
elsif item['s'] == 4
|
||||
list << '²'
|
||||
elsif item['s'] == 5
|
||||
list << '³'
|
||||
end
|
||||
end
|
||||
list << '</ul>'
|
||||
node.previous_element.replace(list)
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,79 @@
|
||||
module Docs
|
||||
class Sqlite
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
ADDITIONAL_ENTRIES = {}
|
||||
|
||||
def get_name
|
||||
name = context[:html_title]
|
||||
name.remove! 'SQLite Query Language: '
|
||||
name.remove! %r{\.\z}
|
||||
name = at_css('#document_title').content if name == 'No Title'
|
||||
name
|
||||
end
|
||||
|
||||
TYPE_BY_SUBPATH_STARTS_WITH = {
|
||||
'c3ref' => 'C Interface',
|
||||
'capi' => 'C Interface',
|
||||
'session' => 'C Interface: Session Module',
|
||||
'optoverview' => 'Query Planner',
|
||||
'queryplanner' => 'Query Planner',
|
||||
'syntax' => 'Syntax Diagrams',
|
||||
'lang' => 'Language',
|
||||
'pragma' => 'PRAGMA Statements',
|
||||
'cli' => 'CLI',
|
||||
'json' => 'JSON',
|
||||
'fileformat' => 'Database File Format',
|
||||
'tcl' => 'Tcl Interface',
|
||||
'malloc' => 'Dynamic Memory Allocation',
|
||||
'vtab' => 'Virtual Table Mechanism',
|
||||
'datatype' => 'Datatypes',
|
||||
'locking' => 'Locking and Concurrency',
|
||||
'foreignkey' => 'Foreign Key Constraints',
|
||||
'wal' => 'Write-Ahead Logging',
|
||||
'fts' => 'Full-Text Search',
|
||||
'rtree' => 'R*Tree Module',
|
||||
'rbu' => 'RBU Extension',
|
||||
'limits' => 'Limits',
|
||||
'howtocorrupt' => 'How To Corrupt'
|
||||
}
|
||||
|
||||
def get_type
|
||||
TYPE_BY_SUBPATH_STARTS_WITH.each_pair do |key, value|
|
||||
return value if subpath.start_with?(key)
|
||||
end
|
||||
|
||||
if slug.in?(%w(cintro carray c_interface))
|
||||
'C Interface'
|
||||
elsif context[:html_title].start_with?('SQLite Query Language')
|
||||
'Query Language'
|
||||
else
|
||||
'Miscellaneous'
|
||||
end
|
||||
end
|
||||
|
||||
IGNORE_ADDITIONAL_ENTRIES_SLUGS = %w(testing uri getthecode whentouse compile)
|
||||
|
||||
def additional_entries
|
||||
if subpath == 'keyword_index.html'
|
||||
css('li a[href*="#"]').each do |node|
|
||||
slug, id = node['href'].split('#')
|
||||
name = node.content.strip
|
||||
next if name.start_with?('-') || IGNORE_ADDITIONAL_ENTRIES_SLUGS.include?(slug)
|
||||
name.remove! %r{\Athe }
|
||||
name.remove! %r{ SQL function\z}
|
||||
name = 'ORDER BY' if name == 'order by'
|
||||
name.sub!(/\A([a-z])([a-z]+) /) { "#{$1.upcase}#{$2} " }
|
||||
ADDITIONAL_ENTRIES[slug] ||= []
|
||||
ADDITIONAL_ENTRIES[slug] << [name, id]
|
||||
end
|
||||
end
|
||||
|
||||
ADDITIONAL_ENTRIES[slug] || []
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
subpath != 'keyword_index.html' && subpath != 'sitemap.html'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,52 @@
|
||||
module Docs
|
||||
class Sqlite < FileScraper
|
||||
self.name = 'SQLite'
|
||||
self.type = 'sqlite'
|
||||
self.release = '3.15.2'
|
||||
self.dir = '/Users/Thibaut/DevDocs/Docs/sqlite/'
|
||||
self.base_url = 'https://sqlite.org/'
|
||||
self.root_path = 'docs.html'
|
||||
self.initial_paths = %w(keyword_index.html)
|
||||
self.links = {
|
||||
home: 'https://sqlite.org/',
|
||||
code: 'https://www.sqlite.org/src/'
|
||||
}
|
||||
|
||||
html_filters.insert_before 'clean_html', 'sqlite/clean_js_tables'
|
||||
html_filters.push 'sqlite/entries', 'sqlite/clean_html'
|
||||
|
||||
options[:only_patterns] = [/\.html\z/]
|
||||
options[:skip_patterns] = [/releaselog/, /consortium/]
|
||||
options[:skip] = %w(
|
||||
index.html
|
||||
about.html
|
||||
download.html
|
||||
copyright.html
|
||||
support.html
|
||||
prosupport.html
|
||||
hp1.html
|
||||
news.html
|
||||
oldnews.html
|
||||
doclist.html
|
||||
dev.html
|
||||
chronology.html
|
||||
not-found.html
|
||||
famous.html
|
||||
books.html
|
||||
crew.html
|
||||
mostdeployed.html
|
||||
requirements.html
|
||||
session/intro.html
|
||||
syntax.html
|
||||
)
|
||||
|
||||
options[:attribution] = 'SQLite is in the Public Domain.'
|
||||
|
||||
private
|
||||
|
||||
def parse(html)
|
||||
html.gsub! %r{(<h2[^>]*>[^<]+)</h1>}, '\1</h2>'
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 520 B |
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in new issue