Update Angular documentation (5.0.1)

pull/699/merge
Thibaut Courouble 7 years ago
parent 391a1644df
commit 187e09ed93

@ -15,29 +15,13 @@ module Docs
Licensed under the Creative Commons Attribution License 4.0. Licensed under the Creative Commons Attribution License 4.0.
HTML HTML
version do module Common
self.release = '4.4.6'
self.base_url = 'https://angular.io/'
self.root_path = 'docs'
html_filters.push 'angular/clean_html', 'angular/entries'
options[:follow_links] = false
options[:only_patterns] = [/\Aguide/, /\Atutorial/, /\Aapi/]
options[:fix_urls_before_parse] = ->(url) do
url.sub! %r{\Aguide/}, '/guide/'
url.sub! %r{\Atutorial/}, '/tutorial/'
url.sub! %r{\Aapi/}, '/api/'
url.sub! %r{\Agenerated/}, '/generated/'
url
end
private private
def initial_urls def initial_urls
initial_urls = [] initial_urls = []
Request.run 'https://angular.io/generated/navigation.json' do |response| Request.run "#{self.class.base_url}generated/navigation.json" do |response|
data = JSON.parse(response.body) data = JSON.parse(response.body)
dig = ->(entry) do dig = ->(entry) do
initial_urls << url_for("generated/docs/#{entry['url']}.json") if entry['url'] && entry['url'] != 'api' initial_urls << url_for("generated/docs/#{entry['url']}.json") if entry['url'] && entry['url'] != 'api'
@ -46,7 +30,7 @@ module Docs
data['SideNav'].each(&dig) data['SideNav'].each(&dig)
end end
Request.run 'https://angular.io/generated/docs/api/api-list.json' do |response| Request.run "#{self.class.base_url}generated/docs/api/api-list.json" do |response|
data = JSON.parse(response.body) data = JSON.parse(response.body)
dig = ->(entry) do dig = ->(entry) do
initial_urls << url_for("generated/docs/#{entry['path']}.json") if entry['path'] initial_urls << url_for("generated/docs/#{entry['path']}.json") if entry['path']
@ -61,7 +45,11 @@ module Docs
def handle_response(response) def handle_response(response)
if response.mime_type.include?('json') if response.mime_type.include?('json')
response.options[:response_body] = JSON.parse(response.body)['contents'] begin
response.options[:response_body] = JSON.parse(response.body)['contents']
rescue JSON::ParserError
response.options[:response_body] = ''
end
response.headers['Content-Type'] = 'text/html' response.headers['Content-Type'] = 'text/html'
response.url.path = response.url.path.sub('/generated/docs/', '/').remove('.json') response.url.path = response.url.path.sub('/generated/docs/', '/').remove('.json')
response.effective_url.path = response.effective_url.path.sub('/generated/docs/', '/').remove('.json') response.effective_url.path = response.effective_url.path.sub('/generated/docs/', '/').remove('.json')
@ -70,6 +58,46 @@ module Docs
end end
end end
version do
self.release = '5.0.1'
self.base_url = 'https://angular.io/'
self.root_path = 'docs'
html_filters.push 'angular/clean_html', 'angular/entries'
options[:follow_links] = false
options[:only_patterns] = [/\Aguide/, /\Atutorial/, /\Aapi/]
options[:fix_urls_before_parse] = ->(url) do
url.sub! %r{\Aguide/}, '/guide/'
url.sub! %r{\Atutorial/}, '/tutorial/'
url.sub! %r{\Aapi/}, '/api/'
url.sub! %r{\Agenerated/}, '/generated/'
url
end
include Docs::Angular::Common
end
version '4' do
self.release = '4.4.6'
self.base_url = 'https://v4.angular.io/'
self.root_path = 'docs'
html_filters.push 'angular/clean_html', 'angular/entries'
options[:follow_links] = false
options[:only_patterns] = [/\Aguide/, /\Atutorial/, /\Aapi/]
options[:fix_urls_before_parse] = ->(url) do
url.sub! %r{\Aguide/}, '/guide/'
url.sub! %r{\Atutorial/}, '/tutorial/'
url.sub! %r{\Aapi/}, '/api/'
url.sub! %r{\Agenerated/}, '/generated/'
url
end
include Docs::Angular::Common
end
version '2' do version '2' do
self.release = '2.4.10' self.release = '2.4.10'
self.base_url = 'https://v2.angular.io/docs/ts/latest/' self.base_url = 'https://v2.angular.io/docs/ts/latest/'

Loading…
Cancel
Save