[devdocsgjs/main: 1439/1867] Add Phpunit version 8 and 9
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 1439/1867] Add Phpunit version 8 and 9
- Date: Fri, 19 Nov 2021 23:48:03 +0000 (UTC)
commit ae21fad7d8651f9fd165bf65a0081c7178cf592b
Author: MasterEnoc <brianhernandez222 hotmail com>
Date: Thu Dec 31 14:00:26 2020 -0600
Add Phpunit version 8 and 9
lib/docs/filters/phpunit/clean_html.rb | 57 +++++---------------------
lib/docs/filters/phpunit/clean_html_old.rb | 64 ++++++++++++++++++++++++++++++
lib/docs/filters/phpunit/entries.rb | 4 +-
lib/docs/filters/phpunit/entries_old.rb | 25 ++++++++++++
lib/docs/scrapers/phpunit.rb | 52 ++++++++++++++++++++----
5 files changed, 146 insertions(+), 56 deletions(-)
---
diff --git a/lib/docs/filters/phpunit/clean_html.rb b/lib/docs/filters/phpunit/clean_html.rb
index 7363f219..e58f85b0 100644
--- a/lib/docs/filters/phpunit/clean_html.rb
+++ b/lib/docs/filters/phpunit/clean_html.rb
@@ -2,59 +2,20 @@ 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
+ css('pre').each do |node|
+ node['class'] = 'highlight'
+ node['data-language'] = 'php'
end
- css('pre', '.term').each do |node|
- node.content = node.content
+ if slug.match(/assertion|annotations|configuration/)
+ css('h2').each do |node|
+ node['id'] = node.content
+ end
end
- css('pre.programlisting').each do |node|
- node['data-language'] = 'php'
+ css('h1').each do |node|
+ node.content = node.content.gsub(/\d*\./, '').strip
end
doc
diff --git a/lib/docs/filters/phpunit/clean_html_old.rb b/lib/docs/filters/phpunit/clean_html_old.rb
new file mode 100644
index 00000000..a3facad8
--- /dev/null
+++ b/lib/docs/filters/phpunit/clean_html_old.rb
@@ -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
diff --git a/lib/docs/filters/phpunit/entries.rb b/lib/docs/filters/phpunit/entries.rb
index 545c55b8..fd426be6 100644
--- a/lib/docs/filters/phpunit/entries.rb
+++ b/lib/docs/filters/phpunit/entries.rb
@@ -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
diff --git a/lib/docs/filters/phpunit/entries_old.rb b/lib/docs/filters/phpunit/entries_old.rb
new file mode 100644
index 00000000..718db81b
--- /dev/null
+++ b/lib/docs/filters/phpunit/entries_old.rb
@@ -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
diff --git a/lib/docs/scrapers/phpunit.rb b/lib/docs/scrapers/phpunit.rb
index 5f2cbfea..7bd1c603 100644
--- a/lib/docs/scrapers/phpunit.rb
+++ b/lib/docs/scrapers/phpunit.rb
@@ -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(
- appendixes.index.html
- appendixes.bibliography.html
- appendixes.copyright.html)
-
options[:attribution] = <<-HTML
- © 2005–2017 Sebastian Bergmann<br>
+ © 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)
+
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]