diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 4929be30..33c0ba6c 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -41,6 +41,7 @@ 'pages/drupal', 'pages/elixir', 'pages/ember', + 'pages/erlang', 'pages/express', 'pages/git', 'pages/go', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 290a8e68..a0caa437 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -41,6 +41,7 @@ 'pages/drupal', 'pages/elixir', 'pages/ember', + 'pages/erlang', 'pages/express', 'pages/git', 'pages/go', diff --git a/assets/stylesheets/pages/_erlang.scss b/assets/stylesheets/pages/_erlang.scss new file mode 100644 index 00000000..aa2ed0f2 --- /dev/null +++ b/assets/stylesheets/pages/_erlang.scss @@ -0,0 +1,14 @@ +.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; +} diff --git a/lib/docs/filters/erlang/attribution.rb b/lib/docs/filters/erlang/attribution.rb new file mode 100644 index 00000000..57a03767 --- /dev/null +++ b/lib/docs/filters/erlang/attribution.rb @@ -0,0 +1,9 @@ +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 new file mode 100644 index 00000000..6c23c8db --- /dev/null +++ b/lib/docs/filters/erlang/clean_html.rb @@ -0,0 +1,13 @@ +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 + end + end + end +end diff --git a/lib/docs/filters/erlang/entries.rb b/lib/docs/filters/erlang/entries.rb new file mode 100644 index 00000000..3d438aa4 --- /dev/null +++ b/lib/docs/filters/erlang/entries.rb @@ -0,0 +1,43 @@ +module Docs + class Erlang + class EntriesFilter < Docs::EntriesFilter + + def get_name + at_css('h1').try(:content).try(:strip) + end + + def get_type + return nil if 'STDLIB Reference Manual' == name + name + 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 + + # 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 + end + end + end + end +end diff --git a/lib/docs/scrapers/erlang.rb b/lib/docs/scrapers/erlang.rb new file mode 100644 index 00000000..2621b920 --- /dev/null +++ b/lib/docs/scrapers/erlang.rb @@ -0,0 +1,40 @@ +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/' + } + + 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' + + # 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$/ + ] + + options[:title] = false + + # Scrape stdlib documentation only + options[:only_patterns] = [/stdlib/] + + options[:attribution] = <<-HTML + Copyright © 1999-2015 Ericsson AB
+ Licensed under the Apache License, Version 2.0. + HTML + end +end diff --git a/public/icons/docs/erlang/16.png b/public/icons/docs/erlang/16.png new file mode 100644 index 00000000..48c57ae5 Binary files /dev/null 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 new file mode 100644 index 00000000..df931a0b Binary files /dev/null and b/public/icons/docs/erlang/16@2x.png differ diff --git a/public/icons/docs/erlang/SOURCE b/public/icons/docs/erlang/SOURCE new file mode 100644 index 00000000..009b1dea --- /dev/null +++ b/public/icons/docs/erlang/SOURCE @@ -0,0 +1,2 @@ +http://www.pixelstech.net/images/icons/article_type/Erlang_logo.png +https://s3.amazonaws.com/cloud.ohloh.net/attachments/1364/erlang2_small.png