From 1ff92971a5bc23521dd13d21fd6c3a87d8f72b76 Mon Sep 17 00:00:00 2001 From: Eddy Shure Date: Thu, 22 Oct 2015 13:12:00 +0200 Subject: [PATCH] Add Elixir documentation --- assets/javascripts/views/pages/elixir.coffee | 6 +++ assets/stylesheets/application-dark.css.scss | 1 + assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_elixir.scss | 4 ++ lib/docs/filters/elixir/clean_html.rb | 50 +++++++++++++++++++ lib/docs/filters/elixir/entries.rb | 35 +++++++++++++ lib/docs/scrapers/elixir.rb | 36 +++++++++++++ public/icons/docs/elixir/16.png | Bin 0 -> 1361 bytes public/icons/docs/elixir/16@2x.png | Bin 0 -> 2369 bytes public/icons/docs/elixir/SOURCE | 2 + 10 files changed, 135 insertions(+) create mode 100644 assets/javascripts/views/pages/elixir.coffee create mode 100644 assets/stylesheets/pages/_elixir.scss create mode 100644 lib/docs/filters/elixir/clean_html.rb create mode 100644 lib/docs/filters/elixir/entries.rb create mode 100644 lib/docs/scrapers/elixir.rb create mode 100644 public/icons/docs/elixir/16.png create mode 100644 public/icons/docs/elixir/16@2x.png create mode 100644 public/icons/docs/elixir/SOURCE 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 0000000000000000000000000000000000000000..eeef08a36eb019b1c786c396c356ee11716324cf GIT binary patch literal 1361 zcmY*XX;2eJ6y8`Ag(9{nP=BZ$#}*W72q2xb9f5%oFbSYRzyy+z8%YQxAqPYf5+w&m zFc1*JsfGjz2!*1t^iVp=S+5GkOhqhOt@Q-$)Y^1I+nIJ}cHj4X?|pA~cAho`pWx%Q z(F*|JlZc7i3*$QXUi}6jOAb`miB9&^47Zi_{+k5d zw(jq*OhZbF;uFIQ)Qnm!r=hx_87f2eVI{k=Qe3|;go)cq6{M;U(@ZK_t)ulk%#L1| z`ugmM%jGJemnVl%5;hZ=(Xt9|lZMk^I@FEWFGrS-S*z`hE z#x73Q?t=srogQCE{)Asl)||0_L5~x{;y<6c%ttJGNo}2?Ri2~62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G~U{}7e@}35jHiFI0dB?oU?xqEJ{HcL#~*q&FSmXxuQQkAeYaff8eB6CgX2ml(iF` zGNb^p6tEP9LIH(R2Rz?_5FCU6)yf2{F%Uw6v8h=>F@@%wqj!EMX7_auJ^r(&b@%+z z^jBcK9Cp3-_f)ygHpbZgIE`H}b7~ldp4J-DQCPI3AHzfMLPrrOr!Yy1O1X-Tjt)@5 z00KCkf|qxZ@ASbq4Jc(hF1+qsEa0b346ec z`pIk2dqQWuR&LBTNjl(VJ((|NI=!5W(yRh9MGu{G3MlsEVQ7MEr-x!s4*9MuQpE6b z4hp3_D4~D_xS*>SES$S8juU(1=Wdw30svqVgF}1AjF95VC@{;K)pn+%Gpjihl2ZXf zEx-(V=k&nwB}NX7z*qxHDMAo9u0pjk0T6%^x;>xIKl1MW!-mmgX@IVS6Ue?&UaD9tY5;9Em~HO73ecC_(F9q1(027*gaFfhu&8Am3YK}Wub zllxD`z|uv?7jnoIa&Hxig|A+J^R>_RFFXlRn7n5Wdq2Pno7dx_v#vn*f?mX-9tG^5 zos1JHS1z94Kg;i#*98D*Of(TRL-fq<#%aqIr}<)j#LxJTW^>tZ9r(xozcia6f*`=k zD_6W{4#9EOPrm*zbQq)5o5$t1UdV^`9QqXF^tN0v^RciU$uJC)t~te8_uSF}t@U6S zgc}@3Z9h1CI8Nde0I=-rv)=doe*(N*gU>jBseu3h03~!qSaf7zbY(hYa%Ew3WdJfT zF*PkQFfB4NR539+GdDUgGAl4LIxsK+I=aLF001R)MObuXVRU6WZEs|0W_bWIFflbP nF)%GMGE^`$IxsOhH8LwOGCD9YEL%uF00000NkvXXu0mjf@!Lk` literal 0 HcmV?d00001 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)