History

Update Go documentation (1.17.2)

Simon Legner committed 5 years ago

Commit 9e880421 parent 9f50c2c3 files · +24 −3Browse files

Unified · Split

3 files
  1. assets/stylesheets/pages/_go.scss +1 −1
  2. lib/docs/filters/go/attribution.rb +12 −0
  3. lib/docs/scrapers/go.rb +11 −2
assets/stylesheets/pages/_go.scss+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33
44 #short-nav, table.dir { margin-left: -1rem; }
55
6− a.source {
6+ a.source, span[title^="Added in Go"] {
77 float: right;
88 font-size: .9em;
99 }
lib/docs/filters/go/attribution.rb+12−0
@@ -0,0 +1,12 @@
1+# frozen_string_literal: true
2+
3+module Docs
4+ class Go
5+ class AttributionFilter < Docs::AttributionFilter
6+ def attribution_link
7+ url = current_url.to_s.sub! 'localhost:6060', 'golang.org'
8+ %(<a href="#{url}" class="_attribution-link">#{url}</a>)
9+ end
10+ end
11+ end
12+end
lib/docs/scrapers/go.rb+11−2
@@ -1,14 +1,23 @@
11 module Docs
22 class Go < UrlScraper
33 self.type = 'go'
4− self.release = '1.16'
4+ self.release = '1.17.2'
55 self.base_url = 'https://golang.org/pkg/'
66 self.links = {
77 home: 'https://golang.org/',
88 code: 'https://go.googlesource.com/go'
99 }
1010
11+ # Run godoc locally, since https://golang.org/pkg/ redirects to https://pkg.go.dev/std with rate limiting / scraping protection.
12+
13+ # curl -LO https://golang.org/dl/go1.17.2.windows-amd64.zip
14+ # go install golang.org/x/tools/cmd/godoc@latest
15+ # go/bin/godoc -zip=go1.17.2.windows-amd64.zip -goroot=/go
16+ self.base_url = 'http://localhost:6060/pkg/'
17+
18+ html_filters.push 'clean_local_urls'
1119 html_filters.push 'go/clean_html', 'go/entries'
20+ text_filters.replace 'attribution', 'go/attribution'
1221
1322 options[:trailing_slash] = true
1423 options[:container] = '#page .container'
@@ -16,7 +25,7 @@ module Docs · 1 unmodified line
1625 options[:skip_patterns] = [/\/\//]
1726
1827 options[:fix_urls] = ->(url) do
19− url.sub 'https://golang.org/pkg//', 'https://golang.org/pkg/'
28+ url.sub '/pkg//', '/pkg/'
2029 end
2130
2231 options[:attribution] = <<-HTML