reactjs / react-docgen

A CLI and library to extract information from React component files for documentation generation purposes.
https://react-docgen.dev
MIT License
3.67k stars 296 forks source link

react-docgen generates platform specific structure #199

Open chaliy opened 7 years ago

chaliy commented 7 years ago
react-docgen --pretty -o lib/metadata.json src/components

On Windows produces:

{
  "src\\components\\ExampleComponent.react.js": {
    "description": "ExampleComponent is an example component.\r\nIt takes a single property, `label`, and\r\ndisplays it.",
    "methods": [],
    "props": {
      "label": {
        "type": {
          "name": "string"
        },
        "required": true,
        "description": "A label that will be printed when this component is rendered."
      }
    }
  }
}

On Linux produces:

{
  "src/components/ExampleComponent.react.js": {
    "description": "ExampleComponent is an example component.\r\nIt takes a single property, `label`, and\r\ndisplays it.",
    "methods": [],
    "props": {
      "label": {
        "type": {
          "name": "string"
        },
        "required": true,
        "description": "A label that will be printed when this component is rendered."
      }
    }
  }
}

This makes some scripts which use results of react-docgen for code generation fail. One example is plotly/dash component generator. Would you consider this is as a bug?

j2l commented 7 years ago

Hi, May I ask you @chaliy how you got react-docgen --pretty -o lib/metadata.json src/components working on Windows? I get "unknown command' I also tried npm run react-docgen --pretty -o lib/metadata.json src/components without luck (missing component).

chaliy commented 7 years ago

@j2l , do you have it installed globally? Something like npm install react-docgen -g?

fkling commented 7 years ago

Would you consider this is as a bug?

Good question, idk. Consistency in the output is certainly important. However would it feel strange if the path was using / on Windows?

I'm not using Windows, so I can't tell if someone would be bothered by this. Ideally, people who use Windows good provide their point of view here.

j2l commented 7 years ago

@chaliy you are right, I didn't, thanks for pointing it out. My bad.

Xtrazyx commented 6 years ago

It is not a bug per say but this inconsistency is annoying. When developing alternatively on windows and on mac OS, which is my case, you will have some issue exploiting the generated path.

To go further on this, the linux/macOS way of labeling the paths works on most windows shells mypath/tatata/coco.js but not the other way around.

So yeah it would be nice to have always the same method, the linux way.