node.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. module Docs
  2. class Node < UrlScraper
  3. self.name = 'Node.js'
  4. self.slug = 'node'
  5. self.type = 'node'
  6. self.links = {
  7. home: 'https://nodejs.org/',
  8. code: 'https://github.com/nodejs/node'
  9. }
  10. html_filters.push 'node/clean_html', 'node/entries', 'title'
  11. options[:title] = false
  12. options[:root_title] = 'Node.js'
  13. options[:container] = '#apicontent'
  14. options[:skip] = %w(index.html all.html documentation.html synopsis.html)
  15. options[:attribution] = <<-HTML
  16. &copy; Joyent, Inc. and other Node contributors<br>
  17. Licensed under the MIT License.<br>
  18. Node.js is a trademark of Joyent, Inc. and is used with its permission.<br>
  19. We are not endorsed by or affiliated with Joyent.
  20. HTML
  21. version do
  22. self.release = '12.9.1'
  23. self.base_url = 'https://nodejs.org/dist/latest-v12.x/docs/api/'
  24. end
  25. version '10 LTS' do
  26. self.release = '10.16.3'
  27. self.base_url = 'https://nodejs.org/dist/latest-v10.x/docs/api/'
  28. end
  29. version '8 LTS' do
  30. self.release = '8.16.1'
  31. self.base_url = 'https://nodejs.org/dist/latest-v8.x/docs/api/'
  32. end
  33. version '6 LTS' do
  34. self.release = '6.14.4'
  35. self.base_url = 'https://nodejs.org/dist/latest-v6.x/docs/api/'
  36. end
  37. version '4 LTS' do
  38. self.release = '4.9.1'
  39. self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/'
  40. end
  41. def get_latest_version(opts)
  42. doc = fetch_doc('https://nodejs.org/en/', opts)
  43. doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1]
  44. end
  45. end
  46. end