Update Elixir documentation (1.3.3)

pull/501/head
Thibaut Courouble 8 years ago
parent 7b35dddb44
commit 6fdf81e649

@ -65,7 +65,7 @@ module Docs
end
def initial_urls
super + self.class.base_urls[1..-1]
super + self.class.base_urls[1..-1].deep_dup
end
def base_urls

@ -2,6 +2,29 @@ module Docs
class Elixir
class CleanHtmlFilter < Filter
def call
if current_url.path.start_with?('/getting-started')
guide
else
api
end
doc
end
def guide
@doc = at_css('#content article')
css('pre > code').each do |node|
node.parent.content = node.content
end
css('div > pre.highlight').each do |node|
node.content = node.content
node['data-language'] = node.parent['class'][/language-(\w+)/, 1]
node.parent.before(node).remove
end
end
def api
css('footer', '.view-source', 'h1 .visible-xs').remove
css('section section.docstring h2').each do |node|
@ -33,8 +56,6 @@ module Docs
css('pre').each do |node|
node['data-language'] = 'elixir'
end
doc
end
end
end

@ -2,26 +2,40 @@ module Docs
class Elixir
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('h1').content.split(' ').first.strip
if current_url.path.start_with?('/getting-started')
at_css('h1').content.strip.remove(/\.\z/)
else
at_css('h1').content.split(' ').first.strip
end
end
def get_type
case at_css('h1 small').try(:content)
when 'exception'
'Exceptions'
when 'protocol'
'Protocols'
if current_url.path.start_with?('/getting-started')
if subpath.start_with?('mix-otp')
'Guide: Mix & OTP'
elsif subpath.start_with?('meta')
'Guide: Metaprogramming'
else
'Guide'
end
else
if name.start_with?('Phoenix')
name.split('.')[0..2].join('.')
case at_css('h1 small').try(:content)
when 'exception'
'Exceptions'
when 'protocol'
'Protocols'
else
name.split('.').first
if name.start_with?('Phoenix')
name.split('.')[0..2].join('.')
else
name.split('.').first
end
end
end
end
def additional_entries
return [] if type == 'Exceptions'
return [] if type == 'Exceptions' || type == 'Guide'
css('.detail-header .signature').map do |node|
id = node.parent['id']

@ -1,9 +1,11 @@
module Docs
class Elixir < UrlScraper
include MultipleBaseUrls
self.name = 'Elixir'
self.type = 'elixir'
self.release = '1.3.2'
self.base_url = 'http://elixir-lang.org/docs/stable/'
self.release = '1.3.3'
self.base_urls = ['http://elixir-lang.org/docs/stable/', 'http://elixir-lang.org/getting-started/']
self.root_path = 'elixir/api-reference.html'
self.initial_paths = %w(
eex/EEx.html
@ -19,7 +21,9 @@ module Docs
html_filters.push 'elixir/clean_html', 'elixir/entries', 'title'
options[:container] = "#content"
options[:container] = ->(filter) {
filter.current_url.path.start_with?('/getting-started') ? '#main' : '#content'
}
options[:title] = false
options[:root_title] = 'Elixir'
@ -27,5 +31,9 @@ module Docs
&copy; 2012&ndash;2016 Plataformatec<br>
Licensed under the Apache License, Version 2.0.
HTML
def initial_urls
super.tap { |urls| urls.last << 'introduction.html' }
end
end
end

Loading…
Cancel
Save