Skip to content

docs: add a Guides section for task oriented pages - #1207

Open
redfish4ktc wants to merge 2 commits into
mainfrom
docs/add_extending-maxgraph_page
Open

redfish4ktc wants to merge 2 commits into
mainfrom
docs/add_extending-maxgraph_page

Conversation

@redfish4ktc

@redfish4ktc redfish4ktc commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Why

The documentation explains how each feature works, but never how to extend maxGraph, and no page walks a reader through one complete task from end to end. Someone who wants to write a custom shape, move an application off Graph, or configure a BaseGraph from scratch has to assemble the answer from three or four reference pages, in an order nothing states.

What

A new Guides section, placed before Usage, for pages that walk a reader through one task. It holds four pages, ordered by what a reader needs first:

Page Content
configure-basegraph.md Building an application on BaseGraph from the bare graph up, deciding one concern at a time
reduce-bundle-size.md The ordered procedure for moving an existing application from Graph to BaseGraph
extend-maxgraph.md Overriding behavior that no factory exposes, writing a custom Shape, declaring your own Cell style properties
migrate-from-mxgraph.md Moved here from usage/, since it is a task rather than a feature

extend-maxgraph.md is new and is the substance of the change. reduce-bundle-size.md takes the procedure out of usage/tree-shaking.md, which contradicted it on getDefaultPlugins() and the registerDefault* functions; the reference page keeps the per-family reference and each prohibition now names the migration as its exception. configure-basegraph.md gathers material that existed, spread over the graph, plugins and tree-shaking pages, but with nothing saying in which order to decide.

usage/plugins.md gains a Kind column, answering what each built-in plugin does when the application never calls it, and an Id column, which is what a reader needs to map a getPlugin call back to a class.

How the content was verified

Every factual claim was checked against packages/core rather than written from memory, over several rounds, which invalidated about forty of them. Among the corrections worth knowing while reviewing: the paint hooks are called by Shape.paintVertexShape, so they run on every shape that does not replace it, and the shapes that do replace it include the whole AbstractPathShape family; augmentBoundingBox is almost never reached, useSvgBoundingBox defaulting to true; the mixin members are properties rather than methods, except insertVertex and insertEdge; inside registerDefaults() the prototype members are callable and only the container and the five collaborators are missing; the bundle floor comes from importing Graph, not from instantiating it.

Each guide was then validated by following it literally to build an application, which corrected it further: the first snippet compiles, the steps that ask the reader to check the result have a diagram to look at, the stylesheet import appears in the snippet that needs it, and the default styles are set before the cells that depend on them.

The advice on custom style properties rests on behaviour measured against the built library rather than read off the source, since the source suggests a plain deep copy: Cell.getClonedStyle() is a hand written recursive copy that gives back the current date for a Date, an empty Map or Set, null for an object created with Object.create(null), and throws when a constructor requires an argument.

Points a reviewer should decide on

  • One published anchor is lost deliberately. #guide-improving-the-tree-shaking-of-an-application-using-graph disappears with the split of usage/tree-shaking.md. An anchor cannot be redirected, since the browser never sends the fragment to the server, so the alternatives were to keep a stub heading or to accept the loss. The page itself keeps its URL, and migrate-from-mxgraph.md keeps its own through a { from, to } redirect entry.
  • The naming convention is now a rule. A guide file name starts with a verb and every other section names a subject with a singular noun, recorded in .claude/rules/documentation/website.md next to the redirect rule it depends on, with the structure the guides follow in guides-structure.md.
  • packages/ts-example changes too. Its two custom shapes set strokeWidth and isRounded in a constructor the registry calls with no argument, and which resetStyles() wipes at the first style change. They are rewritten the way the new page recommends, since an example that contradicts the guide is worse than no example. The same fix is open on the examples repository, maxgraph-integration-examples#312.

Related

The Patching a prototype section of the new guide gives the replacement advice that #420 asks the JSDoc to point at.

This work also produced twelve issues, #1193 to #1204, and a comment on #418; none of them is a prerequisite for this pull request.

Summary by CodeRabbit

  • New Features

    • Added guides for configuring BaseGraph, extending maxGraph, migrating from mxGraph, and reducing bundle size.
  • Documentation

    • Expanded guidance on plugins, tree-shaking, graph setup, CSS, and custom shapes, including migration prerequisites and version requirements.
    • Reorganized navigation and links to make task-oriented guides and related pages easier to find.
    • Added a redirect from the previous mxGraph migration guide URL.
    • Corrected the selected-features example’s description and category, and updated the production setup guidance.

The documentation explained how each feature works, but never how to extend maxGraph, and no page walked a reader
through one complete task. Add a `Guides` section for that kind of page, ordered by what a reader needs first, and move
`migrate-from-mxgraph.md` into it with a redirect keeping its published URL alive.

`extend-maxgraph.md` documents the extension points users actually reach for, with the rules the types do not expose,
such as a shape having to survive construction with no argument. `reduce-bundle-size.md` takes the procedure out of
`usage/tree-shaking.md`, which contradicted it on `getDefaultPlugins()` and the `registerDefault*` functions: a guide
now says what to do and the reference page what to know. `configure-basegraph.md` covers the opposite trajectory, for
which the material existed, spread over the graph, plugins and tree-shaking pages, but nothing said in which order to
decide.

Every factual claim was checked against `packages/core`, which invalidated about forty of them, and each guide was
validated by following it literally to build an application. The two custom shapes of `packages/ts-example` are
rewritten along the way, since their constructor defaults were wiped at the first style change, which is exactly what
the new page tells readers to avoid.

The extending guide also advises flat style properties holding simple types, because the natural reflex, one object
gathering related values, is the shape the API handles worst: `setCellStyles` assigns a top level key only, and it
first clones the style through a hand written recursive copy that corrupts a `Date`, a `Map`, a `Set` and an object
created with `Object.create(null)`, and throws when a constructor requires an argument. Measured against the built
library, since the source suggests a plain deep copy.

The published anchor `#guide-improving-the-tree-shaking-of-an-application-using-graph` disappears with this work,
deliberately, an anchor being impossible to redirect.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Walkthrough

This PR adds guides for BaseGraph setup, bundle-size reduction, and extending maxGraph. It updates migration guidance, plugin and tree-shaking references, website documentation rules, and related links. It also changes a TypeScript custom-shape example to restore style defaults after resets.

Changes

Website documentation and examples

Layer / File(s) Summary
Guide conventions and website structure
.claude/rules/documentation/*, CLAUDE.md, packages/website/docs/guides/_category_.json, packages/website/docs/intro.md
Adds rules for guide structure, page naming, version claims, redirects, build checks, and Storybook links. Adds the Guides category and describes its scope.
BaseGraph setup and bundle sizing
packages/website/docs/guides/configure-basegraph.md, packages/website/docs/guides/reduce-bundle-size.md, packages/website/docs/usage/graph.md, packages/website/docs/usage/tree-shaking.md, packages/website/docs/usage/global-configuration.md, packages/website/docs/usage/css-and-images.md, packages/website/docs/getting-started.mdx, packages/website/docs/demo-and-examples.md
Adds BaseGraph setup and bundle-size migration guides. Updates related registration, initialization, CSS, and example guidance.
Extension and plugin guidance
packages/website/docs/guides/extend-maxgraph.md, packages/website/docs/usage/plugins.md, packages/website/docs/usage/cell-handlers.md, packages/core/src/view/shape/Shape.ts, packages/ts-example/src/custom-shapes.ts, README.md
Adds extension guidance for subclasses, patches, shapes, and custom styles. Updates plugin documentation and changes shape defaults to be reapplied after style resets.
Migration guide and references
packages/website/docs/guides/migrate-from-mxgraph.md, packages/website/docusaurus.config.ts, packages/website/docs/usage/_category_.json, packages/website/docs/usage/graph.md, packages/website/docs/manual/cells.md, README.md, docs/adr/*
Moves the migration guide into Guides, updates its content and links, and adds a redirect from its previous URL.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Merge Risk: 🔵 Low · up to f5873

Readers who copy this setup for rectangular or mixed-shape diagrams may see edges attach incorrectly. Keep the rectangular default or scope the ellipse override; this is a localized documentation issue.

Architecture Summary

Architecture risk: 🔵 Low · up to f5873

The change affects 6 systems.

Changed systems: packages/website, docs, CLAUDE.md, packages/core, packages/ts-example, README.md

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/website (library) was modified; 17 changed files map to changed impact.
  • observed — docs (service) was modified; 2 changed files map to changed impact.
  • observed — CLAUDE.md (service) was modified; 1 changed file maps to changed impact.
  • observed — packages/core (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in CLAUDE.md: Adds references to the website documentation rules covering website-doc changes and guide structure.
  • observed — Modified behavior in README.md: The TypeScript selected-features example description now specifies that it draws the same diagram without custom shape classes, reproducing their appearance with plain style properties.
  • observed — Modified behavior in README.md: The JavaScript selected-features example description was re-added unchanged; the old hunk’s removal is part of the surrounding replacement.
  • observed — Modified behavior in README.md: The migration guide link now targets guides/migrate-from-mxgraph.md instead of usage/migrate-from-mxgraph.md.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a Guides section for task-oriented documentation pages.
Description check ✅ Passed The description provides a detailed rationale, scope, verification approach, migration impact, and related work. It omits the template checklist and explicit confirmations for issue assignment, tests,…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/website/docs/guides/configure-basegraph.md Outdated
| 0.23.0 | Graph mixins start moving into plugins: `TooltipMixin` disappears, its methods becoming those of `TooltipHandler` |
| 0.24.0 | A dedicated registration helper per built-in `EdgeStyle`, and the image bundle feature moves to a plugin |
| 0.25.0 | The cell handlers move from `AbstractGraph` to the `SelectionCellsHandler` plugin, so an application that does not register that plugin no longer bundles `VertexHandler`, `EdgeHandler`, `ElbowEdgeHandler` and `EdgeSegmentHandler` |
| 0.25.0 | The cell handlers move from `AbstractGraph` to the `SelectionCellsHandler` plugin, so an application that does not register that plugin no longer bundles `VertexHandler`, `EdgeHandler`, `ElbowEdgeHandler` and `EdgeSegmentHandler`. `registerDefaultStyleElements()` also appears, grouping the four style `registerDefault*` functions in a single call |

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nitpick: remove refs to registerDefaultStyleElements, not related to tree-shaking. This is an helpers that avoid to call several functions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed for this table, which lists what each version removed from a bundle. registerDefaultStyleElements() groups four registration calls and removes nothing, so it does not belong in it. Dropped in f587301.

I kept the two other mentions on the page, since both warn against the helper rather than present it as a gain: one in the section contrasting the broad shortcut with the narrow registration, the other in the list of what not to load, where calling it "to be safe" is named as an anti-pattern. Tell me if you want those gone as well.

Comment thread packages/website/docs/guides/reduce-bundle-size.md Outdated
Comment thread packages/website/docs/guides/reduce-bundle-size.md Outdated
Comment thread packages/website/docs/guides/reduce-bundle-size.md
Review findings on the Guides section, each checked against the sources rather than taken as a wording preference.

The default vertex and edge styles are returned by reference from the `Stylesheet` map, so one property can be assigned
in place. Spreading the whole object into `putDefaultVertexStyle` restated every value to change one, and needed a
warning about the merge that the shorter form makes pointless. The class JSDoc already documents the in place form.

The over-trimming table said an unrouted edge becomes a straight line between its terminals. `GraphView.updatePoints`
falls back to the waypoints of the geometry when no edge style resolves, so that is only true of an edge without any.
The same table named the arrow head alone, where `ConnectorShape.createMarker` runs for `startArrow` and `endArrow`
alike and the symbol a registration carries can be any shape.

The sizes of step 7 are tied to a version, which the page said in a paragraph placed after them, so a first reader met
the numbers before learning what they were measured on. Moved ahead of them.

`registerDefaultStyleElements()` leaves the tree-shaking milestone table: it groups four registration calls for
convenience and removes nothing from a bundle, so it is not an improvement of that kind.
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 9dc88b8f-23dc-42b3-b168-5518d768c8d3

📥 Commits

Reviewing files that changed from the base of the PR and between e630d48 and f587301.

📒 Files selected for processing (3)
  • packages/website/docs/guides/configure-basegraph.md
  • packages/website/docs/guides/reduce-bundle-size.md
  • packages/website/docs/usage/tree-shaking.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/website/docs/guides/reduce-bundle-size.md
  • packages/website/docs/usage/tree-shaking.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

const stylesheet = graph.getStylesheet();

const defaultVertexStyle = stylesheet.getDefaultVertexStyle();
defaultVertexStyle.perimeter = 'ellipsePerimeter';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '145,205p' packages/website/docs/guides/configure-basegraph.md
sed -n '45,95p' packages/core/src/view/style/Stylesheet.ts
rg -n 'ellipsePerimeter|rectanglePerimeter|defaultVertexStyle' packages/website/docs/guides/configure-basegraph.md

Repository: maxGraph/maxGraph

Length of output: 5467


Match the default perimeter to the documented vertex shapes.

The guide documents both plain rectangles and ellipse styles, but the shared default vertex style still uses shape: 'rectangle'. Setting only defaultVertexStyle.perimeter to ellipsePerimeter can give rectangular vertices incorrect edge endpoints unless every rectangle overrides its perimeter.

Keep rectanglePerimeter as the default for mixed-shape graphs, or state that this override applies only to an all-ellipse graph and show the required ellipse style override.

This branch has not been deployed

No deployments
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.

1 participant