From 38f100fbf36c4a724eb81ff8fdb4485ff8858780 Mon Sep 17 00:00:00 2001 From: Hassan Zamani Date: Wed, 27 Jan 2016 03:17:24 +0330 Subject: [PATCH] add ramda.js --- assets/javascripts/views/pages/ramda.coffee | 6 +++ assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_ramda.scss | 33 ++++++++++++ lib/docs/filters/ramda/clean_html.rb | 53 ++++++++++++++++++++ lib/docs/filters/ramda/entries.rb | 14 ++++++ lib/docs/scrapers/ramda.rb | 22 ++++++++ public/icons/docs/ramda/SOURCE | 1 + public/icons/docs/ramda/ramda-16.png | Bin 0 -> 562 bytes public/icons/docs/ramda/ramda-32.png | Bin 0 -> 1355 bytes 9 files changed, 130 insertions(+) create mode 100644 assets/javascripts/views/pages/ramda.coffee create mode 100644 assets/stylesheets/pages/_ramda.scss create mode 100644 lib/docs/filters/ramda/clean_html.rb create mode 100644 lib/docs/filters/ramda/entries.rb create mode 100644 lib/docs/scrapers/ramda.rb create mode 100644 public/icons/docs/ramda/SOURCE create mode 100644 public/icons/docs/ramda/ramda-16.png create mode 100644 public/icons/docs/ramda/ramda-32.png diff --git a/assets/javascripts/views/pages/ramda.coffee b/assets/javascripts/views/pages/ramda.coffee new file mode 100644 index 00000000..449b5fd0 --- /dev/null +++ b/assets/javascripts/views/pages/ramda.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.RamdaPage extends app.views.BasePage + prepare: -> + @highlightCode @findAll('section > pre:last-child'), 'javascript' + return diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 5a047bb8..35e24aac 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -64,6 +64,7 @@ 'pages/phpunit', 'pages/postgres', 'pages/q', + 'pages/ramda', 'pages/rdoc', 'pages/react', 'pages/redis', diff --git a/assets/stylesheets/pages/_ramda.scss b/assets/stylesheets/pages/_ramda.scss new file mode 100644 index 00000000..573bc340 --- /dev/null +++ b/assets/stylesheets/pages/_ramda.scss @@ -0,0 +1,33 @@ +._ramda { + @extend %simple; + code { @extend %code; } + h2 + div > code { @extend %block-label, %label-blue; } + + h2 { + small { + font-size: small; + float: right; + } + } + + .see a { @extend %label; } + + .params { + .type { + font-style: italic; + text-transform: capitalize; + margin-right: 0.35em; + &::before { content: '<'; } + &::after { content: '>'; } + } + .panel-body { + margin-bottom: 1.5em; + .type { + padding: 0 0 0 2em; + } + .description > p { + display: inline-block; + } + } + } +} diff --git a/lib/docs/filters/ramda/clean_html.rb b/lib/docs/filters/ramda/clean_html.rb new file mode 100644 index 00000000..ec5ce5e8 --- /dev/null +++ b/lib/docs/filters/ramda/clean_html.rb @@ -0,0 +1,53 @@ +module Docs + class Ramda + class CleanHtmlFilter < Filter + def call + @doc = at_css('main') + + # Remove try in repl + css('.try-repl', '.pull-right').remove + + # Place 'Added in' in header + css('.card').each do |card| + title = card.at_css('h2') + added_in = card.at_css('small') + added_in.parent = title + end + + # Prepend links with 'R.' + css('h2 > a.name, .see a').each do |link| + link.content = 'R.' + link.content + end + + css('.params').each do |node| + # Remove params expand link + node.inner_html = node.at_css('.details').inner_html + node.prepend_child "

Parameters

" + + # Count params + if ul = node.at_css('ul') + ul.name = 'ol' + end + + # change param names to + node.css('span.name').each do |n| + n.name = 'code' + n.remove_attribute 'class' + end + + # change returns to

to make consistant look with params header + if returns = node.at_css('span.returns') + returns.name = 'h4' + end + end + + # Remove code highlighting + css('pre').each do |node| + node.content = node.content + end + + doc + end + end + end +end diff --git a/lib/docs/filters/ramda/entries.rb b/lib/docs/filters/ramda/entries.rb new file mode 100644 index 00000000..72bfc313 --- /dev/null +++ b/lib/docs/filters/ramda/entries.rb @@ -0,0 +1,14 @@ +module Docs + class Ramda + class EntriesFilter < Docs::EntriesFilter + def additional_entries + css('ul.toc li').map do |item| + name = item['data-name'] + category = item['data-category'] + + ['R.' + name, name, category] + end + end + end + end +end diff --git a/lib/docs/scrapers/ramda.rb b/lib/docs/scrapers/ramda.rb new file mode 100644 index 00000000..d9424958 --- /dev/null +++ b/lib/docs/scrapers/ramda.rb @@ -0,0 +1,22 @@ +module Docs + class Ramda < UrlScraper + self.name = 'Ramda' + self.slug = 'ramda' + self.type = 'ramda' + self.release = '0.19.1' + self.base_url = 'http://ramdajs.com/docs' + self.links = { + home: 'http://ramdajs.com/', + code: 'https://github.com/ramda/ramda/' + } + + html_filters.push 'ramda/entries', 'ramda/clean_html', 'title' + + options[:title] = 'Ramda' + options[:attribution] = <<-HTML + © 2013–2014 Scott Sauyet and Michael Hurley
+ Licensed under the MIT License. + HTML + end +end + diff --git a/public/icons/docs/ramda/SOURCE b/public/icons/docs/ramda/SOURCE new file mode 100644 index 00000000..4ac07377 --- /dev/null +++ b/public/icons/docs/ramda/SOURCE @@ -0,0 +1 @@ +https://camo.githubusercontent.com/0b4c12a5daec02b72e6e6879861ac70f75046e65/687474703a2f2f72616d64612e6a637068696c6c697070732e636f6d2f6c6f676f2f72616d646146696c6c65645f323030783233352e706e67 diff --git a/public/icons/docs/ramda/ramda-16.png b/public/icons/docs/ramda/ramda-16.png new file mode 100644 index 0000000000000000000000000000000000000000..7ebe9cbc97ebdee320482359a9923a29259985e5 GIT binary patch literal 562 zcmV-20?qx2P)_uJNdYqwGdMXg5QOtv9%L|g-9Af>=aU@5p5(|2zJ`r zSfsHKvC+yu;14j7RBlv6j31D%HQswHvUk~av+L>349`4s-Wi}%4UUt6+;btfDdcvA z+{t!?*+hcFOIC#+Y{rlEtYs<^W!BLbm|m z$KJ0uBhBL7$4SoSs(wPUX6AXhvIn9ob(T{H!okx@o%wu2Vir7oV6rOYHY&J#h^MCm z*ETSZOVz~?Lb^Kb8nNWwLDms0Vq=WVP9tx**=EklP*#M=x_sR->1j0Px__UCU%OFl}Xl z-!oagI&(Q40B7^lW1Vn*_617R>J6^$BTb~lb>hhoRNHtHt^PhV=@ zF9q+ObUzduqatZ@sYU`pMSLW_H;N&f)AUq*Fw-A)_c`v3p{07*qoM6N<$f~I}> A?f?J) literal 0 HcmV?d00001 diff --git a/public/icons/docs/ramda/ramda-32.png b/public/icons/docs/ramda/ramda-32.png new file mode 100644 index 0000000000000000000000000000000000000000..536d0231a7c5519b01df3f57b8c92236740ff2a9 GIT binary patch literal 1355 zcmV-R1+@B!P){1BSsB^O1v(xN_(2=J?_m zVc>+FK?ngx_?n5$Zvg-hx{o`jg7Ib;r~r^t!4&`i0~_xGfChj+w9=O-qVM@+<&=(yGN4;^U?dLyL5G2}ZSGR6AVUXp`Rl`23c(4agVHUXROzzHp9} zZ3UxRGMa4~fXn4uf>CXA{#%Q1PS&y&j27Ym1f#mw?d)tS1fdSM0{~Dk-bv@PZ`5)! zvH8{VvFXz6Dap;9u8@7bZl~KYl7x^~1*2MWGrfGS(`ij4gmu&r;`ik{U+LkDYG2x? z+pQF?`x;uDeF*?N7&c#<&SgJcx@MgJ5b3DDTF$8baWvnj9ua+qZ(-_2r1i{6|cSF>P}`)or&w zSrZhJO0FbZ}$HGGJoziF$km@a|@Nl+Jcu_KQ zOoQ%g_>372zr8RWteT3uthO!baAp)VY%I?bg#UV_DNV?Uui3Lu&m1H;oF)ZOPJ}YhRC#wOZc6Ra5cu zc6TB3Yx&(1R&S)D$IE?&*?a#j%-p;+I`K87w8D=NdH@irsHR0#8f+LqyeZJ1#QPSJ z#{mG)Q%EH(|MmDBrG_*x#-?e;Zh(Gf%>YuC*I!blt>r!^=E%hS)IUqw0Gnqt=q3An zKL45Rx|azd=@k@+^ zs1=!#Vls@vb=AJbu(@+Kzi_Q?29na*A6pymyRJo2mmlf=zJ!hJK5|HPlAidl8!)wju0R%sW^OhKC=|&{{d9_!iobmMo$0$ N002ovPDHLkV1mU(hXVir literal 0 HcmV?d00001