go.rb 794 B

1234567891011121314151617181920212223242526272829
  1. module Docs
  2. class Go < UrlScraper
  3. self.type = 'go'
  4. self.release = '1.8.1'
  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[:attribution] = <<-HTML
  15. &copy; Google, Inc.<br>
  16. Licensed under the Creative Commons Attribution License 3.0.
  17. HTML
  18. private
  19. def parse(response) # Hook here because Nokogori removes whitespace from textareas
  20. response.body.gsub! %r{<textarea\ class="code"[^>]*>([\W\w]+?)</textarea>}, '<pre class="code">\1</pre>'
  21. super
  22. end
  23. end
  24. end