|
1 |
| -const { readdirSync } = require('fs'); |
| 1 | +const { readdirSync, readFileSync } = require('fs'); |
2 | 2 | const cmp = require('semver-compare');
|
3 | 3 | const semver = require('semver');
|
4 | 4 |
|
@@ -40,12 +40,50 @@ module.exports = function () {
|
40 | 40 |
|
41 | 41 | ['classes', 'namespaces', 'modules'].forEach((entity) => {
|
42 | 42 | // add classes
|
43 |
| - revIndex.data.relationships[entity].data.forEach(({id}) => { |
| 43 | + revIndex.data.relationships[entity].data.forEach(({ id }) => { |
44 | 44 | const [, cleanId] = id.match(/^.+-\d+\.\d+\.\d+-(.*)/);
|
45 | 45 | urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}`);
|
| 46 | + |
| 47 | + // TODO only include sub routes if that entity has stuff in that route i.e. if it's empty don't pre-render it |
46 | 48 | urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}/methods`);
|
47 | 49 | urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}/properties`);
|
48 | 50 | urls.push(`/${p}/${uniqVersion}/${entity}/${cleanId}/events`);
|
| 51 | + |
| 52 | + if (entity === 'modules') { |
| 53 | + // id is |
| 54 | + |
| 55 | + const moduleKey = `${encodeURIComponent(id)}`; |
| 56 | + const fileName = revIndex.meta.module[moduleKey]; |
| 57 | + |
| 58 | + if (fileName === undefined) { |
| 59 | + // rare cases when very strange things make it through this far |
| 60 | + // e.g. ember-3.0.0-ember%0A%0ARemove%20after%203.4%20once%20_ENABLE_RENDER_SUPPORT%20flag%20is%20no%20longer%20needed. |
| 61 | + // 🤷♀️ |
| 62 | + return; |
| 63 | + } |
| 64 | + |
| 65 | + const moduleData = require(`${__dirname}/ember-api-docs-data/json-docs/${p}/${highestPatchVersion}/modules/${fileName}.json`); |
| 66 | + |
| 67 | + const staticFunctions = moduleData.data.attributes.staticfunctions; |
| 68 | + |
| 69 | + Object.keys(staticFunctions).forEach((k) => { |
| 70 | + const listOfFunctions = staticFunctions[k]; |
| 71 | + |
| 72 | + listOfFunctions.forEach((func) => { |
| 73 | + urls.push( |
| 74 | + `/${p}/${uniqVersion}/functions/${cleanId.replace( |
| 75 | + '/', |
| 76 | + '%2F' |
| 77 | + )}/${func.name}` |
| 78 | + ); |
| 79 | + }); |
| 80 | + }); |
| 81 | + } |
| 82 | + |
| 83 | + // TODO review that we have got all the URLs that we care about |
| 84 | + |
| 85 | + // TODO discuss only prembering "supported" versions - maybe last version in a major and supported versions |
| 86 | + // alternative is to rely on netlify complex build |
49 | 87 | });
|
50 | 88 | });
|
51 | 89 | });
|
|
0 commit comments