Skip to content

Commit

Permalink
refactor: docugraph to docusaurus-graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsero committed May 27, 2024
1 parent 276c2c3 commit 0e61789
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# docugraph
# docusaurus-graph

<!-- PROJECT LOGO -->
<br />
<p align="center">
<img src="assets/Graphview.png" alt="screenshot" width="700">

<h3 align="center">docugraph</h3>
<h3 align="center">docusaurus-graph</h3>

<p align="center">
Graphview docusaurus
Expand Down Expand Up @@ -63,13 +63,13 @@ To install the plugin, you need to have Docusaurus set up. Follow these steps to
1. Install the plugin via npm or yarn:

```sh
npm install docugraph
npm install docusaurus-graph
```

or

```sh
yarn add docugraph
yarn add docusaurus-graph
```

2. Add the plugin to your Docusaurus site configuration (**docusaurus.config.js**):
Expand All @@ -79,7 +79,7 @@ module.exports = {
// Other Docusaurus configurations...
plugins: [
[
'docugraph',
'docusaurus-graph',
{
path: 'docs', // Specify the folder of your documentation
},
Expand Down Expand Up @@ -121,7 +121,7 @@ module.exports = {
// Other Docusaurus configurations...
plugins: [
[
'docugraph',
'docusaurus-graph',
{
path: 'docs', // Specify the folder of your documentation
},
Expand Down Expand Up @@ -254,7 +254,7 @@ The Docusaurus GraphView Plugin works by parsing your Docusaurus documentation f
- **Graph Visualization**: The constructed graph is then rendered using a graph visualization library (such as note-graph (D3.js)), applying the configured layout and styles.
- **Interactive Elements**: The generated graph is interactive, allowing users to zoom in/out and drag nodes for better viewing.

> After the Docusaurus build process completes, the Docusaurus GraphView Plugin generates a data file containing the parsed documentation structure. This file, typically named `docugraph.json`, includes all the necessary information to construct the graph view, such as nodes (documents) and edges (links between documents). The file is created in the `build` directory of your Docusaurus project.
> After the Docusaurus build process completes, the Docusaurus GraphView Plugin generates a data file containing the parsed documentation structure. This file, typically named `docusaurus-graph.json`, includes all the necessary information to construct the graph view, such as nodes (documents) and edges (links between documents). The file is created in the `build` directory of your Docusaurus project.
## Development

Expand All @@ -263,13 +263,13 @@ If you want to contribute to the plugin or modify it for your own use, follow th
1. Clone the repository

```sh
git clone https://github.com/Arsero/docugraph.git
git clone https://github.com/Arsero/docusaurus-graph.git
```

2. Navigate to the project directory:

```sh
cd docugraph
cd docusaurus-graph
```

3. Install the dependencies:
Expand All @@ -281,7 +281,7 @@ yarn install
4. Make your changes and test them locally. To test them go to the `demo` folder.

```sh
cd .\src\demo
cd demo
yarn install
yarn start
```
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "docusaurus-graph",
"version": "1.0.1",
"version": "1.0.2",
"main": "src/index.ts",
"repository": "https://github.com/Arsero/docugraph.git",
"repository": "https://github.com/Arsero/docusaurus-graph.git",
"author": "Arsero <[email protected]>",
"license": "MIT",
"devDependencies": {
Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { readMarkdownFiles } from './theme/mdUtils';
import * as fs from 'node:fs';
import * as path from 'node:path';

export default async function docuGraph(context: any) {
export default async function docusaurusGraph(context: any) {
const { siteConfig } = context;
return {
name: 'docugraph',
name: 'docusaurus-graph',
async loadContent() {
const themeConfig = siteConfig.themeConfig;
themeConfig.navbar.items.push({
Expand All @@ -19,16 +19,15 @@ export default async function docuGraph(context: any) {
async contentLoaded() {},

async postBuild({ plugins }: any) {
const option = plugins.find((p: any) => p.name === 'docugraph').options[
'path'
];
const option = plugins.find((p: any) => p.name === 'docusaurus-graph')
.options['path'];

const directoryPath = option ? option : 'docs';
const nodes = readMarkdownFiles(directoryPath);

const nodeString = JSON.stringify(nodes, null, 2);
fs.writeFile(
path.join('build', 'docugraph.json'),
path.join('build', 'docusaurus-graph.json'),
nodeString,
'utf8',
(err) => {
Expand Down
2 changes: 1 addition & 1 deletion src/theme/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const templates = {
let graphViewGlobal = null;
async function initGraphView() {
const notes = await (
await fetch('/docugraph.json')
await fetch('/docusaurus-graph.json')
).json();
const graphModel = new NOTE_GRAPH.NoteGraphModel(notes);
Expand Down

0 comments on commit 0e61789

Please sign in to comment.