-
-
Notifications
You must be signed in to change notification settings - Fork 145
Description
What
When working in an addon with a scoped package name (eg: @scope-name/package-name), the "API REFERENCE", "Components" navigation section is incorrectly generated (it shows Class Name). The expected outcome is {{component-name}}.
The link generated is also messed up:
Expected: https://user-or-org.github.io/repo-name/docs/api/components/component-name
Actual: https://user-or-org.github.io/repo-name/docs/api/modules/@scope-name/package-name/components/component-name~Class%20Name
Why
When generating the nav links for API Reference / Component, it assumes that the type will always be the second level of the path.
https://github.com/ember-learn/ember-cli-addon-docs/blob/master/lib/broccoli/docs-compiler/navigation-index-generator.js#L56
Suggested Fix
Replace the above function with:
_resolvedTypeForModule(module) {
let path = module.file.split('/');
// By default we assume that the type is at index 1
let type = path[1];
// If the module is a scoped package, then the type will be at index 2
if (path[0].charAt(0) === '@') {
type = path[2];
}
return RESOLVED_TYPES.includes(type) && type;
}