docz icon indicating copy to clipboard operation
docz copied to clipboard

Trying to get README.md from monorepo in docz viewer

Open eddysims opened this issue 4 years ago • 8 comments

Bug Report

I have a monorepo set up and I would like to have docz get mdx files from the packages inside of it.

  • packages/
    • components/
      • Has mdx files.
    • design/
      • Has mdx files.
    • hooks
      • Has mdx files.
    • docz-theme/
      • Theme for docz (exported as package).
    • docz .doczrc.js README.md (Index page for docz viewer).

doczrc

export default {
  ...,
  typescript: true,
  src: path.join(__dirname, "..", ".."),
  files: "{README.md,**/*.mdx}",
};

When running docz dev the build freezes and will not finish.

To Reproduce

This issue can be easily reproduced by using the monorepo example.

npx create-docz-app docz-app-monorepo-separate-docs --example monorepo-separate-docs

add to packages/docs/doczrc.js

export default {
    ...
    src: '../../',
}

the build freezes at:

```sh
⠦ source and transform nodes
⚠  warning   No cache was found with your props definitions
⚠  warning   We'll parse your components to get props from them
⠴ source and transform nodes

eddysims avatar Jul 28 '20 21:07 eddysims

Hey, our monorepo looks something like this

├── packages
│   ├── app
│   ├── components
│   ├── docz

And the doczrc.js file looks as follows

export default {
	...,
	files: ['../components/src/**/*.{md,markdown,mdx}'],
	docgenConfig: {
		searchPatterns: ['../components/src/**/*.{ts,tsx,js}'],
	},

The docgenConfig entry is for the <Props/> Components so it finds the corresponding files.

Fruitseller avatar Aug 13 '20 06:08 Fruitseller

@Fruitseller if your monorepo looked like this

├── packages
│   ├── app
│   ├── components
│   ├── docz-theme
│   ├── docz
README.md

Are you able to get the README.md working? That is the issue im having. When i do something like this

files: ['../../README.md']

docz just continues to build over and over.

eddysims avatar Aug 13 '20 17:08 eddysims

also using a monorepo...

docz just continues to build over and over.

this is the issue I am trying to solve. when running docz dev I get a continual build that loops over this about every 3 seconds:

[docz] success Checking for changed pages - 0.000s
[docz] success update schema - 0.014s
[docz] success onPreExtractQueries - 0.001s
[docz] success extract queries from components - 0.012s
[docz] success write out requires - 0.001s
[docz] success building schema - 0.127s
[docz] success createPages - 0.001s

jasongaare avatar Aug 17 '20 22:08 jasongaare

@jasongaare something that i think worked. I haven't fully tested it yet is moving my .md files into a docs directory at the root. My repo now looks something like this

├── packages
│   ├── app
│   ├── components
│   ├── docz-theme
│   ├── docz
├── docs
│   ├──README.md

and my doczrc.js looks something like this

{
...,
files: [
    ...,
    '../../docs/**/*.{md,mdx}'
]
}

Github will also allow this.

eddysims avatar Aug 18 '20 15:08 eddysims

I think my issue is re: docgenConfig.searchPaths

// doczrc.js
export default {
  docgenConfig: {
    searchPatterns: [
      "../src/{mobile,shared}/**/*.{js,jsx}",
      "!**/node_modules",
      "!**/doczrc.js",
    ],
  },
};

when I comment out the searchPatterns then gatsby does not continually build, but as was mentioned about without that then the <Props> component doesn't render any types/props for components

The docgenConfig entry is for the <Props/> Components so it finds the corresponding files.

jasongaare avatar Aug 18 '20 21:08 jasongaare

I have the same issue as @jasongaare.

  • No props show up on any pages when using the Props component
  • Adding the docgenConfig.searchPatterns to .docz.js with the path to my components makes props show up
  • ... but Docz (Gatsby) won't stop looping rebuilding

This just loops and never stops

success building schema - 0.324s
success createPages - 0.033s
success Checking for changed pages - 0.009s
success update schema - 0.035s
success onPreExtractQueries - 0.005s
success extract queries from components - 0.038s
success write out requires - 0.006s

Using Docz 2.3.1 and NOT using TypeScript for any files. The docs kinda give the impression the props display only works if you're using TypeScript but not sure that is the case.

sheedy avatar Aug 24 '20 05:08 sheedy

@sheedy Im still getting the same issue, have you found any solution to this yet?

eddysims avatar Sep 02 '20 23:09 eddysims

@Fruitseller if your monorepo looked like this

├── packages
│   ├── app
│   ├── components
│   ├── docz-theme
│   ├── docz
README.md

Are you able to get the README.md working? That is the issue im having. When i do something like this

files: ['../../README.md']

docz just continues to build over and over.

Sorry for not responding. We do not have a root level README file so I can't help you with that.

Fruitseller avatar Sep 04 '20 13:09 Fruitseller