Merge pull request #1354 from MasterEnoc/typescript

Update Typescript to 4.0.5
pull/1357/head
Simon Legner 4 years ago committed by GitHub
commit 6e8441dc1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -783,7 +783,7 @@ credits = [
'https://twig.symfony.com/license' 'https://twig.symfony.com/license'
], [ ], [
'TypeScript', 'TypeScript',
'2012-2019 Microsoft', '2012-2020 Microsoft',
'Apache', 'Apache',
'https://raw.githubusercontent.com/Microsoft/TypeScript-Handbook/master/LICENSE' 'https://raw.githubusercontent.com/Microsoft/TypeScript-Handbook/master/LICENSE'
], [ ], [

@ -2,30 +2,38 @@ module Docs
class Typescript class Typescript
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
@doc = at_css('.doc-content-container')
if root_page? # Top menu bar
at_css('h1').content = 'TypeScript Documentation' css('#top-menu').remove
end css('.skip-to-main').remove
css('.xs-toc-container').remove # Sidebar
css('.anchor-hash').remove css('#sidebar').remove
css('article h1').each do |node| # Pound symbol before each title
node.name = 'h2' css('.anchor').remove
end
css('> header', '> article').each do |node| css('#handbook-content > h2').each do |node|
node.before(node.children).remove node.name = 'h1'
end end
css('pre > code').each do |node| css('a:contains("Try")').remove
node.parent['data-language'] = node['class'].sub('ts', 'typescript').sub('js', 'javascript').remove('language-') if node['class'] css('pre').each do |node|
node.content = node.content.gsub(' ', ' ') node.content = node.content
node.before(node.children).remove node['data-language'] = 'typescript'
node.remove_attribute('class')
end end
# 'Next' title area
css('.whitespace-tight').remove
# Right side floating box
css('.handbook-toc').remove
css('#site-footer').remove
doc doc
end end
end end
end end

@ -1,41 +1,26 @@
module Docs module Docs
class Typescript class Typescript
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
name = at_css('h1').content.strip return 'Typescript' if current_url == root_url
name.sub! ' and ', ' & ' return at_css('h2').content
name
end end
def get_type def get_type
return 'Declaration Files' if subpath.include?('declaration-files') name
return 'Project Configuration' if slug == 'handbook/configuring-watch'
type = at_css('#main-nav a.active').ancestors('.panel').first.at_css('> a').content
type = name if type == 'Handbook'
type
end 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', 'Overview', 'Related', 'Table of contents']
def additional_entries def additional_entries
return [] unless slug.start_with?('handbook') entries = []
return [] if slug.include?('release-notes')
return [] if slug == 'handbook/writing-definition-files'
css('.post-content h1, .post-content h2').each_with_object [] do |node, entries| css('h2').each do |node|
next if node.next_element.try(:name) == 'h2' entries << [node.content, node['id'], name]
node.css('.anchor-hash').remove
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
entries
end end
end end
end end
end end

@ -2,9 +2,9 @@ module Docs
class Typescript < UrlScraper class Typescript < UrlScraper
self.name = 'TypeScript' self.name = 'TypeScript'
self.type = 'simple' self.type = 'simple'
self.release = '3.7.4' self.release = '4.0.5'
self.base_url = 'https://www.typescriptlang.org/docs/' self.base_url = 'https://www.typescriptlang.org/docs/handbook'
self.root_path = 'tutorial.html' self.root_path = 'index.html'
self.links = { self.links = {
home: 'https://www.typescriptlang.org', home: 'https://www.typescriptlang.org',
code: 'https://github.com/Microsoft/TypeScript' code: 'https://github.com/Microsoft/TypeScript'
@ -12,16 +12,27 @@ module Docs
html_filters.push 'typescript/entries', 'typescript/clean_html' html_filters.push 'typescript/entries', 'typescript/clean_html'
options[:container] = '#doc-content' options[:skip] = [
options[:skip] = %w(home.html handbook/release-notes/overview.html) '/react-&-webpack.html',
options[:skip_link] = ->(node) { node.parent.parent['class'] == 'dropdown-menu' } '/asp-net-core.html',
options[:fix_urls] = ->(url) { '/gulp.html',
url.sub!(/(\w+)\.md/) { "#{$1.downcase}.html" } '/dom-manipulation.html',
url '/migrating-from-javascript.html',
} '/babel-with-typescript.html',
'/intro.html'
]
options[:skip_patterns] = [
/2/,
/typescript-/,
/release-notes/,
/introduction/,
/tutorials/,
/intro.html/
]
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2012-2019 Microsoft<br> &copy; 2012-2020 Microsoft<br>
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML

Loading…
Cancel
Save