node.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 = '14.15.0'
  23. self.base_url = 'https://nodejs.org/dist/latest-v14.x/docs/api/'
  24. end
  25. version '12 LTS' do
  26. self.release = '12.19.0'
  27. self.base_url = 'https://nodejs.org/dist/latest-v12.x/docs/api/'
  28. end
  29. version '10 LTS' do
  30. self.release = '10.16.3'
  31. self.base_url = 'https://nodejs.org/dist/latest-v10.x/docs/api/'
  32. end
  33. version '8 LTS' do
  34. self.release = '8.16.1'
  35. self.base_url = 'https://nodejs.org/dist/latest-v8.x/docs/api/'
  36. end
  37. version '6 LTS' do
  38. self.release = '6.14.4'
  39. self.base_url = 'https://nodejs.org/dist/latest-v6.x/docs/api/'
  40. end
  41. version '4 LTS' do
  42. self.release = '4.9.1'
  43. self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/'
  44. end
  45. def get_latest_version(opts)
  46. doc = fetch_doc('https://nodejs.org/en/', opts)
  47. doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1]
  48. end
  49. end
  50. end