angular.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. module Docs
  2. class Angular < UrlScraper
  3. self.type = 'angular'
  4. self.root_path = 'api/'
  5. self.links = {
  6. home: 'https://angular.io/',
  7. code: 'https://github.com/angular/angular'
  8. }
  9. html_filters.push 'angular/entries', 'angular/clean_html'
  10. options[:skip_patterns] = [/deprecated/]
  11. options[:skip] = %w(
  12. index.html
  13. styleguide.html
  14. quickstart.html
  15. guide/cheatsheet.html
  16. guide/style-guide.html)
  17. options[:replace_paths] = {
  18. 'testing/index.html' => 'guide/testing.html',
  19. 'guide/glossary.html' => 'glossary.html',
  20. 'tutorial' => 'tutorial/'
  21. }
  22. options[:fix_urls] = -> (url) do
  23. url.sub! %r{\A(https://angular\.io/docs/.+/)index\.html\z}, '\1'
  24. url.sub! %r{\A(https://angular\.io/docs/.+/index)/\z}, '\1'
  25. url
  26. end
  27. options[:attribution] = <<-HTML
  28. &copy; 2010&ndash;2016 Google, Inc.<br>
  29. Licensed under the Creative Commons Attribution License 4.0.
  30. HTML
  31. stub 'api/' do
  32. capybara = load_capybara_selenium
  33. capybara.app_host = 'https://angular.io'
  34. capybara.visit('/docs/ts/latest/api/')
  35. capybara.execute_script('return document.body.innerHTML')
  36. end
  37. version '2.0 TypeScript' do
  38. self.release = '2.0.0rc3'
  39. self.base_url = "https://angular.io/docs/ts/latest/"
  40. end
  41. private
  42. def parse(string)
  43. string.gsub! '<code-example', '<pre'
  44. string.gsub! '</code-example', '</pre'
  45. string.gsub! '<code-pane', '<pre'
  46. string.gsub! '</code-pane', '</pre'
  47. super string
  48. end
  49. end
  50. end