Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add playwright documentation #2142

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/javascripts/news.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[
[
"2024-01-24",
"New documentation: <a href=\"/playwright/\">Playwright</a>"
],
[
"2024-01-20",
"New documentation: <a href=\"/htmx/\">htmx</a>"
Expand Down
4 changes: 2 additions & 2 deletions docs/file-scrapers.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ download it, extract it with `dpkg -x $PACKAGE ./` and move `./usr/share/doc/ope
to `path/to/devdocs/docs/openjdk~$VERSION`

```sh
curl -O http://ftp.at.debian.org/debian/pool/main/o/openjdk-21/openjdk-21-doc_21.0.1+12-3_all.deb
tar xf openjdk-21-doc_21.0.1+12-3_all.deb
curl -O http://ftp.at.debian.org/debian/pool/main/o/openjdk-21/openjdk-21-doc_21.0.2+13-2_all.deb
tar xf openjdk-21-doc_21.0.2+13-2_all.deb
tar xf data.tar.xz
mv ./usr/share/doc/openjdk-21-jre-headless/api/ docs/openjdk~$VERSION
```
Expand Down
1 change: 1 addition & 0 deletions lib/docs/filters/openjdk/clean_html_new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def call
end

css('.header .sub-title', 'hr', '.table-tabs').remove
css('.copy').remove

# fix ul section that contains summaries or tables
css('ul').each do |node|
Expand Down
29 changes: 29 additions & 0 deletions lib/docs/filters/playwright/clean_html.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Docs
class Playwright
class CleanHtmlFilter < Filter
def call
@doc = at_css('.markdown')

css('x-search').remove
css('hr').remove
css('font:contains("Added in")').remove
css('.list-anchor').remove

css('.alert').each do |node|
node.name = 'blockquote'
end

css('pre').each do |node|
node.content = node.css('.token-line').map(&:content).join("\n")
node.remove_attribute('style')
node['data-language'] = node.content =~ /\A\s*</ ? 'html' : 'javascript'
node.ancestors('.theme-code-block').first.replace(node)
end

css('*[class]').remove_attribute('class')

doc
end
end
end
end
23 changes: 23 additions & 0 deletions lib/docs/filters/playwright/entries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Docs
class Playwright
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('h1').children.select(&:text?).map(&:content).join.strip
end

def type
type = at_css('.menu__link--active').content
return "#{type}: #{name}" if slug.starts_with?('api/')
type
end

def additional_entries
css('x-search').each_with_object [] do |node, entries|
prev = node.previous_element
prev = prev.previous_element until prev['id']
entries << [node.text, prev['id']]
end
end
end
end
end
27 changes: 27 additions & 0 deletions lib/docs/scrapers/playwright.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Docs
class Playwright < UrlScraper
self.name = 'Playwright'
self.type = 'simple'
self.release = '1.41.1'
self.base_url = 'https://playwright.dev/docs/'
self.root_path = 'intro'
self.links = {
home: 'https://playwright.dev/',
code: 'https://github.com/microsoft/playwright'
}

# Docusaurus like react_native
html_filters.push 'playwright/entries', 'playwright/clean_html'
options[:download_images] = false

# https://github.com/microsoft/playwright/blob/main/LICENSE
options[:attribution] = <<-HTML
&copy; 2024 Microsoft<br>
Licensed under the Apache License, Version 2.0.
HTML

def get_latest_version(opts)
get_npm_version('@playwright/test', opts)
end
end
end
Binary file added public/icons/docs/playwright/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/playwright/16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/docs/playwright/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://playwright.dev/img/playwright-logo.svg