styleguidist-scrapper

1.0.1 • Public • Published

styleguidist-scrapper

This is a scrapper script targeting documentation generated by react-styleguidist.

It's main purpose is to generate metadata of documented examples which can be used to generate visual snapshot tests using jest, jest-image-snapshot and puppeteer.

API

scrape(styleguideUrl: string): Promise<Array<ExampleMetadata>>

Types

ExampleMetadata

type ExampleMetadata = {
  // component name
  component: string,
  // directory where it is located
  dir: string,
  // URL with isolated example
  url: string,
  // title for the example
  // assumed to be paragraph above the example
  title: string,
  // CSS selector for the example
  // useful for targeting screenshots
  selector: string,
}

Usage

const fs = require('fs')
const scrape = require('styleguidist-scrapper')
 
scrape('http://localhost:6060').then(examples => {
  fs.writeFile('./examples-metadata.json', JSON.stringify(examples), 'utf8')
})

Package Sidebar

Install

npm i styleguidist-scrapper

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • yrobag
  • dgebara00
  • stanislaw-rakowski
  • ziggykraus
  • andarist
  • konradk
  • walaszczykm
  • klarzynskik
  • jawinski