Skip to content

Commit

Permalink
Update TypeScript documentation (New Handbook)
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Mar 5, 2021
1 parent e9d7849 commit 91138ad
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
'pages/tcl_tk',
'pages/tensorflow',
'pages/terraform',
'pages/typescript',
'pages/underscore',
'pages/vue',
'pages/webpack',
Expand Down
4 changes: 4 additions & 0 deletions assets/stylesheets/pages/_typescript.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
._typescript {
@extend %simple;
.deprecated { @extend %label-red; }
}
11 changes: 10 additions & 1 deletion lib/docs/filters/typescript/clean_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def root

def other
if base_url.path == '/docs/handbook/'
deprecated = at_css('#deprecated-content')
deprecated.css('h3', '#deprecated-icon').remove if deprecated
deprecated.add_class('deprecated') if deprecated
@doc = at_css('article > .whitespace > .markdown')
doc.child.before(deprecated) if deprecated
else # tsconfig page
@doc = at_css('.markdown > div')

Expand All @@ -36,9 +40,14 @@ def other
css('pre').each do |node|
language = node.at_css('.language-id') ? node.at_css('.language-id').content : 'typescript'
node.css('.language-id').remove
node.content = node.content
if node.at_css('.line').nil?
node.content = node.content
else
node.content = node.css('.line').map(&:content).join("\n")
end
node['data-language'] = LANGUAGE_REPLACE[language] || language
node.remove_attribute('class')
node.remove_attribute('style')
end
end

Expand Down
18 changes: 17 additions & 1 deletion lib/docs/filters/typescript/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@ module Docs
class Typescript
class EntriesFilter < Docs::EntriesFilter

DEPRECATED_PAGES = %w(
advanced-types
basic-types
classes
functions
generics
interfaces
literal-types
unions-and-intersections
)

def get_name
at_css('h1') ? at_css('h1').content : at_css('h2').content
end

def get_type
name
if DEPRECATED_PAGES.include? slug
'Handbook (deprecated)'
else
name
end
end

def additional_entries
return [] if DEPRECATED_PAGES.include? slug
base_url.path == '/' ? tsconfig_entries : handbook_entries
end

Expand Down
5 changes: 2 additions & 3 deletions lib/docs/scrapers/typescript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class Typescript < UrlScraper
include MultipleBaseUrls

self.name = 'TypeScript'
self.type = 'simple'
self.release = '4.2.2'
self.type = 'typescript'
self.release = '4.2.3'
self.base_urls = [
'https://www.typescriptlang.org/docs/handbook/',
'https://www.typescriptlang.org/'
Expand All @@ -29,7 +29,6 @@ def initial_urls
]

options[:skip_patterns] = [
/2/,
/release-notes/,
/play\//
]
Expand Down

0 comments on commit 91138ad

Please sign in to comment.