mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add Go documentation
This commit is contained in:
parent
50f1ca9309
commit
f657dfddf6
14 changed files with 126 additions and 1 deletions
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 44 KiB |
|
@ -115,6 +115,11 @@ credits = [
|
|||
'2005-2014 Linus Torvalds and others',
|
||||
'GPLv2',
|
||||
'https://raw.github.com/git/git/master/COPYING'
|
||||
], [
|
||||
'Go',
|
||||
'Google, Inc.',
|
||||
'CC BY',
|
||||
'http://creativecommons.org/licenses/by/3.0/'
|
||||
], [
|
||||
'HTTP',
|
||||
'1999 The Internet Society',
|
||||
|
|
|
@ -24,7 +24,10 @@ newsItem = (date, news) ->
|
|||
result
|
||||
|
||||
app.news = [
|
||||
[ 1396137600000, # March 30, 2014
|
||||
[ 1396742400000, # April 6, 2014
|
||||
""" New <a href="/go/">Go</a> documentation """,
|
||||
], [
|
||||
1396137600000, # March 30, 2014
|
||||
""" New <a href="/cpp/">C++</a> documentation """,
|
||||
], [
|
||||
1394928000000, # March 16, 2014
|
||||
|
|
6
assets/javascripts/views/pages/go.coffee
Normal file
6
assets/javascripts/views/pages/go.coffee
Normal file
|
@ -0,0 +1,6 @@
|
|||
#= require views/pages/base
|
||||
|
||||
class app.views.GoPage extends app.views.BasePage
|
||||
afterRender: ->
|
||||
@highlightCode @findAll('pre'), 'go'
|
||||
return
|
|
@ -33,6 +33,7 @@
|
|||
'pages/coffeescript',
|
||||
'pages/d3',
|
||||
'pages/ember',
|
||||
'pages/go',
|
||||
'pages/jquery',
|
||||
'pages/knockout',
|
||||
'pages/git',
|
||||
|
|
|
@ -52,3 +52,4 @@
|
|||
%icon-path { background-position: -3rem -7rem; }
|
||||
._icon-yii:before { background-position: -4rem -7rem; }
|
||||
._icon-cpp:before { background-position: 0 -8rem; }
|
||||
._icon-go:before { background-position: -1rem -8rem; }
|
||||
|
|
7
assets/stylesheets/pages/_go.scss
Normal file
7
assets/stylesheets/pages/_go.scss
Normal file
|
@ -0,0 +1,7 @@
|
|||
._go {
|
||||
padding-left: 1rem;
|
||||
|
||||
h1, h2, #short-nav, table.dir { margin-left: -1rem; }
|
||||
h2 { @extend %block-heading; }
|
||||
h3 { @extend %block-label, %label-blue; }
|
||||
}
|
46
lib/docs/filters/go/clean_html.rb
Normal file
46
lib/docs/filters/go/clean_html.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Docs
|
||||
class Go
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
at_css('h1').content = 'Go Programming Language'
|
||||
|
||||
# Remove empty columns
|
||||
css('tr:first-child + tr', 'th:first-child + th', 'td:first-child + td').remove
|
||||
|
||||
# Remove links to unscraped pages
|
||||
css('td + td:empty').each do |node|
|
||||
node.previous_element.content = node.previous_element.content
|
||||
end
|
||||
end
|
||||
|
||||
css('#plusone', '#nav', '.pkgGopher', '#footer', '.collapsed').remove
|
||||
|
||||
# Remove triangle character
|
||||
css('h2', '.exampleHeading').each do |node|
|
||||
node.content = node.content.sub("\u25BE", '')
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
# Turn <dl> into <ul>
|
||||
css('#short-nav', '#manual-nav').each do |node|
|
||||
node.children = node.css('dd').tap { |nodes| nodes.each { |dd| dd.name = 'li' } }
|
||||
node.name = 'ul'
|
||||
end
|
||||
|
||||
# Remove code highlighting
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
# Fix example markup
|
||||
css('.play').each do |node|
|
||||
node.children = node.at_css('.code').children
|
||||
node.name = 'pre'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
lib/docs/filters/go/entries.rb
Normal file
33
lib/docs/filters/go/entries.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Docs
|
||||
class Go
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1').content
|
||||
name.sub! 'Package ', ''
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
subpath[/\A[^\/]+/]
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
css('#manual-nav a').each_with_object [] do |node, entries|
|
||||
case node.content
|
||||
when /type\ (\w+)/
|
||||
name = $1
|
||||
when /func\ (?:\(.+\)\ )?(\w+)\(/
|
||||
name = "#{$1}()"
|
||||
name.prepend "#{$1}." if node['href'] =~ /#(\w+)\.#{$1}/
|
||||
end
|
||||
|
||||
entries << ["#{name} (#{self.name})", node['href'][1..-1]] if name
|
||||
end
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
!at_css('h1 + table.dir')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
lib/docs/scrapers/go.rb
Normal file
22
lib/docs/scrapers/go.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Docs
|
||||
class Go < UrlScraper
|
||||
self.type = 'go'
|
||||
self.version = '1.2.1'
|
||||
self.base_url = 'http://golang.org/pkg/'
|
||||
|
||||
html_filters.push 'go/clean_html', 'go/entries'
|
||||
|
||||
options[:container] = '#page .container'
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Google, Inc.<br>
|
||||
Licensed under the Creative Commons Attribution License 3.0.
|
||||
HTML
|
||||
|
||||
private
|
||||
|
||||
def parse(html) # Hook here because Nokogori removes whitespace from textareas
|
||||
super html.gsub %r{<textarea\ class="code"[^>]*>([\W\w]+?)</textarea>}, '<pre class="code">\1</pre>'
|
||||
end
|
||||
end
|
||||
end
|
BIN
public/icons/docs/go/16.png
Normal file
BIN
public/icons/docs/go/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 605 B |
BIN
public/icons/docs/go/16@2x.png
Normal file
BIN
public/icons/docs/go/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
1
public/icons/docs/go/SOURCE
Normal file
1
public/icons/docs/go/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
http://golang.org/doc/gopher/
|
Loading…
Reference in a new issue