Skip to content

Commit 8abd360

Browse files
mkfreemanFilmbostock
committed
Update CONTRIBUTING.md
Co-authored-by: Philippe Rivière <[email protected]> Co-authored-by: Mike Bostock <[email protected]>
1 parent 5ba59d9 commit 8abd360

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

CONTRIBUTING.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
# Observable Plot - Contributing
22

3-
Observable Plot is released under the ISC license. You are welcome to fork this repository and to send us pull requests to contribute bug fixes or new features.
3+
Observable Plot is released under the ISC license. You are welcome to [fork this repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and to [send us pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) to contribute bug fixes or new features.
44

5-
To develop Observable Plot locally, clone this repository and install its dependencies:
5+
## Set up
66

7-
```
8-
git clone [email protected]:observablehq/plot.git
7+
To set up your local development environment for Plot, follow these steps on your terminal:
8+
9+
```bash
10+
# 1. Clone your fork of the repository
11+
git clone https://github.com/USER-NAME/plot.git
912
cd plot
13+
14+
# 2. Install dependencies listed in the package.json file
1015
yarn
1116
```
1217

13-
Plot is written in ES modules and uses [Vite](https://vitejs.dev/) for development; this means that you can edit the Plot source code and examples, and they’ll update live as you save changes. To start Vite:
18+
## Development
19+
20+
Plot is written in ES modules and uses [Vite](https://vitejs.dev/) for development; this means that you can edit the Plot source code, and the test plots will update live in your browser as you save changes. To start Vite:
1421

1522
```
1623
yarn dev
1724
```
1825

19-
This should open http://localhost:8008/ where you can browse the tests.
26+
This should open http://localhost:8008/ in your browser where you can see the tests plots defined in `test/plots`.
27+
28+
![local development environment](img/localhost.png)
29+
30+
If you’d like to create a new test plot as part of your development, see the instructions below for *snapshot tests*.
2031

2132
## Testing
2233

@@ -41,7 +52,7 @@ export default async function() {
4152
}
4253
```
4354

44-
When a snapshot test is run, its output is compared against the SVG snapshot saved in the `test/output` folder. This makes it easier to see the effect of code changes and to catch unintended changes.
55+
When a snapshot test is run, its output is compared against the SVG or HTML snapshot saved in the `test/output` folder. This makes it easier to see the effect of code changes and to catch unintended changes.
4556

4657
To add a new snapshot test, create a new JavaScript file in the `test/plots` folder. Then register your test in the test registry, `test/plots/index.js`. Once you’ve registered your test, it will also appear automatically in the test browser (http://localhost:8008), where you can inspect and debug the output. (Snapshot tests must have deterministic, reproducible behavior; they should not depend on live data, external servers, the current time, the weather, etc. To use randomness in a test, use a seeded random number generator such as [d3.randomLcg](https://github.com/d3/d3-random/blob/master/README.md#randomLcg).)
4758

@@ -59,3 +70,21 @@ If your code intentionally changes some of the existing snapshots, simply blow a
5970
rm -rf test/output
6071
yarn test
6172
```
73+
74+
## Documentation
75+
76+
Please update the [README.md](./README.md) to reflect any changes to Plot’s public API, and reference any related [issues](https://github.com/observablehq/plot/issues).
77+
78+
If you’d like to share a motivating example in an Observable notebook, you can bundle your changes into a single file:
79+
80+
```bash
81+
# Compile into the file `dist/plot.umd.js`
82+
yarn prepublishOnly
83+
```
84+
85+
You can then attach the `dist/plot.umd.js` file to your notebook using a [File Attachment](https://observablehq.com/@observablehq/file-attachments), and load it into your notebook:
86+
87+
```js
88+
// Load your copy into Observable
89+
Plot = require(await FileAttachment("plot.umd.js").url())
90+
```

img/localhost.png

52.7 KB
Loading

0 commit comments

Comments
 (0)