Update Perl documentation (5.32)

pull/1395/head
Phil Scherer 4 years ago
parent a525a79d97
commit 3af0bbe37b

@ -578,7 +578,7 @@ credits = [
'https://raw.githubusercontent.com/pydata/pandas/master/LICENSE' 'https://raw.githubusercontent.com/pydata/pandas/master/LICENSE'
], [ ], [
'Perl', 'Perl',
'1993-2016 Larry Wall and others', '1993-2020 Larry Wall and others',
'GPLv1', 'GPLv1',
'https://perldoc.perl.org/index-licence.html' 'https://perldoc.perl.org/index-licence.html'
], [ ], [

@ -1,5 +1,9 @@
._perl { ._perl {
@extend %simple; @extend %simple;
> h4 { @extend %block-label; } dt + dt { margin-top: 1em; }
> dl > dt { @extend %block-label; }
> dl > dt.function { @extend %label-blue; }
> dl > dt.variable { @extend %label-green; }
} }

@ -128,8 +128,6 @@ bsdtar --extract --to-stdout --file openjdk-8-doc_8u272-b10-1_all.deb data.tar.x
bsdtar --extract --xz --file - --strip-components=6 --directory=docs/openjdk\~8/ ./usr/share/doc/openjdk-8-jre-headless/api/ bsdtar --extract --xz --file - --strip-components=6 --directory=docs/openjdk\~8/ ./usr/share/doc/openjdk-8-jre-headless/api/
``` ```
## Perl
## PHP ## PHP
## Python ## Python

@ -2,49 +2,21 @@ module Docs
class Perl class Perl
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
root_page? ? root : other
doc
end
def root
doc.inner_html = '<h1>Perl 5 Documentation</h1>'
end
def other
@doc = at_css('#content_body')
css('noscript', '#recent_pages', '#from_search', '#page_index', '.mod_az_list').remove
css('h1, h2, h3, h4').each do |node| css('h1, h2, h3, h4').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end end
at_css('h2').name = 'h1' css('pre > code').each do |node|
node.parent['data-language'] = 'perl'
css('a[name] + h2', 'a[name] + h3', 'a[name] + h4', 'a[name] + h5').each do |node|
node['id'] = node.previous_element['name']
end
css('li > a[name]').each do |node|
node.parent['id'] = node['name']
end
css('pre').each do |node|
node.css('li').each do |li|
li.content = li.content + "\n"
end
node.content = node.content node.content = node.content
node.inner_html = node.inner_html.strip_heredoc
node['data-language'] = 'perl'
end end
if slug =~ /functions/ || slug == 'perlvar' css('dl > dt').each do |node|
css('ul > li[id]').each do |node| case slug
heading = node.at_css('b') when 'perlfunc'
heading.name = 'h2' node['class'] = 'function'
heading['id'] = node['id'] when 'perlvar'
node.parent.before(node.children) node['class'] = 'variable'
node.remove
end end
end end

@ -2,54 +2,101 @@ module Docs
class Perl class Perl
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
REPLACE_TYPES = { REPLACE_TYPES = {
'Platform specific' => 'Platform Specific', 'Platform-Specific' => 'Platform Specific',
'Internals and C language interface' => 'Internals', 'Internals and C Language Interface' => 'Internals',
'Tutorials' => 'Manual: Tutorials',
'Overview' => 'Manual: Overview'
}
# Individual pages within the Perl documentation are missing all context
# for anything even resembling a 'type'. So we're going to grab it
# elsewhere with a neat trick: dynamically generate a map from a few
# ~index~ pages at runtime which is then referenced on future pages.
# Prepopulate w/ edge cases
TYPES = {
'pod2man' => 'Utilities',
'pod2text' => 'Utilities',
'encguess' => 'Utilities',
'streamzip' => 'Utilities',
'pl2pm' => 'Utilities',
'perl' => 'Manual: Overview',
'perldoc' => 'Manual: Overview',
'perlintro' => 'Manual: Overview',
'perlop' => 'Operators', 'perlop' => 'Operators',
'perlvar' => 'Variables', 'perlvar' => 'Variables',
'Functions' => 'Functions' 'perlref' => 'Reference Manual',
'modules' => 'Standard Modules',
'perlutil' => 'Utilities',
'warnings' => 'Pragmas',
'strict' => 'Pragmas',
'Pod::Text::Overstrike' => 'Standard Modules',
'Test2::EventFacet::Hub' => 'Standard Modules'
} }
MANUAL_TYPES = %w(Overview Tutorials FAQs) def call
case slug
when 'perl'
css('h2').each do |heading|
heading.next_element.css('a').each do |node|
TYPES[node.content] = heading.content
end
end
def breadcrumbs when 'modules'
@breadcrumbs ||= at_css('#breadcrumbs').content.split('>').each { |s| s.strip! } node = at_css('#Pragmatic-Modules')
end node = node.next_element while node.name != 'ul'
node.css('li').each do |n|
TYPES[n.at_css('a').content] = 'Pragmas'
end
def include_default_entry? node = at_css('#Standard-Modules')
slug !~ /\Aindex/ node = node.next_element while node.name != 'ul'
node.css('li').each do |n|
TYPES[n.at_css('a').content] = 'Standard Modules'
end
when 'perlutil'
css('dl > dt').each do |node|
TYPES[node['id']] = "Utilities"
end
end
super
end end
def get_name def get_name
at_css('h1').content.strip slug
end end
def get_type def get_type
case breadcrumbs[1] case slug
when 'Language reference' when /perl.*faq/
REPLACE_TYPES[breadcrumbs[2]] || 'Language' 'Manual: FAQs'
when /\ACore modules/
'Core Modules'
else else
type = REPLACE_TYPES[breadcrumbs[1]] || breadcrumbs[1] if TYPES.key? name
type.prepend 'Manual: ' if MANUAL_TYPES.include?(type) REPLACE_TYPES[TYPES[name]] || TYPES[name]
type else
'Other'
end
end end
end end
def additional_entries def additional_entries
case slug case slug
when 'perlfunc'
css(':not(p) + dl > dt').each_with_object [] do |node, entries|
entries << [node.content, node['id'], 'Functions']
end
when 'perlop' when 'perlop'
css('h2').map do |node| css('h2').each_with_object [] do |node, entries|
name = node.content entries << [node.content, node['id'], 'Operators']
id = node.previous_element['name']
[name, id]
end end
when 'perlvar' when 'perlvar'
css('#content_body > ul > li > b').map do |node| css('> dl > dt').each_with_object [] do |node, entries|
name = node.content entries << [node.content, node['id'], 'Variables']
id = node.previous_element['name']
[name, id]
end end
else else
[] []

@ -0,0 +1,17 @@
module Docs
class Perl
class PreCleanHtmlFilter < Filter
def call
css('#links', '.leading-notice', '.permalink').remove
# Bug somewhere prevents these two ids from loading
if slug == 'perlvar'
at_css('#\$\"')['id'] = '$ls'
at_css('#\$\#')['id'] = '$hash'
end
doc
end
end
end
end

@ -1,46 +1,62 @@
module Docs module Docs
class Perl < FileScraper class Perl < UrlScraper
self.name = 'Perl' self.name = 'Perl'
self.type = 'perl' self.type = 'perl'
self.root_path = 'index.html' # self.root_path = 'index.html'
self.initial_paths = ['modules.html', 'perlutil.html', 'perl.html']
self.links = { self.links = {
home: 'https://www.perl.org/' home: 'https://www.perl.org/'
} }
html_filters.push 'perl/entries', 'perl/clean_html' html_filters.push 'perl/pre_clean_html', 'perl/entries', 'perl/clean_html', 'title'
options[:container] = '#perldocdiv'
options[:skip] = %w( options[:skip] = %w(
preferences.html perlbook perlcommunity perlexperiment perlartistic perlgpl perlhist
perlartistic.html perlcn perljp perlko perltw
perlgpl.html perlboot perlbot perlrepository perltodo perltooc perltoot )
perlhist.html
perltodo.html )
options[:skip_patterns] = [/\.pdf/, /delta\.html/] options[:skip_patterns] = [/\Afunctions/, /\Avariables/, /\.pdf/, /delta/]
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 1993&ndash;2016 Larry Wall and others<br> &copy; 1993&ndash;2020 Larry Wall and others<br>
Licensed under the GNU General Public License version 1 or later, or the Artistic License.<br> Licensed under the GNU General Public License version 1 or later, or the Artistic License.<br>
The Perl logo is a trademark of the Perl Foundation. The Perl logo is a trademark of the Perl Foundation.
HTML HTML
version '5.32' do
self.release = '5.32.0'
self.base_url = "https://perldoc.perl.org/#{self.release}/"
end
version '5.30' do
self.release = '5.30.3'
self.base_url = "https://perldoc.perl.org/#{self.release}/"
end
version '5.28' do
self.release = '5.28.3'
self.base_url = "https://perldoc.perl.org/#{self.release}/"
end
version '5.26' do version '5.26' do
self.release = '5.26.0' self.release = '5.26.3'
self.base_url = "https://perldoc.perl.org/#{self.release}/" self.base_url = "https://perldoc.perl.org/#{self.release}/"
end end
version '5.24' do version '5.24' do
self.release = '5.24.0' self.release = '5.24.4'
self.base_url = "https://perldoc.perl.org/#{self.release}/" self.base_url = "https://perldoc.perl.org/#{self.release}/"
end end
version '5.22' do version '5.22' do
self.release = '5.22.0' self.release = '5.22.4'
self.base_url = "https://perldoc.perl.org/#{self.release}/" self.base_url = "https://perldoc.perl.org/#{self.release}/"
end end
version '5.20' do version '5.20' do
self.release = '5.20.2' self.release = '5.20.3'
self.base_url = "https://perldoc.perl.org/#{self.release}/" self.base_url = "https://perldoc.perl.org/#{self.release}/"
end end

Loading…
Cancel
Save