go.rb 834 B

123456789101112131415161718192021222324252627282930
  1. module Docs
  2. class Go < UrlScraper
  3. self.type = 'go'
  4. self.release = '1.10.0'
  5. self.base_url = 'https://golang.org/pkg/'
  6. self.links = {
  7. home: 'https://golang.org/',
  8. code: 'https://go.googlesource.com/go'
  9. }
  10. html_filters.push 'go/clean_html', 'go/entries'
  11. options[:trailing_slash] = true
  12. options[:container] = '#page .container'
  13. options[:skip] = %w(runtime/msan/)
  14. options[:skip_patterns] = [/\/\//]
  15. options[:attribution] = <<-HTML
  16. &copy; Google, Inc.<br>
  17. Licensed under the Creative Commons Attribution License 3.0.
  18. HTML
  19. private
  20. def parse(response) # Hook here because Nokogori removes whitespace from textareas
  21. response.body.gsub! %r{<textarea\ class="code"[^>]*>([\W\w]+?)</textarea>}, '<pre class="code">\1</pre>'
  22. super
  23. end
  24. end
  25. end