phoenix.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. module Docs
  2. class Phoenix < UrlScraper
  3. self.type = 'elixir'
  4. self.release = '1.6.11'
  5. self.base_url = 'https://hexdocs.pm/'
  6. self.root_path = 'phoenix/Phoenix.html'
  7. self.initial_paths = %w(
  8. phoenix/api-reference.html
  9. ecto/api-reference.html
  10. phoenix_html/api-reference.html
  11. phoenix_live_view/api-reference.html
  12. phoenix_pubsub/api-reference.html
  13. plug/api-reference.html)
  14. self.links = {
  15. home: 'http://www.phoenixframework.org',
  16. code: 'https://github.com/phoenixframework/phoenix'
  17. }
  18. html_filters.push 'elixir/clean_html', 'elixir/entries'
  19. options[:container] = '#content'
  20. options[:skip_patterns] = [/extra-api-reference/, /js/, /\d+\.\d+\.\d+/]
  21. options[:only_patterns] = [
  22. /\Aphoenix\//,
  23. /\Aecto\//,
  24. /\Aphoenix_pubsub\//,
  25. /\Aphoenix_html\//,
  26. /\Aphoenix_live_view\//,
  27. /\Aplug\//
  28. ]
  29. options[:attribution] = -> (filter) {
  30. if filter.slug.start_with?('ecto')
  31. <<-HTML
  32. &copy; 2013 Plataformatec<br>
  33. &copy; 2020 Dashbit<br>
  34. Licensed under the Apache License, Version 2.0.
  35. HTML
  36. elsif filter.slug.start_with?('plug')
  37. <<-HTML
  38. &copy; 2013 Plataformatec<br>
  39. Licensed under the Apache License, Version 2.0.
  40. HTML
  41. elsif filter.slug.start_with?('phoenix_live_view')
  42. <<-HTML
  43. &copy; 2018 Chris McCord<br>
  44. Licensed under the MIT License.
  45. HTML
  46. else
  47. <<-HTML
  48. &copy; 2014 Chris McCord<br>
  49. Licensed under the MIT License.
  50. HTML
  51. end
  52. }
  53. def get_latest_version(opts)
  54. doc = fetch_doc('https://hexdocs.pm/phoenix/Phoenix.html', opts)
  55. doc.at_css('.sidebar-projectVersion').content.strip[1..-1]
  56. end
  57. end
  58. end