History

Merge pull request #1455 from MasterEnoc/phpunit

Add Phpunit version 8 and 9

Simon Legner committed 5 years ago

Commit 6fe102e2 parents 08e3646 ae21fad5 files · +146 −56Browse files

Unified · Split

5 files
  1. lib/docs/filters/phpunit/clean_html.rb +9 −48
  2. lib/docs/filters/phpunit/clean_html_old.rb +64 −0
  3. lib/docs/filters/phpunit/entries.rb +3 −1
  4. lib/docs/filters/phpunit/entries_old.rb +25 −0
  5. lib/docs/scrapers/phpunit.rb +45 −7
lib/docs/filters/phpunit/clean_html.rb+9−48
@@ -2,59 +2,20 @@ module Docs · 1 unmodified line
2 class Phpunit2 class Phpunit
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 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|6 css('pre').each do |node|
41 node.remove if node.content == 'Note'7 node['class'] = 'highlight'
42 end8 node['data-language'] = 'php'
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 end9 end
51 10
52 css('pre', '.term').each do |node|11 if slug.match(/assertion|annotations|configuration/)
53 node.content = node.content12 css('h2').each do |node|
13 node['id'] = node.content
14 end
54 end15 end
55 16
56 css('pre.programlisting').each do |node|17 css('h1').each do |node|
57 node['data-language'] = 'php'18 node.content = node.content.gsub(/\d*\./, '').strip
58 end19 end
59 20
60 doc21 doc
lib/docs/filters/phpunit/clean_html_old.rb+64−0
@@ -0,0 +1,64 @@
1module 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
64end
lib/docs/filters/phpunit/entries.rb+3−1
@@ -1,12 +1,13 @@
1module Docs1module Docs
2 class Phpunit2 class Phpunit
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
4 def get_name5 def get_name
5 at_css('h1').content6 at_css('h1').content
6 end7 end
7 8
8 def get_type9 def get_type
9 if name.in?(%w(Assertions Annotations))10 if name.in? ['Assertions', 'Annotations', 'The XML Configuration File']
10 name11 name
11 else12 else
12 'Guides'13 'Guides'
@@ -20,6 +21,7 @@ module Docs · 7 unmodified lines
20 [node.content, node['id']]21 [node.content, node['id']]
21 end22 end
22 end23 end
24
23 end25 end
24 end26 end
25end27end
lib/docs/filters/phpunit/entries_old.rb+25−0
@@ -0,0 +1,25 @@
1module 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
25end
lib/docs/scrapers/phpunit.rb+45−7
@@ -8,34 +8,71 @@ module Docs · 7 unmodified lines
8 code: 'https://github.com/sebastianbergmann/phpunit'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 options[:root_title] = 'PHPUnit'16 options[:root_title] = 'PHPUnit'
14 options[:title] = false17 options[:title] = false
15 18
16 options[:skip] = %w(
17 appendixes.index.html
18 appendixes.bibliography.html
19 appendixes.copyright.html)
20
21 options[:attribution] = <<-HTML19 options[:attribution] = <<-HTML
22 &copy; 2005&ndash;2017 Sebastian Bergmann<br>20 &copy; 2005&ndash;2020 Sebastian Bergmann<br>
23 Licensed under the Creative Commons Attribution 3.0 Unported License.21 Licensed under the Creative Commons Attribution 3.0 Unported License.
24 HTML22 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 version '6' do51 version '6' do
27 self.release = '6.5'52 self.release = '6.5'
28 self.base_url = "https://phpunit.de/manual/#{release}/en/"53 self.base_url = "https://phpunit.de/manual/#{release}/en/"
54
55 html_filters.push OLDFILTERS
56
57 options[:skip] = OLDSKIP
29 end58 end
30 59
31 version '5' do60 version '5' do
32 self.release = '5.7'61 self.release = '5.7'
33 self.base_url = "https://phpunit.de/manual/#{release}/en/"62 self.base_url = "https://phpunit.de/manual/#{release}/en/"
63
64 html_filters.push OLDFILTERS
65
66 options[:skip] = OLDSKIP
34 end67 end
35 68
36 version '4' do69 version '4' do
37 self.release = '4.8'70 self.release = '4.8'
38 self.base_url = "https://phpunit.de/manual/#{release}/en/"71 self.base_url = "https://phpunit.de/manual/#{release}/en/"
72
73 options[:skip] = OLDSKIP
74
75 html_filters.push OLDFILTERS
39 end76 end
40 77
41 def get_latest_version(opts)78 def get_latest_version(opts)
@@ -43,5 +80,6 @@ module Docs · 1 unmodified line
43 label = doc.at_css('.rst-current-version').content.strip80 label = doc.at_css('.rst-current-version').content.strip
44 label.scan(/v: ([0-9.]+)/)[0][0]81 label.scan(/v: ([0-9.]+)/)[0][0]
45 end82 end
83
46 end84 end
47end85end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t