mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #2142 from freeCodeCamp/playwright
Add playwright documentation
This commit is contained in:
commit
02c4871c43
7 changed files with 84 additions and 0 deletions
|
@ -1,4 +1,8 @@
|
|||
[
|
||||
[
|
||||
"2024-01-24",
|
||||
"New documentation: <a href=\"/playwright/\">Playwright</a>"
|
||||
],
|
||||
[
|
||||
"2024-01-20",
|
||||
"New documentation: <a href=\"/htmx/\">htmx</a>"
|
||||
|
|
29
lib/docs/filters/playwright/clean_html.rb
Normal file
29
lib/docs/filters/playwright/clean_html.rb
Normal file
|
@ -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
lib/docs/filters/playwright/entries.rb
Normal file
23
lib/docs/filters/playwright/entries.rb
Normal file
|
@ -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
lib/docs/scrapers/playwright.rb
Normal file
27
lib/docs/scrapers/playwright.rb
Normal file
|
@ -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
|
||||
© 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
|
BIN
public/icons/docs/playwright/16.png
Normal file
BIN
public/icons/docs/playwright/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 534 B |
BIN
public/icons/docs/playwright/16@2x.png
Normal file
BIN
public/icons/docs/playwright/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
1
public/icons/docs/playwright/SOURCE
Normal file
1
public/icons/docs/playwright/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://playwright.dev/img/playwright-logo.svg
|
Loading…
Reference in a new issue