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
3 3
4 #short-nav, table.dir { margin-left: -1rem; }4 #short-nav, table.dir { margin-left: -1rem; }
5 5
6 a.source {6 a.source, span[title^="Added in Go"] {
7 float: right;7 float: right;
8 font-size: .9em;8 font-size: .9em;
9 }9 }
lib/docs/filters/go/attribution.rb+12−0
@@ -0,0 +1,12 @@
1# frozen_string_literal: true
2
3module 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
12end
lib/docs/scrapers/go.rb+11−2
@@ -1,14 +1,23 @@
1module Docs1module Docs
2 class Go < UrlScraper2 class Go < UrlScraper
3 self.type = 'go'3 self.type = 'go'
4 self.release = '1.16'4 self.release = '1.17.2'
5 self.base_url = 'https://golang.org/pkg/'5 self.base_url = 'https://golang.org/pkg/'
6 self.links = {6 self.links = {
7 home: 'https://golang.org/',7 home: 'https://golang.org/',
8 code: 'https://go.googlesource.com/go'8 code: 'https://go.googlesource.com/go'
9 }9 }
10 10
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'
11 html_filters.push 'go/clean_html', 'go/entries'19 html_filters.push 'go/clean_html', 'go/entries'
20 text_filters.replace 'attribution', 'go/attribution'
12 21
13 options[:trailing_slash] = true22 options[:trailing_slash] = true
14 options[:container] = '#page .container'23 options[:container] = '#page .container'
@@ -16,7 +25,7 @@ module Docs · 1 unmodified line
16 options[:skip_patterns] = [/\/\//]25 options[:skip_patterns] = [/\/\//]
17 26
18 options[:fix_urls] = ->(url) do27 options[:fix_urls] = ->(url) do
19 url.sub 'https://golang.org/pkg//', 'https://golang.org/pkg/'28 url.sub '/pkg//', '/pkg/'
20 end29 end
21 30
22 options[:attribution] = <<-HTML31 options[:attribution] = <<-HTML