From 8d27cd6c2931aa14ff10154b6d517df797368504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denilson=20S=C3=A1=20Maia?= Date: Fri, 17 Oct 2025 21:42:09 +0200 Subject: [PATCH 1/3] New docs: Lit As requested in: * https://trello.com/c/PVnfdeaN#comment-665fffaa2798a59513617915 * https://trello.com/c/PVnfdeaN#comment-60a7c84181482c8dce7d0f55 In a period of one year, it went from 17k to 20k stars on GitHub. This is my first time contributing to devdocs, it took me an entire day to learn how to write a new scraper and new filters for this documentation, including the time spent fine-tuning the result. --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_lit.scss | 52 +++++++++++++++++ lib/docs/filters/lit/clean_html.rb | 71 +++++++++++++++++++++++ lib/docs/filters/lit/entries.rb | 72 ++++++++++++++++++++++++ lib/docs/scrapers/lit.rb | 55 ++++++++++++++++++ public/icons/docs/lit/16.png | Bin 0 -> 399 bytes public/icons/docs/lit/16@2x.png | Bin 0 -> 538 bytes public/icons/docs/lit/SOURCE | 3 + 8 files changed, 254 insertions(+) create mode 100644 assets/stylesheets/pages/_lit.scss create mode 100644 lib/docs/filters/lit/clean_html.rb create mode 100644 lib/docs/filters/lit/entries.rb create mode 100644 lib/docs/scrapers/lit.rb create mode 100644 public/icons/docs/lit/16.png create mode 100644 public/icons/docs/lit/16@2x.png create mode 100644 public/icons/docs/lit/SOURCE diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index b45e7b602e..12247d4405 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -82,6 +82,7 @@ 'pages/kubernetes', 'pages/laravel', 'pages/liquid', + 'pages/lit', 'pages/love', 'pages/lua', 'pages/gnu_make', diff --git a/assets/stylesheets/pages/_lit.scss b/assets/stylesheets/pages/_lit.scss new file mode 100644 index 0000000000..c12f99c073 --- /dev/null +++ b/assets/stylesheets/pages/_lit.scss @@ -0,0 +1,52 @@ +._lit { + @extend %simple; + + h4 { @extend %block-label, %label-blue; } + + .propertyDetails { + padding-left:1.5em + } + .heading.property { + margin-top:2em + } + .heading.property > h4 { + font-weight:400 + } + .newKeyword, + .readonlyKeyword, + .staticKeyword { + font-style:italic + } + .functionName, + .propertyName { + font-weight:700 + } + aside.litdev-aside { + display: flex; + border-style: solid; + border-width: 1px; + padding: 1em 1em 1em 0em; + margin: 1em 0; + svg { + width: 1.5em; + margin-inline: 1em; + } + } + litdev-switchable-sample { + pre[data-language] { + position: relative; + } + pre[data-language]::before { + position: absolute; + top: 0; + right: 16px; + opacity: 0.5; + } + pre[data-language="js"]::before { + content: "JavaScript"; + } + pre[data-language="ts"]::before { + content: "TypeScript"; + } + } +} diff --git a/lib/docs/filters/lit/clean_html.rb b/lib/docs/filters/lit/clean_html.rb new file mode 100644 index 0000000000..da7eb03c2c --- /dev/null +++ b/lib/docs/filters/lit/clean_html.rb @@ -0,0 +1,71 @@ +module Docs + class Lit + class CleanHtmlFilter < Filter + def call + + css('.offscreen, #inlineToc, a.anchor, [aria-hidden="true"], #prevAndNextLinks').remove + + css('[tabindex]').remove_attribute('tabindex') + + # Removing the side navigation. + css('#docsNavWrapper, #rhsTocWrapper').remove + + # Removing this extra div. + div = at_css('#articleWrapper') + article = div.at_css('article') + article.remove_attribute('id') + div.replace(article) + + # Expanding and replacing the