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
116116 'pages/tcl_tk',
117117 'pages/tensorflow',
118118 'pages/terraform',
119+ 'pages/typescript',
119120 'pages/underscore',
120121 'pages/vue',
121122 '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
2424
2525 def other
2626 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
2730 @doc = at_css('article > .whitespace > .markdown')
31+ doc.child.before(deprecated) if deprecated
2832 else # tsconfig page
2933 @doc = at_css('.markdown > div')
3034
@@ -36,9 +40,14 @@ module Docs · 5 unmodified lines
3640 css('pre').each do |node|
3741 language = node.at_css('.language-id') ? node.at_css('.language-id').content : 'typescript'
3842 node.css('.language-id').remove
39− node.content = node.content
43+ 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
4048 node['data-language'] = LANGUAGE_REPLACE[language] || language
4149 node.remove_attribute('class')
50+ node.remove_attribute('style')
4251 end
4352 end
4453
lib/docs/filters/typescript/entries.rb+17−1
@@ -2,15 +2,31 @@ module Docs · 1 unmodified line
22 class Typescript
33 class EntriesFilter < Docs::EntriesFilter
44
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+
516 def get_name
617 at_css('h1') ? at_css('h1').content : at_css('h2').content
718 end
819
920 def get_type
10− name
21+ if DEPRECATED_PAGES.include? slug
22+ 'Handbook (deprecated)'
23+ else
24+ name
25+ end
1126 end
1227
1328 def additional_entries
29+ return [] if DEPRECATED_PAGES.include? slug
1430 base_url.path == '/' ? tsconfig_entries : handbook_entries
1531 end
1632
lib/docs/scrapers/typescript.rb+2−3
@@ -3,8 +3,8 @@ module Docs · 2 unmodified lines
33 include MultipleBaseUrls
44
55 self.name = 'TypeScript'
6− self.type = 'simple'
7− self.release = '4.2.2'
6+ self.type = 'typescript'
7+ self.release = '4.2.3'
88 self.base_urls = [
99 'https://www.typescriptlang.org/docs/handbook/',
1010 'https://www.typescriptlang.org/'
@@ -29,7 +29,6 @@ module Docs · 18 unmodified lines
2929 ]
3030
3131 options[:skip_patterns] = [
32− /2/,
3332 /release-notes/,
3433 /play\//
3534 ]