Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docz-core): allow custom pattern for globbing components #1316

Merged

Conversation

axe312ger
Copy link
Contributor

@axe312ger axe312ger commented Dec 12, 2019

Description

With #1315 I am able to include docs from within my dependencies and my source directory. This change adds support for globbing components from multiple directories.

My config:

{
  resolve: `gatsby-theme-docz`,
  options: {
    files: [
      `src/components/mdx/**/docs/*.{md,markdown,mdx}`,
      `node_modules/@gatsby-mdx-suite/*/docs/*.{md,markdown,mdx}`,
      `../../node_modules/@gatsby-mdx-suite/*/docs/*.{md,markdown,mdx}`,
    ],
    customPattern: [
      `src/components/mdx/**/*.{js,jsx,mjs}`,
      `node_modules/@gatsby-mdx-suite/**/*.{js,jsx,mjs}`,
      `../../node_modules/@gatsby-mdx-suite/**/*.{js,jsx,mjs}`,
    ],
  },
}

Review

  • is the naming correct?
  • should we merge the custom pattern with the default one?

@rakannimer
Copy link
Contributor

Hey @axe312ger

Thanks for the PR 👍

I can definitely see the use of having an additional flag to give the user more control to tell docz where to look for components.

is the naming correct?

The name customPattern seems like it could be confusing.

What do you think about adding it as a property to docgenConfig called searchPatterns.

should we merge the custom pattern with the default one?

We could add the logic to the getPattern function. If docgenConfig.searchPatterns is defined than we return it as is (we can assume that by providing this flag the user takes full responsibility of the search patterns and won't want us to tamper with it) and if not we'll keep the logic to return the patterns as is.

@axe312ger
Copy link
Contributor Author

Good idea! Ill refactor :)

@axe312ger
Copy link
Contributor Author

Done. I decided not to touch the user defined search pattern at all, because:

  • only that way we give full control
  • in some of my cases I want node_modules to be included
  • just attaching '!**/doczrc.js' to the pattern felt odd as we can assume users will include their folder properly

Next todos:

  • document the exact behaviour of how docz searches components when
    • using the default way, pattern is build out of root, src & docgen.searchPath + user ignores + default ignores
    • using searchPatterns which will give 100% control but you need to take care of where you looking for files #performance
  • consider using debug module so users can see which files and folders are actually searched for docs & components by setting a environment variable (I feel like that be useful even without this pr!)

@rakannimer
Copy link
Contributor

Looks good !

I think the next todos you mentioned are very important and needed.

Let's merge this PR and we'll get to the next todos in different PRs.

Not sure if I've already invited you but please feel free to join docz's slack workspace if you'd like to chat more about future features or issues.

@rakannimer rakannimer merged commit 29e0165 into doczjs:master Dec 14, 2019
@axe312ger axe312ger deleted the feat/custom-component-glob-pattern branch December 14, 2019 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants