History

Update TypeScript documentation (5.3.3)

Simon Legner committed 2 years ago

Commit ddfeed41 parent 53a96533 files · +26 −5Browse files

Unified · Split

3 files
  1. lib/docs/filters/typescript/clean_html.rb +4 −0
  2. lib/docs/filters/typescript/entries.rb +9 −2
  3. lib/docs/scrapers/typescript.rb +13 −3
lib/docs/filters/typescript/clean_html.rb+4−0
@@ -9,6 +9,7 @@ module Docs · 8 unmodified lines
9 }9 }
10 10
11 def call11 def call
12 @doc = at_css('main')
12 root_page? ? root : other13 root_page? ? root : other
13 doc14 doc
14 end15 end
@@ -17,6 +18,9 @@ module Docs · 2 unmodified lines
17 header = at_css('h1')18 header = at_css('h1')
18 header.parent.before(header).remove19 header.parent.before(header).remove
19 20
21 # css('#above-the-fold-headline-code').remove
22 # css('#adopt-gradually-content').remove
23
20 css('h4').each do |node|24 css('h4').each do |node|
21 node.name = 'h2'25 node.name = 'h2'
22 end26 end
lib/docs/filters/typescript/entries.rb+9−2
@@ -21,8 +21,15 @@ module Docs · 20 unmodified lines
21 def get_type21 def get_type
22 if DEPRECATED_PAGES.include? slug22 if DEPRECATED_PAGES.include? slug
23 'Handbook (deprecated)'23 'Handbook (deprecated)'
24 elsif slug.include?('declaration-files')
25 'Declaration Files'
26 elsif slug == 'download'
27 'Handbook'
28 elsif slug == 'why-create-typescript'
29 'Handbook'
24 else30 else
25 name31 button = at_css('nav#sidebar > ul > li.open.highlighted > button')
32 button ? button.content : name
26 end33 end
27 end34 end
28 35
@@ -39,7 +46,7 @@ module Docs · 10 unmodified lines
39 end46 end
40 47
41 def handbook_entries48 def handbook_entries
42 css('h2').each_with_object [] do |node, entries|49 css('h2', 'h3:has(code)').each_with_object [] do |node, entries|
43 entries << ["#{name}: #{node.content}", node['id']] if node['id']50 entries << ["#{name}: #{node.content}", node['id']] if node['id']
44 end51 end
45 end52 end
lib/docs/scrapers/typescript.rb+13−3
@@ -4,12 +4,14 @@ module Docs · 3 unmodified lines
4 4
5 self.name = 'TypeScript'5 self.name = 'TypeScript'
6 self.type = 'typescript'6 self.type = 'typescript'
7 self.release = '5.1.3'7 self.release = '5.3.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/'
11 ]11 ]
12 12
13 self.root_path = 'docs/'
14
13 def initial_urls15 def initial_urls
14 [ 'https://www.typescriptlang.org/docs/handbook/',16 [ 'https://www.typescriptlang.org/docs/handbook/',
15 'https://www.typescriptlang.org/tsconfig' ]17 'https://www.typescriptlang.org/tsconfig' ]
@@ -22,16 +24,24 @@ module Docs · 6 unmodified lines
22 24
23 html_filters.push 'typescript/entries', 'typescript/clean_html', 'title'25 html_filters.push 'typescript/entries', 'typescript/clean_html', 'title'
24 26
25 options[:container] = 'main'27 options[:fix_urls_before_parse] = ->(url) do
28 url.sub! '/docs/handbook/esm-node.html', '/docs/handbook/modules/reference.html#node16-nodenext'
29 url.sub! '/docs/handbook/modules.html', '/docs/handbook/modules/introduction.html'
30 url
31 end
26 32
27 options[:skip] = [33 options[:skip] = [
28 'react-&-webpack.html'34 'react-&-webpack.html'
29 ]35 ]
30 36
31 options[:skip_patterns] = [37 options[:skip_patterns] = [
38 /\Abranding/,
39 /\Acommunity/,
40 /\Adocs\Z/,
41 /\Atools/,
32 /release-notes/,42 /release-notes/,
33 /dt\/search/,43 /dt\/search/,
34 /play\//44 /play/
35 ]45 ]
36 46
37 options[:attribution] = <<-HTML47 options[:attribution] = <<-HTML