Update TypeScript documentation (New Handbook)

https://devblogs.microsoft.com/typescript/announcing-the-new-typescript-handbook/
This commit is contained in:
Simon Legner 2021-03-06 00:37:42 +01:00
parent e9d7849412
commit 91138ad508
5 changed files with 34 additions and 5 deletions

View file

@ -116,6 +116,7 @@
'pages/tcl_tk',
'pages/tensorflow',
'pages/terraform',
'pages/typescript',
'pages/underscore',
'pages/vue',
'pages/webpack',

View file

@ -0,0 +1,4 @@
._typescript {
@extend %simple;
.deprecated { @extend %label-red; }
}

View file

@ -24,7 +24,11 @@ module Docs
def other
if base_url.path == '/docs/handbook/'
deprecated = at_css('#deprecated-content')
deprecated.css('h3', '#deprecated-icon').remove if deprecated
deprecated.add_class('deprecated') if deprecated
@doc = at_css('article > .whitespace > .markdown')
doc.child.before(deprecated) if deprecated
else # tsconfig page
@doc = at_css('.markdown > div')
@ -36,9 +40,14 @@ module Docs
css('pre').each do |node|
language = node.at_css('.language-id') ? node.at_css('.language-id').content : 'typescript'
node.css('.language-id').remove
node.content = node.content
if node.at_css('.line').nil?
node.content = node.content
else
node.content = node.css('.line').map(&:content).join("\n")
end
node['data-language'] = LANGUAGE_REPLACE[language] || language
node.remove_attribute('class')
node.remove_attribute('style')
end
end

View file

@ -2,15 +2,31 @@ module Docs
class Typescript
class EntriesFilter < Docs::EntriesFilter
DEPRECATED_PAGES = %w(
advanced-types
basic-types
classes
functions
generics
interfaces
literal-types
unions-and-intersections
)
def get_name
at_css('h1') ? at_css('h1').content : at_css('h2').content
end
def get_type
name
if DEPRECATED_PAGES.include? slug
'Handbook (deprecated)'
else
name
end
end
def additional_entries
return [] if DEPRECATED_PAGES.include? slug
base_url.path == '/' ? tsconfig_entries : handbook_entries
end

View file

@ -3,8 +3,8 @@ module Docs
include MultipleBaseUrls
self.name = 'TypeScript'
self.type = 'simple'
self.release = '4.2.2'
self.type = 'typescript'
self.release = '4.2.3'
self.base_urls = [
'https://www.typescriptlang.org/docs/handbook/',
'https://www.typescriptlang.org/'
@ -29,7 +29,6 @@ module Docs
]
options[:skip_patterns] = [
/2/,
/release-notes/,
/play\//
]