Skip to content

[Omnidoc] Link examples from each prop#6899

Merged
ckifer merged 5 commits intomainfrom
example-link
Jan 18, 2026
Merged

[Omnidoc] Link examples from each prop#6899
ckifer merged 5 commits intomainfrom
example-link

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Jan 17, 2026

Description

Reuses the parser from #6897 to automatically generate a link to relevant example for each component and each prop in the docs.

Related Issue

#6069

Summary by CodeRabbit

  • Documentation
    • Richly expanded API docs with per-prop example links and new top-level example link lists across many components, improving discoverability and usage guidance.
  • Tests
    • Tests updated to validate example retrieval and deduplication; example data shape expectations adjusted to include name+URL objects.
  • Chores
    • Added lightweight Storybook arg-type placeholders and a small public example label update for clearer UI display.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Walkthrough

GenerateApiDoc and its helpers were updated to accept and thread an ExampleReader; ExampleReader now returns ExampleResult objects (name+url). Tests and Storybook arg generation were updated to pass ExampleReader. Many API doc files were enriched with per-prop examples and top-level links metadata.

Changes

Cohort / File(s) Summary
Core omnidoc generator
omnidoc/generateApiDoc.ts, omnidoc/generateApiDoc.spec.ts, omnidoc/generateStorybookArgs.ts
Threaded ExampleReader through generateApiDoc, getLinksFromProp, and getLinksFromComponent signatures; updated call sites and tests to pass an ExampleReader instance.
Example reader
omnidoc/readExamples.ts, omnidoc/readExamples.spec.ts
Introduced ExampleResult { name, url }; ExampleReader.getExamples now returns ExampleResult[]; internal maps changed to store ExampleResult entries; tests updated to expect object shape.
Tests referencing examples
omnidoc/readProject.spec.ts, omnidoc/generateApiDoc.spec.ts, omnidoc/verifyExamples.spec.ts
Tests updated to instantiate and pass ExampleReader; assertions adjusted for ExampleResult objects and deduplication; verifyExamples list extended with additional symbols.
Storybook arg-types (generated)
storybook/stories/API/arg-types/useActiveTooltipCoordinateArgs.ts, storybook/stories/API/arg-types/useIsTooltipActiveArgs.ts
Added two auto-generated empty StorybookArgs files.
API docs enrichment (many files)
www/src/docs/api/*.tsx (AreaAPI, AreaChartAPI, BarAPI, BarChartAPI, BarStackAPI, BrushAPI, CartesianGridAPI, CellAPI, ComposedChartAPI, DefaultLegendContentAPI, DefaultTooltipContentAPI, DefaultZIndexesAPI, ErrorBarAPI, LabelAPI, LabelListAPI, LegendAPI, LineAPI, LineChartAPI, PieAPI, PieChartAPI, PolarAngleAxisAPI, PolarGridAPI, PolarRadiusAxisAPI, RadarAPI, RadarChartAPI, RadialBarAPI, RadialBarChartAPI, RectangleAPI, ReferenceLineAPI, ResponsiveContainerAPI, ScatterAPI, ScatterChartAPI, SectorAPI, TooltipAPI, TreemapAPI, XAxisAPI, YAxisAPI, ZAxisAPI)
Added per-prop examples arrays and new top-level links arrays across many ApiDoc exports; multiple prop descriptors converted to richer objects including examples metadata.
API examples label change
www/src/docs/apiExamples/useChartWidth/index.ts
Renamed an example display name ('Simple Line Chart Example''useChartWidth API Example').
Minor doc JSDoc fix
src/cartesian/Bar.tsx
Adjusted JSDoc link trailing slash for min bar height example (docs reference only).

Sequence Diagram(s)

sequenceDiagram
  participant Generator as generateApiDoc
  participant Reader as ExampleReader
  participant Project as ProjectDocReader
  participant Output as ApiDoc

  Note over Generator,Reader: New flow threads ExampleReader through link gathering

  Generator->>Reader: request getExamples(component[, prop])
  Reader-->>Generator: ExampleResult[] (name, url)
  Generator->>Project: read JSDoc links for component/prop
  Project-->>Generator: JSDoc links
  Generator->>Generator: merge & dedupe JSDoc links + ExampleResult entries
  Generator-->>Output: ApiDoc (props + examples + links)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is minimal but includes related issue reference and a brief mention of reusing a parser; however, it lacks most required template sections (Motivation/Context, Testing details, Types of changes, and Checklist items) that would provide comprehensive context for reviewers. Expand the description to include Motivation and Context, How it was tested, and complete the Types of changes and Checklist sections for better documentation clarity.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title '[Omnidoc] Link examples from each prop' clearly and concisely describes the main change: automatically linking examples from documentation for each prop, which aligns with the PR's primary objective of reusing a parser to generate example links.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
www/src/docs/api/ZAxisAPI.tsx (1)

106-131: Add examples to zAxisId prop to match documentation pattern for xAxisId and yAxisId.

The zAxisId property (lines 172-184) lacks an examples array, while the corresponding xAxisId and yAxisId properties in XAxisAPI.tsx and YAxisAPI.tsx both include examples showing multi-axis scenarios. For consistency and to help users understand when multiple Z-axes are needed, add relevant example links (e.g., scatter chart examples that use multiple Z-axes).

🤖 Fix all issues with AI agents
In `@omnidoc/readExamples.ts`:
- Around line 70-83: The merge currently iterates implicitExamples into
explicitExamples causing implicit entries to overwrite explicit ones; change the
merge so explicitExamples take precedence by either (a) creating a new Map from
implicitExamples and then copying explicitExamples into it, or (b) iterating
explicitExamples and setting those into implicitExamples, then return the
combined map values; update the merge logic referencing the explicitExamples and
implicitExamples Maps accordingly so explicit examples override implicit when
URLs collide.

In `@www/src/docs/api/BarAPI.tsx`:
- Around line 327-330: The examples array in BarAPI.tsx contains duplicate
entries for the same demo with inconsistent URL formatting (one with trailing
slash and one without); update the data or dedupe logic to normalize URLs (e.g.,
trim trailing slashes) before comparison so duplicates are collapsed, or simply
remove one of the two entries in the examples array (the objects containing name
'Chart with min bar height' / 'Bar Chart With Min Height' and url
'/examples/BarChartWithMinHeight' vs '/examples/BarChartWithMinHeight/').
🧹 Nitpick comments (7)
www/src/docs/api/SectorAPI.tsx (1)

33-35: Consider extracting the repeated example object into a shared constant.

This avoids duplication across multiple props and the top-level links, making future edits safer.

♻️ Proposed refactor
 import { ApiDoc } from './types';
 
+const customActiveShapeExample = {
+  name: 'Custom Active Shape Pie Chart',
+  url: '/examples/CustomActiveShapePieChart/',
+  isExternal: false,
+};
+
 export const SectorAPI: ApiDoc = {
   name: 'Sector',
   props: [
@@
-      examples: [
-        { name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false },
-      ],
+      examples: [customActiveShapeExample],
@@
-      examples: [
-        { name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false },
-      ],
+      examples: [customActiveShapeExample],
@@
-      examples: [
-        { name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false },
-      ],
+      examples: [customActiveShapeExample],
@@
-      examples: [
-        { name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false },
-      ],
+      examples: [customActiveShapeExample],
@@
-      examples: [
-        { name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false },
-      ],
+      examples: [customActiveShapeExample],
@@
-      examples: [
-        { name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false },
-      ],
+      examples: [customActiveShapeExample],
@@
-  links: [{ name: 'Custom Active Shape Pie Chart', url: '/examples/CustomActiveShapePieChart/', isExternal: false }],
+  links: [customActiveShapeExample],
 };

Also applies to: 49-51, 65-67, 94-96, 110-112, 126-128, 226-227

www/src/docs/api/RadialBarAPI.tsx (1)

444-444: LGTM!

Root-level links array correctly added to the API documentation.

Consider extracting the repeated example object into a shared constant if these files are manually maintained. However, if this is auto-generated by the parser mentioned in the PR description, this suggestion can be disregarded.

www/src/docs/api/ErrorBarAPI.tsx (1)

100-108: Consider extracting repeated example object to a constant.

The same example object is defined 4 times in this file. If this file is manually maintained (rather than fully auto-generated), extracting it to a constant would improve maintainability.

♻️ Optional refactor
+const candlestickExample = { name: 'Candlestick', url: '/examples/Candlestick/', isExternal: false };
+
 export const ErrorBarAPI: ApiDoc = {
   name: 'ErrorBar',
   props: [
     {
       name: 'dataKey',
       // ...
-      examples: [{ name: 'Candlestick', url: '/examples/Candlestick/', isExternal: false }],
+      examples: [candlestickExample],
     },
     // ... apply similarly to other occurrences
   ],
-  links: [{ name: 'Candlestick', url: '/examples/Candlestick/', isExternal: false }],
+  links: [candlestickExample],
 };
www/src/docs/api/TooltipAPI.tsx (1)

154-170: Consider adding a desc field for consistency.

The defaultIndex prop is missing a description while most other props in this file have one. A brief explanation of what this prop controls (e.g., initial active tooltip index) and how null, number, and string values behave would help users understand its purpose.

📝 Suggested addition
     {
       name: 'defaultIndex',
       type: 'null | number | string',
       isOptional: true,
+      desc: {
+        'en-US': (
+          <section>
+            <p>
+              Sets the initial active index for the tooltip. When set, the tooltip will display data for this index on mount.
+            </p>
+          </section>
+        ),
+      },
       examples: [
         { name: 'Population Pyramid', url: '/examples/PopulationPyramid/', isExternal: false },
omnidoc/readExamples.ts (1)

280-291: Redundant type guard.

The check Node.isObjectLiteralExpression(element) at line 283 is redundant since the outer condition at line 258 already confirms element is an ObjectLiteralExpression.

♻️ Simplify by removing redundant check
                if (componentSourceFile) {
                  const filePath = componentSourceFile.getFilePath();

                  // Try to find 'name' property in the object literal
                  let name = 'Example';
-                  if (Node.isObjectLiteralExpression(element)) {
-                    const nameProp = element.getProperty('name');
-                    if (nameProp && Node.isPropertyAssignment(nameProp)) {
-                      const nameInitializer = nameProp.getInitializerIfKind(SyntaxKind.StringLiteral);
-                      if (nameInitializer) {
-                        name = nameInitializer.getLiteralValue();
-                      }
+                  const nameProp = element.getProperty('name');
+                  if (nameProp && Node.isPropertyAssignment(nameProp)) {
+                    const nameInitializer = nameProp.getInitializerIfKind(SyntaxKind.StringLiteral);
+                    if (nameInitializer) {
+                      name = nameInitializer.getLiteralValue();
                     }
                   }
www/src/docs/api/ComposedChartAPI.tsx (1)

216-225: Consider adding "Composed Responsive Container" example for consistency.

The responsive prop examples list 8 Area Chart examples but omits the "Composed Responsive Container" example that appears in the top-level links array (line 505) and other props like children, data, and margin. Since responsive is directly related to responsive container behavior, this example seems particularly relevant here.

Suggested addition
       { name: 'Target Price Chart with active Label', url: '/examples/TargetPriceChart/', isExternal: false },
+      { name: 'Composed Responsive Container', url: '/examples/ComposedResponsiveContainer/', isExternal: false },
     ],
www/src/docs/api/AreaChartAPI.tsx (1)

208-218: Consider adding "Area Responsive Container" example.

The responsive prop's examples list includes the "Chart sizing guide" but doesn't include the "Area Responsive Container" example that appears in the top-level links array (line 492). Since this prop directly controls responsive behavior, the responsive container example would be highly relevant.

Suggested addition
       { name: 'Area Chart Fill By Value', url: '/examples/AreaChartFillByValue/', isExternal: false },
+      { name: 'Area Responsive Container', url: '/examples/AreaResponsiveContainer/', isExternal: false },
     ],

@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.43%. Comparing base (a2c1e23) to head (4e7f1d4).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6899      +/-   ##
==========================================
+ Coverage   94.27%   94.43%   +0.15%     
==========================================
  Files         565      565              
  Lines       53858    55259    +1401     
  Branches     5178     5178              
==========================================
+ Hits        50777    52182    +1405     
+ Misses       3072     3068       -4     
  Partials        9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@codecov
Copy link

codecov bot commented Jan 18, 2026

Bundle Report

Bundle size has no change ✅

@ckifer ckifer merged commit 23a42f4 into main Jan 18, 2026
48 checks passed
@PavelVanecek PavelVanecek deleted the example-link branch January 18, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants