mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add Phpunit version 8 and 9
This commit is contained in:
parent
1d1cc790a0
commit
ae21fad7d8
5 changed files with 149 additions and 59 deletions
|
@ -2,61 +2,22 @@ module Docs
|
|||
class Phpunit
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
doc.inner_html = ' '
|
||||
end
|
||||
|
||||
def other
|
||||
@doc = doc.at_css('div.appendix, div.chapter')
|
||||
|
||||
css('.example-break', '.table-break').remove
|
||||
|
||||
css('a[id]').each do |node|
|
||||
next unless node.content.blank?
|
||||
node.parent['id'] = node['id']
|
||||
node.remove
|
||||
end
|
||||
|
||||
css('.titlepage').each do |node|
|
||||
title = node.at_css('h1, .title')
|
||||
title.content = title.content.remove(/(Chapter|Appendix)\s+\w+\.\s+/)
|
||||
node.before(title).remove
|
||||
end
|
||||
|
||||
css('.section').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('[style], [border], [valign]').each do |node|
|
||||
node.remove_attribute('style')
|
||||
node.remove_attribute('border')
|
||||
node.remove_attribute('valign')
|
||||
end
|
||||
|
||||
css('.warning h3', '.alert h3').each do |node|
|
||||
node.remove if node.content == 'Note'
|
||||
end
|
||||
|
||||
css('p > code.literal:first-child:last-child').each do |node|
|
||||
next if node.previous_sibling && node.previous_sibling.content.present?
|
||||
next if node.next_sibling && node.next_sibling.content.present?
|
||||
node.parent.name = 'pre'
|
||||
node.parent['class'] = 'programlisting'
|
||||
node.parent.content = node.content
|
||||
end
|
||||
|
||||
css('pre', '.term').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
css('pre.programlisting').each do |node|
|
||||
css('pre').each do |node|
|
||||
node['class'] = 'highlight'
|
||||
node['data-language'] = 'php'
|
||||
end
|
||||
|
||||
if slug.match(/assertion|annotations|configuration/)
|
||||
css('h2').each do |node|
|
||||
node['id'] = node.content
|
||||
end
|
||||
end
|
||||
|
||||
css('h1').each do |node|
|
||||
node.content = node.content.gsub(/\d*\./, '').strip
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
|
|
64
lib/docs/filters/phpunit/clean_html_old.rb
Normal file
64
lib/docs/filters/phpunit/clean_html_old.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
module Docs
|
||||
class Phpunit
|
||||
class CleanHtmlOldFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
doc.inner_html = ' '
|
||||
end
|
||||
|
||||
def other
|
||||
@doc = doc.at_css('div.appendix, div.chapter')
|
||||
|
||||
css('.example-break', '.table-break').remove
|
||||
|
||||
css('a[id]').each do |node|
|
||||
next unless node.content.blank?
|
||||
node.parent['id'] = node['id']
|
||||
node.remove
|
||||
end
|
||||
|
||||
css('.titlepage').each do |node|
|
||||
title = node.at_css('h1, .title')
|
||||
title.content = title.content.remove(/(Chapter|Appendix)\s+\w+\.\s+/)
|
||||
node.before(title).remove
|
||||
end
|
||||
|
||||
css('.section').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('[style], [border], [valign]').each do |node|
|
||||
node.remove_attribute('style')
|
||||
node.remove_attribute('border')
|
||||
node.remove_attribute('valign')
|
||||
end
|
||||
|
||||
css('.warning h3', '.alert h3').each do |node|
|
||||
node.remove if node.content == 'Note'
|
||||
end
|
||||
|
||||
css('p > code.literal:first-child:last-child').each do |node|
|
||||
next if node.previous_sibling && node.previous_sibling.content.present?
|
||||
next if node.next_sibling && node.next_sibling.content.present?
|
||||
node.parent.name = 'pre'
|
||||
node.parent['class'] = 'programlisting'
|
||||
node.parent.content = node.content
|
||||
end
|
||||
|
||||
css('pre', '.term').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
css('pre.programlisting').each do |node|
|
||||
node['data-language'] = 'php'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +1,13 @@
|
|||
module Docs
|
||||
class Phpunit
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
def get_name
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def get_type
|
||||
if name.in?(%w(Assertions Annotations))
|
||||
if name.in? ['Assertions', 'Annotations', 'The XML Configuration File']
|
||||
name
|
||||
else
|
||||
'Guides'
|
||||
|
@ -20,6 +21,7 @@ module Docs
|
|||
[node.content, node['id']]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
25
lib/docs/filters/phpunit/entries_old.rb
Normal file
25
lib/docs/filters/phpunit/entries_old.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Docs
|
||||
class Phpunit
|
||||
class EntriesOldFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def get_type
|
||||
if name.in?(%w(Assertions Annotations))
|
||||
name
|
||||
else
|
||||
'Guides'
|
||||
end
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] if type == 'Guides'
|
||||
|
||||
css('h2').map do |node|
|
||||
[node.content, node['id']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,34 +8,71 @@ module Docs
|
|||
code: 'https://github.com/sebastianbergmann/phpunit'
|
||||
}
|
||||
|
||||
html_filters.push 'phpunit/clean_html', 'phpunit/entries', 'title'
|
||||
options[:skip] = [
|
||||
'bibliography.html',
|
||||
'copyright.html'
|
||||
]
|
||||
|
||||
options[:root_title] = 'PHPUnit'
|
||||
options[:title] = false
|
||||
|
||||
options[:skip] = %w(
|
||||
options[:attribution] = <<-HTML
|
||||
© 2005–2020 Sebastian Bergmann<br>
|
||||
Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||
HTML
|
||||
|
||||
FILTERS = %w(phpunit/clean_html phpunit/entries title)
|
||||
|
||||
version '9' do
|
||||
self.release = '9.5'
|
||||
self.base_url = "https://phpunit.readthedocs.io/en/#{release}/"
|
||||
|
||||
html_filters.push FILTERS
|
||||
|
||||
options[:container] = '.document'
|
||||
end
|
||||
|
||||
version '8' do
|
||||
self.release = '8.5'
|
||||
self.base_url = "https://phpunit.readthedocs.io/en/#{release}/"
|
||||
|
||||
html_filters.push FILTERS
|
||||
|
||||
options[:container] = '.document'
|
||||
end
|
||||
|
||||
OLDFILTERS = %w(phpunit/clean_html_old phpunit/entries_old title)
|
||||
|
||||
OLDSKIP = %w(
|
||||
appendixes.index.html
|
||||
appendixes.bibliography.html
|
||||
appendixes.copyright.html)
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2005–2017 Sebastian Bergmann<br>
|
||||
Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||
HTML
|
||||
|
||||
version '6' do
|
||||
self.release = '6.5'
|
||||
self.base_url = "https://phpunit.de/manual/#{release}/en/"
|
||||
|
||||
html_filters.push OLDFILTERS
|
||||
|
||||
options[:skip] = OLDSKIP
|
||||
end
|
||||
|
||||
version '5' do
|
||||
self.release = '5.7'
|
||||
self.base_url = "https://phpunit.de/manual/#{release}/en/"
|
||||
|
||||
html_filters.push OLDFILTERS
|
||||
|
||||
options[:skip] = OLDSKIP
|
||||
end
|
||||
|
||||
version '4' do
|
||||
self.release = '4.8'
|
||||
self.base_url = "https://phpunit.de/manual/#{release}/en/"
|
||||
|
||||
options[:skip] = OLDSKIP
|
||||
|
||||
html_filters.push OLDFILTERS
|
||||
end
|
||||
|
||||
def get_latest_version(opts)
|
||||
|
@ -43,5 +80,6 @@ module Docs
|
|||
label = doc.at_css('.rst-current-version').content.strip
|
||||
label.scan(/v: ([0-9.]+)/)[0][0]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue