Merge pull request #2266 from breunigs/ex-1.16-1.17

Update Elixir documentation (1.16 and 1.17)
pull/2289/head
Simon Legner 6 months ago committed by GitHub
commit 15b8875a54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,32 +2,12 @@ module Docs
class Elixir class Elixir
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
if current_url.path.start_with?('/getting-started')
guide
else
api api
end
doc doc
end 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 def api
css('.hover-link', 'footer', ':not(.detail-header) > .view-source').remove css('.top-search').remove
css('h1 .settings').remove
css('.summary').each do |node| css('.summary').each do |node|
node.name = 'dl' node.name = 'dl'
@ -65,6 +45,11 @@ module Docs
end end
end end
css('h1 a.icon-action[title="View Source"]').each do |node|
node['class'] = 'source'
node.content = "Source"
end
css('pre').each do |node| css('pre').each do |node|
node['data-language'] = 'elixir' node['data-language'] = 'elixir'
node.content = node.content node.content = node.content

@ -3,25 +3,21 @@ module Docs
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
css('h1 .app-vsn').remove css('h1 .app-vsn').remove
name = (at_css('h1 > span') or at_css('h1')).content.strip (at_css('h1 > span') or at_css('h1')).content.strip
if current_url.path.start_with?('/getting-started')
name.remove(/\.\z/)
else
name = name.split(' ').first unless name.start_with?('mix ') # ecto
name
end
end end
def get_type def get_type
if current_url.path.start_with?('/getting-started') section = at_css('h1 a.source').attr('href').match('elixir/pages/([^/]+)/')&.captures&.first
if subpath.start_with?('mix-otp') if section == "mix-and-otp"
'Guide: Mix & OTP' return "Mix & OTP"
elsif subpath.start_with?('meta') elsif section
'Guide: Metaprogramming' return section.gsub("-", " ").capitalize
else
'Guide'
end end
name = at_css('h1 span').text
case name.split(' ').first
when 'mix' then 'Mix Tasks'
when 'Changelog' then 'References'
else else
case at_css('h1 small').try(:content) case at_css('h1 small').try(:content)
when 'exception' when 'exception'
@ -29,19 +25,13 @@ module Docs
when 'protocol' when 'protocol'
'Protocols' 'Protocols'
else else
if name.start_with?('Phoenix') name
name.split('.')[0..2].join('.')
elsif name.start_with?('mix ')
'Mix Tasks'
else
name.split('.').first
end
end end
end end
end end
def additional_entries def additional_entries
return [] if type == 'Exceptions' || type == 'Guide' || root_page? return [] if root_page?
css('.detail-header').map do |node| css('.detail-header').map do |node|
id = node['id'] id = node['id']

@ -4,7 +4,7 @@ module Docs
self.name = 'Elixir' self.name = 'Elixir'
self.type = 'elixir' self.type = 'elixir'
self.root_path = 'api-reference.html' self.root_path = 'introduction.html'
self.links = { self.links = {
home: 'https://elixir-lang.org/', home: 'https://elixir-lang.org/',
code: 'https://github.com/elixir-lang/elixir' code: 'https://github.com/elixir-lang/elixir'
@ -12,27 +12,50 @@ module Docs
html_filters.push 'elixir/clean_html', 'elixir/entries', 'title' html_filters.push 'elixir/clean_html', 'elixir/entries', 'title'
options[:container] = ->(filter) { options[:container] = '#content'
filter.current_url.path.start_with?('/getting-started') ? '#main' : '#content'
}
options[:title] = false options[:title] = false
options[:root_title] = 'Elixir' options[:root_title] = 'Elixir'
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2012 Plataformatec<br> &copy; 2012-2024 The Elixir Team<br>
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML
def initial_urls def initial_urls
[ "https://hexdocs.pm/elixir/#{self.class.release}/api-reference.html", [ "https://hexdocs.pm/elixir/#{self.class.release}/introduction.html",
"https://hexdocs.pm/eex/#{self.class.release}/EEx.html", "https://hexdocs.pm/eex/#{self.class.release}/EEx.html",
"https://hexdocs.pm/ex_unit/#{self.class.release}/ExUnit.html", "https://hexdocs.pm/ex_unit/#{self.class.release}/ExUnit.html",
"https://hexdocs.pm/iex/#{self.class.release}/IEx.html", "https://hexdocs.pm/iex/#{self.class.release}/IEx.html",
"https://hexdocs.pm/logger/#{self.class.release}/Logger.html", "https://hexdocs.pm/logger/#{self.class.release}/Logger.html",
"https://hexdocs.pm/mix/#{self.class.release}/Mix.html", "https://hexdocs.pm/mix/#{self.class.release}/Mix.html" ]
"https://elixir-lang.org/getting-started/introduction.html" ] end
version '1.17' do
self.release = '1.17.2'
self.base_urls = [
"https://hexdocs.pm/elixir/#{release}/",
"https://hexdocs.pm/eex/#{release}/",
"https://hexdocs.pm/ex_unit/#{release}/",
"https://hexdocs.pm/iex/#{release}/",
"https://hexdocs.pm/logger/#{release}/",
"https://hexdocs.pm/mix/#{release}/"
]
end end
version '1.16' do
self.release = '1.16.3'
self.base_urls = [
"https://hexdocs.pm/elixir/#{release}/",
"https://hexdocs.pm/eex/#{release}/",
"https://hexdocs.pm/ex_unit/#{release}/",
"https://hexdocs.pm/iex/#{release}/",
"https://hexdocs.pm/logger/#{release}/",
"https://hexdocs.pm/mix/#{release}/"
]
end
# scraping of older versions is no longer supported!
version '1.15' do version '1.15' do
self.release = '1.15.4' self.release = '1.15.4'
self.base_urls = [ self.base_urls = [

Loading…
Cancel
Save