yarn.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. module Docs
  2. class Yarn < UrlScraper
  3. self.type = 'simple'
  4. options[:root_title] = 'Yarn'
  5. options[:trailing_slash] = false
  6. options[:skip] = %w(nightly)
  7. options[:attribution] = <<-HTML
  8. &copy; 2016&ndash;present Yarn Contributors<br>
  9. Licensed under the BSD License.
  10. HTML
  11. version do
  12. self.release = '4.5.1'
  13. self.base_url = 'https://yarnpkg.com/'
  14. self.links = {
  15. home: 'https://yarnpkg.com/',
  16. code: 'https://github.com/yarnpkg/berry'
  17. }
  18. self.root_path = 'getting-started'
  19. html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry'
  20. options[:skip] = ['cli', 'cli/builder', 'cli/pnpify', 'cli/sdks', 'protocols']
  21. options[:skip_patterns] = [/\Aapi/, /\Ablog/, /\Apackage/, /\Aassets/]
  22. end
  23. version '3' do
  24. self.release = '3.1.1'
  25. self.base_url = 'https://v3.yarnpkg.com/'
  26. self.links = {
  27. home: 'https://v3.yarnpkg.com/',
  28. code: 'https://github.com/yarnpkg/berry'
  29. }
  30. self.root_path = 'getting-started'
  31. html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry', 'title'
  32. options[:skip] = ['features', 'cli', 'configuration', 'advanced']
  33. options[:skip_patterns] = [/\Aapi/, /\Apackage/] end
  34. version 'Classic' do
  35. self.release = '1.22.17'
  36. self.base_url = 'https://classic.yarnpkg.com/en/docs/'
  37. self.links = {
  38. home: 'https://classic.yarnpkg.com/',
  39. code: 'https://github.com/yarnpkg/yarn'
  40. }
  41. html_filters.push 'yarn/entries', 'yarn/clean_html', 'title'
  42. options[:skip_patterns] = [/\Aorg\//]
  43. end
  44. def get_latest_version(opts)
  45. get_latest_github_release('yarnpkg', 'berry', opts)[/[\d.]+/]
  46. end
  47. private
  48. # Some pages contain null bytes and cause the parser to fail
  49. def parse(response)
  50. response.body.gsub!(/[\x00\u0000\0]/, '')
  51. super
  52. end
  53. end
  54. end