JetBrains / web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
Apache License 2.0
279 stars 25 forks source link

Source pathing is wrong, which prevents navigation #23

Closed JasonLandbridge closed 3 years ago

JasonLandbridge commented 3 years ago

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:

  1. Install vue-docgen-web-types in your project: npm i vue-docgen-web-types
  2. Add the following to package.json
    "scripts": {
        "update-web-types": "vue-docgen-web-types"
    },
    "web-types": "./web-types.json",
  3. Run the update-web-types npm command.
  4. Check the ./web-types.json

I also don't have JsDoc installed.

piotrtomiak commented 3 years ago

@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.

JasonLandbridge commented 3 years ago

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?

piotrtomiak commented 3 years ago

@JasonLandbridge I believe this is a good enough solution :) Could you please create a PR?

JasonLandbridge commented 3 years ago

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

piotrtomiak commented 3 years ago

@JasonLandbridge Thanks for the contribution! I've published version 0.1.7 with your fix.

JasonLandbridge commented 3 years ago

Great! I can confirm it is working now! Thanks for your help!