Skip to content

Commit

Permalink
chore(doc): fix edit links for reference API (#2303)
Browse files Browse the repository at this point in the history
* chore(doc): edit this page links now points to develop

This might not be in sync with the current content but those will be the
current next version.

* chore(doc): fix edit links for reference API

The script was assuming the name of the repo would be `instantsearch.js`
which might be an issue if the name of the folder is different.

Also refactor the way we figure out the path of each file because there
was a discrepancy.

FIX #2301
  • Loading branch information
bobylito authored Sep 5, 2017
1 parent 1eac842 commit 3b30375
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docgen/layouts/archetypes/content-with-menu.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body.documentation
a.sidebar-opener
.documentation-container
if(editable)
a.editThisPage(href=`http://github.com/algolia/instantsearch.js/edit/master/${githubSource}`) Edit this page
a.editThisPage(href=`http://github.com/algolia/instantsearch.js/edit/develop/${githubSource}`) Edit this page
block content

include ../common/footer.pug
Expand Down
20 changes: 10 additions & 10 deletions docgen/plugins/documentationjs-data.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import path from 'path';

import {uniqBy, forEach, reduce, groupBy, findIndex, find, filter, isArray, isObject} from 'lodash';
import documentation from 'documentation';
import remark from 'remark';
import md from '../mdRenderer';

const baseDir = path.resolve(process.cwd(), '..');
function getGithubSource(symbol) {
return symbol.context.file.split(baseDir)[1].substring(1);
}

function formatMD(ast) {
if (ast && ast.type === 'root') {
// 1. extract the raw markdown string from the remark AST
Expand Down Expand Up @@ -82,8 +89,6 @@ function groupSymbolsByCategories(symbols) {
function mapInstantSearch([instantsearchFactory, InstantSearch], symbols, files) {
const fileName = 'instantsearch.html';

const githubSource = InstantSearch.context.file.split('instantsearch.js')[1];

files[fileName] = {
mode: '0764',
contents: '',
Expand All @@ -101,7 +106,7 @@ function mapInstantSearch([instantsearchFactory, InstantSearch], symbols, files)
},
withHeadings: true,
editable: true,
githubSource: githubSource,
githubSource: getGithubSource(InstantSearch),
};
}

Expand All @@ -114,9 +119,6 @@ function mapConnectors(connectors, symbols, files) {
relatedTypes: findRelatedTypes(symbol, symbols),
};

const githubSource = 'http://github.com/algolia/instantsearch.js/edit/master' +
symbolWithRelatedType.context.file.split('instantsearch.js')[1];

files[fileName] = {
mode: '0764',
contents: '',
Expand All @@ -128,7 +130,7 @@ function mapConnectors(connectors, symbols, files) {
jsdoc: symbolWithRelatedType,
withHeadings: true,
editable: true,
githubSource: githubSource,
githubSource: getGithubSource(symbolWithRelatedType),
};
});
}
Expand All @@ -146,8 +148,6 @@ function mapWidgets(widgets, symbols, files) {
relatedTypes,
};

const githubSource = symbolWithRelatedType.context.file.split('instantsearch.js/')[1];

files[fileName] = {
mode: '0764',
contents: '',
Expand All @@ -159,7 +159,7 @@ function mapWidgets(widgets, symbols, files) {
jsdoc: symbolWithRelatedType,
withHeadings: true,
editable: true,
githubSource: githubSource,
githubSource: getGithubSource(symbolWithRelatedType),
};
});
}
Expand Down

0 comments on commit 3b30375

Please sign in to comment.