From 555f434f328e6b3684a04de6c5f82fd116723ebe Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sat, 17 Sep 2016 12:31:30 -0400 Subject: [PATCH] Update Angular documentation (2.0.0) --- assets/stylesheets/global/_classes.scss | 3 +++ assets/stylesheets/pages/_angular.scss | 1 + lib/docs/filters/angular/clean_html.rb | 16 +++++++++------- lib/docs/filters/angular/entries.rb | 4 ++-- lib/docs/scrapers/angular.rb | 7 +++++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/assets/stylesheets/global/_classes.scss b/assets/stylesheets/global/_classes.scss index f75c29e2..3ad027dc 100644 --- a/assets/stylesheets/global/_classes.scss +++ b/assets/stylesheets/global/_classes.scss @@ -48,7 +48,10 @@ } %pre-heading { + margin: 0; padding: .375rem .625rem; + font-size: inherit; + font-weight: normal; line-height: 1.5; border-bottom-left-radius: 0; border-bottom-right-radius: 0; diff --git a/assets/stylesheets/pages/_angular.scss b/assets/stylesheets/pages/_angular.scss index 842ab92d..2ce3a57f 100644 --- a/assets/stylesheets/pages/_angular.scss +++ b/assets/stylesheets/pages/_angular.scss @@ -11,6 +11,7 @@ h2 { @extend %block-heading; } > h3 { @extend %block-label, %label-blue; } + .code-example > h4, .pre-title { @extend %pre-heading; } p > code, .status-badge { @extend %label; } diff --git a/lib/docs/filters/angular/clean_html.rb b/lib/docs/filters/angular/clean_html.rb index 607fd29d..94d42b8a 100644 --- a/lib/docs/filters/angular/clean_html.rb +++ b/lib/docs/filters/angular/clean_html.rb @@ -3,7 +3,13 @@ module Docs class CleanHtmlFilter < Filter def call container = at_css('article.docs-content') - container.child.before(at_css('header.hero h1')).before(css('header.hero .badges')).before(css('header.hero + .banner')) + badges = css('header.hero .badge, header.hero .hero-subtitle').map do |node| + node.name = 'span' + node['class'] = 'status-badge' + node.to_html + end.join(' ') + badges = %(
#{badges}
) + container.child.before(at_css('header.hero h1')).before(badges).before(css('header.hero + .banner')) @doc = container css('pre.no-bg-with-indent').each do |node| @@ -17,7 +23,7 @@ module Docs css('button.verbose', 'button.verbose + .l-verbose-section', 'a[id=top]', 'a[href="#top"]').remove - css('.c10', '.showcase', '.showcase-content', '.l-main-section', 'div.div', 'div[flex]', 'code-tabs', 'md-card', 'md-card-content', 'div:not([class])', 'footer', '.card-row', '.card-row-container', 'figure', 'blockquote', 'exported', 'defined', 'div.ng-scope').each do |node| + css('.c10', '.showcase', '.showcase-content', '.l-main-section', 'div.div', 'div[flex]', 'code-tabs', 'md-card', 'md-card-content', 'div:not([class])', 'footer', '.card-row', '.card-row-container', 'figure', 'blockquote', 'exported', 'defined', 'div.ng-scope', '.code-example header').each do |node| node.before(node.children).remove end @@ -60,11 +66,7 @@ module Docs end css('pre[name]').each do |node| - case node['data-language'] - when 'html' then node.content = "\n\n" + node.content - when 'css' then node.content = "/* #{node['name']} */\n\n" + node.content - else node.content = "// #{node['name']}\n\n" + node.content - end + node.before(%(
#{node['name']}
)) end css('a.is-button > h3').each do |node| diff --git a/lib/docs/filters/angular/entries.rb b/lib/docs/filters/angular/entries.rb index 63c1c797..0f191261 100644 --- a/lib/docs/filters/angular/entries.rb +++ b/lib/docs/filters/angular/entries.rb @@ -18,7 +18,7 @@ module Docs end end - name << '()' if at_css('.status-badge').try(:content) == 'Function' + name << '()' if at_css('.hero-subtitle').try(:content) == 'Function' name end @@ -30,7 +30,7 @@ module Docs elsif slug == 'glossary' 'Guide' else - type = at_css('.is-nav-title-selected').content.strip + type = at_css('.nav-title.is-selected').content.strip type.remove! ' Reference' type << ": #{mod}" if mod type diff --git a/lib/docs/scrapers/angular.rb b/lib/docs/scrapers/angular.rb index 30bc4afc..d4f9afbb 100644 --- a/lib/docs/scrapers/angular.rb +++ b/lib/docs/scrapers/angular.rb @@ -42,8 +42,8 @@ module Docs end version '2.0 TypeScript' do - self.release = '2.0.0rc6' - self.base_url = "https://angular.io/docs/ts/latest/" + self.release = '2.0.0' + self.base_url = 'https://angular.io/docs/ts/latest/' end private @@ -53,6 +53,9 @@ module Docs string.gsub! '', 'live example' + string.gsub! '