Script to fetch a doc's icon from its website

Aperta
#2,780 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nodejs

Direzione di ricerca

Start with the PR template and the existing public/icons/docs/<slug>/ layout to see the three files the script must write (16.png, [email protected], SOURCE), then find where npm scripts and the Node tests and type check are configured. The work covers HTML icon-tag discovery, PNG and ICO parsing, and alpha-aware downscaling, so read the draft PR #2781 before writing anything. Done means the script works for the three example sites and the tests pass, but the maintainer has not yet confirmed the approach.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Feature request

Summary

A small script that fetches a doc's icon from the documented project's website and saves it the way DevDocs expects:

npm run icon -- <doc_slug> <website>

It writes public/icons/docs/<slug>/16.png, [email protected] and SOURCE, the three files the PR template asks for.

Today, each new doc's icon is found, resized to 16 and 32 pixels and saved by hand. The script does that step for contributors and keeps the SOURCE file accurate. It also helps when updating a doc whose icon has changed.

How it works:

  • It looks for the icon in the page's <link rel="icon"> and <link rel="apple-touch-icon"> tags, trying the smallest one that is at least 32 pixels first. If none works, it tries /apple-touch-icon.png and /favicon.ico.
  • It reads PNG files and ICO files, including ICO files that contain bitmaps rather than PNGs.
  • It scales the icon by averaging pixels with premultiplied alpha, so 16-pixel icons stay crisp and transparent edges don't darken.
  • It uses only Node's standard library, so there are no new dependencies. It sits beside the existing Node tests and type check.
  • SVG-only icons can't be converted without a dependency, so the script says so. --icon <image address> then uses a specific PNG or ICO instead.

Contributors should still check the result at 16 pixels, as they do today. The script only automates finding, resizing and recording the source.

I've prepared an implementation with tests in draft PR #2781. Would you be open to this? I'm happy to change the approach, for example to a thor task.

Examples

Tried on real sites:

  • npm run icon -- python https://www.python.org saves the icon from /static/apple-touch-icon-precomposed.png.
  • npm run icon -- github https://docs.github.com saves the icon from /assets/cb-345/images/site/favicon.png.
  • npm run icon -- vue https://vuejs.org explains that the site only offers logo.svg, and suggests --icon.
Lingua principale
Ruby
Stelle
39.6k
Fork
2.7k
Merge medio
21h 1m
PR unite (30g)
21

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di freeCodeCamp/devdocs

Tutte le issue di freeCodeCamp/devdocs

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.