Skip to content

Commit 290e9c3

Browse files
authored
Add "clean" option to start to force process all versions (#62)
1 parent 2e2bbdc commit 290e9c3

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ You need an additional flag `AWS_SHOULD_PUBLISH=true` for publishing the docs.
4343
- First run `yarn start` so that you have all the docs from s3 on your local. This is important so that we don't loose other versions of docs that are already out there when the index files are generated
4444
- Then go to `./tmp/s3-docs/<the_version_you_want_to_replace>` and override the file there with the yuidoc file that you want to be processed. Ensure that the file name is same as the one that's already there.
4545
- Then run `yarn start --project=ember-data --version=3.2.0 --ignorePreviouslyIndexedDoc`. Make sure you enter the entire version(including patch version).
46+
- To run against all versions of ember and ember-data regardless of indexed version, run `node --max_old_space_size=8192 index.js --clean`
4647

4748
## Generating API Documentation and Testing API Docs Locally
4849

@@ -56,7 +57,6 @@ app with documentation pulled from a local copy of ember.js.
5657
- [ember-api-docs](https://github.com/ember-learn/ember-api-docs)
5758
1. Set up the project according to the instructions above in `Running the app`.
5859
1. From the `ember-jsonapi-docs` directory, run `./generate-local.sh yui ember 2.18.0`. This command runs the Ember documentation build, generates jsonapi output, and copies it to the `ember-api-docs` directory. To build ember data documentation, run `./generate-local.sh yui ember-data 2.17.2`.
59-
- \_If you encounter an error like `ember-2.18.0 has already been indexed in json-docs`, then use a new unique version number like `2.18.1`, or whatever is appropriate.
6060
- If your `rev-index/ember-X.X.X.json` file fails to generate, make sure you have all dependencies installed for the ember.js repo
6161
- If you are debugging failed builds, periodically clear out the contents of the `tmp` directory, and run the script again. Past failed runs can cause subsequent runs to fail in unexpected ways.\_
6262
1. Run the API app with the newly generated local data by running `API_HOST=http://localhost:4200 ember s` in the `ember-api-docs` directory.

generate-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fi
3232

3333
cd ../ember-jsonapi-docs
3434
echo "🏃 💨 Running ember-jsonapi-docs for version $VERSION 🏃 💨 "
35-
yarn start -- --project $PROJECT --version $VERSION
35+
yarn start --project $PROJECT --version $VERSION --ignorePreviouslyIndexedDoc
3636
echo "🚚 💨 Copying rev-index json file to ember-api-docs app... 🚚 💨 "
3737
rm -f ../ember-api-docs/public/rev-index/$PROJECT-$VERSION.json
3838
mkdir -p ../ember-api-docs/public/rev-index

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ let specificDocsVersion = argv.version ? argv.version : ''
99

1010
let ignorePreviouslyIndexedDoc =
1111
projects.length !== 0 && specificDocsVersion !== '' && argv.ignorePreviouslyIndexedDoc
12+
let runClean = !!argv.clean
1213

1314
const { apiDocsProcessor } = require('./main.js')
14-
apiDocsProcessor(projects, specificDocsVersion, ignorePreviouslyIndexedDoc)
15+
apiDocsProcessor(projects, specificDocsVersion, ignorePreviouslyIndexedDoc, runClean)

lib/read-docs.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { dasherize } from 'inflected'
77
export default function readDocs(
88
projects,
99
specificVersion = '',
10-
ignorePreviouslyIndexedDoc = false
10+
ignorePreviouslyIndexedDoc = false,
11+
runClean = false
1112
) {
1213
console.log('Reading project files')
1314

@@ -25,14 +26,16 @@ export default function readDocs(
2526
})
2627
}
2728

28-
folders = folders.filter(f => {
29-
if (!prevIndexedVersions.includes(f) || ignorePreviouslyIndexedDoc) {
30-
return f
31-
} else {
32-
let version = f.replace('tmp/s3-docs/v', '').replace(`/${projectName}-docs.json`, '')
33-
console.log(`${projectName}-${version} has already been indexed in json-docs`)
34-
}
35-
})
29+
if (!runClean) {
30+
folders = folders.filter(f => {
31+
if (!prevIndexedVersions.includes(f) || ignorePreviouslyIndexedDoc) {
32+
return f
33+
} else {
34+
let version = f.replace('tmp/s3-docs/v', '').replace(`/${projectName}-docs.json`, '')
35+
console.log(`${projectName}-${version} has already been indexed in json-docs`)
36+
}
37+
})
38+
}
3639

3740
docs[projectName] = folders.map(docs => {
3841
let version = path.basename(path.dirname(docs)).replace('v', '')

main.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import saveDoc from './lib/save-document'
1313
import revProjVersionFiles from './lib/rev-docs'
1414
import { downloadExistingDocsToLocal, uploadToS3 } from './lib/s3-sync'
1515

16-
export function apiDocsProcessor(projects, specificDocsVersion, ignorePreviouslyIndexedDoc) {
16+
export function apiDocsProcessor(
17+
projects,
18+
specificDocsVersion,
19+
ignorePreviouslyIndexedDoc,
20+
runClean
21+
) {
1722
RSVP.on('error', reason => {
1823
console.log(reason)
1924
process.exit(1)
@@ -23,8 +28,8 @@ export function apiDocsProcessor(projects, specificDocsVersion, ignorePreviously
2328
console.log(`Downloading docs for ${projects.join(' & ')}${docsVersionMsg}`)
2429

2530
downloadExistingDocsToLocal()
26-
.then(() => fetchYuiDocs(projects, specificDocsVersion, ignorePreviouslyIndexedDoc))
27-
.then(() => readDocs(projects, specificDocsVersion, ignorePreviouslyIndexedDoc))
31+
.then(() => fetchYuiDocs(projects, specificDocsVersion, ignorePreviouslyIndexedDoc || runClean))
32+
.then(() => readDocs(projects, specificDocsVersion, ignorePreviouslyIndexedDoc, runClean))
2833
.then(docs => {
2934
return RSVP.map(projects, projectName => {
3035
return RSVP.map(docs[projectName], doc => {

0 commit comments

Comments
 (0)