Skip to content

Commit 04e7579

Browse files
committed
Updates to docs
1 parent ef00b67 commit 04e7579

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

src/babylonjs/renderer/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ constructor( scene: Scene )
3636
### .parse
3737

3838
```js
39-
parse( buffer: ArrayBuffer, uri: string ): Promise<Object>
39+
async parse( buffer: ArrayBuffer, uri: string ): Promise<Object>
4040
```
4141

4242

@@ -75,7 +75,7 @@ constructor( scene: Scene )
7575
### .parse
7676

7777
```js
78-
parse(
78+
async parse(
7979
buffer: ArrayBuffer,
8080
uri: string,
8181
extension: string

src/three/plugins/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,11 @@ for how to obtain these values.
857857
### .getPropertyTextureDataAsync
858858
859859
```js
860-
getPropertyTextureDataAsync(
860+
async getPropertyTextureDataAsync(
861861
triangle: number,
862862
barycoord: Vector3,
863863
target = []: Array
864-
): Promise<Array>
864+
): Array
865865
```
866866
867867
Returns the same data as `getPropertyTextureData` but performs texture reads

src/three/plugins/gltf/metadata/classes/StructuralMetadata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class StructuralMetadata {
170170
* @param {number} triangle Triangle index from a raycast hit.
171171
* @param {Vector3} barycoord Barycentric coordinate of the hit point.
172172
* @param {Array} [target=[]] Optional target array to write into.
173-
* @returns {Promise<Array>}
173+
* @returns {Array}
174174
*/
175175
async getPropertyTextureDataAsync( triangle, barycoord, target = [] ) {
176176

utils/docs/RenderDocsUtils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ function renderCallable( doc, heading, sigPrefix, callbackMap ) {
309309
export function renderMethod( doc, callbackMap = {} ) {
310310

311311
const isStatic = doc.scope === 'static';
312-
const prefix = isStatic ? 'static ' : '';
313-
return renderCallable( doc, `### ${ prefix }.${ doc.name }`, prefix, callbackMap );
312+
const headingPrefix = isStatic ? 'static ' : '';
313+
const sigPrefix = isStatic ? `static ${ doc.async ? 'async ' : '' }` : ( doc.async ? 'async ' : '' );
314+
return renderCallable( doc, `### ${ headingPrefix }.${ doc.name }`, sigPrefix, callbackMap );
314315

315316
}
316317

utils/docs/build.js

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ const ENTRY_POINTS = [
4040
];
4141

4242
// Run JSDoc for all entry points and build a global type registry for cross-file links
43-
const results = ENTRY_POINTS.map( entry => ( {
44-
entry,
45-
jsdoc: filterDocumented( runJsDoc( path.resolve( ROOT_DIR, entry.source ) ) )
46-
} ) );
43+
const results = ENTRY_POINTS.map( entry => {
44+
45+
let jsdoc = filterDocumented( runJsDoc( path.resolve( ROOT_DIR, entry.source ) ) );
46+
if ( entry.exclude ) {
47+
48+
const excludePath = path.resolve( ROOT_DIR, entry.exclude );
49+
jsdoc = jsdoc.filter( d => ! d.meta || ! d.meta.path || ! d.meta.path.startsWith( excludePath ) );
50+
51+
}
52+
53+
return { entry, jsdoc };
54+
55+
} );
4756

4857
// Doclet type predicates
4958
const isClass = d => d.kind === 'class';
@@ -69,7 +78,8 @@ for ( const { entry, jsdoc } of results ) {
6978

7079
}
7180

72-
// Pass 2: render each entry point.
81+
// Pass 2: render each entry point and accumulate sections per output file.
82+
const outputSections = {}; // output file -> accumulated sections array
7383
for ( const { entry, jsdoc } of results ) {
7484

7585
const resolveLink = name => {
@@ -173,7 +183,7 @@ for ( const { entry, jsdoc } of results ) {
173183

174184
}
175185

176-
// construct the readme files
186+
// construct sections for this entry point
177187
const sections = [ `# ${ entry.title }`, '' ];
178188

179189
for ( const [ groupName, consts ] of Object.entries( constsByGroup ) ) {
@@ -207,23 +217,23 @@ for ( const { entry, jsdoc } of results ) {
207217

208218
}
209219

210-
const header = '<!-- This file is generated automatically. Do not edit it directly. -->\n';
211-
const output = header + resolveLinks( sections.join( '\n' ) );
212-
fs.writeFileSync( path.join( ROOT_DIR, entry.output ), output );
213-
console.log( `Written: ${ entry.output }` );
220+
if ( ! outputSections[ entry.output ] ) outputSections[ entry.output ] = [];
221+
outputSections[ entry.output ].push( ...sections );
214222

215223
}
216224

217-
//
218-
219-
function runJsDoc( source ) {
225+
// Write each output file once, after all entry points have been processed.
226+
const header = '<!-- This file is generated automatically. Do not edit it directly. -->\n';
227+
for ( const [ outputFile, sections ] of Object.entries( outputSections ) ) {
220228

221-
// Default maxBuffer is 1 MB; large source directories can exceed that, so raise it to 32 MB.
222-
const result = execSync( `npx jsdoc -X -r "${ source }"`, { maxBuffer: 32 * 1024 * 1024 } ).toString();
223-
return JSON.parse( result );
229+
const output = header + resolveLinks( sections.join( '\n' ) );
230+
fs.writeFileSync( path.join( ROOT_DIR, outputFile ), output );
231+
console.log( `Written: ${ outputFile }` );
224232

225233
}
226234

235+
//
236+
227237
function groupByTag( docs, predicate, defaultGroup ) {
228238

229239
const groups = {};
@@ -240,6 +250,14 @@ function groupByTag( docs, predicate, defaultGroup ) {
240250

241251
}
242252

253+
function runJsDoc( source ) {
254+
255+
// Default maxBuffer is 1 MB; large source directories can exceed that, so raise it to 32 MB.
256+
const result = execSync( `npx jsdoc -X -r "${ source }"`, { maxBuffer: 32 * 1024 * 1024 } ).toString();
257+
return JSON.parse( result );
258+
259+
}
260+
243261
// Topological sort: every parent class appears before its subclasses.
244262
// Siblings (subclasses sharing the same parent) are kept together and ordered alphabetically.
245263
function topologicalSortClasses( classes ) {

0 commit comments

Comments
 (0)