Skip to content

Commit 4860fc4

Browse files
authored
Merge pull request #32 from ts-graphviz/improve-architecture-and-design-principles
Improve architecture and design principles
2 parents 6fb3149 + b09a573 commit 4860fc4

Some content is hidden

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

46 files changed

+858
-412
lines changed

docs/ts-graphviz/04-intermediate-topics/01-rendering-graphs-to-images.md renamed to docs/ts-graphviz/03-guides/01-rendering-graphs-to-images.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Ensure that [Graphviz](https://graphviz.org/download/) is installed on your syst
2626
### Converting DOT to an Image Stream
2727

2828
```typescript
29-
import { toStream } from '@ts-graphviz/adapter';
29+
import { toStream } from 'ts-graphviz/adapter';
3030

3131
const dot = `
3232
digraph example {
@@ -46,7 +46,7 @@ await stream.pipeTo(Deno.stdout.writable);
4646
### Writing DOT to an Image File
4747

4848
```typescript
49-
import { toFile } from '@ts-graphviz/adapter';
49+
import { toFile } from 'ts-graphviz/adapter';
5050

5151
const dot = `
5252
digraph example {
@@ -63,7 +63,7 @@ await toFile(dot, './result.svg', { format: 'svg' });
6363
- **Output Formats**: Specify the desired output format (e.g., `svg`, `png`) through the options.
6464
- **Runtime Compatibility**: Designed to work seamlessly in both Node.js and Deno environments.
6565

66-
## When to Use `@ts-graphviz/adapter`
66+
## When to Use `ts-graphviz/adapter` module
6767

6868
- When you need to render your graphs into image files for visualization.
6969
- If you want to generate images dynamically within your application.

docs/ts-graphviz/11-advanced-usage/02-extending-ts-graphviz.md renamed to docs/ts-graphviz/03-guides/03-extending-ts-graphviz.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
description: How to extend ts-graphviz with custom classes.
2+
description: How to extend ts-graphviz for advanced use cases.
33
---
44
# Extending ts-graphviz
55

6-
`ts-graphviz` is designed to be extensible, allowing advanced users to customize and enhance the library's functionality to meet specific needs. This section covers how to extend the type system and create custom implementations.
6+
`ts-graphviz` is designed to be extensible, allowing intermediate users to customize and enhance the library's functionality to meet specific needs. This section covers how to extend the type system and create custom implementations.
77

88
## Creating Custom Classes
99

@@ -172,3 +172,58 @@ console.log(
172172
),
173173
);
174174
```
175+
176+
---
177+
178+
179+
## Internal Package Overview
180+
181+
For users interested in extending or customizing `ts-graphviz`, understanding the internal packages can be valuable. Below is an overview of the internal packages and how they can be used in advanced scenarios.
182+
183+
184+
### `@ts-graphviz/adapter`
185+
186+
**Purpose**: Provides interfaces to execute Graphviz commands and convert DOT language strings into various output formats.
187+
188+
**Usage**:
189+
190+
- Convert DOT strings to streams or files.
191+
- Use in environments where you need to render graphs to images or other formats.
192+
193+
:::note
194+
You can use either `@ts-graphviz/adapter` or `ts-graphviz/adapter` imports. The latter is maintained for backward compatibility.
195+
:::
196+
197+
198+
### `@ts-graphviz/ast`
199+
200+
**Purpose**: Allows manipulation of the DOT language at the Abstract Syntax Tree (AST) level.
201+
202+
**Usage**:
203+
204+
- Parse DOT strings into AST nodes.
205+
- Manipulate and transform the AST programmatically.
206+
- Useful for advanced analysis or transformations of existing DOT code.
207+
208+
:::note
209+
You can use either `@ts-graphviz/ast` or `ts-graphviz/ast` imports. The latter is maintained for backward compatibility.
210+
:::
211+
212+
### `@ts-graphviz/common`
213+
214+
**Purpose**: Centralizes Graphviz domain knowledge, providing type definitions, constants, and utilities. It is designed to handle use cases such as extending types.
215+
216+
**Usage**:
217+
218+
- Extend or customize types and attributes.
219+
- Ensure type safety when working with custom attributes.
220+
- Aggregate domain knowledge of Graphviz for consistent usage across packages.
221+
222+
### `@ts-graphviz/core`
223+
224+
**Purpose**: Contains the core implementations of the models and functions provided to users.
225+
226+
**Usage**:
227+
228+
- Use object-oriented APIs for fine-grained control over graph elements.
229+
- Extend classes for custom behaviors or attributes.

0 commit comments

Comments
 (0)