Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahsonder committed Jun 13, 2024
1 parent c292ff1 commit 7c5a1bf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Removed the `isClass` and `stack_frame` attributes and embedded them as the types `.class` and `.frame`.
- Renamed the input for blank objects from `BLANK` to `.blank`.
- Created new type `.blank-frame` to denote blank stack frames.
- Created a CLI for MemoryViz.

### ✨ Enhancements

Expand All @@ -23,6 +24,8 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### 📚 Documentation and demo website changes

- Added documentation page for the MemoryViz CLI.

### 🔧 Internal changes

- Added a changelog and pull request template.
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ produces a file `simple_demo.svg` that looks like the following:

For more information, check out the project [documentation website](https://www.cs.toronto.edu/~david/memory-viz/) and [demo](https://www.cs.toronto.edu/~david/memory-viz/demo/).

### MemoryViz CLI

To run MemoryViz from your terminal, run:

```console
$ npx memory-viz <path-to-file>
```

replacing `<path-to-file>` with the path to a file containing MemoryViz-compatible JSON. The output is an SVG image generated by MemoryViz and the image is saved in the same folder in which the CLI is called. For more information, check out the project [documentation website](https://www.cs.toronto.edu/~david/memory-viz/docs/cli).

## Developers

### Installation
Expand Down
21 changes: 21 additions & 0 deletions docs/docs/06-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: MemoryViz CLI
---

# MemoryViz CLI

You can run MemoryViz straight from your terminal!

## Input

To run the MemoryViz CLI, run:

```console
$ npx memory-viz <path-to-file>
```

replacing `<path-to-file>` with the path to a file containing MemoryViz-compatible JSON. If the file extension is not `.json` or if the file content is not compatible with MemoryViz, an error will be thrown.

## Output

The output is an SVG image generated by MemoryViz and the image is saved in the same folder in which the CLI is called. The name of the SVG will be the same as that of the inputted file (i.e., if the inputted file is `david-is-cool.json`, the output will be `david-is-cool.svg`).
10 changes: 10 additions & 0 deletions memory-viz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ produces a file `simple_demo.svg` that looks like the following:

For more information, check out the project [documentation website](https://www.cs.toronto.edu/~david/memory-viz/) and [demo](https://www.cs.toronto.edu/~david/memory-viz/demo/).

### MemoryViz CLI

To run MemoryViz from your terminal, run:

```console
$ npx memory-viz <path-to-file>
```

replacing `<path-to-file>` with the path to a file containing MemoryViz-compatible JSON. The output is an SVG image generated by MemoryViz and the image is saved in the same folder in which the CLI is called. For more information, check out the project [documentation website](https://www.cs.toronto.edu/~david/memory-viz/docs/cli).

## Developers

### Installation
Expand Down
10 changes: 3 additions & 7 deletions memory-viz/src/tests/draw.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ describe("memory-viz cli", () => {
execSync(`npx memory-viz ${path.resolve(__dirname, "cli-test.json")}`);

const svgFilePath = path.resolve(process.cwd(), "cli-test.svg");
const fileContent = fs.readFileSync(svgFilePath, "utf8");

if (fs.existsSync(svgFilePath)) {
const fileContent = fs.readFileSync(svgFilePath, "utf8");
expect(fileContent).toMatchSnapshot();
fs.unlinkSync(svgFilePath);
} else {
expect(fs.existsSync(svgFilePath)).toBe(true); // This should fail if the files does not exist.
}
expect(fileContent).toMatchSnapshot();
fs.unlinkSync(svgFilePath);
});
});

Expand Down

0 comments on commit 7c5a1bf

Please sign in to comment.