Skip to content

Commit fb06ed3

Browse files
committed
Update scripts
1 parent 450877e commit fb06ed3

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var fs = require( 'fs' );
24+
var path = require( 'path' );
25+
var flattenObject = require( '@stdlib/utils/flatten-object' );
26+
var objectKeys = require( '@stdlib/utils/keys' );
27+
var exists = require( '@stdlib/fs/exists' ).sync;
28+
var version = require( './../../../../package.json' ).version;
29+
var tree = require( '../public/assets/v'+version+'/package_tree.json' );
30+
31+
32+
// MAIN //
33+
34+
var docsPath = path.resolve( __dirname, '..', 'public', 'assets', 'v'+version );
35+
36+
// Create object with information on each package about whether it has benchmarks and tests:
37+
var paths = flattenObject( tree, {
38+
'delimiter': '/'
39+
});
40+
41+
var keys = objectKeys( paths );
42+
43+
for ( var i = 0; i < keys.length; i++ ) {
44+
console.log( path.join( docsPath, '@stdlib', keys[ i ], 'test.html' ) );
45+
console.log( exists( path.join( docsPath, '@stdlib', keys[ i ], 'test.html' ) ) )
46+
paths[ keys[ i ] ] = {
47+
'benchmark': exists( path.join( docsPath, '@stdlib', keys[ i ], 'benchmark.html' ) ),
48+
'test': exists( path.join( docsPath, '@stdlib', keys[ i ], 'test.html' ) )
49+
}
50+
}
51+
fs.writeFileSync( path.join( docsPath, 'package_resources.json' ), JSON.stringify( paths ) );

tools/docs/www/scripts/generate_docs.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* @license Apache-2.0
43
*
@@ -17,6 +16,8 @@
1716
* limitations under the License.
1817
*/
1918

19+
'use strict';
20+
2021
// MODULES //
2122

2223
var fs = require( 'fs' );
@@ -38,9 +39,13 @@ var tree = pkgTree.sync();
3839
// Index one level into the tree:
3940
tree = tree[ '@stdlib' ];
4041

42+
// Hide internal tools from user-facing documentation:
43+
delete tree[ '_tools' ];
44+
4145
// Create and save HTML fragments:
4246

43-
var docsPath = path.resolve( __dirname, '..', 'public', 'assets', 'v'+version );
47+
var assetPath = path.resolve( __dirname, '..', 'public', 'assets' );
48+
var docsPath = path.resolve( assetPath, 'v'+version );
4449

4550
var dir = path.resolve( __dirname, './../../../../lib/node_modules' );
4651
var opts = {
@@ -117,4 +122,4 @@ function onBenchmarks( err ) {
117122
}
118123

119124
// Save JSON file to source directory to populate sidebar menu:
120-
fs.writeFileSync( path.join( docsPath, 'package_tree.json' ), JSON.stringify( tree, null, 2 ) );
125+
fs.writeFileSync( path.join( docsPath, 'package_tree.json' ), JSON.stringify( tree ) );

0 commit comments

Comments
 (0)