mirror of https://github.com/freeCodeCamp/devdocs
parent
9b4f4c2ef4
commit
905d6cee9e
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 107 KiB |
@ -0,0 +1,10 @@
|
||||
#= require views/pages/base
|
||||
|
||||
class app.views.SimplePage extends app.views.BasePage
|
||||
prepare: ->
|
||||
for el in @findAllByTag('pre') when el.hasAttribute('data-language')
|
||||
@highlightCode el, el.getAttribute('data-language')
|
||||
return
|
||||
|
||||
app.views.TypescriptPage =
|
||||
app.views.SimplePage
|
@ -0,0 +1,27 @@
|
||||
module Docs
|
||||
class Typescript
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('.doc-content-container')
|
||||
|
||||
css('.xs-toc-container').remove
|
||||
|
||||
css('article h1').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
css('> header', '> article').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('pre > code').each do |node|
|
||||
node.parent['data-language'] = node['class'].sub('ts', 'typescript').sub('js', 'javascript').remove('language-')
|
||||
node.content = node.content.gsub(' ', ' ')
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,37 @@
|
||||
module Docs
|
||||
class Typescript
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1').content
|
||||
name.sub! ' and ', ' & '
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
type = at_css('#main-nav a.active').ancestors('.panel').first.at_css('> a').content
|
||||
type = name if type == 'Handbook'
|
||||
type
|
||||
end
|
||||
|
||||
SKIP_ENTRIES = ['Introduction', 'A note', 'A Note', ', and', 'Techniques', ' Concepts', 'Hello World', 'Working with', 'Our ', 'Implementing ', 'Difference between', 'Basic', 'sample', 'Questions', 'Example', 'Export as close', 'Red Flags', 'First steps', 'Pitfalls', 'Well-known', 'Starting out', 'Comparing ', 'Do not', 'Trade-off', ' vs']
|
||||
|
||||
def additional_entries
|
||||
return [] unless slug.start_with?('handbook')
|
||||
return [] if slug == 'handbook/writing-definition-files'
|
||||
|
||||
css('h1, h2').each_with_object [] do |node, entries|
|
||||
next if node.next_element.try(:name) == 'h2'
|
||||
name = node.content.strip
|
||||
next if name.length > 40
|
||||
next if name == self.name || SKIP_ENTRIES.any? { |str| name.include?(str) }
|
||||
name.remove! %r{\A#{self.name.remove(/s\z/)}s? }
|
||||
name.sub! 'for..of', 'for...of'
|
||||
name.remove! 'Symbol.'
|
||||
name.remove! '/// '
|
||||
name.prepend "#{self.name}: "
|
||||
entries << [name, node['id']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,29 @@
|
||||
module Docs
|
||||
class Typescript < UrlScraper
|
||||
self.name = 'TypeScript'
|
||||
self.type = 'typescript'
|
||||
self.release = '1.8'
|
||||
self.base_url = 'https://www.typescriptlang.org/docs/'
|
||||
self.root_path = 'tutorial.html'
|
||||
self.links = {
|
||||
home: 'https://www.typescriptlang.org',
|
||||
code: 'https://github.com/Microsoft/TypeScript'
|
||||
}
|
||||
|
||||
html_filters.push 'typescript/entries', 'typescript/clean_html'
|
||||
|
||||
options[:container] = '#content'
|
||||
options[:skip_link] = ->(node) { node.parent.parent['class'] == 'dropdown-menu' }
|
||||
options[:fix_urls] = ->(url) {
|
||||
url.sub!(/(\w+)\.md/) { "#{$1.downcase}.html" }
|
||||
url
|
||||
}
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Microsoft and other contributors<br>
|
||||
Licensed under the Apache License, Version 2.0.
|
||||
HTML
|
||||
end
|
||||
end
|
||||
|
||||
|
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 734 B |
@ -0,0 +1 @@
|
||||
https://github.com/remojansen/logo.ts
|
Loading…
Reference in new issue