# P5 Analysis [![npm version](https://badge.fury.io/js/p5-analysis.svg)](https://www.npmjs.com/package/p5-analysis) - [Installation](#installation) - [Command-Line Usage](#command-line-usage) - [API](#api) - [Implementation Notes](#implementation-notes) - [Sketch detection](#sketch-detection) - [Sketch descriptions](#sketch-descriptions) - [Automatic library inclusion](#automatic-library-inclusion) - [Associated files](#associated-files) - [Limitations](#limitations) - [License](#license) This library provides a programmatic API for finding, analyzing, and generating [P5.js sketches](https://p5js.org). It was created for the [p5-server](https://github.com/osteele/p5-server#p5js-server) command-line tool, and the [P5 Server Visual Studio Code extension](https://github.com/osteele/vscode-p5server#readme). The API consists of three classes: - {@link Sketch} represents an sketch. This is at least a script file, and may also include an HTML file and additional scripts an assets. It is the interface to generate sketch files, find associated files, infer libraries, and scan directories for sketches that they contain. - {@link Script} represents a JavaScript file. It provides script analysis features that are used to detect whether a script is a p5.js sketch, and to perform automatic library inclusion. - {@link Library} represents a [p5.js library](https://p5js.org/libraries/). The API reference is [here](https://osteele.github.io/p5-server/p5-analysis/). These APIs are not stable until this package reaches version 1.0. ## Installation ```sh npm install --save p5-analysis yard add p5-analysis ``` ## Command-Line Usage `p5-libraries list` – list the known libraries With `--json`, this can be used with [jq](https://stedolan.github.io/jq/), e.g. `bun run cli:libraries list --json | jq '.[].importPath'` to list all the import paths, or `bun run cli:libraries list --json | jq '.[] | select(.packageName) | .name'` to print the names of libraries that have been published as NPM packages. `p5-libraries check all` – validate the library homepages, import paths, and other properties `p5-library describe LIBRARY_NAME` – print the name, home page, import path, and defines of a specific library `p5-library property LIBRARY_NAME import-path [--html]` – print the import path for named library. With the `--html` options, print a `