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
99 }
1010
1111 def call
12+ @doc = at_css('main')
1213 root_page? ? root : other
1314 doc
1415 end
@@ -17,6 +18,9 @@ module Docs · 2 unmodified lines
1718 header = at_css('h1')
1819 header.parent.before(header).remove
1920
21+ # css('#above-the-fold-headline-code').remove
22+ # css('#adopt-gradually-content').remove
23+
2024 css('h4').each do |node|
2125 node.name = 'h2'
2226 end
lib/docs/filters/typescript/entries.rb+9−2
@@ -21,8 +21,15 @@ module Docs · 20 unmodified lines
2121 def get_type
2222 if DEPRECATED_PAGES.include? slug
2323 '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'
2430 else
25− name
31+ button = at_css('nav#sidebar > ul > li.open.highlighted > button')
32+ button ? button.content : name
2633 end
2734 end
2835
@@ -39,7 +46,7 @@ module Docs · 10 unmodified lines
3946 end
4047
4148 def handbook_entries
42− css('h2').each_with_object [] do |node, entries|
49+ css('h2', 'h3:has(code)').each_with_object [] do |node, entries|
4350 entries << ["#{name}: #{node.content}", node['id']] if node['id']
4451 end
4552 end
lib/docs/scrapers/typescript.rb+13−3
@@ -4,12 +4,14 @@ module Docs · 3 unmodified lines
44
55 self.name = 'TypeScript'
66 self.type = 'typescript'
7− self.release = '5.1.3'
7+ self.release = '5.3.3'
88 self.base_urls = [
99 'https://www.typescriptlang.org/docs/handbook/',
1010 'https://www.typescriptlang.org/'
1111 ]
1212
13+ self.root_path = 'docs/'
14+
1315 def initial_urls
1416 [ 'https://www.typescriptlang.org/docs/handbook/',
1517 'https://www.typescriptlang.org/tsconfig' ]
@@ -22,16 +24,24 @@ module Docs · 6 unmodified lines
2224
2325 html_filters.push 'typescript/entries', 'typescript/clean_html', 'title'
2426
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
2632
2733 options[:skip] = [
2834 'react-&-webpack.html'
2935 ]
3036
3137 options[:skip_patterns] = [
38+ /\Abranding/,
39+ /\Acommunity/,
40+ /\Adocs\Z/,
41+ /\Atools/,
3242 /release-notes/,
3343 /dt\/search/,
34− /play\//
44+ /play/
3545 ]
3646
3747 options[:attribution] = <<-HTML