Skip to content

Commit dfc3aa7

Browse files
committed
add all routes for classes namespaces and modules
1 parent 4a5b9fe commit dfc3aa7

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

prember-urls.js

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const { readdirSync } = require('fs');
2+
const cmp = require('semver-compare');
3+
const semver = require('semver');
24

35
module.exports = function () {
46
const projects = readdirSync('ember-api-docs-data/json-docs');
@@ -9,16 +11,43 @@ module.exports = function () {
911
// add release for each of the projects
1012
urls.push(`/${p}/release`);
1113

14+
const fullProjectVersions = readdirSync(
15+
`ember-api-docs-data/json-docs/${p}`
16+
).filter((v) => v.match(/\d+\.\d+\.\d+/));
17+
1218
// add landing page for each of the projects versions
13-
const projectVersions = readdirSync(`ember-api-docs-data/json-docs/${p}`)
14-
.filter((v) => v.match(/\d+\.\d+\.\d+/))
15-
.map((v) => {
16-
let [, major, minor] = v.match(/(\d+)\.(\d+)\.\d+/);
17-
return `${major}.${minor}`;
18-
}); // uniq
19-
20-
[...new Set(projectVersions)].forEach((v) => {
21-
urls.push(`/${p}/${v}`);
19+
const projectVersions = fullProjectVersions.map((v) => {
20+
let [, major, minor] = v.match(/(\d+)\.(\d+)\.\d+/);
21+
return `${major}.${minor}`;
22+
}); // uniq
23+
24+
const uniqueProjectVersions = [...new Set(projectVersions)];
25+
26+
uniqueProjectVersions.forEach((uniqVersion) => {
27+
urls.push(`/${p}/${uniqVersion}`);
28+
29+
const sortedPatchVersions = fullProjectVersions
30+
.filter((projectVersion) => {
31+
// console.log("comparing", projectVersion, uniqVersion, semver.satisfies(projectVersion, uniqVersion))
32+
return semver.satisfies(projectVersion, uniqVersion);
33+
})
34+
.sort(cmp);
35+
36+
const highestPatchVersion =
37+
sortedPatchVersions[sortedPatchVersions.length - 1];
38+
39+
const revIndex = require(`${__dirname}/ember-api-docs-data/rev-index/${p}-${highestPatchVersion}.json`);
40+
41+
['classes', 'namespaces', 'modules'].forEach((entity) => {
42+
// add classes
43+
revIndex.data.relationships[entity].data.forEach(({id}) => {
44+
const [, cleanId] = id.match(/^.+-\d+\.\d+\.\d+-(.*)/);
45+
urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}`);
46+
urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}/methods`);
47+
urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}/properties`);
48+
urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}/events`);
49+
});
50+
});
2251
});
2352
});
2453

@@ -31,4 +60,6 @@ if (process.env.DEBUG === 'prember-urls') {
3160
let urls = module.exports();
3261

3362
urls.forEach((url) => console.log(url));
63+
64+
console.log(`\n${urls.length} total URLs`);
3465
}

0 commit comments

Comments
 (0)