diff --git a/assets/javascripts/views/pages/elixir.coffee b/assets/javascripts/views/pages/elixir.coffee new file mode 100644 index 00000000..f46e2517 --- /dev/null +++ b/assets/javascripts/views/pages/elixir.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.ElixirPage extends app.views.BasePage + prepare: -> + @highlightCode @findAll('pre.elixir'), 'elixir' + return diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index e1dfe466..acb915b0 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -38,6 +38,7 @@ 'pages/coffeescript', 'pages/d3', 'pages/drupal', + 'pages/elixir', 'pages/ember', 'pages/express', 'pages/git', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index dbc803fb..a262f124 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -38,6 +38,7 @@ 'pages/coffeescript', 'pages/d3', 'pages/drupal', + 'pages/elixir', 'pages/ember', 'pages/express', 'pages/git', diff --git a/assets/stylesheets/pages/_elixir.scss b/assets/stylesheets/pages/_elixir.scss new file mode 100644 index 00000000..a05cb6c3 --- /dev/null +++ b/assets/stylesheets/pages/_elixir.scss @@ -0,0 +1,4 @@ +._elixir { + @extend %simple; + h3 { @extend %block-label; } +} diff --git a/lib/docs/filters/elixir/clean_html.rb b/lib/docs/filters/elixir/clean_html.rb new file mode 100644 index 00000000..6031967b --- /dev/null +++ b/lib/docs/filters/elixir/clean_html.rb @@ -0,0 +1,50 @@ +module Docs + class Elixir + class CleanHtmlFilter < Filter + def call + + # Strip h1 content + css('h1').each do |node| + node.content = node.content.strip + end + + # Make subtitles smaller + css('h2').each do |node| + node.name = 'h4' + end + + # Remove footer + at_css('footer').remove + + # Remove behaviour after module name + css('h1').each do |node| + if !(node.has_attribute?('id')) + node.content = node.content.split(" ")[0] + end + end + + # Remove links from summary headings + css('.summary > h4 > a').each do |node| + node.delete('href') + end + + # Add elixir class to each pre for syntax highlighting + css('pre').each do |node| + node['class'] = "elixir" + end + + # Rewrite .detail -> .method-detail + css('.detail').each do |node| + node['class'] = "method-detail" + end + + # Change .detail-header to h3 + css('.detail-header .signature').each do |node| + node.name = 'h3' + end + + doc + end + end + end +end diff --git a/lib/docs/filters/elixir/entries.rb b/lib/docs/filters/elixir/entries.rb new file mode 100644 index 00000000..ee830983 --- /dev/null +++ b/lib/docs/filters/elixir/entries.rb @@ -0,0 +1,35 @@ +module Docs + class Elixir + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').content.gsub('behaviour', ' ').strip + end + + def get_type + return nil if (slug.split("#")[1] == "functions") + slug.split("#")[1] + end + + def additional_entries + return [] if root_page? + + entries = [] + + # Add itself (moduledoc) to entries + klass = at_css('h1').content.strip.split(" ")[0] + entries << [klass, klass, name] + + # Add functions + css('.summary-functions .summary-signature a').each do |node| + entries << [(name + node['href']), node['href'][1..-1], name] + end + + return entries + end + + def include_default_entry? + !initial_page? + end + end + end +end diff --git a/lib/docs/scrapers/elixir.rb b/lib/docs/scrapers/elixir.rb new file mode 100644 index 00000000..e427002f --- /dev/null +++ b/lib/docs/scrapers/elixir.rb @@ -0,0 +1,36 @@ +module Docs + class Elixir < UrlScraper + self.name = 'Elixir' + self.type = 'elixir' + self.version = '1.1.1' + self.base_url = 'http://elixir-lang.org/docs/stable/elixir/' + self.root_path = 'extra-api-reference.html' + self.links = { + home: 'https://elixir-lang.org/', + code: 'https://github.com/elixir-lang/elixir' + } + + html_filters.push 'elixir/clean_html', 'elixir/entries', 'title' + + # Skip exceptions + options[:skip_patterns] = [/Error/] + # Skip protocols + options[:skip] = %w( + Collectable.html + Enumerable.html + Inspect.html + List.Chars.html + String.Chars.html + ) + + options[:follow_links] = ->(filter) { filter.root_page? } + options[:container] = "#content" + options[:title] = false + options[:root_title] = 'Elixir' + + options[:attribution] = <<-HTML + © 2012 Plataformatec
+ Licensed under the Apache License, Version 2.0 + HTML + end +end diff --git a/public/icons/docs/elixir/16.png b/public/icons/docs/elixir/16.png new file mode 100644 index 00000000..eeef08a3 Binary files /dev/null and b/public/icons/docs/elixir/16.png differ diff --git a/public/icons/docs/elixir/16@2x.png b/public/icons/docs/elixir/16@2x.png new file mode 100644 index 00000000..ed3e8ae8 Binary files /dev/null and b/public/icons/docs/elixir/16@2x.png differ diff --git a/public/icons/docs/elixir/SOURCE b/public/icons/docs/elixir/SOURCE new file mode 100644 index 00000000..ba422b56 --- /dev/null +++ b/public/icons/docs/elixir/SOURCE @@ -0,0 +1,2 @@ +http://elixir-lang.org/docs/stable/elixir/assets/logo.png +with permission from José Valim (https://twitter.com/josevalim/status/657125748659126272)