angular.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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
  25. end
  26. options[:attribution] = <<-HTML
  27. &copy; 2010&ndash;2016 Google, Inc.<br>
  28. Licensed under the Creative Commons Attribution License 4.0.
  29. HTML
  30. stub 'api/' do
  31. capybara = load_capybara_selenium
  32. capybara.app_host = 'https://angular.io'
  33. capybara.visit('/docs/ts/latest/api/')
  34. capybara.execute_script('return document.body.innerHTML')
  35. end
  36. version '2 TypeScript' do
  37. self.release = '2.1.0'
  38. self.base_url = 'https://angular.io/docs/ts/latest/'
  39. end
  40. private
  41. def parse(string)
  42. string.gsub! '<code-example', '<pre'
  43. string.gsub! '</code-example', '</pre'
  44. string.gsub! '<code-pane', '<pre'
  45. string.gsub! '</code-pane', '</pre'
  46. string.gsub! '<live-example></live-example>', 'live example'
  47. string.gsub! '<live-example', '<span'
  48. string.gsub! '</live-example', '</span'
  49. super string
  50. end
  51. end
  52. end