docs: add content to getting started page by HalilFocic · Pull Request #598 · maxGraph/maxGraph · GitHub
Skip to content

docs: add content to getting started page#598

Merged
tbouffard merged 10 commits into
maxGraph:mainfrom
HalilFocic:docs/getting-started-page
Dec 29, 2024
Merged

docs: add content to getting started page#598
tbouffard merged 10 commits into
maxGraph:mainfrom
HalilFocic:docs/getting-started-page

Conversation

@HalilFocic

@HalilFocic HalilFocic commented Dec 8, 2024

Copy link
Copy Markdown

PR Checklist

  • Addresses an existing open issue: Migrate the mxGraph documentation #345
  • You have discussed this issue with the maintainers of maxGraph, and you are assigned to the issue.
  • The scope of the PR is sufficiently narrow to be examined in a single session. A PR covering several issues must be split into separate PRs. Do not create a large PR, otherwise it cannot be reviewed and you will be asked to split it later or the PR will be closed.
  • I have added tests to prove my fix is effective or my feature works. This can be done in the form of automatic tests in packages/core/_tests_ or a new or altered Storybook story in packages/html/stories (an existing story may also demonstrate the change).
  • I have provided screenshot/videos to demonstrate the change. If no releavant, explain why.
  • I have added or edited necessary documentation, or no docs changes are needed.
  • The PR title follows the "Conventional Commits" guidelines.

Overview

Since we didn't have any getting started page on our docs, I took some time to add basic getting started guide which includes the following:

  • Installing via npm, pnpm or yarn
  • importing the module and displaying first graph
  • Explaining core graph parts (vertex, edge and group).
  • How to handle events (click and cells moved event)
  • Basic vertex styling

Notes

This probably is not the final version of the Getting started docs but it is sure a better version than what we have now.

Summary by CodeRabbit

  • New Features

    • Enhanced "Getting Started" documentation with a work-in-progress warning and updated licensing information.
    • Added sections for "Installation" and "Basic Usage" with detailed examples and code snippets.
    • Introduced subsections on "Basic Operations" covering adding elements and event handling.
    • Included a "Need Help?" section for user support resources.
    • Expanded installation instructions in the README to include npm, yarn, and pnpm commands.
    • Updated the "Getting Started" section with a detailed example of displaying a rectangle connected to an orange circle.
  • Bug Fixes

    • Corrected the link to the GitHub releases page for the maxGraph package.

@coderabbitai

coderabbitai Bot commented Dec 8, 2024

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (6)
packages/website/docs/manual/getting-started.md (6)

Line range hint 1-4: Enhance the description to be more specific

Consider expanding the description to better reflect the content, for example:
"A comprehensive guide to installing, configuring, and creating your first graph with maxGraph."

🧰 Tools
🪛 LanguageTool

[style] ~64-~64: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...want to use TypeScript, adapt it if you want to use JavaScript (mainly, remove referenc...

(REP_WANT_TO_VB)


[uncategorized] ~112-~112: You might be missing the article “a” here.
Context: ... into your application, you should have minimal graph displayed with a rectangle connec...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~127-~127: Possible typo: you repeated a word
Context: ...ents in an architectural diagram. #### Edges Edges are the connections in your graph that ...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~134-~134: Possible typo: you repeated a word
Context: ...tionships in organization charts. #### Groups Groups in maxGraph allow you to logically orga...

(ENGLISH_WORD_REPEAT_RULE)

🪛 Markdownlint (0.35.0)

114-114: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


208-208: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


37-52: Enhance installation instructions with additional details

Consider adding:

  • Version specification guidance (e.g., @maxgraph/core@latest vs specific versions)
  • Any peer dependencies that need to be installed
  • A verification step to confirm successful installation

67-111: Improve TypeScript code example with better practices

Consider these improvements to the code example:

  1. Use more idiomatic TypeScript for type assertion:
-const container = <HTMLElement>document.getElementById('graph-container');
+const container = document.getElementById('graph-container') as HTMLElement;
  1. Add null check for container:
-const container = <HTMLElement>document.getElementById('graph-container');
+const container = document.getElementById('graph-container');
+if (!container) {
+  throw new Error('Container element not found');
+}

121-125: Improve Key Concepts section formatting and content

  1. Fix repeated headers by using different heading levels:
-#### Vertices
-Vertices are...
+#### Vertices
+These are...
  1. Consider adding simple code examples for each concept to demonstrate their usage.

  2. Add a table or list comparing the key properties and methods available for each concept.

Also applies to: 127-132, 134-149

🧰 Tools
🪛 LanguageTool

[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


176-190: Enhance event handling example with more comprehensive coverage

Consider expanding the event handling example to include:

  1. More common event types (e.g., double-click, right-click)
  2. Type safety for event properties
  3. Error handling

Example:

// Add type safety for event properties
type ClickEventProperties = {
  cell: Cell | null;
  event: MouseEvent;
};

graph.addListener(InternalEvent.CLICK, (sender, evt) => {
  try {
    const cell = evt.getProperty<Cell>('cell');
    const mouseEvent = evt.getProperty<MouseEvent>('event');
    
    if (cell) {
      // Handle cell click
      console.log('Clicked cell:', cell);
      console.log('Mouse coordinates:', mouseEvent.clientX, mouseEvent.clientY);
    }
  } catch (error) {
    console.error('Error handling click event:', error);
  }
});

211-213: Expand the Help section with additional resources

Consider adding:

  • Link to Stack Overflow tags
  • Community chat/forum links (if available)
  • Links to related documentation sections
  • Common troubleshooting scenarios
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 62d4c8f and dd3da55.

⛔ Files ignored due to path filters (2)
  • packages/website/docs/manual/assets/getting-started/first-graph.gif is excluded by !**/*.gif
  • packages/website/docs/manual/assets/getting-started/vertex-style.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • packages/website/docs/manual/getting-started.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/website/docs/manual/getting-started.md

[style] ~64-~64: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...want to use TypeScript, adapt it if you want to use JavaScript (mainly, remove referenc...

(REP_WANT_TO_VB)


[uncategorized] ~112-~112: You might be missing the article “a” here.
Context: ... into your application, you should have minimal graph displayed with a rectangle connec...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~127-~127: Possible typo: you repeated a word
Context: ...ents in an architectural diagram. #### Edges Edges are the connections in your graph that ...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~134-~134: Possible typo: you repeated a word
Context: ...tionships in organization charts. #### Groups Groups in maxGraph allow you to logically orga...

(ENGLISH_WORD_REPEAT_RULE)

🪛 Markdownlint (0.35.0)
packages/website/docs/manual/getting-started.md

114-114: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


208-208: null
Images should have alternate text (alt text)

(MD045, no-alt-text)

Comment thread packages/website/docs/manual/getting-started.md Outdated
Comment thread packages/website/docs/manual/getting-started.md Outdated
Comment thread packages/website/docs/manual/getting-started.md
HalilFocic and others added 3 commits December 8, 2024 17:55
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@tbouffard tbouffard added the documentation Improvements or additions to documentation label Dec 9, 2024

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
packages/website/docs/manual/getting-started.md (6)

Line range hint 1-36: LGTM! Consider adding version compatibility information.

The header section is well-structured with clear licensing, proper attribution, and helpful warning about the WIP status. Consider adding information about which versions of maxGraph this documentation applies to.

🧰 Tools
🪛 LanguageTool

[style] ~64-~64: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...want to use TypeScript, adapt it if you want to use JavaScript (mainly, remove referenc...

(REP_WANT_TO_VB)


[uncategorized] ~112-~112: Possible missing article found.
Context: ... into your application, you should have minimal graph displayed with a rectangle connec...

(AI_HYDRA_LEO_MISSING_A)


[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~127-~127: Possible typo: you repeated a word
Context: ...ents in an architectural diagram. #### Edges Edges are the connections in your graph that ...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~134-~134: Possible typo: you repeated a word
Context: ...tionships in organization charts. #### Groups Groups in maxGraph allow you to logically orga...

(ENGLISH_WORD_REPEAT_RULE)


37-53: Consider enhancing installation instructions.

While the basic installation commands are clear, consider adding:

  • Example package.json configuration
  • List of peer dependencies (if any)
  • Common troubleshooting steps
  • Minimum required Node.js version

81-111: Consider adding error handling and type safety to the graph creation example.

The example could benefit from:

  • Type annotations for the vertex and edge objects
  • Error handling for failed insertions
  • Comments explaining the style properties

121-121: Fix repeated headings in the key concepts section.

Remove the duplicate headings for better readability:

-#### Vertices
Vertices
+#### Vertices
-#### Edges
Edges
+#### Edges
-#### Groups
Groups
+#### Groups

Also applies to: 127-127, 134-134

🧰 Tools
🪛 LanguageTool

[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


179-189: Enhance event handling examples with type safety and error handling.

Consider adding:

  • TypeScript interfaces for event properties
  • Error handling in callbacks
  • Examples of other common events
+interface CellEvent extends Event {
+  getProperty(key: string): any;
+}

 graph.addListener(InternalEvent.CLICK, (sender, evt) => {
-  const cell = evt.getProperty('cell');
+  try {
+    const cell = (evt as CellEvent).getProperty('cell');
     if (cell) {
       console.log('Clicked cell:', cell);
     }
+  } catch (error) {
+    console.error('Error handling cell click:', error);
+  }
 });

192-212: Expand the styling section with more examples.

Consider adding:

  • Examples of edge styling
  • Custom style definitions
  • Common style properties and their effects
  • Style inheritance and overrides
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dd3da55 and 02e73e9.

📒 Files selected for processing (1)
  • packages/website/docs/manual/getting-started.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/website/docs/manual/getting-started.md

[style] ~64-~64: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...want to use TypeScript, adapt it if you want to use JavaScript (mainly, remove referenc...

(REP_WANT_TO_VB)


[uncategorized] ~112-~112: Possible missing article found.
Context: ... into your application, you should have minimal graph displayed with a rectangle connec...

(AI_HYDRA_LEO_MISSING_A)


[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~127-~127: Possible typo: you repeated a word
Context: ...ents in an architectural diagram. #### Edges Edges are the connections in your graph that ...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~134-~134: Possible typo: you repeated a word
Context: ...tionships in organization charts. #### Groups Groups in maxGraph allow you to logically orga...

(ENGLISH_WORD_REPEAT_RULE)

Comment thread packages/website/docs/manual/getting-started.md
Comment thread packages/website/docs/manual/assets/getting-started/first-graph.gif

@tbouffard tbouffard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, this looks great.
I will try to have a look at it this week (I have currently limited time to work on maxGraph).

In the meantime, I will answer to your question about the documentation roadmap in #595. IMHO, it is important we agree on a plan for the documentation. For example, what we put in the README (to limit the duplication with the documentation to reduce maintenance needs), what we keep from the former mxGraph documenation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/website/docs/manual/getting-started.mdx (5)

1-4: Consider adding version compatibility information

Since this is a getting started guide, it would be helpful to specify the minimum supported versions of Node.js and TypeScript required to use maxGraph.

 ---
 sidebar_position: 2
 description: Getting started with maxGraph.
+requirements:
+  - Node.js >= 14.0.0
+  - TypeScript >= 3.8.0
 ---

41-61: Consider adding peer dependencies information

If maxGraph has any peer dependencies, it would be helpful to list them in the installation section.


138-144: Improve section headers to avoid word repetition

Consider revising the section headers to avoid word repetition:

-#### Vertices
-Vertices are the fundamental elements...
+#### Vertex Elements
+Vertices are the fundamental elements...

-#### Edges
-Edges are the connections...
+#### Edge Connections
+Edges are the connections...

-#### Groups
-Groups in `maxGraph`...
+#### Grouping Elements
+Groups in `maxGraph`...

Also applies to: 152-152

🧰 Tools
🪛 LanguageTool

[duplication] ~138-~138: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~144-~144: Possible typo: you repeated a word
Context: ...ents in an architectural diagram. #### Edges Edges are the connections in your graph that ...

(ENGLISH_WORD_REPEAT_RULE)


196-210: Enhance event handling examples

Consider adding more practical event handling examples such as:

  • Double-click events for editing
  • Context menu events
  • Drag and drop events

214-227: Expand styling examples

Consider adding more comprehensive styling examples including:

  • Edge styling
  • Custom shapes
  • Gradient fills
  • Custom markers
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02e73e9 and 63743bf.

📒 Files selected for processing (3)
  • README.md (4 hunks)
  • packages/website/docs/intro.md (2 hunks)
  • packages/website/docs/manual/getting-started.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/website/docs/intro.md
🧰 Additional context used
🪛 LanguageTool
packages/website/docs/manual/getting-started.mdx

[style] ~79-~79: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...want to use TypeScript, adapt it if you want to use JavaScript (mainly, remove referenc...

(REP_WANT_TO_VB)


[duplication] ~138-~138: Possible typo: you repeated a word
Context: ...nts: vertices, edges, and groups. #### Vertices Vertices are the fundamental elements of your gr...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~144-~144: Possible typo: you repeated a word
Context: ...ents in an architectural diagram. #### Edges Edges are the connections in your graph that ...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~152-~152: Possible typo: you repeated a word
Context: ...tionships in organization charts. #### Groups Groups in maxGraph allow you to logically or...

(ENGLISH_WORD_REPEAT_RULE)

🔇 Additional comments (3)
packages/website/docs/manual/getting-started.mdx (2)

228-228: Verify the image asset exists

Please ensure that the image file ./assets/getting-started/vertex-style.png exists in the correct location and is committed to the repository.

✅ Verification successful

Image asset exists at the specified location

The image file vertex-style.png is present in the correct location at packages/website/docs/manual/assets/getting-started/vertex-style.png.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the image file exists
fd -t f "vertex-style.png" packages/website/docs/manual/assets/getting-started/

Length of output: 148


129-129: Verify the image asset exists

Please ensure that the image file ./assets/getting-started/first-graph.gif exists in the correct location and is committed to the repository.

✅ Verification successful

Image asset exists at the specified location

The referenced image file first-graph.gif exists at the correct path: packages/website/docs/manual/assets/getting-started/first-graph.gif

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the image file exists
fd -t f "first-graph.gif" packages/website/docs/manual/assets/getting-started/

Length of output: 146

README.md (1)

Line range hint 43-183: LGTM! Documentation sections are well-organized

The addition of comment markers clearly indicates which sections are shared across different documentation files, making maintenance easier.

@tbouffard tbouffard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this contribution @HalilFocic

I took the liberty of making a few changes directly in the branch of this PR:

  • use the same gif in the README and documentation
  • mark the parts of the README that are duplicated in the documentation for easier maintenance
  • use tabs in the installation paragraph to shorten content
  • a few styling adjustments

The content of this getting started section can be repeated later, once the mxGraph tutorial has been integrated into the documentation.

I'm going to leave this PR open for a few days to allow you to give feedback if the changes I've applied cause any problems.

@HalilFocic

Copy link
Copy Markdown
Author

I'm going to leave this PR open for a few days to allow you to give

Thanks. I will check it tomorrow first thing in the morning. We can chat more about docs parts in the dicsussion I started. I am willing to translate the existing mxGraph to maxGraph docs but I think we should structure it differently so it's easier for newcommers to adopt max graph.

@tbouffard

Copy link
Copy Markdown
Member

I'm going to leave this PR open for a few days to allow you to give

Thanks. I will check it tomorrow first thing in the morning. We can chat more about docs parts in the dicsussion I started. I am willing to translate the existing mxGraph to maxGraph docs but I think we should structure it differently so it's easier for newcommers to adopt max graph.

I'm thinking exactly the same thing and I also wanted to share some thoughts on the subject and how we might move forward on this theme.
Unfortunately, I don't have much time at the moment and haven't found any to share everything 😸 . Hopefully I'll be able to do it this week, otherwise it'll probably be early 2025.

@HalilFocic

Copy link
Copy Markdown
Author

@tbouffard tbouffard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants