Skip to content

Commit e38c1fb

Browse files
committed
Revert "Allows users to omit the last extension"
1 parent 41b326f commit e38c1fb

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ For example, ``src/MyClass.js`` will be referred to as ``import MyClass from 'my
1111
However, in practice it is different from the real import path when you use because it is transpiled
1212
(for example, ``import MyClass from 'my-module/lib/MyClass.js'``).
1313

14-
By default, esdoc will also include the file extension, e.g. ``.js``. With the ``extension`` option you are able to control
15-
whether the extension will be included (``true``, ``default``), or completely omitted (``false``).
16-
1714
Therefore, convert the import path by using following setting.
1815

1916
```json
@@ -26,8 +23,7 @@ Therefore, convert the import path by using following setting.
2623
"option": {
2724
"replaces": [
2825
{"from": "^src/", "to": "lib/"}
29-
],
30-
"extension" : true|false
26+
]
3127
}
3228
}
3329
]
@@ -58,8 +54,7 @@ setup ``plugin`` property in ``esdoc.json``
5854
"option": {
5955
"replaces": [
6056
{"from": "^src/", "to": "lib"}
61-
],
62-
"extension" : true|false
57+
]
6358
}
6459
}
6560
]

src/Plugin.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ export function onStart(ev) {
1212
for (let item of option.replaces) {
1313
item.from = new RegExp(item.from);
1414
}
15-
if (typeof option.extension === 'undefined') {
16-
option.extension = true;
17-
}
1815
}
1916

2017
/**
@@ -52,15 +49,12 @@ export function onHandleTag(ev) {
5249
importPath = importPath.replace(item.from, item.to);
5350
}
5451

55-
let actualImportPath = importPath
56-
if (!option.extension) actualImportPath = actualImportPath.replace(/[.][^.]+$/, '');
57-
5852
if (importPath === mainPath) {
5953
tag.importPath = packageName;
6054
} else if (packageName) {
61-
tag.importPath = `${packageName}/${actualImportPath}`;
55+
tag.importPath = `${packageName}/${importPath}`;
6256
} else {
63-
tag.importPath = actualImportPath;
57+
tag.importPath = importPath;
6458
}
6559
}
6660
}

test/fixture/esdoc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"replaces": [
1010
{"from": "^src/", "to": "lib/"},
1111
{"from": "^lib/FooClass.js", "to": "lib/foo"}
12-
],
13-
"extension": false
12+
]
1413
}
1514
}
1615
]

test/src/ImportPathTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import assert from 'power-assert';
77
describe('Import Path', ()=> {
88
it('simply convert', ()=> {
99
const html = fs.readFileSync('./test/fixture/esdoc/class/src/MyClass.js~MyClass.html').toString();
10-
assert(html.includes('>esdoc-importpath-plugin/lib/MyClass<'));
10+
assert(html.includes('>esdoc-importpath-plugin/lib/MyClass.js<'));
1111
});
1212

1313
it('multiple convert', ()=>{

0 commit comments

Comments
 (0)