[devdocsgjs/main: 1848/1867] Update Go documentation (1.17.2)
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 1848/1867] Update Go documentation (1.17.2)
- Date: Fri, 19 Nov 2021 23:48:22 +0000 (UTC)
commit 9e880425e28e2fa0feb4d0161a2b088636baeee3
Author: Simon Legner <Simon Legner gmail com>
Date: Mon Nov 1 10:16:43 2021 +0100
Update Go documentation (1.17.2)
assets/stylesheets/pages/_go.scss | 2 +-
lib/docs/filters/go/attribution.rb | 12 ++++++++++++
lib/docs/scrapers/go.rb | 13 +++++++++++--
3 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/assets/stylesheets/pages/_go.scss b/assets/stylesheets/pages/_go.scss
index e4f7da09..6fd7a15e 100644
--- a/assets/stylesheets/pages/_go.scss
+++ b/assets/stylesheets/pages/_go.scss
@@ -3,7 +3,7 @@
#short-nav, table.dir { margin-left: -1rem; }
- a.source {
+ a.source, span[title^="Added in Go"] {
float: right;
font-size: .9em;
}
diff --git a/lib/docs/filters/go/attribution.rb b/lib/docs/filters/go/attribution.rb
new file mode 100644
index 00000000..9be6982f
--- /dev/null
+++ b/lib/docs/filters/go/attribution.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+module Docs
+ class Go
+ class AttributionFilter < Docs::AttributionFilter
+ def attribution_link
+ url = current_url.to_s.sub! 'localhost:6060', 'golang.org'
+ %(<a href="#{url}" class="_attribution-link">#{url}</a>)
+ end
+ end
+ end
+end
diff --git a/lib/docs/scrapers/go.rb b/lib/docs/scrapers/go.rb
index 18abcbac..4d72474d 100644
--- a/lib/docs/scrapers/go.rb
+++ b/lib/docs/scrapers/go.rb
@@ -1,14 +1,23 @@
module Docs
class Go < UrlScraper
self.type = 'go'
- self.release = '1.16'
+ self.release = '1.17.2'
self.base_url = 'https://golang.org/pkg/'
self.links = {
home: 'https://golang.org/',
code: 'https://go.googlesource.com/go'
}
+ # Run godoc locally, since https://golang.org/pkg/ redirects to https://pkg.go.dev/std with rate
limiting / scraping protection.
+
+ # curl -LO https://golang.org/dl/go1.17.2.windows-amd64.zip
+ # go install golang.org/x/tools/cmd/godoc@latest
+ # go/bin/godoc -zip=go1.17.2.windows-amd64.zip -goroot=/go
+ self.base_url = 'http://localhost:6060/pkg/'
+
+ html_filters.push 'clean_local_urls'
html_filters.push 'go/clean_html', 'go/entries'
+ text_filters.replace 'attribution', 'go/attribution'
options[:trailing_slash] = true
options[:container] = '#page .container'
@@ -16,7 +25,7 @@ module Docs
options[:skip_patterns] = [/\/\//]
options[:fix_urls] = ->(url) do
- url.sub 'https://golang.org/pkg//', 'https://golang.org/pkg/'
+ url.sub '/pkg//', '/pkg/'
end
options[:attribution] = <<-HTML
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]