Skip to content

Commit f0204f7

Browse files
authored
feat: smart commits blocked, also fixed doc generation (#2614)
* fix: bundle requires browser output in platform (#2608) * fix: bundle requires browser output in platform * fix: rolldown issues * fix: finalize rollup * chore: prettier * chore: prettier * fix: adjust root name for better local linking. Dist folder package confused pnpm * fix: update lockfile for ci * fix: update tests for unbuild * fix: simplified canary * fix: package name copying * feat: cleaned up docs, please god trigger a push * feat: actual push, I hate git * feat: prettier changes
1 parent bc75ea1 commit f0204f7

File tree

6 files changed

+28
-98
lines changed

6 files changed

+28
-98
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ __diff_output__
2424
# IDE/editor files
2525
.idea
2626
.vscode
27+
.claude/settings.local.json
2728

2829
# Package/lock files
2930
package-lock.json

docs/loaders/use-gltf.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ useGLTF.setDecoderPath(path)
5757
If for example your model [`facecap.glb`](https://github.com/mrdoob/three.js/blob/master/examples/models/gltf/facecap.glb) needs KTX2 textures, you can `extendLoader`:
5858

5959
```tsx
60-
import { KTX2Loader } from 'three-stdlib'
60+
import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader'
6161
const ktx2Loader = new KTX2Loader()
6262
ktx2Loader.setTranscoderPath('https://unpkg.com/three@0.168.0/examples/jsm/libs/basis/')
6363

docs/misc/example.mdx

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,9 @@
11
---
22
title: Example
3-
sourcecode: src/core/Example.tsx
3+
sourcecode: src/core/Helpers/Example/Example.tsx
44
---
55

6-
[![](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.vercel.app/?path=/story/misc-example--example-st)
6+
[![](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.pmnd.rs/?path=/story/misc-example--example-st)
77

8-
> [!Note]
9-
> Solely for [`CONTRIBUTING`](CONTRIBUTING.md#example) purposes
8+
A simple counter example component. Click to increment, meta-click to decrement.
109

11-
A "counter" example.
12-
13-
```tsx
14-
<Example font="/Inter_Bold.json" />
15-
```
16-
17-
```tsx
18-
type ExampleProps = {
19-
font: string
20-
color?: Color
21-
debug?: boolean
22-
bevelSize?: number
23-
}
24-
```
25-
26-
Ref-api:
27-
28-
```tsx
29-
const api = useRef<ExampleApi>()
30-
31-
<Example ref={api} font="/Inter_Bold.json" />
32-
```
33-
34-
```tsx
35-
type ExampleApi = {
36-
incr: (x?: number) => void
37-
decr: (x?: number) => void
38-
}
39-
```

docs/portals/view.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sourcecode: src/core/Portal/View/View.tsx
2020
</li>
2121
</Grid>
2222

23-
Uses gl.scissor to create viewport segments tied to HTML tracking elements.
23+
Uses renderer.scissor to create viewport segments tied to HTML tracking elements.
2424
Allows multiple views with a single canvas. Views follow their tracking elements,
2525
scroll, resize, etc. Use View.Port inside Canvas to render all views.
2626

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
#!/usr/bin/env ts-node
1+
#!/usr/bin/env node
22

33
//* Docs Generation Config ==============================
44
// Configuration for TSDoc to MDX documentation generation
55

66
import * as path from 'path'
7+
import { fileURLToPath } from 'url'
8+
9+
const __filename = fileURLToPath(import.meta.url)
10+
const __dirname = path.dirname(__filename)
711

812
// Source Directories --------------------------------------
913
// Maps component category folders to their doc output folders
10-
export const docCategories: Record<string, string> = {
14+
export const docCategories = {
1115
Abstractions: 'abstractions',
1216
Cameras: 'cameras',
1317
Controls: 'controls',
@@ -24,7 +28,7 @@ export const docCategories: Record<string, string> = {
2428
}
2529

2630
// Tiers to process (folders under src/)
27-
export const tiers = ['core', 'web', 'external', 'experimental'] as const
31+
export const tiers = ['core', 'web', 'external', 'experimental']
2832

2933
// Injection Tags --------------------------------------
3034
// Tags that can be used in .docs.mdx templates to inject auto-generated content
@@ -34,9 +38,7 @@ export const injectionTags = [
3438
'AUTO:props', // Props table generated from types
3539
'AUTO:badges', // Storybook/suspense badges
3640
'AUTO:all', // All of the above in default order
37-
] as const
38-
39-
export type InjectionTag = (typeof injectionTags)[number]
41+
]
4042

4143
// Paths --------------------------------------
4244
export const paths = {
@@ -47,7 +49,7 @@ export const paths = {
4749

4850
// Badge Templates --------------------------------------
4951
export const badges = {
50-
storybook: (storyPath: string) =>
52+
storybook: (storyPath) =>
5153
`[![](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.pmnd.rs/?path=/story/${storyPath})`,
5254
suspense: '[![](https://img.shields.io/badge/-suspense-brightgreen)](https://r3f.docs.pmnd.rs/api/hooks#useloader)',
5355
domOnly: '![](https://img.shields.io/badge/-Dom%20only-red)',
@@ -56,16 +58,7 @@ export const badges = {
5658

5759
// Component Metadata Overrides --------------------------------------
5860
// For components that need special handling or metadata not derivable from TSDoc
59-
export const componentOverrides: Record<
60-
string,
61-
{
62-
title?: string
63-
badges?: string[]
64-
storyPath?: string
65-
suspense?: boolean
66-
domOnly?: boolean
67-
}
68-
> = {
61+
export const componentOverrides = {
6962
// Example overrides - add as needed
7063
// 'Html': { domOnly: true },
7164
// 'useGLTF': { suspense: true },
@@ -87,7 +80,7 @@ export const filePatterns = {
8780
* - useGLTF -> use-gltf
8881
* - Text3D -> text3d
8982
*/
90-
export function toKebabCase(name: string): string {
83+
export function toKebabCase(name) {
9184
return name
9285
.replace(/([a-z])([A-Z])/g, '$1-$2') // Add hyphen between camelCase boundaries
9386
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2') // Handle consecutive caps like GLTF -> gltf
@@ -97,6 +90,6 @@ export function toKebabCase(name: string): string {
9790
/**
9891
* Generate the output filename for a component's documentation.
9992
*/
100-
export function getDocFileName(componentName: string): string {
93+
export function getDocFileName(componentName) {
10194
return `${toKebabCase(componentName)}.mdx`
10295
}

scripts/generate-docs.ts

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,10 @@ import * as fs from 'fs'
88
import * as path from 'path'
99
import * as chokidar from 'chokidar'
1010
import { parse as parseComment } from 'comment-parser'
11-
import { withCompilerOptions, PropItem } from 'react-docgen-typescript'
12-
import {
13-
docCategories,
14-
tiers,
15-
paths,
16-
badges,
17-
componentOverrides,
18-
InjectionTag,
19-
toKebabCase,
20-
getDocFileName,
21-
} from './docs-config'
22-
23-
//* Types ==============================
24-
25-
interface ExtractedDoc {
26-
name: string
27-
description: string
28-
examples: { title: string; code: string }[]
29-
props: PropInfo[]
30-
see: string[]
31-
remarks: string[]
32-
sourcePath: string
33-
category: string
34-
storyPath: string
35-
}
36-
37-
interface PropInfo {
38-
name: string
39-
type: string
40-
required: boolean
41-
defaultValue: string | null
42-
description: string
43-
}
44-
45-
interface ProcessedComponent {
46-
filePath: string
47-
docsTemplatePath: string | null
48-
outputPath: string
49-
extracted: ExtractedDoc | null
50-
}
11+
import reactDocgen from 'react-docgen-typescript'
12+
const { withCompilerOptions } = reactDocgen
13+
import { docCategories, tiers, paths, badges, componentOverrides, toKebabCase, getDocFileName } from './docs-config.js'
14+
import type { InjectionTag } from './docs-config.js'
5115

5216
//* TSDoc Extraction ==============================
5317

@@ -58,10 +22,10 @@ const docgenParser = withCompilerOptions(
5822
savePropValueAsString: true,
5923
shouldExtractLiteralValuesFromEnum: true,
6024
shouldRemoveUndefinedFromOptional: true,
61-
propFilter: (prop: PropItem) => {
25+
propFilter: (prop: any) => {
6226
// Filter out inherited HTML/React props unless explicitly documented
6327
if (prop.declarations && prop.declarations.length > 0) {
64-
const isFromNodeModules = prop.declarations.some((d) => d.fileName.includes('node_modules'))
28+
const isFromNodeModules = prop.declarations.some((d: any) => d.fileName.includes('node_modules'))
6529
if (isFromNodeModules) return false
6630
}
6731
return true
@@ -678,8 +642,10 @@ function handleFileChange(filePath: string, componentMap: Map<string, ProcessedC
678642
console.log(` ✅ Updated: ${path.relative(paths.docs, component.outputPath)}`)
679643
}
680644

681-
// Run
682-
if (require.main === module) {
645+
// Run (ESM equivalent of require.main === module)
646+
import { fileURLToPath } from 'url'
647+
const __filename = fileURLToPath(import.meta.url)
648+
if (process.argv[1] === __filename) {
683649
main().catch(console.error)
684650
}
685651

0 commit comments

Comments
 (0)