Unified · Split
| @@ -1,8 +1,16 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Typescript |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | + | |
| 4 | 5 | def call |
| 5 | − root_page? ? root : other | |
| 6 | + if slug.include?('index') | |
| 7 | + root | |
| 8 | + elsif slug == ('tsconfig/') | |
| 9 | + tsconfig | |
| 10 | + else | |
| 11 | + other | |
| 12 | + end | |
| 13 | + | |
| 6 | 14 | doc |
| 7 | 15 | end |
| 8 | 16 | |
| @@ -27,6 +35,12 @@ module Docs · 18 unmodified lines | ||
| 27 | 35 | node.remove_attribute('class') |
| 28 | 36 | end |
| 29 | 37 | end |
| 38 | + | |
| 39 | + def tsconfig | |
| 40 | + css('h2 a', 'h3 a').remove | |
| 41 | + css('svg').remove | |
| 42 | + end | |
| 43 | + | |
| 30 | 44 | end |
| 31 | 45 | end |
| 32 | 46 | end |
| @@ -3,7 +3,7 @@ module Docs · 2 unmodified lines | ||
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | |
| 5 | 5 | def get_name |
| 6 | − return at_css('h2').content | |
| 6 | + at_css('h1') ? at_css('h1').content : at_css('h2').content | |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | def get_type |
| @@ -11,9 +11,25 @@ module Docs · 1 unmodified line | ||
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | 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 | 22 | entries << [node.content, node['id'], name] |
| 16 | 23 | 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 | 33 | end |
| 18 | 34 | |
| 19 | 35 | end |
| @@ -2,9 +2,13 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Typescript < UrlScraper |
| 3 | 3 | self.name = 'TypeScript' |
| 4 | 4 | self.type = 'simple' |
| 5 | − self.release = '4.1.2' | |
| 6 | − self.base_url = 'https://www.typescriptlang.org/docs/handbook/' | |
| 7 | − self.root_path = 'index.html' | |
| 5 | + self.release = '4.1.3' | |
| 6 | + self.base_url = 'https://www.typescriptlang.org/' | |
| 7 | + self.root_path = 'docs/handbook/index.html' | |
| 8 | + self.initial_paths = [ | |
| 9 | + 'tsconfig/' | |
| 10 | + ] | |
| 11 | + | |
| 8 | 12 | self.links = { |
| 9 | 13 | home: 'https://www.typescriptlang.org', |
| 10 | 14 | code: 'https://github.com/Microsoft/TypeScript' |
| @@ -15,14 +19,24 @@ module Docs · 4 unmodified lines | ||
| 15 | 19 | options[:container] = 'main' |
| 16 | 20 | |
| 17 | 21 | options[:skip] = [ |
| 18 | − 'react-&-webpack.html', | |
| 22 | + 'docs/handbook/react-&-webpack.html' | |
| 19 | 23 | ] |
| 20 | 24 | |
| 21 | 25 | options[:skip_patterns] = [ |
| 22 | 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 | 40 | options[:attribution] = <<-HTML |
| 27 | 41 | © 2012-2020 Microsoft<br> |
| 28 | 42 | Licensed under the Apache License, Version 2.0. |
| @@ -31,5 +45,6 @@ module Docs · 2 unmodified lines | ||
| 31 | 45 | def get_latest_version(opts) |
| 32 | 46 | get_latest_github_release('Microsoft', 'TypeScript', opts) |
| 33 | 47 | end |
| 48 | + | |
| 34 | 49 | end |
| 35 | 50 | end |