Source pathing is wrong, which prevents navigation
JasonLandbridge opened this issue · 6 comments
This is what you currently get in the generated web-types.json
file:
"source": {
"module": "./src\\components\\General\\Page.vue",
"symbol": "default"
}
But if you fix the pathing manually to:
"source": {
"module": "./src/components/General/Page.vue",
"symbol": "default"
}
Then everything works, is this a bug or should this be changed through the configuration?
This is how I did it:
- Install vue-docgen-web-types in your project:
npm i vue-docgen-web-types
- Add the following to
package.json
"scripts": {
"update-web-types": "vue-docgen-web-types"
},
"web-types": "./web-types.json",
- Run the
update-web-types
npm command. - Check the
./web-types.json
I also don't have JsDoc installed.
@JasonLandbridge Yes, it is definitely a bug, a wrong kind of slashes is generated on Windows. It would be awesome, if you can create a PR with a fix, otherwise I will have a look at the issue hopefully this week.
Sure! I have been able to isolate the issue to function ensureRelative() as it is used here.
A "hack" would be to just stick .replace('\\', '/')
at the end of the function:
function ensureRelative(path: string) {
return (path.startsWith("./") || path.startsWith("../") ? path : "./" + path).replace('\\', '/');
}
But I'm unsure if that would be a fix or just make it worse for others who are using it.
Is there a way for me to check what kind of filesystem it is running on and apply the .replace('\\', '/')
based on that?
@JasonLandbridge I believe this is a good enough solution :) Could you please create a PR?
Sure, I have just created a pull request. I tested the function ensureRelative() in isolation and its working when I feed it the paths but I haven't been able to test in during the build generation. I hope you can give it a quick test :D
@JasonLandbridge Thanks for the contribution! I've published version 0.1.7 with your fix.
Great! I can confirm it is working now! Thanks for your help!