mirror of https://github.com/freeCodeCamp/devdocs
parent
50f1ca9309
commit
f657dfddf6
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 44 KiB |
@ -0,0 +1,6 @@
|
||||
#= require views/pages/base
|
||||
|
||||
class app.views.GoPage extends app.views.BasePage
|
||||
afterRender: ->
|
||||
@highlightCode @findAll('pre'), 'go'
|
||||
return
|
@ -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; }
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 1.6 KiB |
@ -0,0 +1 @@
|
||||
http://golang.org/doc/gopher/
|
Loading…
Reference in new issue