-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from ember-learn/semi
add semis back
- Loading branch information
Showing
31 changed files
with
637 additions
and
638 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ module.exports = { | |
}, | ||
}, | ||
], | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"printWidth": 100, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
// eslint-disable-next-line | ||
require = require('esm')(module /*, options*/) | ||
|
||
const argv = require('minimist')(process.argv.slice(2)) | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
|
||
let possibleProjects = ['ember', 'ember-data'] | ||
let possibleProjects = ['ember', 'ember-data']; | ||
let projects = | ||
argv.project && possibleProjects.includes(argv.project) ? [argv.project] : possibleProjects | ||
let specificDocsVersion = argv.version ? argv.version : '' | ||
argv.project && possibleProjects.includes(argv.project) ? [argv.project] : possibleProjects; | ||
let specificDocsVersion = argv.version ? argv.version : ''; | ||
|
||
let runClean = !!argv.clean | ||
let noSync = !argv.sync | ||
let runClean = !!argv.clean; | ||
let noSync = !argv.sync; | ||
|
||
const { apiDocsProcessor } = require('./main.js') | ||
apiDocsProcessor(projects, specificDocsVersion, runClean, noSync) | ||
const { apiDocsProcessor } = require('./main.js'); | ||
apiDocsProcessor(projects, specificDocsVersion, runClean, noSync); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
import _ from 'lodash' | ||
import _ from 'lodash'; | ||
|
||
export default function addInheritedItems(docSets) { | ||
docSets.forEach(versionData => { | ||
let data = versionData.data | ||
let classes = _.values(data.classes).filter(klass => klass && klass.name) | ||
classes = classes.filter(removeLongDocsBecauseEmber1HasWeirdDocs) | ||
let classItems = data.classitems.filter(({ itemtype }) => itemtype) | ||
let data = versionData.data; | ||
let classes = _.values(data.classes).filter(klass => klass && klass.name); | ||
classes = classes.filter(removeLongDocsBecauseEmber1HasWeirdDocs); | ||
let classItems = data.classitems.filter(({ itemtype }) => itemtype); | ||
|
||
classes.forEach(klass => { | ||
let parents = getParents(klass, classes) | ||
let parents = getParents(klass, classes); | ||
|
||
for (let i = 0; i < parents.length; ++i) { | ||
parents = parents.concat(getParents(parents[i], classes)) | ||
parents = parents.concat(getParents(parents[i], classes)); | ||
} | ||
parents.forEach(parent => { | ||
if (!parent) return | ||
let parentItems = classItems.filter(item => item.class === parent.name) | ||
if (!parent) return; | ||
let parentItems = classItems.filter(item => item.class === parent.name); | ||
parentItems = parentItems.map(item => { | ||
item = _.clone(item) | ||
item.inherited = true | ||
item.inheritedFrom = item.class | ||
item.class = klass.name | ||
return item | ||
}) | ||
data.classitems = data.classitems.concat(parentItems) | ||
}) | ||
}) | ||
}) | ||
item = _.clone(item); | ||
item.inherited = true; | ||
item.inheritedFrom = item.class; | ||
item.class = klass.name; | ||
return item; | ||
}); | ||
data.classitems = data.classitems.concat(parentItems); | ||
}); | ||
}); | ||
}); | ||
|
||
return Promise.resolve(docSets) | ||
return Promise.resolve(docSets); | ||
} | ||
|
||
function getParents(klass, classes) { | ||
let parents = [] | ||
let parents = []; | ||
if (klass.extends) { | ||
parents = parents.concat([klass.extends]) | ||
parents = parents.concat([klass.extends]); | ||
} | ||
if (klass.uses && klass.uses.length) { | ||
parents = parents.concat(klass.uses.reverse()) | ||
parents = parents.concat(klass.uses.reverse()); | ||
} | ||
return parents | ||
.map(parent => _.find(classes, ({ name }) => name === parent)) | ||
.filter(parent => parent) | ||
.filter(parent => parent); | ||
} | ||
|
||
function removeLongDocsBecauseEmber1HasWeirdDocs({ name }) { | ||
let str = 'A Suite can' | ||
return !name.includes(str) | ||
let str = 'A Suite can'; | ||
return !name.includes(str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
import _ from 'lodash' | ||
import _ from 'lodash'; | ||
|
||
export default function addSinceTags(docSets) { | ||
let versionIndex = Object.create(null) | ||
let versionIndex = Object.create(null); | ||
|
||
docSets.forEach(versionData => { | ||
let data = versionData.data | ||
let version = (versionData.version = versionData.version.replace('v', '')) | ||
let classItems = data.classitems.filter(({ itemtype }) => itemtype) | ||
let data = versionData.data; | ||
let version = (versionData.version = versionData.version.replace('v', '')); | ||
let classItems = data.classitems.filter(({ itemtype }) => itemtype); | ||
|
||
classItems.forEach(classItem => { | ||
let classItemName = `${classItem.class}#${classItem.name}` | ||
classItem.version = version | ||
createMethodEntry(versionIndex, classItemName, classItem.itemtype, version) | ||
}) | ||
let classItemName = `${classItem.class}#${classItem.name}`; | ||
classItem.version = version; | ||
createMethodEntry(versionIndex, classItemName, classItem.itemtype, version); | ||
}); | ||
|
||
let classes = _.values(data.classes) | ||
let classes = _.values(data.classes); | ||
|
||
classes.forEach(klass => { | ||
klass.version = version | ||
createMethodEntry(versionIndex, klass.name, 'class', version) | ||
}) | ||
}) | ||
klass.version = version; | ||
createMethodEntry(versionIndex, klass.name, 'class', version); | ||
}); | ||
}); | ||
|
||
sortVersionIndex(versionIndex) | ||
sortVersionIndex(versionIndex); | ||
|
||
let classItems = classItemsWithItemType(docSets) | ||
let classItems = classItemsWithItemType(docSets); | ||
|
||
classItems.forEach(classItem => { | ||
let classItemName = `${classItem.class}#${classItem.name}` | ||
let version = versionIndex[classItem.itemtype][classItemName][0] | ||
let classItemName = `${classItem.class}#${classItem.name}`; | ||
let version = versionIndex[classItem.itemtype][classItemName][0]; | ||
|
||
classItem.since = version | ||
}) | ||
classItem.since = version; | ||
}); | ||
|
||
let classes = _.chain(docSets) | ||
.map('data') | ||
.map('classes') | ||
.flatten() | ||
.map(klassSet => _.values(klassSet)) | ||
.flatten() | ||
.value() | ||
.value(); | ||
|
||
classes.forEach(klass => (klass.since = versionIndex['class'][klass.name][0])) | ||
classes.forEach(klass => (klass.since = versionIndex['class'][klass.name][0])); | ||
|
||
return Promise.resolve(docSets) | ||
return Promise.resolve(docSets); | ||
} | ||
|
||
function sortVersionIndex(versionIndex) { | ||
let keys = Object.keys(versionIndex) | ||
let keys = Object.keys(versionIndex); | ||
|
||
keys.forEach(key => | ||
Object.keys(versionIndex[key]).forEach(item => versionIndex[key][item].sort()), | ||
) | ||
); | ||
} | ||
|
||
const createMethodEntry = (versionIndex, method, itemType, version) => { | ||
versionIndex[itemType] = versionIndex[itemType] || Object.create(null) | ||
versionIndex[itemType][method] = versionIndex[itemType][method] || [] | ||
versionIndex[itemType][method].push(version) | ||
} | ||
versionIndex[itemType] = versionIndex[itemType] || Object.create(null); | ||
versionIndex[itemType][method] = versionIndex[itemType][method] || []; | ||
versionIndex[itemType][method].push(version); | ||
}; | ||
|
||
const classItemsWithItemType = versions => | ||
versions.reduce( | ||
(memo, { data }) => memo.concat(data.classitems.filter(({ itemtype }) => itemtype)), | ||
[], | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import saveDoc from './save-document.js' | ||
import saveDoc from './save-document.js'; | ||
|
||
export default async function (document, projectName, projectVersion) { | ||
let things = document.data | ||
let things = document.data; | ||
|
||
for (const klass of things) { | ||
if (!klass.id) { | ||
console.log(klass) | ||
console.log(new Error('WHAT').stack) | ||
process.exit(1) | ||
console.log(klass); | ||
console.log(new Error('WHAT').stack); | ||
process.exit(1); | ||
} | ||
const doc = { | ||
data: klass, | ||
} | ||
}; | ||
|
||
console.log(`Creating ${klass.id} in ${projectName}-${projectVersion}`) | ||
await saveDoc(doc, projectName, projectVersion) | ||
console.log(`Creating ${klass.id} in ${projectName}-${projectVersion}`); | ||
await saveDoc(doc, projectName, projectVersion); | ||
} | ||
|
||
return document | ||
return document; | ||
} |
Oops, something went wrong.