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 @@
1._angular {1._angular {
2 padding-left: 1rem;2 padding-left: 1rem;
3 3
4 h1, h2, > h3, .banner, .badges { margin-left: -1rem; }4 h1, h2, > h3, .banner, .badges, .breadcrumbs { margin-left: -1rem; }
5 5
6 ._mobile & {6 ._mobile & {
7 padding-left: 0;7 padding-left: 0;
8 8
9 h1, h2, > h3, .banner, .badges { margin-left: 0; }9 h1, h2, > h3, .banner, .badges, .breadcrumbs { margin-left: 0; }
10 }10 }
11 11
12 h2 { @extend %block-heading; }12 h2 { @extend %block-heading; }
13 > h3 { @extend %block-label, %label-blue; }13 > h3 { @extend %block-label, %label-blue; }
14 .code-example > h4, .pre-title { @extend %pre-heading; }14 .code-example > h4, .pre-title { @extend %pre-heading; }
15 15
16 p > code, .status-badge { @extend %label; }16 p > code, dd > code, .status-badge { @extend %label; }
17 17
18 .l-sub-section, .alert, .banner { @extend %note; }18 .l-sub-section, .alert, .banner, .breadcrumbs { @extend %note; }
19 .banner { @extend %note-green; }19 .banner { @extend %note-green; }
20 .alert.is-important { @extend %note-red; }20 .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; }
22 23
23 td > h3, .l-sub-section > h3, .l-sub-section > h4, .alert > h3, .alert > h4, .row-margin > h3 {24 td > h3, .l-sub-section > h3, .l-sub-section > h4, .alert > h3, .alert > h4, .row-margin > h3 {
24 margin-top: .25rem;25 margin-top: .25rem;
lib/docs/filters/angular/clean_html.rb+11−3
@@ -9,7 +9,7 @@ module Docs · 8 unmodified lines
9 node.to_html9 node.to_html
10 end.join(' ')10 end.join(' ')
11 badges = %(<div class="badges">#{badges}</div>)11 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'))
13 @doc = container13 @doc = container
14 14
15 title = at_css('h1').content.strip15 title = at_css('h1').content.strip
@@ -17,6 +17,8 @@ module Docs · 1 unmodified line
17 at_css('h1').content = result[:entries].first.name17 at_css('h1').content = result[:entries].first.name
18 elsif title == 'Angular'18 elsif title == 'Angular'
19 at_css('h1').content = slug.split('/').last.gsub('-', ' ')19 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
20 end22 end
21 23
22 css('pre.no-bg-with-indent').each do |node|24 css('pre.no-bg-with-indent').each do |node|
@@ -28,9 +30,9 @@ module Docs · 5 unmodified lines
28 node.parent.content = node.parent.css('code, pre').map(&:content).join("\n")30 node.parent.content = node.parent.css('code, pre').map(&:content).join("\n")
29 end31 end
30 32
31 css('button.verbose', 'button.verbose + .l-verbose-section', 'a[id=top]', 'a[href="#top"]').remove33 css('button.verbose', 'button.verbose + .l-verbose-section', 'a[id=top]', 'a[href="#top"]', '.sidebar').remove
32 34
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|
34 node.before(node.children).remove36 node.before(node.children).remove
35 end37 end
36 38
@@ -44,6 +46,12 @@ module Docs · 7 unmodified lines
44 46
45 css('pre.prettyprint').each do |node|47 css('pre.prettyprint').each do |node|
46 node.content = node.content.strip48 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
47 end55 end
48 56
49 css('a[id]:empty').each do |node|57 css('a[id]:empty').each do |node|
lib/docs/filters/angular/entries.rb+10−3
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if slug.start_with?('tutorial') || slug.start_with?('guide')5 if slug.start_with?('tutorial') || slug.start_with?('guide')
6 name = at_css('.nav-list-item.is-selected').content.strip6 name = at_css('.nav-list-item.is-selected, header.hero h1').content.strip
7 else7 else
8 name = at_css('header.hero h1').content.strip8 name = at_css('header.hero h1').content.strip
9 end9 end
@@ -18,7 +18,11 @@ module Docs · 8 unmodified lines
18 end18 end
19 end19 end
20 20
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)
22 name26 name
23 end27 end
24 28
@@ -46,7 +50,10 @@ module Docs · 21 unmodified lines
46 private50 private
47 51
48 def mod52 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
50 end57 end
51 end58 end
52 end59 end
lib/docs/scrapers/angular.rb+11−1
@@ -36,7 +36,7 @@ module Docs · 35 unmodified lines
36 stub 'api/' do36 stub 'api/' do
37 capybara = load_capybara_selenium37 capybara = load_capybara_selenium
38 capybara.app_host = 'https://angular.io'38 capybara.app_host = 'https://angular.io'
39 capybara.visit('/docs/ts/latest/api/')39 capybara.visit(URL.parse(self.base_url).path + 'api/')
40 capybara.execute_script('return document.body.innerHTML')40 capybara.execute_script('return document.body.innerHTML')
41 end41 end
42 42
@@ -45,6 +45,16 @@ module Docs · 2 unmodified lines
45 self.base_url = 'https://angular.io/docs/ts/latest/'45 self.base_url = 'https://angular.io/docs/ts/latest/'
46 end46 end
47 47
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
48 private58 private
49 59
50 def parse(string)60 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