diff --git a/assets/images/icons.png b/assets/images/icons.png index 220fecf9..4a8fe500 100644 Binary files a/assets/images/icons.png and b/assets/images/icons.png differ diff --git a/assets/images/icons@2x.png b/assets/images/icons@2x.png index 6bc93bdf..6d27e38e 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index fc3c35bd..d1bd731b 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,7 +1,7 @@ [ [ "2016-01-31", - "New documentation: Tcl/Tk" + "New documentations: Erlang and Tcl/Tk" ], [ "2016-01-24", "“Multi-version support” has landed!\nClick Select documentation to pick which versions to use. More versions will be added in the coming weeks.\nIf you notice any bugs, please report them on GitHub." diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 19e7343a..ce8ded53 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -154,6 +154,11 @@ credits = [ '2012 Plataformatec', 'Apache', 'https://raw.githubusercontent.com/elixir-lang/elixir/master/LICENSE' + ], [ + 'Erlang', + '1999-2015 Ericsson AB', + 'Apache', + 'https://raw.githubusercontent.com/erlang/otp/maint/LICENSE.txt' ], [ 'Express', '2009-2015 TJ Holowaychuk', diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index c9b7d110..df20b04d 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -123,3 +123,4 @@ ._icon-relay:before { background-position: -8rem -9rem; } ._icon-phoenix:before { background-position: -9rem -9rem; } ._icon-tcl_tk:before { background-position: 0 -10rem; } +._icon-erlang:before { background-position: -1rem -10rem; } diff --git a/assets/stylesheets/pages/_erlang.scss b/assets/stylesheets/pages/_erlang.scss index aa2ed0f2..317699dd 100644 --- a/assets/stylesheets/pages/_erlang.scss +++ b/assets/stylesheets/pages/_erlang.scss @@ -1,14 +1,8 @@ -.REFBODY { - margin-bottom: 20px; -} -.REFBODY+p { - margin-top: 30px; - margin-bottom: 5px; -} -.function-name { - font-family: $monoFont; - display: block; - margin: 0; - min-height: none; - font-weight: bold; +._erlang { + @extend %simple; + + h3.code { @extend %code; } + .note { @extend %note; } + .warning { @extend %note, %note-red; } + .note .label, .warning .label { font-weight: bold; } } diff --git a/lib/docs/filters/erlang/attribution.rb b/lib/docs/filters/erlang/attribution.rb deleted file mode 100644 index 57a03767..00000000 --- a/lib/docs/filters/erlang/attribution.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Docs - class Erlang - class AttributionFilter < Docs::AttributionFilter - def attribution_link - %(#{base_url}) - end - end - end -end diff --git a/lib/docs/filters/erlang/clean_html.rb b/lib/docs/filters/erlang/clean_html.rb index 6c23c8db..47535e33 100644 --- a/lib/docs/filters/erlang/clean_html.rb +++ b/lib/docs/filters/erlang/clean_html.rb @@ -2,10 +2,106 @@ module Docs class Erlang class CleanHtmlFilter < Filter def call - css('#leftnav').remove - css('#content .innertube center:last-child').remove - css('.function-name+br').remove - css('#content .footer').remove + @doc = at_css('#content .innertube') + + # frontpage + + css('center:last-child').remove # copyright + + css('center').each do |node| + node.before(node.children).remove + end + + css('> br').remove + + css('> font[size="+1"]:first-child').each do |node| + node.name = 'h1' + end + + css('p > b:first-child:last-child > font[size="+1"]').each do |node| + node = node.parent.parent + node.name = 'h2' + node.content = node.content + end + + css('font').each do |node| + node.before(node.children).remove + end + + # others + + # css('p > br:last-child').remove + + css('a[name]').each do |node| + parent = node.parent + parent = parent.parent while parent.name == 'span' + parent['id'] = node['name'] + node.before(node.children).remove + end + + css('h3').each do |node| + node.name = 'h2' + content = node.content + node.content = content.capitalize if content == content.upcase + end + + css('p > span.bold_code:first-child ~ br:last-child').each do |node| + parent = node.parent + parent.name = 'h3' + parent['class'] = 'code' + parent.css('*:not(a):not(br)').each { |n| n.before(n.children).remove } + node.remove + parent.inner_html = parent.inner_html.strip + end + + css('span.code').each do |node| + node.name = 'code' + end + + css('pre *:not(a)').each do |node| + node.before(node.children).remove + end + + css('pre').each do |node| + node.inner_html = node.inner_html.strip_heredoc + end + + css('.REFBODY').each do |node| + if node.element_children.length == 0 + node.name = 'p' + else + node.before(node.children).remove + end + end + + css('.REFTYPES').each do |node| + next unless node.parent + html = "
"
+          while node['class'] == 'REFTYPES'
+            node.inner_html = node.inner_html.remove(/\n/).gsub('
', "\n") + node.css('*:not(a)').each { |n| n.before(n.children).remove } + html << node.inner_html.strip + "\n" + node = node.next_element + node.previous_element.remove + end + html.strip! + html << "
" + node.before(html) + end + + css('.REFTYPES').remove + + css('table').each do |node| + node.remove_attribute('border') + node.remove_attribute('cellpadding') + node.remove_attribute('cellspacing') + end + + css('td').each do |node| + node.remove_attribute('align') + node.remove_attribute('valign') + end + doc end end diff --git a/lib/docs/filters/erlang/entries.rb b/lib/docs/filters/erlang/entries.rb index 3d438aa4..23050193 100644 --- a/lib/docs/filters/erlang/entries.rb +++ b/lib/docs/filters/erlang/entries.rb @@ -1,43 +1,35 @@ module Docs class Erlang class EntriesFilter < Docs::EntriesFilter - def get_name - at_css('h1').try(:content).try(:strip) + name = at_css('h1').content.strip + name.prepend 'Guide: ' if doc.inner_html.include?('User\'s Guide') + name end def get_type - return nil if 'STDLIB Reference Manual' == name - name + type = subpath[/lib\/(.+?)[\-\/]/, 1] + type << "/#{name}" if type == 'stdlib' && entry_nodes.length >= 10 + type end - def additional_entries - css('div.REFBODY+p > a').map do |node| - - id = node.attribute('name').value - - # Here, "node" represents an empty tag. It will later be removed - # by CleanTextFilter. - # We need to pass its id attribute to another element in order to - # make the function anchors in the sidebar work properly. - node.next_sibling['id'] = id - node.next_sibling['class'] = 'function-name' - - if id == name - # Module index page - [name, id, name] - else - # Erlang functions are identified - # by name + arity (no. of parameters). - # The notation is func_name/arity + def include_default_entry? + !at_css('.frontpage') + end - # Replaces the last hyphen with a slash. - # E.g: to_string-3 becomes to_string/3 - function_name = id.gsub(/\-(?.*)$/, '/\k') - ["#{name}:" + function_name, id, name] - end + def additional_entries + entry_nodes.map do |node| + id = node['name'] + name = id.gsub %r{\-(?.*)\z}, '/\k' + name.remove! 'Module:' + name.prepend "#{self.name}:" + [name, id] end end + + def entry_nodes + @entry_nodes ||= css('div.REFBODY + p > a') + end end end end diff --git a/lib/docs/filters/erlang/pre_clean_html.rb b/lib/docs/filters/erlang/pre_clean_html.rb new file mode 100644 index 00000000..75824b49 --- /dev/null +++ b/lib/docs/filters/erlang/pre_clean_html.rb @@ -0,0 +1,10 @@ +module Docs + class Erlang + class PreCleanHtmlFilter < Filter + def call + css('.flipMenu li[title] > a').remove + doc + end + end + end +end diff --git a/lib/docs/scrapers/erlang.rb b/lib/docs/scrapers/erlang.rb index 2621b920..031df7bc 100644 --- a/lib/docs/scrapers/erlang.rb +++ b/lib/docs/scrapers/erlang.rb @@ -1,40 +1,43 @@ module Docs class Erlang < FileScraper - self.version = '18.1' self.type = 'erlang' - self.dir = File.expand_path('~/devdocs/erlang') - self.base_url = 'http://www.erlang.org/doc/' self.root_path = 'doc/index.html' self.links = { - home: 'http://erlang.org/' + home: 'https://www.erlang.org/', + code: 'https://github.com/erlang/otp' } + html_filters.insert_after 'container', 'erlang/pre_clean_html' html_filters.push 'erlang/entries', 'erlang/clean_html' - # The folder structure of the offline documentation - # differs from the online structure. We need - # to replace the attribution filter to generate the - # right attribution_link - text_filters.replace 'attribution', 'erlang/attribution' + options[:only_patterns] = [/\Alib/] - # Do not scrape these unnecessary links options[:skip_patterns] = [ - /\.pdf$/, - /users_guide\.html$/, - /release_notes\.html$/, - /\/html\/.*_app\.html$/, - /\/html\/unicode_usage\.html$/, - /\/html\/io_protocol\.html$/ + /pdf/, + /release_notes/, + /result/, + /java/, + /\/html\/.*_app\.html\z/, + /_examples\.html\z/, + /\Alib\/edoc/, + /\Alib\/erl_docgen/, + /\Alib\/hipe/, + /\Alib\/ose/, + /\Alib\/test_server/, + /\Alib\/jinterface/, + /\Alib\/wx/, + /\Alib\/ic/, + /\Alib\/Cos/i ] - options[:title] = false - - # Scrape stdlib documentation only - options[:only_patterns] = [/stdlib/] - options[:attribution] = <<-HTML - Copyright © 1999-2015 Ericsson AB
+ © 1999–2015 Ericsson AB
Licensed under the Apache License, Version 2.0. HTML + + version '18' do + self.release = '18.2' + self.dir = '/Users/Thibaut/DevDocs/Docs/Erlang18' + end end end diff --git a/public/icons/docs/erlang/16.png b/public/icons/docs/erlang/16.png index 48c57ae5..7612c8cb 100644 Binary files a/public/icons/docs/erlang/16.png and b/public/icons/docs/erlang/16.png differ diff --git a/public/icons/docs/erlang/16@2x.png b/public/icons/docs/erlang/16@2x.png index df931a0b..04ac2043 100644 Binary files a/public/icons/docs/erlang/16@2x.png and b/public/icons/docs/erlang/16@2x.png differ diff --git a/public/icons/docs/erlang/SOURCE b/public/icons/docs/erlang/SOURCE index 009b1dea..af247617 100644 --- a/public/icons/docs/erlang/SOURCE +++ b/public/icons/docs/erlang/SOURCE @@ -1,2 +1 @@ -http://www.pixelstech.net/images/icons/article_type/Erlang_logo.png -https://s3.amazonaws.com/cloud.ohloh.net/attachments/1364/erlang2_small.png +https://github.com/Kapeli/Dash-X-Platform-Resources \ No newline at end of file