History

Add Angular 2 Dart documentation

Thibaut Courouble committed 10 years ago

Commit a05ed031 parent ffb991a4 files · +38 −12Browse files

Unified · Split

4 files
  1. assets/stylesheets/pages/_angular.scss +6 −5
  2. lib/docs/filters/angular/clean_html.rb +11 −3
  3. lib/docs/filters/angular/entries.rb +10 −3
  4. lib/docs/scrapers/angular.rb +11 −1
assets/stylesheets/pages/_angular.scss+6−5
@@ -1,24 +1,25 @@
11 ._angular {
22 padding-left: 1rem;
33
4− h1, h2, > h3, .banner, .badges { margin-left: -1rem; }
4+ h1, h2, > h3, .banner, .badges, .breadcrumbs { margin-left: -1rem; }
55
66 ._mobile & {
77 padding-left: 0;
88
9− h1, h2, > h3, .banner, .badges { margin-left: 0; }
9+ h1, h2, > h3, .banner, .badges, .breadcrumbs { margin-left: 0; }
1010 }
1111
1212 h2 { @extend %block-heading; }
1313 > h3 { @extend %block-label, %label-blue; }
1414 .code-example > h4, .pre-title { @extend %pre-heading; }
1515
16− p > code, .status-badge { @extend %label; }
16+ p > code, dd > code, .status-badge { @extend %label; }
1717
18− .l-sub-section, .alert, .banner { @extend %note; }
18+ .l-sub-section, .alert, .banner, .breadcrumbs { @extend %note; }
1919 .banner { @extend %note-green; }
2020 .alert.is-important { @extend %note-red; }
21− .alert.is-helpful { @extend %note-blue; }
21+ .alert.is-helpful, .breadcrumbs { @extend %note-blue; }
22+ .breadcrumbs { padding-left: 2em; }
2223
2324 td > h3, .l-sub-section > h3, .l-sub-section > h4, .alert > h3, .alert > h4, .row-margin > h3 {
2425 margin-top: .25rem;
lib/docs/filters/angular/clean_html.rb+11−3
@@ -9,7 +9,7 @@ module Docs · 8 unmodified lines
99 node.to_html
1010 end.join(' ')
1111 badges = %(<div class="badges">#{badges}</div>)
12− container.child.before(at_css('header.hero h1')).before(badges).before(css('header.hero + .banner'))
12+ container.child.before(at_css('header.hero h1')).before(badges).before(css('header.hero + .banner, header.hero .breadcrumbs'))
1313 @doc = container
1414
1515 title = at_css('h1').content.strip
@@ -17,6 +17,8 @@ module Docs · 1 unmodified line
1717 at_css('h1').content = result[:entries].first.name
1818 elsif title == 'Angular'
1919 at_css('h1').content = slug.split('/').last.gsub('-', ' ')
20+ elsif at_css('.breadcrumbs') && title != result[:entries].first.name
21+ at_css('h1').content = result[:entries].first.name
2022 end
2123
2224 css('pre.no-bg-with-indent').each do |node|
@@ -28,9 +30,9 @@ module Docs · 5 unmodified lines
2830 node.parent.content = node.parent.css('code, pre').map(&:content).join("\n")
2931 end
3032
31− css('button.verbose', 'button.verbose + .l-verbose-section', 'a[id=top]', 'a[href="#top"]').remove
33+ css('button.verbose', 'button.verbose + .l-verbose-section', 'a[id=top]', 'a[href="#top"]', '.sidebar').remove
3234
33− 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|
35+ 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', 'section.desc', '.row', '.dart-api-entry-main', '.main-content', 'section.summary', 'span.signature').each do |node|
3436 node.before(node.children).remove
3537 end
3638
@@ -44,6 +46,12 @@ module Docs · 7 unmodified lines
4446
4547 css('pre.prettyprint').each do |node|
4648 node.content = node.content.strip
49+ node['data-language'] = 'dart' if node['class'].include?('dart')
50+ end
51+
52+ css('.multi-line-signature').each do |node|
53+ node.name = 'pre'
54+ node.content = node.content.strip
4755 end
4856
4957 css('a[id]:empty').each do |node|
lib/docs/filters/angular/entries.rb+10−3
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
55 if slug.start_with?('tutorial') || slug.start_with?('guide')
6− name = at_css('.nav-list-item.is-selected').content.strip
6+ name = at_css('.nav-list-item.is-selected, header.hero h1').content.strip
77 else
88 name = at_css('header.hero h1').content.strip
99 end
@@ -18,7 +18,11 @@ module Docs · 8 unmodified lines
1818 end
1919 end
2020
21− name << '()' if at_css('.hero-subtitle').try(:content) == 'Function'
21+ subtitle = at_css('.hero-subtitle').try(:content)
22+ breadcrumbs = css('.breadcrumbs li').map(&:content)[2..-2]
23+
24+ name.prepend "#{breadcrumbs.join('.')}#" if breadcrumbs.present? && breadcrumbs[0] != name
25+ name << '()' if %w(Function Method Constructor).include?(subtitle)
2226 name
2327 end
2428
@@ -46,7 +50,10 @@ module Docs · 21 unmodified lines
4650 private
4751
4852 def mod
49− @mod ||= slug[/api\/([\w\-]+)\//, 1]
53+ return @mod if defined?(@mod)
54+ @mod = slug[/api\/([\w\-\.]+)\//, 1]
55+ @mod.remove! 'angular2.' if @mod
56+ @mod
5057 end
5158 end
5259 end
lib/docs/scrapers/angular.rb+11−1
@@ -36,7 +36,7 @@ module Docs · 35 unmodified lines
3636 stub 'api/' do
3737 capybara = load_capybara_selenium
3838 capybara.app_host = 'https://angular.io'
39− capybara.visit('/docs/ts/latest/api/')
39+ capybara.visit(URL.parse(self.base_url).path + 'api/')
4040 capybara.execute_script('return document.body.innerHTML')
4141 end
4242
@@ -45,6 +45,16 @@ module Docs · 2 unmodified lines
4545 self.base_url = 'https://angular.io/docs/ts/latest/'
4646 end
4747
48+ version '2 Dart' do
49+ self.release = '2.1.2'
50+ self.base_url = 'https://angular.io/docs/dart/latest/'
51+
52+ options[:skip_patterns] += [/angular2\.compiler/]
53+ options[:skip_link] = ->(link) do
54+ link.parent['class'].try(:include?, 'inherited') || link.parent.parent['class'].try(:include?, 'inherited')
55+ end
56+ end
57+
4858 private
4959
5060 def parse(string)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t