Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(docs): retrieve source descriptor dynamically.
Browse files Browse the repository at this point in the history
At the moment the doc descriptor is retrieved through hard-coding.
This causes problems when a component is not located in the hard-coded folder `src/components`
After this fix, the doc descriptor will be dynamically parsed (using the last possible descriptor criteria), so this allows components to be located everywhere in the project.
This fixes the wrong GitHub links for the ripple service / component.

Fixes #7131. Closes #7319
  • Loading branch information
devversion authored and ThomasBurleson committed Apr 1, 2016
1 parent 9106e8e commit 23e7f00
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/config/processors/componentsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ var buildConfig = require('../../../config/build.config.js');
// add many kilobytes of loading overhead.
function publicDocData(doc, extraData) {
var options = _.assign(extraData || {}, { hasDemo: (doc.docType === 'directive') });
return buildDocData(doc, options, 'components');

// This RegEx always retrieves the last source descriptor.
// For example it retrieves from `/opt/material/src/core/services/ripple/ripple.js` the following
// source descriptor: `src/core/`.
// This is needed because components are not only located in `src/components`.
var descriptor = doc.fileInfo.filePath.toString().match(/src\/.*?\//g).pop();
if (descriptor) {
descriptor = descriptor.substring(descriptor.indexOf('/') + 1, descriptor.lastIndexOf('/'));
}

return buildDocData(doc, options, descriptor || 'components');
}

function coreServiceData(doc, extraData) {
Expand All @@ -14,6 +24,7 @@ function coreServiceData(doc, extraData) {
}

function buildDocData(doc, extraData, descriptor) {

var module = 'material.' + descriptor;
var githubBaseUrl = buildConfig.repository + '/blob/master/src/' + descriptor + '/';
var jsName = doc.module.split(module + '.').pop();
Expand Down

0 comments on commit 23e7f00

Please sign in to comment.