From f11b89a3dec6431a34cfbbbde7c5e0e2878d440f Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 16 Dec 2022 12:44:52 +0000 Subject: [PATCH] docs: publish api docs (#14) Updates project config to publish api docs --- .github/dependabot.yml | 3 +++ .gitignore | 9 +++++---- README.md | 29 +++++++++++++---------------- package.json | 17 +++++++++++------ src/list.ts | 9 +++++++++ src/map.ts | 9 +++++++++ src/set.ts | 9 +++++++++ 7 files changed, 59 insertions(+), 26 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 290ad02837..0bc3b42de8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,6 @@ updates: interval: daily time: "10:00" open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/.gitignore b/.gitignore index db79d1f189..910f6339ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ node_modules -coverage -.nyc_output +build +dist +.docs +.coverage +node_modules package-lock.json yarn.lock -docs -dist diff --git a/README.md b/README.md index 227cd11ae6..a70858d081 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ # @libp2p/peer-collections [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) -[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-peer-collections.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-peer-collections) -[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-peer-collections/actions/workflows/js-test-and-release.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-peer-collections/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-peer-collections/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) > Stores values against a peer id ## Table of contents - [Install](#install) + - [Browser ` +``` -## Example +## Description -```JavaScript -import { peerMap, peerSet, peerList } from '@libp2p/peer-collections' +We can't use PeerIds as collection keys because collection keys are compared using same-value-zero equality, so this is just a group of collections that stringifies PeerIds before storing them. -const map = peerMap() -map.set(peerId, 'value') +PeerIds cache stringified versions of themselves so this should be a cheap operation. -const set = peerSet() -set.add(peerId) +## API Docs -const list = peerList() -list.push(peerId) -``` +- ## License diff --git a/package.json b/package.json index 354faa9dec..d61bec1441 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "types": "./dist/src/index.d.ts", "files": [ "src", - "dist/src", + "dist", "!dist/test", "!**/*.tsbuildinfo" ], @@ -65,15 +65,15 @@ "release": "patch" }, { - "type": "chore", + "type": "docs", "release": "patch" }, { - "type": "docs", + "type": "test", "release": "patch" }, { - "type": "test", + "type": "deps", "release": "patch" }, { @@ -103,7 +103,11 @@ }, { "type": "docs", - "section": "Trivial Changes" + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" }, { "type": "test", @@ -131,7 +135,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "test:node": "aegir test -t node --cov", "test:electron-main": "aegir test -t electron-main", - "release": "aegir release" + "release": "aegir release", + "docs": "aegir docs" }, "dependencies": { "@libp2p/interface-peer-id": "^1.0.4", diff --git a/src/list.ts b/src/list.ts index 48d8d14786..34c99eaf4b 100644 --- a/src/list.ts +++ b/src/list.ts @@ -9,6 +9,15 @@ import { mapIterable } from './util.js' * * PeerIds cache stringified versions of themselves so this * should be a cheap operation. + * + * @example + * + * ```JavaScript + * import { peerList } from '@libp2p/peer-collections' + * + * const list = peerList() + * list.push(peerId) + * ``` */ export class PeerList { private readonly list: string[] diff --git a/src/map.ts b/src/map.ts index ec5441e7fd..5989d37a12 100644 --- a/src/map.ts +++ b/src/map.ts @@ -9,6 +9,15 @@ import { mapIterable } from './util.js' * * PeerIds cache stringified versions of themselves so this * should be a cheap operation. + * + * @example + * + * ```JavaScript + * import { peerMap } from '@libp2p/peer-collections' + * + * const map = peerMap() + * map.set(peerId, 'value') + * ``` */ export class PeerMap { private readonly map: Map diff --git a/src/set.ts b/src/set.ts index 6aaf5a97e5..f7e1f0021a 100644 --- a/src/set.ts +++ b/src/set.ts @@ -9,6 +9,15 @@ import { mapIterable } from './util.js' * * PeerIds cache stringified versions of themselves so this * should be a cheap operation. + * + * @example + * + * ```JavaScript + * import { peerSet } from '@libp2p/peer-collections' + * + * const set = peerSet() + * set.add(peerId) + * ``` */ export class PeerSet { private readonly set: Set