doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.55k stars 1.45k forks source link

Would it be possible in a react native project with Typescript to read the tsx components inside node_modules ? #1752

Closed fxneel closed 3 months ago

fxneel commented 3 months ago

Question

In my doczrc.js

export default {
  typescript: true,
  lang: 'pt',
  files: './src/components/**/*.mdx',
  ignore: ['**/*.md', 'README.md', 'CHANGELOG.md'],
  dest: './dist-docz',
  title: description,
  description: `${description}.`,
  base: ``,
  propsParser: true,
  public: './docs/public',
  docgenConfig: {
    searchPath: './node_modules/my-components-tsx/src/components',
  },
  filterComponents: (files) => {
    const regexpComponent = new RegExp('\\/[A-Z]\\w*?\\.(jsx|js|tsx|ts)', 'gm');
    return files.filter((filepath) => regexpComponent.test(filepath));
  },

In my tsconfig

{
  "include": ["src", "./node_modules/my-components-tsx/src/**/*"],
  "exclude": [
    "./node_modules/*",
    "!./node_modules/my-components-tsx/src/**/*",
    "**/*.spec.ts"
  ],
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "lib": ["dom", "esnext"],
    "importHelpers": true,
    "declaration": true,
    "sourceMap": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "jsx": "react",
    "esModuleInterop": true
  }
}

In package.json in "my-components-tsx": "2.9.0",

  "dependencies": {
    "@nejcm/docz-theme-extended": "2.0.14",
    "@react-native-async-storage/async-storage": "1.17.7",
    "dls-fonts": "^1.0.5",
    "my-components-tsx": "2.9.0",
    "docz": "2.3.1",
    "lottie-react-native": "5.1.5",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-native-safe-area-context": "3.3.2",
    "react-native-tab-view": "3.1.1",
    "react-native-web": "0.11.7",
    "react-powerplug": "1.0.0",
    "typescript": "^5.4.3",
    "universal-console": "^0.1.3"
  },
  "devDependencies": {
    "ignore-not-found-export-webpack-plugin": "1.0.2"
  },
  "resolutions": {
    "gatsby-theme-docz": "2.4.0"
  }
fxneel commented 3 months ago

I managed to resolve it here, I will close the issue.