Skip to content

Commit f3b89ce

Browse files
PaulRBergsmol-ninja
authored andcommitted
refactor: update and polish API docs
refactor: better organization for static images refactor: rename AdmonitionSimpleCode to CautionNonProduction refactor: simplify and polish CLI refactor: update indexers tables
1 parent ea425bd commit f3b89ce

File tree

112 files changed

+922
-2350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+922
-2350
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.docusaurus
44
build
55
node_modules
6+
repomix
67
src/autogen/**/*.mdx
78

89
# files

CONTRIBUTING.md

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,31 @@ informal concerns or feedback, please join our [Discord server](https://discord.
55

66
Contributions to Sablier Docs are welcome by anyone interested in improving readability, or adding new features.
77

8-
## Pre Requisites
8+
## Prerequisites
99

10-
You will need the following software on your machine:
10+
- [Node.js](https://nodejs.org) (v20+)
11+
- [Bun](https://bun.sh) (package manager)
1112

12-
- [Git] (https://git-scm.com/downloads)
13-
- [Node.Js] (https://nodejs.org/en/download/)
14-
- [Bun] (https://bun.sh/)
13+
### Setup
1514

16-
### Set Up
17-
18-
Clone this repository:
19-
20-
```shell
21-
$ git clone [email protected]:sablier-labs/docs.git && cd docs
22-
```
23-
24-
Then, inside the project's directory, run this to install the Node.js dependencies:
25-
26-
```shell
27-
$ bun install
28-
```
29-
30-
Create a new branch and switch to it, this is where all development work should be done:
31-
32-
```shell
33-
$ git switch <branch-name>
15+
```bash
16+
git clone https://github.com/sablier-labs/docs.git sablier-docs
17+
cd sablier-docs
18+
bun install
3419
```
3520

36-
Now you can start making changes.
37-
38-
Run the following command to starts a local development server and opens up a browser window.
21+
### Available Commands
3922

40-
```shell
41-
$ bun run start
23+
```bash
24+
bun run # Show all available commands
25+
bun run start # Build the docs site locally on localhost:3000
26+
bun run check # Run all code checks
4227
```
4328

44-
To see a list of all available scripts:
45-
46-
```shell
47-
$ bun run
48-
```
49-
50-
## Pull Requests
51-
52-
- Before you submit your Pull Request (PR), search the project for an open or closed PR related to your submission to
53-
avoid duplicating effort.
54-
- Make your changes in a new git branch.
55-
- Commit your changes. Your commit message should follow the
56-
[Conventional Commits](https://conventionalcommits.org/en/v1.0.0/) specification
57-
- Make sure `bun run check` passes.
58-
- Open a pull request from your forked repository to the original repository.
59-
60-
When making a pull request, ensure that:
29+
### Development Workflow
6130

62-
- A descriptive summary of the PR has been provided.
31+
1. Fork the repository
32+
2. Create a feature branch
33+
3. Make your changes
34+
4. Run `bun run check` to verify code quality
35+
5. Submit a pull request

bun.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"@mdx-js/mdx": "~3.1",
1919
"@mdx-js/react": "~3.1",
2020
"@sablier/devkit": "github:sablier-labs/devkit#main",
21-
"@sablier/indexers": "1.0.0-alpha.4",
21+
"@sablier/indexers": "1.0.0-alpha.6",
2222
"@vercel/analytics": "^1.5",
2323
"axios": "^1.9",
2424
"clsx": "^2.1",
2525
"docusaurus-plugin-remote-content": "^4.0",
2626
"docusaurus-theme-github-codeblock": "^2.0",
2727
"function-plot": "^1.25",
2828
"hast-util-is-element": "3.0",
29+
"lodash": "^4.17",
2930
"prism-react-renderer": "^2.4",
3031
"react": "18.2",
3132
"react-dom": "18.2",
@@ -50,7 +51,6 @@
5051
"eslint-plugin-react": "^7.37",
5152
"husky": "^9.1",
5253
"lint-staged": "^16.1",
53-
"lodash": "^4.17",
5454
"prettier": "^3.5",
5555
"typescript": "5.8.3",
5656
"vercel": "^42.3",
@@ -748,7 +748,7 @@
748748

749749
"@sablier/devkit": ["@sablier/devkit@github:sablier-labs/devkit#c12bc44", {}, "sablier-labs-devkit-c12bc44"],
750750

751-
"@sablier/indexers": ["@sablier/[email protected].4", "", { "dependencies": { "lodash": "^4.17", "sablier": "1.0.0-beta.2" } }, "sha512-bW8vEMpfRPSC5IHAlzpCjqP29W5VfGQFK2FA3HMUs4bTRoVhkyf/P7nhxpkT8buT5P0oGk4J5J4CpuTZ6xFegw=="],
751+
"@sablier/indexers": ["@sablier/[email protected].6", "", { "dependencies": { "lodash": "^4.17", "sablier": "1.0.0-beta.2" } }, "sha512-2YpYCyyFJnuTrsPcY+v4CDW+R/e/+qzxzxIFZmNq2wjFA2l5EFBI+bgKSWzd/+P2lgMI2rAjaKe4GhxbGXjKXw=="],
752752

753753
"@scure/base": ["@scure/[email protected]", "", {}, "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg=="],
754754

cli/commands/deployments.ts renamed to cli/commands/autogen/deployments.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { Command } from "commander";
2+
import _ from "lodash";
23
import { Protocol, type Sablier, sablier } from "sablier";
3-
import type { CliOptions } from "../types";
4-
import { Links } from "../../src/constants";
5-
import * as helpers from "../helpers";
4+
import type { CliOptions } from "../../types";
5+
import { Links } from "../../../src/constants";
6+
import { autogenFilePaths, getRelative, writeFileWithOverwrite } from "../../helpers";
67

78
export function createDeploymentsCommand(): Command {
89
return new Command("deployments")
910
.description("Generate deployment tables for all Sablier releases")
10-
.action(async (_options, command) => {
11-
const globalOptions = command.parent?.opts() || {};
12-
await generateDeployments(globalOptions);
11+
.action(async (_options, command: Command) => {
12+
const mergedOptions = command.optsWithGlobals();
13+
await generateDeployments(mergedOptions);
1314
});
1415
}
1516

@@ -24,11 +25,12 @@ export async function generateDeployments(options: CliOptions = {}): Promise<voi
2425
continue;
2526
}
2627

27-
const fileName = helpers.autogenFileNames.deployments(release.version);
28-
const filePath = helpers.getAutogenFilePath(release.protocol, fileName);
28+
const filePath = autogenFilePaths.deployments(release);
2929

30-
if (helpers.writeFileWithOverride({ filePath, content: tables, options })) {
31-
helpers.log(`✅ Generated table with deployments for ${release.protocol} ${release.version}`, options);
30+
if (writeFileWithOverwrite({ filePath, content: tables, options })) {
31+
const protocol = _.capitalize(release.protocol);
32+
const version = _.capitalize(release.version);
33+
console.log(`✔️ Generated deployments table for ${protocol} ${version} at: ${getRelative(filePath)}`);
3234
}
3335
}
3436
}
@@ -47,34 +49,36 @@ function generateTables(release: Sablier.Release) {
4749
for (const deployment of mainnetDeployments) {
4850
const chain = sablier.chains.get(deployment.chainId);
4951
content += `### ${chain.name}\n\n`;
50-
content += generateDeploymentTable(deployment, release.protocol, release.version);
52+
content += generateDeploymentTable(deployment, release);
5153
content += "\n";
5254
}
5355

5456
content += "## Testnets\n\n";
5557
for (const deployment of testnetDeployments) {
5658
const chain = sablier.chains.get(deployment.chainId);
5759
content += `### ${chain.name}\n\n`;
58-
content += generateDeploymentTable(deployment, release.protocol, release.version);
60+
content += generateDeploymentTable(deployment, release);
5961
content += "\n";
6062
}
6163

6264
return content;
6365
}
6466

65-
function generateDeploymentTable(deployment: Sablier.Deployment, protocol: Sablier.Protocol, version: string): string {
67+
function generateDeploymentTable(deployment: Sablier.Deployment, release: Sablier.Release): string {
6668
let table = `| Contract | Address | Deployment |\n`;
6769
table += `| :-------- | :-------- | :--------- |\n`;
6870

6971
for (const contract of deployment.contracts) {
70-
let address: string;
72+
let addressCell: string;
7173
if (contract.explorerURL) {
72-
address = `[\`${contract.address}\`](${contract.explorerURL})`;
74+
addressCell = `[\`${contract.address}\`](${contract.explorerURL})`;
7375
} else {
74-
address = `\`${contract.address}\``;
76+
addressCell = `\`${contract.address}\``;
7577
}
76-
const link = `[\`${protocol}-${version}\`](${Links.GitHub.SDK}/blob/main/deployments/${protocol}/${version})`;
77-
table += `| ${contract.name} | ${address} | ${link} |\n`;
78+
const protocol = release.protocol;
79+
const version = release.version;
80+
const linkCell = `[\`${protocol}-${version}\`](${Links.GitHub.SDK}/blob/main/deployments/${protocol}/${version})`;
81+
table += `| ${contract.name} | ${addressCell} | ${linkCell} |\n`;
7882
}
7983

8084
return table;

cli/commands/autogen/indexers.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { type Indexer, indexers } from "@sablier/indexers";
2+
import { Command } from "commander";
3+
import _ from "lodash";
4+
import { sablier } from "sablier";
5+
import type { CliOptions } from "../../types";
6+
import { autogenFilePaths, getRelative, writeFileWithOverwrite } from "../../helpers";
7+
8+
export function createIndexersCommand(): Command {
9+
return new Command("indexers")
10+
.description("Generate indexer endpoint tables for all Sablier protocols")
11+
.action(async (_options, command: Command) => {
12+
const mergedOptions = command.optsWithGlobals();
13+
await generateIndexers(mergedOptions);
14+
});
15+
}
16+
17+
export async function generateIndexers(options: CliOptions = {}): Promise<void> {
18+
generateTables("airdrops", options);
19+
generateTables("flow", options);
20+
generateTables("lockup", options);
21+
}
22+
23+
function generateTables(protocol: Indexer.Protocol, options: CliOptions): void {
24+
const graphTable = generateGraphTable(indexers.graph[protocol]);
25+
const envioTable = generateEnvioTable(indexers.envio[protocol]);
26+
27+
const graphFilePath = autogenFilePaths.graph(protocol);
28+
if (writeFileWithOverwrite({ filePath: graphFilePath, content: graphTable, options })) {
29+
console.log(
30+
`✔️ Generated ${_.capitalize(protocol)} endpoints table for The Graph at: ${getRelative(graphFilePath)}`,
31+
);
32+
}
33+
34+
const envioFilePath = autogenFilePaths.envio(protocol);
35+
if (writeFileWithOverwrite({ filePath: envioFilePath, content: envioTable, options })) {
36+
console.log(`✔️ Generated ${_.capitalize(protocol)} endpoints table for Envio at: ${getRelative(envioFilePath)}`);
37+
}
38+
}
39+
40+
function generateGraphTable(indexers: Indexer[]): string {
41+
let markdown = `| Chain | Production URL | Testing URL | Explorer URL |\n`;
42+
markdown += `| -------- | -------------- | ----------- | ------------ |\n`;
43+
44+
for (const indexer of indexers) {
45+
const chain = sablier.chains.getOrThrow(indexer.chainId);
46+
47+
const productionURL = indexer.endpoint.url;
48+
const testingURL = indexer.playgroundURL;
49+
const explorerURL = indexer.explorerURL;
50+
51+
const productionCell = `[${indexer.name}](${productionURL})`;
52+
const testingCell = testingURL ? `[Testing](${testingURL})` : "N/A";
53+
const explorerCell = explorerURL ? `[Explorer](${explorerURL})` : "N/A";
54+
55+
markdown += `| ${chain.name} | ${productionCell} | ${testingCell} | ${explorerCell} |\n`;
56+
}
57+
58+
return markdown;
59+
}
60+
61+
function generateEnvioTable(indexers: Indexer[]): string {
62+
let markdown = `| Chain | Production URL | Testing URL |\n`;
63+
markdown += `| -------- | -------------- | ----------- |\n`;
64+
65+
for (const indexer of indexers) {
66+
const chain = sablier.chains.get(indexer.chainId);
67+
if (!chain || !chain.name) {
68+
continue;
69+
}
70+
71+
const productionURL = indexer.endpoint.url;
72+
const testingURL = `https://cloud.hasura.io/public/graphiql?endpoint=${encodeURIComponent(productionURL)}`;
73+
74+
const productionCell = `${productionURL}`;
75+
const testingCell = `[Testing](${testingURL})`;
76+
markdown += `| ${chain.name} | ${productionCell} | ${testingCell} |\n`;
77+
}
78+
79+
return markdown;
80+
}

cli/commands/indexers.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)