History

Update TypeScript documentation (New Handbook)

https://devblogs.microsoft.com/typescript/announcing-the-new-typescript-handbook/

Simon Legner committed 5 years ago

Commit 91138ad1 parent e9d78495 files · +34 −5Browse files

Unified · Split

5 files
  1. assets/stylesheets/application.css.scss +1 −0
  2. assets/stylesheets/pages/_typescript.scss +4 −0
  3. lib/docs/filters/typescript/clean_html.rb +10 −1
  4. lib/docs/filters/typescript/entries.rb +17 −1
  5. lib/docs/scrapers/typescript.rb +2 −3
assets/stylesheets/application.css.scss+1−0
@@ -116,6 +116,7 @@ · 115 unmodified lines
116 'pages/tcl_tk',116 'pages/tcl_tk',
117 'pages/tensorflow',117 'pages/tensorflow',
118 'pages/terraform',118 'pages/terraform',
119 'pages/typescript',
119 'pages/underscore',120 'pages/underscore',
120 'pages/vue',121 'pages/vue',
121 'pages/webpack',122 'pages/webpack',
assets/stylesheets/pages/_typescript.scss+4−0
@@ -0,0 +1,4 @@
1._typescript {
2 @extend %simple;
3 .deprecated { @extend %label-red; }
4}
lib/docs/filters/typescript/clean_html.rb+10−1
@@ -24,7 +24,11 @@ module Docs · 23 unmodified lines
24 24
25 def other25 def other
26 if base_url.path == '/docs/handbook/'26 if base_url.path == '/docs/handbook/'
27 deprecated = at_css('#deprecated-content')
28 deprecated.css('h3', '#deprecated-icon').remove if deprecated
29 deprecated.add_class('deprecated') if deprecated
27 @doc = at_css('article > .whitespace > .markdown')30 @doc = at_css('article > .whitespace > .markdown')
31 doc.child.before(deprecated) if deprecated
28 else # tsconfig page32 else # tsconfig page
29 @doc = at_css('.markdown > div')33 @doc = at_css('.markdown > div')
30 34
@@ -36,9 +40,14 @@ module Docs · 5 unmodified lines
36 css('pre').each do |node|40 css('pre').each do |node|
37 language = node.at_css('.language-id') ? node.at_css('.language-id').content : 'typescript'41 language = node.at_css('.language-id') ? node.at_css('.language-id').content : 'typescript'
38 node.css('.language-id').remove42 node.css('.language-id').remove
39 node.content = node.content43 if node.at_css('.line').nil?
44 node.content = node.content
45 else
46 node.content = node.css('.line').map(&:content).join("\n")
47 end
40 node['data-language'] = LANGUAGE_REPLACE[language] || language48 node['data-language'] = LANGUAGE_REPLACE[language] || language
41 node.remove_attribute('class')49 node.remove_attribute('class')
50 node.remove_attribute('style')
42 end51 end
43 end52 end
44 53
lib/docs/filters/typescript/entries.rb+17−1
@@ -2,15 +2,31 @@ module Docs · 1 unmodified line
2 class Typescript2 class Typescript
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 4
5 DEPRECATED_PAGES = %w(
6 advanced-types
7 basic-types
8 classes
9 functions
10 generics
11 interfaces
12 literal-types
13 unions-and-intersections
14 )
15
5 def get_name16 def get_name
6 at_css('h1') ? at_css('h1').content : at_css('h2').content17 at_css('h1') ? at_css('h1').content : at_css('h2').content
7 end18 end
8 19
9 def get_type20 def get_type
10 name21 if DEPRECATED_PAGES.include? slug
22 'Handbook (deprecated)'
23 else
24 name
25 end
11 end26 end
12 27
13 def additional_entries28 def additional_entries
29 return [] if DEPRECATED_PAGES.include? slug
14 base_url.path == '/' ? tsconfig_entries : handbook_entries30 base_url.path == '/' ? tsconfig_entries : handbook_entries
15 end31 end
16 32
lib/docs/scrapers/typescript.rb+2−3
@@ -3,8 +3,8 @@ module Docs · 2 unmodified lines
3 include MultipleBaseUrls3 include MultipleBaseUrls
4 4
5 self.name = 'TypeScript'5 self.name = 'TypeScript'
6 self.type = 'simple'6 self.type = 'typescript'
7 self.release = '4.2.2'7 self.release = '4.2.3'
8 self.base_urls = [8 self.base_urls = [
9 'https://www.typescriptlang.org/docs/handbook/',9 'https://www.typescriptlang.org/docs/handbook/',
10 'https://www.typescriptlang.org/'10 'https://www.typescriptlang.org/'
@@ -29,7 +29,6 @@ module Docs · 18 unmodified lines
29 ]29 ]
30 30
31 options[:skip_patterns] = [31 options[:skip_patterns] = [
32 /2/,
33 /release-notes/,32 /release-notes/,
34 /play\//33 /play\//
35 ]34 ]