History

add ramda.js

Hassan Zamani committed 10 years ago

Commit 38f100f1 parent 1fa82439 files · +128 −-2Browse files

Showing the changes to lib/docs (3 of 9 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/ramda/clean_html.rb +53 −0
  2. lib/docs/filters/ramda/entries.rb +14 −0
  3. lib/docs/scrapers/ramda.rb +22 −0
lib/docs/filters/ramda/clean_html.rb+53−0
@@ -0,0 +1,53 @@
1module Docs
2 class Ramda
3 class CleanHtmlFilter < Filter
4 def call
5 @doc = at_css('main')
6
7 # Remove try in repl
8 css('.try-repl', '.pull-right').remove
9
10 # Place 'Added in' in header
11 css('.card').each do |card|
12 title = card.at_css('h2')
13 added_in = card.at_css('small')
14 added_in.parent = title
15 end
16
17 # Prepend links with 'R.'
18 css('h2 > a.name, .see a').each do |link|
19 link.content = 'R.' + link.content
20 end
21
22 css('.params').each do |node|
23 # Remove params expand link
24 node.inner_html = node.at_css('.details').inner_html
25 node.prepend_child "<h4>Parameters</h4>"
26
27 # Count params
28 if ul = node.at_css('ul')
29 ul.name = 'ol'
30 end
31
32 # change param names to <code>
33 node.css('span.name').each do |n|
34 n.name = 'code'
35 n.remove_attribute 'class'
36 end
37
38 # change returns to <h4> to make consistant look with params header
39 if returns = node.at_css('span.returns')
40 returns.name = 'h4'
41 end
42 end
43
44 # Remove code highlighting
45 css('pre').each do |node|
46 node.content = node.content
47 end
48
49 doc
50 end
51 end
52 end
53end
lib/docs/filters/ramda/entries.rb+14−0
@@ -0,0 +1,14 @@
1module Docs
2 class Ramda
3 class EntriesFilter < Docs::EntriesFilter
4 def additional_entries
5 css('ul.toc li').map do |item|
6 name = item['data-name']
7 category = item['data-category']
8
9 ['R.' + name, name, category]
10 end
11 end
12 end
13 end
14end
lib/docs/scrapers/ramda.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class Ramda < UrlScraper
3 self.name = 'Ramda'
4 self.slug = 'ramda'
5 self.type = 'ramda'
6 self.release = '0.19.1'
7 self.base_url = 'http://ramdajs.com/docs'
8 self.links = {
9 home: 'http://ramdajs.com/',
10 code: 'https://github.com/ramda/ramda/'
11 }
12
13 html_filters.push 'ramda/entries', 'ramda/clean_html', 'title'
14
15 options[:title] = 'Ramda'
16 options[:attribution] = <<-HTML
17 &copy; 2013&ndash;2014 Scott Sauyet and Michael Hurley<br>
18 Licensed under the MIT License.
19 HTML
20 end
21end
22

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t