Skip to content

Commit 631e03b

Browse files
authored
Merge pull request #168 from ethdebug/docs
Revamp documentation
2 parents 6eeccde + 017ee54 commit 631e03b

179 files changed

Lines changed: 19019 additions & 1236 deletions

File tree

Some content is hidden

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

.eslintignore

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

.eslintrc.json

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

bin/start

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ else
1010
fi
1111

1212
# Run the commands with concurrently
13-
concurrently --names=format,pointers,bugc,playground,web,tests \
13+
concurrently --names=format,pointers,evm,bugc,programs-react,playground,web,tests \
1414
"cd ./packages/format && yarn watch" \
1515
"cd ./packages/pointers && yarn watch" \
16+
"cd ./packages/evm && yarn watch" \
1617
"cd ./packages/bugc && yarn watch" \
18+
"cd ./packages/programs-react && yarn watch" \
1719
"cd ./packages/playground && yarn watch" \
1820
"cd ./packages/web && yarn start $DOCUSAURUS_NO_OPEN" \
1921
"sleep 5 && yarn test --ui --watch --coverage $VITEST_NO_OPEN"

eslint.config.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import globals from "globals";
4+
import reactHooks from "eslint-plugin-react-hooks";
5+
6+
export default tseslint.config(
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{
10+
files: ["**/*.ts", "**/*.tsx"],
11+
plugins: {
12+
"react-hooks": reactHooks,
13+
},
14+
languageOptions: {
15+
globals: {
16+
...globals.node,
17+
...globals.es2022,
18+
},
19+
parserOptions: {
20+
projectService: true,
21+
},
22+
},
23+
rules: {
24+
"@typescript-eslint/no-explicit-any": "warn",
25+
"@typescript-eslint/no-unused-vars": [
26+
"error",
27+
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_" },
28+
],
29+
"@typescript-eslint/no-namespace": "off",
30+
"@typescript-eslint/no-empty-object-type": "off",
31+
"no-console": "warn",
32+
"require-yield": "off",
33+
"react-hooks/rules-of-hooks": "error",
34+
"react-hooks/exhaustive-deps": "warn",
35+
"no-restricted-imports": [
36+
"error",
37+
{
38+
patterns: [
39+
{
40+
group: ["../types/*/index*", "../types/*/index"],
41+
message: "Use #types/* alias instead of relative imports",
42+
},
43+
{
44+
group: [
45+
"../materials/*",
46+
"../data/*",
47+
"../pointer/*",
48+
"../program/*",
49+
"../type/*",
50+
],
51+
message: "Use #types/* alias instead of relative imports",
52+
},
53+
{
54+
group: ["../../test/*", "../../../test/*"],
55+
message: "Use #test/* alias instead of relative imports",
56+
},
57+
{
58+
group: ["../describe*"],
59+
message: "Use #describe alias instead of relative imports",
60+
},
61+
],
62+
},
63+
],
64+
},
65+
},
66+
{
67+
ignores: [
68+
"node_modules/",
69+
"**/dist/",
70+
"coverage/",
71+
"**/*.d.ts",
72+
"**/*.config.js",
73+
"**/*.config.ts",
74+
"packages/format/src/schemas/yamls.ts",
75+
"packages/web/.docusaurus/",
76+
"packages/web/build/",
77+
],
78+
},
79+
);

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"packages/*"
66
],
77
"scripts": {
8-
"build": "tsc --build packages/format packages/pointers packages/bugc",
8+
"build": "tsc --build packages/format packages/pointers packages/evm packages/bugc packages/programs-react packages/pointers-react",
99
"bundle": "tsx ./bin/bundle-schema.ts",
1010
"test": "vitest",
1111
"test:coverage": "vitest run --coverage",
@@ -15,21 +15,25 @@
1515
"prepare": "husky",
1616
"format": "prettier --write .",
1717
"format:check": "prettier --check .",
18-
"lint": "eslint . --ext .ts,.tsx",
19-
"lint:fix": "eslint . --ext .ts,.tsx --fix"
18+
"lint": "eslint .",
19+
"lint:fix": "eslint . --fix"
2020
},
2121
"devDependencies": {
22+
"@eslint/js": "^9.39.2",
2223
"@typescript-eslint/eslint-plugin": "^8.21.0",
2324
"@typescript-eslint/parser": "^8.21.0",
2425
"@vitest/coverage-v8": "^3.2.4",
2526
"@vitest/ui": "^3.2.4",
2627
"concurrently": "^8.2.2",
27-
"eslint": "^8.57.1",
28+
"eslint": "^9.0.0",
29+
"eslint-plugin-react-hooks": "^7.0.1",
30+
"globals": "^17.0.0",
2831
"husky": "^9.1.7",
2932
"lerna": "^8.2.4",
3033
"lint-staged": "^15.4.1",
3134
"prettier": "^3.4.2",
3235
"tsx": "^4.21.0",
36+
"typescript-eslint": "^8.53.0",
3337
"vitest": "^3.2.4"
3438
},
3539
"lint-staged": {

packages/bugc-react/package.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "@ethdebug/bugc-react",
3+
"version": "0.1.0-0",
4+
"description": "React components for visualizing BUG compiler output",
5+
"type": "module",
6+
"main": "dist/src/index.js",
7+
"types": "dist/src/index.d.ts",
8+
"license": "MIT",
9+
"imports": {
10+
"#components/*": {
11+
"types": "./src/components/*.tsx",
12+
"default": "./dist/src/components/*.js"
13+
},
14+
"#hooks/*": {
15+
"types": "./src/hooks/*.ts",
16+
"default": "./dist/src/hooks/*.js"
17+
},
18+
"#utils/*": {
19+
"types": "./src/utils/*.ts",
20+
"default": "./dist/src/utils/*.js"
21+
},
22+
"#types": {
23+
"types": "./src/types.ts",
24+
"default": "./dist/src/types.js"
25+
}
26+
},
27+
"scripts": {
28+
"prepare": "tsc",
29+
"build": "tsc",
30+
"watch": "tsc --watch --preserveWatchOutput",
31+
"test": "vitest run"
32+
},
33+
"dependencies": {
34+
"@ethdebug/bugc": "^0.1.0-0"
35+
},
36+
"devDependencies": {
37+
"@testing-library/dom": "^10.0.0",
38+
"@testing-library/react": "^16.0.0",
39+
"@types/react": "^18.2.43",
40+
"@types/react-dom": "^18.2.17",
41+
"jsdom": "^26.0.0",
42+
"react": "^18.2.0",
43+
"react-dom": "^18.2.0",
44+
"typescript": "^5.0.0",
45+
"vitest": "^3.2.4"
46+
},
47+
"peerDependencies": {
48+
"react": "^18.0.0",
49+
"react-dom": "^18.0.0"
50+
},
51+
"optionalDependencies": {
52+
"@monaco-editor/react": "^4.7.0",
53+
"dagre": "^0.8.5",
54+
"react-flow-renderer": "^10.3.17"
55+
},
56+
"publishConfig": {
57+
"access": "public"
58+
}
59+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Styles for AstView component.
3+
*/
4+
5+
@import "./variables.css";
6+
7+
.ast-view {
8+
height: 100%;
9+
overflow: auto;
10+
}
11+
12+
.ast-json {
13+
margin: 0;
14+
padding: 1rem;
15+
font-family: "Consolas", "Monaco", "Courier New", monospace;
16+
font-size: 0.875rem;
17+
line-height: 1.5;
18+
color: var(--bugc-text-code);
19+
white-space: pre;
20+
overflow: auto;
21+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* AstView component for displaying the AST of a BUG program.
3+
*/
4+
5+
import React from "react";
6+
import type { Ast } from "@ethdebug/bugc";
7+
8+
/**
9+
* Props for AstView component.
10+
*/
11+
export interface AstViewProps {
12+
/** The AST to display */
13+
ast: Ast.Program;
14+
}
15+
16+
/**
17+
* Displays a BUG program's Abstract Syntax Tree as formatted JSON.
18+
*
19+
* Automatically excludes parent references to avoid circular structures.
20+
*
21+
* @param props - AST to display
22+
* @returns AstView element
23+
*
24+
* @example
25+
* ```tsx
26+
* <AstView ast={compileResult.ast} />
27+
* ```
28+
*/
29+
export function AstView({ ast }: AstViewProps): JSX.Element {
30+
// Format AST as JSON, excluding parent references to avoid circular structure
31+
const astJson = JSON.stringify(
32+
ast,
33+
(key, value) => {
34+
if (key === "parent") return undefined;
35+
return value;
36+
},
37+
2,
38+
);
39+
40+
return (
41+
<div className="ast-view">
42+
<pre className="ast-json">{astJson}</pre>
43+
</div>
44+
);
45+
}

0 commit comments

Comments
 (0)