Skip to content

Commit 1ff9297

Browse files
mntnsThibaut
authored andcommitted
Add Elixir documentation
1 parent a796be9 commit 1ff9297

10 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#= require views/pages/base
2+
3+
class app.views.ElixirPage extends app.views.BasePage
4+
prepare: ->
5+
@highlightCode @findAll('pre.elixir'), 'elixir'
6+
return

assets/stylesheets/application-dark.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'pages/coffeescript',
3939
'pages/d3',
4040
'pages/drupal',
41+
'pages/elixir',
4142
'pages/ember',
4243
'pages/express',
4344
'pages/git',

assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'pages/coffeescript',
3939
'pages/d3',
4040
'pages/drupal',
41+
'pages/elixir',
4142
'pages/ember',
4243
'pages/express',
4344
'pages/git',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
._elixir {
2+
@extend %simple;
3+
h3 { @extend %block-label; }
4+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module Docs
2+
class Elixir
3+
class CleanHtmlFilter < Filter
4+
def call
5+
6+
# Strip h1 content
7+
css('h1').each do |node|
8+
node.content = node.content.strip
9+
end
10+
11+
# Make subtitles smaller
12+
css('h2').each do |node|
13+
node.name = 'h4'
14+
end
15+
16+
# Remove footer
17+
at_css('footer').remove
18+
19+
# Remove behaviour after module name
20+
css('h1').each do |node|
21+
if !(node.has_attribute?('id'))
22+
node.content = node.content.split(" ")[0]
23+
end
24+
end
25+
26+
# Remove links from summary headings
27+
css('.summary > h4 > a').each do |node|
28+
node.delete('href')
29+
end
30+
31+
# Add elixir class to each pre for syntax highlighting
32+
css('pre').each do |node|
33+
node['class'] = "elixir"
34+
end
35+
36+
# Rewrite .detail -> .method-detail
37+
css('.detail').each do |node|
38+
node['class'] = "method-detail"
39+
end
40+
41+
# Change .detail-header to h3
42+
css('.detail-header .signature').each do |node|
43+
node.name = 'h3'
44+
end
45+
46+
doc
47+
end
48+
end
49+
end
50+
end

lib/docs/filters/elixir/entries.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Docs
2+
class Elixir
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
at_css('h1').content.gsub('behaviour', ' ').strip
6+
end
7+
8+
def get_type
9+
return nil if (slug.split("#")[1] == "functions")
10+
slug.split("#")[1]
11+
end
12+
13+
def additional_entries
14+
return [] if root_page?
15+
16+
entries = []
17+
18+
# Add itself (moduledoc) to entries
19+
klass = at_css('h1').content.strip.split(" ")[0]
20+
entries << [klass, klass, name]
21+
22+
# Add functions
23+
css('.summary-functions .summary-signature a').each do |node|
24+
entries << [(name + node['href']), node['href'][1..-1], name]
25+
end
26+
27+
return entries
28+
end
29+
30+
def include_default_entry?
31+
!initial_page?
32+
end
33+
end
34+
end
35+
end

lib/docs/scrapers/elixir.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module Docs
2+
class Elixir < UrlScraper
3+
self.name = 'Elixir'
4+
self.type = 'elixir'
5+
self.version = '1.1.1'
6+
self.base_url = 'http://elixir-lang.org/docs/stable/elixir/'
7+
self.root_path = 'extra-api-reference.html'
8+
self.links = {
9+
home: 'https://elixir-lang.org/',
10+
code: 'https://github.com/elixir-lang/elixir'
11+
}
12+
13+
html_filters.push 'elixir/clean_html', 'elixir/entries', 'title'
14+
15+
# Skip exceptions
16+
options[:skip_patterns] = [/Error/]
17+
# Skip protocols
18+
options[:skip] = %w(
19+
Collectable.html
20+
Enumerable.html
21+
Inspect.html
22+
List.Chars.html
23+
String.Chars.html
24+
)
25+
26+
options[:follow_links] = ->(filter) { filter.root_page? }
27+
options[:container] = "#content"
28+
options[:title] = false
29+
options[:root_title] = 'Elixir'
30+
31+
options[:attribution] = <<-HTML
32+
&copy; 2012 Plataformatec<br>
33+
Licensed under the Apache License, Version 2.0
34+
HTML
35+
end
36+
end

public/icons/docs/elixir/16.png

1.33 KB
Loading
2.31 KB
Loading

public/icons/docs/elixir/SOURCE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
http://elixir-lang.org/docs/stable/elixir/assets/logo.png
2+
with permission from José Valim (https://twitter.com/josevalim/status/657125748659126272)

0 commit comments

Comments
 (0)