From 8469d7148c924ff21d7c218d9b3a57f56055c146 Mon Sep 17 00:00:00 2001 From: Jairo S Date: Thu, 3 Dec 2015 00:31:26 -0200 Subject: [PATCH] Adding Erlang docs. --- assets/stylesheets/application-dark.css.scss | 1 + assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_erlang.scss | 14 ++++++ lib/docs/filters/erlang/attribution.rb | 9 ++++ lib/docs/filters/erlang/clean_html.rb | 13 ++++++ lib/docs/filters/erlang/entries.rb | 43 +++++++++++++++++++ lib/docs/scrapers/erlang.rb | 40 +++++++++++++++++ public/icons/docs/erlang/16.png | Bin 0 -> 637 bytes public/icons/docs/erlang/16@2x.png | Bin 0 -> 1869 bytes public/icons/docs/erlang/SOURCE | 2 + 10 files changed, 123 insertions(+) create mode 100644 assets/stylesheets/pages/_erlang.scss create mode 100644 lib/docs/filters/erlang/attribution.rb create mode 100644 lib/docs/filters/erlang/clean_html.rb create mode 100644 lib/docs/filters/erlang/entries.rb create mode 100644 lib/docs/scrapers/erlang.rb create mode 100644 public/icons/docs/erlang/16.png create mode 100644 public/icons/docs/erlang/16@2x.png create mode 100644 public/icons/docs/erlang/SOURCE 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 0000000000000000000000000000000000000000..48c57ae50faa0ee69b5bdeafdcbef61a6cd308cf GIT binary patch literal 637 zcmV-@0)qXCP)8zA6BW%lep|o&Y=2(|*V zh{oK|I0;Rs{qbGQ4X1KkI-X?WdJhS059RmzFYKK+^2`8VJWu)l{4H}s<9u@W<#ENv z5*l4s(AKw609rh^^8~5AIMLNjs#}|>Zf&MWQP|s!t&R0#e`JWy$M1G(a*LB$L6ANu>)&ZF7gOeJ_sO!f2^L ziEZu_5XWsNk2GhYgcg^{BvbhTH7BTSvK?r!wx8uv{{sx=rTYPYRE>>q^990|o;wAz z;?iR{$NIVa>>-}Tk67&W`*$$^`a^;E!jpTP?zo!k%c?DOett>K`EvlI6G@_LTQJsm zOJ12S%G%V79E9z_4_TX%s%&j-iHJxz9L|Ze zwW_KjA`%LPL_}nHX-Q&QOp3$d@IYHz8{~v9W=oX&Sn&1EA|VCey#C^85Xm&1Pn2X8{NXgG8fI0)YT-x0{89 z1(e#_T2iSLR;v|9w2Sz%ycfM76)&1R#wx0kxQI=Z^L7#$tOZnyIn XV2>%n6Cmj~00000NkvXXu0mjf=3^#A literal 0 HcmV?d00001 diff --git a/public/icons/docs/erlang/16@2x.png b/public/icons/docs/erlang/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..df931a0b9241fd2d5678e4c5009011f5b935f77c GIT binary patch literal 1869 zcmV-T2eSByP)+3S$FuBw6n1u+w|suB^>mnw)OImlhFuo0M?0v!m^ci|lj6b%W!^+c&qr^RL>^7*?<>f9+onJu-G;j`wue zSAFpHxi8_m!S9qz|K(36&YrEJ3I&j!f*s7d{^kempN0S`U9rU4^wh$xrY;M<=c`|z zv}CauL(GF&6G4QSW8L4JS^aAL;gfwWUA=d|>AX^Z>*z;0vx@SjmqCW|00P`6`W%jGK>R-Qu{4l?|9PBIb=y>U?7 z7+DYH74Xz2FJGL$q};^-F&F|s%YU{KU^RmDj;RvUKxbRqUoHiZ4J1j0AdsXF{>aVt zzPopa;y|iU;u_1zC|o+nAO>RF#FN1>;|f7ND?+ z$rlWycWFch@xH!TclRTM{TBOb`TgO0ZIV@*aNO4b;%?R%&H_Q}t8Il*id`JWsp zKu}eaNRZ7o0EkKZHA>!Z#iCIYV^swnKe%Yf42Ug&0JYUMk)Gbi^k8g3f#1qhLqz;| z2Sf}e6@elWn_*f|%LiIQpB9 zpH0C@(`Jhob=kVrPdr_kl<4RS!Io_#DcN}b-QVVxPm`pZJ8jysw|2bp&p#F|U*tw( ztRgltZyo(O{B;}K)*yQf`XCUAk&K-2OMd@r&axA3KZrbLC1Ma_rq7?}tT?*6_y;ek z5wa~65m&}MSttTE!XS2#(c9cv|MrnVj14iAhdN?Xk)rQExBAq+f@jN(#u5@vNN++T zu%vY5(p4WHEL*)wjDS5>Ah!9+o_AV5`OH5y+fGCyQT)fDz?X0QVf?exr@pdQj6sTX z@X*KP7oYp_r*prmtLtgFOR+eO$(p!eR{pFRY&jxAOkRD-;@hWAUw-{nB8dPL1WXb zO+Pi_=1(sgdR07pn5f6;DHDU59<9qDBdHNDGh!AI8e+{sYXqZe6D!o3SWvKQ=dPxk zHy18g==gm5_V2H(tnBFMm^W{pWmzXqoVak|!u6OP2uT6Zn>SZfRP5cmx4gW3 zX=yoo_H12UT{4+e)jN0YL?V&a*4Ep%Z>wr|clY`8=j-a~RJE(CtEHtyRYjzs zp&=X&yRO^T)|N;lRJEt4=fQ&qs;a7?Q0VaC!|m