Add playwright documentation
Unified · Split
| @@ -1,4 +1,8 @@ | |||
| 1 | [ | 1 | [ |
| 2 | [ | ||
| 3 | "2024-01-24", | ||
| 4 | "New documentation: <a href=\"/playwright/\">Playwright</a>" | ||
| 5 | ], | ||
| 2 | [ | 6 | [ |
| 3 | "2024-01-20", | 7 | "2024-01-20", |
| 4 | "New documentation: <a href=\"/htmx/\">htmx</a>" | 8 | "New documentation: <a href=\"/htmx/\">htmx</a>" |
| @@ -0,0 +1,29 @@ | |||
| 1 | module Docs | ||
| 2 | class Playwright | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | @doc = at_css('.markdown') | ||
| 6 | |||
| 7 | css('x-search').remove | ||
| 8 | css('hr').remove | ||
| 9 | css('font:contains("Added in")').remove | ||
| 10 | css('.list-anchor').remove | ||
| 11 | |||
| 12 | css('.alert').each do |node| | ||
| 13 | node.name = 'blockquote' | ||
| 14 | end | ||
| 15 | |||
| 16 | css('pre').each do |node| | ||
| 17 | node.content = node.css('.token-line').map(&:content).join("\n") | ||
| 18 | node.remove_attribute('style') | ||
| 19 | node['data-language'] = node.content =~ /\A\s*</ ? 'html' : 'javascript' | ||
| 20 | node.ancestors('.theme-code-block').first.replace(node) | ||
| 21 | end | ||
| 22 | |||
| 23 | css('*[class]').remove_attribute('class') | ||
| 24 | |||
| 25 | doc | ||
| 26 | end | ||
| 27 | end | ||
| 28 | end | ||
| 29 | end | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | module Docs | ||
| 2 | class Playwright | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | def get_name | ||
| 5 | at_css('h1').children.select(&:text?).map(&:content).join.strip | ||
| 6 | end | ||
| 7 | |||
| 8 | def type | ||
| 9 | type = at_css('.menu__link--active').content | ||
| 10 | return "#{type}: #{name}" if slug.starts_with?('api/') | ||
| 11 | type | ||
| 12 | end | ||
| 13 | |||
| 14 | def additional_entries | ||
| 15 | css('x-search').each_with_object [] do |node, entries| | ||
| 16 | prev = node.previous_element | ||
| 17 | prev = prev.previous_element until prev['id'] | ||
| 18 | entries << [node.text, prev['id']] | ||
| 19 | end | ||
| 20 | end | ||
| 21 | end | ||
| 22 | end | ||
| 23 | end | ||
| @@ -0,0 +1,27 @@ | |||
| 1 | module Docs | ||
| 2 | class Playwright < UrlScraper | ||
| 3 | self.name = 'Playwright' | ||
| 4 | self.type = 'simple' | ||
| 5 | self.release = '1.41.1' | ||
| 6 | self.base_url = 'https://playwright.dev/docs/' | ||
| 7 | self.root_path = 'intro' | ||
| 8 | self.links = { | ||
| 9 | home: 'https://playwright.dev/', | ||
| 10 | code: 'https://github.com/microsoft/playwright' | ||
| 11 | } | ||
| 12 | |||
| 13 | # Docusaurus like react_native | ||
| 14 | html_filters.push 'playwright/entries', 'playwright/clean_html' | ||
| 15 | options[:download_images] = false | ||
| 16 | |||
| 17 | # https://github.com/microsoft/playwright/blob/main/LICENSE | ||
| 18 | options[:attribution] = <<-HTML | ||
| 19 | © 2024 Microsoft<br> | ||
| 20 | Licensed under the Apache License, Version 2.0. | ||
| 21 | HTML | ||
| 22 | |||
| 23 | def get_latest_version(opts) | ||
| 24 | get_npm_version('@playwright/test', opts) | ||
| 25 | end | ||
| 26 | end | ||
| 27 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://playwright.dev/img/playwright-logo.svg | ||