react-docgen icon indicating copy to clipboard operation
react-docgen copied to clipboard

react-docgen generates platform specific structure

Open chaliy opened this issue 8 years ago • 5 comments

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?

chaliy avatar Jul 29 '17 22:07 chaliy

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

j2l avatar Sep 05 '17 10:09 j2l

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

chaliy avatar Sep 06 '17 20:09 chaliy

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.

fkling avatar Sep 06 '17 20:09 fkling

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

j2l avatar Sep 06 '17 20:09 j2l

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.

Xtrazyx avatar Aug 20 '18 12:08 Xtrazyx