History

Finish Erlang documentation

Thibaut Courouble committed 10 years ago

Commit d5219631 parent 8469d7114 files · +166 −75Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/news.json +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. assets/stylesheets/pages/_erlang.scss +7 −13
  7. lib/docs/filters/erlang/attribution.rb +0 −9
  8. lib/docs/filters/erlang/clean_html.rb +100 −4
  9. lib/docs/filters/erlang/entries.rb +20 −28
  10. lib/docs/filters/erlang/pre_clean_html.rb +10 −0
  11. lib/docs/scrapers/erlang.rb +25 −22
  12. public/icons/docs/erlang/16.png +0 −0
  13. public/icons/docs/erlang/16@2x.png +0 −0
  14. public/icons/docs/erlang/SOURCE +1 −2
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
1[1[
2 [2 [
3 "2016-01-31",3 "2016-01-31",
4 "New documentation: <a href=\"/tcl_tk/\">Tcl/Tk</a>"4 "New documentations: <a href=\"/erlang/\">Erlang</a> and <a href=\"/tcl_tk/\">Tcl/Tk</a>"
5 ], [5 ], [
6 "2016-01-24",6 "2016-01-24",
7 "&ldquo;Multi-version support&rdquo; has landed!\nClick <a href=\"#\" data-pick-docs>Select documentation</a> to pick which versions to use. More versions will be added in the coming weeks.\nIf you notice any bugs, please report them on <a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">GitHub</a>."7 "&ldquo;Multi-version support&rdquo; has landed!\nClick <a href=\"#\" data-pick-docs>Select documentation</a> to pick which versions to use. More versions will be added in the coming weeks.\nIf you notice any bugs, please report them on <a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">GitHub</a>."
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -154,6 +154,11 @@ credits = [ · 153 unmodified lines
154 '2012 Plataformatec',154 '2012 Plataformatec',
155 'Apache',155 'Apache',
156 'https://raw.githubusercontent.com/elixir-lang/elixir/master/LICENSE'156 'https://raw.githubusercontent.com/elixir-lang/elixir/master/LICENSE'
157 ], [
158 'Erlang',
159 '1999-2015 Ericsson AB',
160 'Apache',
161 'https://raw.githubusercontent.com/erlang/otp/maint/LICENSE.txt'
157 ], [162 ], [
158 'Express',163 'Express',
159 '2009-2015 TJ Holowaychuk',164 '2009-2015 TJ Holowaychuk',
assets/stylesheets/global/_icons.scss+1−0
@@ -123,3 +123,4 @@ · 122 unmodified lines
123._icon-relay:before { background-position: -8rem -9rem; }123._icon-relay:before { background-position: -8rem -9rem; }
124._icon-phoenix:before { background-position: -9rem -9rem; }124._icon-phoenix:before { background-position: -9rem -9rem; }
125._icon-tcl_tk:before { background-position: 0 -10rem; }125._icon-tcl_tk:before { background-position: 0 -10rem; }
126._icon-erlang:before { background-position: -1rem -10rem; }
assets/stylesheets/pages/_erlang.scss+7−13
@@ -1,14 +1,8 @@
1.REFBODY {1._erlang {
2 margin-bottom: 20px;2 @extend %simple;
3}3
4.REFBODY+p {4 h3.code { @extend %code; }
5 margin-top: 30px;5 .note { @extend %note; }
6 margin-bottom: 5px;6 .warning { @extend %note, %note-red; }
7}7 .note .label, .warning .label { font-weight: bold; }
8.function-name {
9 font-family: $monoFont;
10 display: block;
11 margin: 0;
12 min-height: none;
13 font-weight: bold;
14}8}
lib/docs/filters/erlang/attribution.rb+0−9
@@ -1,9 +0,0 @@
1module Docs
2 class Erlang
3 class AttributionFilter < Docs::AttributionFilter
4 def attribution_link
5 %(<a href="#{base_url}" class="_attribution-link">#{base_url}</a>)
6 end
7 end
8 end
9end
lib/docs/filters/erlang/clean_html.rb+100−4
@@ -2,10 +2,106 @@ module Docs · 1 unmodified line
2 class Erlang2 class Erlang
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 css('#leftnav').remove5 @doc = at_css('#content .innertube')
6 css('#content .innertube center:last-child').remove6
7 css('.function-name+br').remove7 # frontpage
8 css('#content .footer').remove8
9 css('center:last-child').remove # copyright
10
11 css('center').each do |node|
12 node.before(node.children).remove
13 end
14
15 css('> br').remove
16
17 css('> font[size="+1"]:first-child').each do |node|
18 node.name = 'h1'
19 end
20
21 css('p > b:first-child:last-child > font[size="+1"]').each do |node|
22 node = node.parent.parent
23 node.name = 'h2'
24 node.content = node.content
25 end
26
27 css('font').each do |node|
28 node.before(node.children).remove
29 end
30
31 # others
32
33 # css('p > br:last-child').remove
34
35 css('a[name]').each do |node|
36 parent = node.parent
37 parent = parent.parent while parent.name == 'span'
38 parent['id'] = node['name']
39 node.before(node.children).remove
40 end
41
42 css('h3').each do |node|
43 node.name = 'h2'
44 content = node.content
45 node.content = content.capitalize if content == content.upcase
46 end
47
48 css('p > span.bold_code:first-child ~ br:last-child').each do |node|
49 parent = node.parent
50 parent.name = 'h3'
51 parent['class'] = 'code'
52 parent.css('*:not(a):not(br)').each { |n| n.before(n.children).remove }
53 node.remove
54 parent.inner_html = parent.inner_html.strip
55 end
56
57 css('span.code').each do |node|
58 node.name = 'code'
59 end
60
61 css('pre *:not(a)').each do |node|
62 node.before(node.children).remove
63 end
64
65 css('pre').each do |node|
66 node.inner_html = node.inner_html.strip_heredoc
67 end
68
69 css('.REFBODY').each do |node|
70 if node.element_children.length == 0
71 node.name = 'p'
72 else
73 node.before(node.children).remove
74 end
75 end
76
77 css('.REFTYPES').each do |node|
78 next unless node.parent
79 html = "<pre>"
80 while node['class'] == 'REFTYPES'
81 node.inner_html = node.inner_html.remove(/\n/).gsub('<br>', "\n")
82 node.css('*:not(a)').each { |n| n.before(n.children).remove }
83 html << node.inner_html.strip + "\n"
84 node = node.next_element
85 node.previous_element.remove
86 end
87 html.strip!
88 html << "</pre>"
89 node.before(html)
90 end
91
92 css('.REFTYPES').remove
93
94 css('table').each do |node|
95 node.remove_attribute('border')
96 node.remove_attribute('cellpadding')
97 node.remove_attribute('cellspacing')
98 end
99
100 css('td').each do |node|
101 node.remove_attribute('align')
102 node.remove_attribute('valign')
103 end
104
9 doc105 doc
10 end106 end
11 end107 end
lib/docs/filters/erlang/entries.rb+20−28
@@ -1,43 +1,35 @@
1module Docs1module Docs
2 class Erlang2 class Erlang
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
5 def get_name4 def get_name
6 at_css('h1').try(:content).try(:strip)5 name = at_css('h1').content.strip
6 name.prepend 'Guide: ' if doc.inner_html.include?('<strong>User\'s Guide</strong>')
7 name
7 end8 end
8 9
9 def get_type10 def get_type
10 return nil if 'STDLIB Reference Manual' == name11 type = subpath[/lib\/(.+?)[\-\/]/, 1]
11 name12 type << "/#{name}" if type == 'stdlib' && entry_nodes.length >= 10
13 type
12 end14 end
13 15
14 def additional_entries16 def include_default_entry?
15 css('div.REFBODY+p > a').map do |node|17 !at_css('.frontpage')
16 18 end
17 id = node.attribute('name').value
18
19 # Here, "node" represents an empty <a> tag. It will later be removed
20 # by CleanTextFilter.
21 # We need to pass its id attribute to another element in order to
22 # make the function anchors in the sidebar work properly.
23 node.next_sibling['id'] = id
24 node.next_sibling['class'] = 'function-name'
25
26 if id == name
27 # Module index page
28 [name, id, name]
29 else
30 # Erlang functions are identified
31 # by name + arity (no. of parameters).
32 # The notation is func_name/arity
33 19
34 # Replaces the last hyphen with a slash.20 def additional_entries
35 # E.g: to_string-3 becomes to_string/321 entry_nodes.map do |node|
36 function_name = id.gsub(/\-(?<arity>.*)$/, '/\k<arity>')22 id = node['name']
37 ["#{name}:" + function_name, id, name]23 name = id.gsub %r{\-(?<arity>.*)\z}, '/\k<arity>'
38 end24 name.remove! 'Module:'
25 name.prepend "#{self.name}:"
26 [name, id]
39 end27 end
40 end28 end
29
30 def entry_nodes
31 @entry_nodes ||= css('div.REFBODY + p > a')
32 end
41 end33 end
42 end34 end
43end35end
lib/docs/filters/erlang/pre_clean_html.rb+10−0
@@ -0,0 +1,10 @@
1module Docs
2 class Erlang
3 class PreCleanHtmlFilter < Filter
4 def call
5 css('.flipMenu li[title] > a').remove
6 doc
7 end
8 end
9 end
10end
lib/docs/scrapers/erlang.rb+25−22
@@ -1,40 +1,43 @@
1module Docs1module Docs
2 class Erlang < FileScraper2 class Erlang < FileScraper
3 self.version = '18.1'
4 self.type = 'erlang'3 self.type = 'erlang'
5 self.dir = File.expand_path('~/devdocs/erlang')
6 self.base_url = 'http://www.erlang.org/doc/'
7 self.root_path = 'doc/index.html'4 self.root_path = 'doc/index.html'
8 self.links = {5 self.links = {
9 home: 'http://erlang.org/'6 home: 'https://www.erlang.org/',
7 code: 'https://github.com/erlang/otp'
10 }8 }
11 9
10 html_filters.insert_after 'container', 'erlang/pre_clean_html'
12 html_filters.push 'erlang/entries', 'erlang/clean_html'11 html_filters.push 'erlang/entries', 'erlang/clean_html'
13 12
14 # The folder structure of the offline documentation13 options[:only_patterns] = [/\Alib/]
15 # differs from the online structure. We need
16 # to replace the attribution filter to generate the
17 # right attribution_link
18 text_filters.replace 'attribution', 'erlang/attribution'
19 14
20 # Do not scrape these unnecessary links
21 options[:skip_patterns] = [15 options[:skip_patterns] = [
22 /\.pdf$/,16 /pdf/,
23 /users_guide\.html$/,17 /release_notes/,
24 /release_notes\.html$/,18 /result/,
25 /\/html\/.*_app\.html$/,19 /java/,
26 /\/html\/unicode_usage\.html$/,20 /\/html\/.*_app\.html\z/,
27 /\/html\/io_protocol\.html$/21 /_examples\.html\z/,
22 /\Alib\/edoc/,
23 /\Alib\/erl_docgen/,
24 /\Alib\/hipe/,
25 /\Alib\/ose/,
26 /\Alib\/test_server/,
27 /\Alib\/jinterface/,
28 /\Alib\/wx/,
29 /\Alib\/ic/,
30 /\Alib\/Cos/i
28 ]31 ]
29 32
30 options[:title] = false
31
32 # Scrape stdlib documentation only
33 options[:only_patterns] = [/stdlib/]
34
35 options[:attribution] = <<-HTML33 options[:attribution] = <<-HTML
36 Copyright &copy; 1999-2015 Ericsson AB<br>34 &copy; 1999&ndash;2015 Ericsson AB<br>
37 Licensed under the Apache License, Version 2.0.35 Licensed under the Apache License, Version 2.0.
38 HTML36 HTML
37
38 version '18' do
39 self.release = '18.2'
40 self.dir = '/Users/Thibaut/DevDocs/Docs/Erlang18'
41 end
39 end42 end
40end43end
public/icons/docs/erlang/16.png+0−0

Binary file not shown.

public/icons/docs/erlang/16@2x.png+0−0

Binary file not shown.

public/icons/docs/erlang/SOURCE+1−2
@@ -1,2 +1 @@
1http://www.pixelstech.net/images/icons/article_type/Erlang_logo.png1https://github.com/Kapeli/Dash-X-Platform-Resources
2https://s3.amazonaws.com/cloud.ohloh.net/attachments/1364/erlang2_small.png