Skip to content

Remove since tag, get version from project-version relationship #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function extractMethodsFromClasses(classes) {
currentClass.data.attributes.methods
.reduce((classMethods, currentMethod) => {
// Transform the current method and push on to methods.
classMethods.push(schemas.methodSchema(currentMethod))
classMethods.push(schemas.methodSchema(currentMethod, currentClass))
return classMethods
}, [])
// Merge all methods of all classes into a single array
Expand All @@ -187,7 +187,7 @@ function extractStaticFunctionsFromModules(modules) {

return moduleStaticFunctions
.reduce((moduleStaticFunctions, currentStaticFunction) => {
moduleStaticFunctions.push(schemas.methodSchema(currentStaticFunction))
moduleStaticFunctions.push(schemas.methodSchema(currentStaticFunction, currentModule))
return moduleStaticFunctions
}, [])
.concat(methods)
Expand Down
5 changes: 3 additions & 2 deletions lib/schemas/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
export default function classSchema(classObj) {
const data = classObj.data
const attributes = data.attributes
const versionId = data.relationships['project-version'].data.id;
const version = versionId.substring(versionId.lastIndexOf('-')+1);

return {
id: data.id,
Expand All @@ -14,8 +16,7 @@ export default function classSchema(classObj) {
namespace: attributes.namespace,
_tags: [
`module:${attributes.module}`,
`version:${attributes.version}`,
`since:${attributes.since}`
`version:${version}`
]
}
}
8 changes: 5 additions & 3 deletions lib/schemas/method.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* @param {Object} method - An object with the method information.
* @returns {Object} - Transformed object
*/
export default function methodSchema(method) {
export default function methodSchema(method, versioned) {
let versionId = versioned.data.relationships['project-version'].data.id;
let version = versionId.substring(versionId.lastIndexOf('-')+1);

return {
file: method.file,
line: method.line,
Expand All @@ -17,8 +20,7 @@ export default function methodSchema(method) {

_tags: [
`module:${method.module}`,
`version:${method.version}`,
`since:${method.since}`
`version:${version}`
],

hierarchy: {
Expand Down
8 changes: 6 additions & 2 deletions lib/schemas/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
export default function moduleSchema(module) {
const data = module.data
const attributes = data.attributes

let versionId = data.relationships['project-version'].data.id;
let version = versionId.substring(versionId.lastIndexOf('-')+1);
return {
id: data.id,
name: attributes.name,
submodules: attributes.submodules,
namespaces: attributes.namespaces,
_tags: [`module:${attributes.name}`, `version:${attributes.version}`]
_tags: [
`module:${attributes.name}`,
`version:${version}`
]
}
}