History

Typescript: add 'tsconfig' section and update scraper to 4.1.3

MasterEnoc committed 5 years ago

Commit 2f5ed721 parent 6a4c1f23 files · +53 −8Browse files

Unified · Split

3 files
  1. lib/docs/filters/typescript/clean_html.rb +15 −1
  2. lib/docs/filters/typescript/entries.rb +18 −2
  3. lib/docs/scrapers/typescript.rb +20 −5
lib/docs/filters/typescript/clean_html.rb+15−1
@@ -1,8 +1,16 @@
1module Docs1module Docs
2 class Typescript2 class Typescript
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4
4 def call5 def call
5 root_page? ? root : other6 if slug.include?('index')
7 root
8 elsif slug == ('tsconfig/')
9 tsconfig
10 else
11 other
12 end
13
6 doc14 doc
7 end15 end
8 16
@@ -27,6 +35,12 @@ module Docs · 18 unmodified lines
27 node.remove_attribute('class')35 node.remove_attribute('class')
28 end36 end
29 end37 end
38
39 def tsconfig
40 css('h2 a', 'h3 a').remove
41 css('svg').remove
42 end
43
30 end44 end
31 end45 end
32end46end
lib/docs/filters/typescript/entries.rb+18−2
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 4
5 def get_name5 def get_name
6 return at_css('h2').content6 at_css('h1') ? at_css('h1').content : at_css('h2').content
7 end7 end
8 8
9 def get_type9 def get_type
@@ -11,9 +11,25 @@ module Docs · 1 unmodified line
11 end11 end
12 12
13 def additional_entries13 def additional_entries
14 css('h2').each_with_object [] do |node,entries|14 entries = []
15
16 css('h2').each do |node|
17
18 if slug == 'tsconfig/'
19 node.css('a').remove
20 end
21
15 entries << [node.content, node['id'], name]22 entries << [node.content, node['id'], name]
16 end23 end
24
25 if slug == 'tsconfig/'
26 css('h3').each do |node|
27 node.css('a').remove
28 entries << [node.content, node['id'], name]
29 end
30 end
31
32 entries
17 end33 end
18 34
19 end35 end
lib/docs/scrapers/typescript.rb+20−5
@@ -2,9 +2,13 @@ module Docs · 1 unmodified line
2 class Typescript < UrlScraper2 class Typescript < UrlScraper
3 self.name = 'TypeScript'3 self.name = 'TypeScript'
4 self.type = 'simple'4 self.type = 'simple'
5 self.release = '4.1.2'5 self.release = '4.1.3'
6 self.base_url = 'https://www.typescriptlang.org/docs/handbook/'6 self.base_url = 'https://www.typescriptlang.org/'
7 self.root_path = 'index.html'7 self.root_path = 'docs/handbook/index.html'
8 self.initial_paths = [
9 'tsconfig/'
10 ]
11
8 self.links = {12 self.links = {
9 home: 'https://www.typescriptlang.org',13 home: 'https://www.typescriptlang.org',
10 code: 'https://github.com/Microsoft/TypeScript'14 code: 'https://github.com/Microsoft/TypeScript'
@@ -15,14 +19,24 @@ module Docs · 4 unmodified lines
15 options[:container] = 'main'19 options[:container] = 'main'
16 20
17 options[:skip] = [21 options[:skip] = [
18 'react-&-webpack.html',22 'docs/handbook/react-&-webpack.html'
19 ]23 ]
20 24
21 options[:skip_patterns] = [25 options[:skip_patterns] = [
22 /2/,26 /2/,
23 /release-notes/,27 /release-notes/
28 ]
29
30 options[:only_patterns] = [
31 /docs\/handbook\//,
32 /tsconfig\//
24 ]33 ]
25 34
35 options[:fix_urls] = -> (url) do
36 url.gsub!(/docs\/handbook\/index.html/, "index.html")
37 url
38 end
39
26 options[:attribution] = <<-HTML40 options[:attribution] = <<-HTML
27 &copy; 2012-2020 Microsoft<br>41 &copy; 2012-2020 Microsoft<br>
28 Licensed under the Apache License, Version 2.0.42 Licensed under the Apache License, Version 2.0.
@@ -31,5 +45,6 @@ module Docs · 2 unmodified lines
31 def get_latest_version(opts)45 def get_latest_version(opts)
32 get_latest_github_release('Microsoft', 'TypeScript', opts)46 get_latest_github_release('Microsoft', 'TypeScript', opts)
33 end47 end
48
34 end49 end
35end50end