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

Ben/multi org #107

Merged
merged 38 commits into from
Dec 20, 2021
Merged

Ben/multi org #107

merged 38 commits into from
Dec 20, 2021

Conversation

blugavere
Copy link
Contributor

@blugavere blugavere commented Dec 20, 2021

Add recursive folder structure reading & labeling support.

#82

image

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 20, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8c05da2:

Sandbox Source
demo Configuration

cwd: openapiPath,
ignore: GlobExcludeDefault,
})
).filter((x) => !x.includes("_category_")); // todo: regex exclude?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think _category_ should be excluded by GlobExcludeDefault above, which excludes anything that starts with an underscore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

doesn't appear to work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea looks like it doesn't ignore json files with _

  // Ignore files starting with _
  '**/_*.{js,jsx,ts,tsx,md,mdx}',

  // Ignore folders starting with _ (including folder content)
  '**/_*/**',

  // Ignore tests
  '**/*.test.{js,jsx,ts,tsx}',
  '**/__tests__/**',

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe try something like this then:

[...GlobExcludeDefault, '**/_*.{json,yaml,yml}']

@bourdakos1
Copy link
Member

bourdakos1 commented Dec 20, 2021

Can we rename __test__ to __fixtures__?

Copy link
Member

@bourdakos1 bourdakos1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I still need to look over the category tree stuff

packages/docusaurus-plugin-openapi/src/sidebars/index.ts Outdated Show resolved Hide resolved
Comment on lines +71 to +72
source: prototype?.source,
sourceDirName: prototype?.sourceDirName ?? ".",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me a little uncomfortable having the existence of source being tied to the existence of api.info. Maybe we should just use items[0].source and items[0].sourceDirName? However, with hardcoding zero index we have to think if there is ever a case were items is an empty array? Maybe an empty directory, or spec that wouldn't generate any pages, etc... We should probably have a case that skips creating the category/subitems if we don't have the right info

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is ever a case were items is an empty array?

I don't think so but can mull on it.

The current implementation (for all of multi-spec) relies on the folder structure being generated from OpenAPI Specs (& these lines are only hit if there are > 1 spec files).

Arbitrary markdown files aren't supported. Introductions are automatically generated from the info.description field so in all cases a section is only created for an openapi spec. Here we're ignoring the auto-generated markdown file from being used to select the sidebar label after being grouped by source.

The fn input items[] is a flattened array of ["auto-generated markdown for spec a", "openapi path for spec a"]. The .find fn is getting not the zero index, but the first element in the group which is non-markdown & has the openapi spec info. If falsy, defaults to filename.

Copy link
Member

@bourdakos1 bourdakos1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! We can investigate potential issues with an empty array of pages later

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