Add Phpunit version 8 and 9
Unified · Split
| @@ -2,59 +2,20 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Phpunit |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − root_page? ? root : other | |
| 6 | − doc | |
| 7 | − end | |
| 8 | − | |
| 9 | − def root | |
| 10 | − doc.inner_html = ' ' | |
| 11 | − end | |
| 12 | − | |
| 13 | − def other | |
| 14 | − @doc = doc.at_css('div.appendix, div.chapter') | |
| 15 | − | |
| 16 | − css('.example-break', '.table-break').remove | |
| 17 | − | |
| 18 | − css('a[id]').each do |node| | |
| 19 | − next unless node.content.blank? | |
| 20 | − node.parent['id'] = node['id'] | |
| 21 | − node.remove | |
| 22 | − end | |
| 23 | − | |
| 24 | − css('.titlepage').each do |node| | |
| 25 | − title = node.at_css('h1, .title') | |
| 26 | − title.content = title.content.remove(/(Chapter|Appendix)\s+\w+\.\s+/) | |
| 27 | − node.before(title).remove | |
| 28 | − end | |
| 29 | − | |
| 30 | − css('.section').each do |node| | |
| 31 | − node.before(node.children).remove | |
| 32 | − end | |
| 33 | − | |
| 34 | − css('[style], [border], [valign]').each do |node| | |
| 35 | − node.remove_attribute('style') | |
| 36 | − node.remove_attribute('border') | |
| 37 | − node.remove_attribute('valign') | |
| 38 | − end | |
| 39 | 5 | |
| 40 | − css('.warning h3', '.alert h3').each do |node| | |
| 41 | − node.remove if node.content == 'Note' | |
| 42 | − end | |
| 43 | − | |
| 44 | − css('p > code.literal:first-child:last-child').each do |node| | |
| 45 | − next if node.previous_sibling && node.previous_sibling.content.present? | |
| 46 | − next if node.next_sibling && node.next_sibling.content.present? | |
| 47 | − node.parent.name = 'pre' | |
| 48 | − node.parent['class'] = 'programlisting' | |
| 49 | − node.parent.content = node.content | |
| 6 | + css('pre').each do |node| | |
| 7 | + node['class'] = 'highlight' | |
| 8 | + node['data-language'] = 'php' | |
| 50 | 9 | end |
| 51 | 10 | |
| 52 | − css('pre', '.term').each do |node| | |
| 53 | − node.content = node.content | |
| 11 | + if slug.match(/assertion|annotations|configuration/) | |
| 12 | + css('h2').each do |node| | |
| 13 | + node['id'] = node.content | |
| 14 | + end | |
| 54 | 15 | end |
| 55 | 16 | |
| 56 | − css('pre.programlisting').each do |node| | |
| 57 | − node['data-language'] = 'php' | |
| 17 | + css('h1').each do |node| | |
| 18 | + node.content = node.content.gsub(/\d*\./, '').strip | |
| 58 | 19 | end |
| 59 | 20 | |
| 60 | 21 | doc |
| @@ -0,0 +1,64 @@ | ||
| 1 | +module Docs | |
| 2 | + class Phpunit | |
| 3 | + class CleanHtmlOldFilter < Filter | |
| 4 | + def call | |
| 5 | + root_page? ? root : other | |
| 6 | + doc | |
| 7 | + end | |
| 8 | + | |
| 9 | + def root | |
| 10 | + doc.inner_html = ' ' | |
| 11 | + end | |
| 12 | + | |
| 13 | + def other | |
| 14 | + @doc = doc.at_css('div.appendix, div.chapter') | |
| 15 | + | |
| 16 | + css('.example-break', '.table-break').remove | |
| 17 | + | |
| 18 | + css('a[id]').each do |node| | |
| 19 | + next unless node.content.blank? | |
| 20 | + node.parent['id'] = node['id'] | |
| 21 | + node.remove | |
| 22 | + end | |
| 23 | + | |
| 24 | + css('.titlepage').each do |node| | |
| 25 | + title = node.at_css('h1, .title') | |
| 26 | + title.content = title.content.remove(/(Chapter|Appendix)\s+\w+\.\s+/) | |
| 27 | + node.before(title).remove | |
| 28 | + end | |
| 29 | + | |
| 30 | + css('.section').each do |node| | |
| 31 | + node.before(node.children).remove | |
| 32 | + end | |
| 33 | + | |
| 34 | + css('[style], [border], [valign]').each do |node| | |
| 35 | + node.remove_attribute('style') | |
| 36 | + node.remove_attribute('border') | |
| 37 | + node.remove_attribute('valign') | |
| 38 | + end | |
| 39 | + | |
| 40 | + css('.warning h3', '.alert h3').each do |node| | |
| 41 | + node.remove if node.content == 'Note' | |
| 42 | + end | |
| 43 | + | |
| 44 | + css('p > code.literal:first-child:last-child').each do |node| | |
| 45 | + next if node.previous_sibling && node.previous_sibling.content.present? | |
| 46 | + next if node.next_sibling && node.next_sibling.content.present? | |
| 47 | + node.parent.name = 'pre' | |
| 48 | + node.parent['class'] = 'programlisting' | |
| 49 | + node.parent.content = node.content | |
| 50 | + end | |
| 51 | + | |
| 52 | + css('pre', '.term').each do |node| | |
| 53 | + node.content = node.content | |
| 54 | + end | |
| 55 | + | |
| 56 | + css('pre.programlisting').each do |node| | |
| 57 | + node['data-language'] = 'php' | |
| 58 | + end | |
| 59 | + | |
| 60 | + doc | |
| 61 | + end | |
| 62 | + end | |
| 63 | + end | |
| 64 | +end | |
| @@ -1,12 +1,13 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Phpunit |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | + | |
| 4 | 5 | def get_name |
| 5 | 6 | at_css('h1').content |
| 6 | 7 | end |
| 7 | 8 | |
| 8 | 9 | def get_type |
| 9 | − if name.in?(%w(Assertions Annotations)) | |
| 10 | + if name.in? ['Assertions', 'Annotations', 'The XML Configuration File'] | |
| 10 | 11 | name |
| 11 | 12 | else |
| 12 | 13 | 'Guides' |
| @@ -20,6 +21,7 @@ module Docs · 7 unmodified lines | ||
| 20 | 21 | [node.content, node['id']] |
| 21 | 22 | end |
| 22 | 23 | end |
| 24 | + | |
| 23 | 25 | end |
| 24 | 26 | end |
| 25 | 27 | end |
| @@ -0,0 +1,25 @@ | ||
| 1 | +module Docs | |
| 2 | + class Phpunit | |
| 3 | + class EntriesOldFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + at_css('h1').content | |
| 6 | + end | |
| 7 | + | |
| 8 | + def get_type | |
| 9 | + if name.in?(%w(Assertions Annotations)) | |
| 10 | + name | |
| 11 | + else | |
| 12 | + 'Guides' | |
| 13 | + end | |
| 14 | + end | |
| 15 | + | |
| 16 | + def additional_entries | |
| 17 | + return [] if type == 'Guides' | |
| 18 | + | |
| 19 | + css('h2').map do |node| | |
| 20 | + [node.content, node['id']] | |
| 21 | + end | |
| 22 | + end | |
| 23 | + end | |
| 24 | + end | |
| 25 | +end | |
| @@ -8,34 +8,71 @@ module Docs · 7 unmodified lines | ||
| 8 | 8 | code: 'https://github.com/sebastianbergmann/phpunit' |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | − html_filters.push 'phpunit/clean_html', 'phpunit/entries', 'title' | |
| 11 | + options[:skip] = [ | |
| 12 | + 'bibliography.html', | |
| 13 | + 'copyright.html' | |
| 14 | + ] | |
| 12 | 15 | |
| 13 | 16 | options[:root_title] = 'PHPUnit' |
| 14 | 17 | options[:title] = false |
| 15 | 18 | |
| 16 | − options[:skip] = %w( | |
| 17 | − appendixes.index.html | |
| 18 | − appendixes.bibliography.html | |
| 19 | − appendixes.copyright.html) | |
| 20 | − | |
| 21 | 19 | options[:attribution] = <<-HTML |
| 22 | − © 2005–2017 Sebastian Bergmann<br> | |
| 20 | + © 2005–2020 Sebastian Bergmann<br> | |
| 23 | 21 | Licensed under the Creative Commons Attribution 3.0 Unported License. |
| 24 | 22 | HTML |
| 25 | 23 | |
| 24 | + FILTERS = %w(phpunit/clean_html phpunit/entries title) | |
| 25 | + | |
| 26 | + version '9' do | |
| 27 | + self.release = '9.5' | |
| 28 | + self.base_url = "https://phpunit.readthedocs.io/en/#{release}/" | |
| 29 | + | |
| 30 | + html_filters.push FILTERS | |
| 31 | + | |
| 32 | + options[:container] = '.document' | |
| 33 | + end | |
| 34 | + | |
| 35 | + version '8' do | |
| 36 | + self.release = '8.5' | |
| 37 | + self.base_url = "https://phpunit.readthedocs.io/en/#{release}/" | |
| 38 | + | |
| 39 | + html_filters.push FILTERS | |
| 40 | + | |
| 41 | + options[:container] = '.document' | |
| 42 | + end | |
| 43 | + | |
| 44 | + OLDFILTERS = %w(phpunit/clean_html_old phpunit/entries_old title) | |
| 45 | + | |
| 46 | + OLDSKIP = %w( | |
| 47 | + appendixes.index.html | |
| 48 | + appendixes.bibliography.html | |
| 49 | + appendixes.copyright.html) | |
| 50 | + | |
| 26 | 51 | version '6' do |
| 27 | 52 | self.release = '6.5' |
| 28 | 53 | self.base_url = "https://phpunit.de/manual/#{release}/en/" |
| 54 | + | |
| 55 | + html_filters.push OLDFILTERS | |
| 56 | + | |
| 57 | + options[:skip] = OLDSKIP | |
| 29 | 58 | end |
| 30 | 59 | |
| 31 | 60 | version '5' do |
| 32 | 61 | self.release = '5.7' |
| 33 | 62 | self.base_url = "https://phpunit.de/manual/#{release}/en/" |
| 63 | + | |
| 64 | + html_filters.push OLDFILTERS | |
| 65 | + | |
| 66 | + options[:skip] = OLDSKIP | |
| 34 | 67 | end |
| 35 | 68 | |
| 36 | 69 | version '4' do |
| 37 | 70 | self.release = '4.8' |
| 38 | 71 | self.base_url = "https://phpunit.de/manual/#{release}/en/" |
| 72 | + | |
| 73 | + options[:skip] = OLDSKIP | |
| 74 | + | |
| 75 | + html_filters.push OLDFILTERS | |
| 39 | 76 | end |
| 40 | 77 | |
| 41 | 78 | def get_latest_version(opts) |
| @@ -43,5 +80,6 @@ module Docs · 1 unmodified line | ||
| 43 | 80 | label = doc.at_css('.rst-current-version').content.strip |
| 44 | 81 | label.scan(/v: ([0-9.]+)/)[0][0] |
| 45 | 82 | end |
| 83 | + | |
| 46 | 84 | end |
| 47 | 85 | end |