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

Chart docs: annotate types #2139

Closed
dlabrecq opened this issue Jun 3, 2019 · 14 comments · Fixed by patternfly/patternfly-org#1671, #3651 or #5315
Closed

Chart docs: annotate types #2139

dlabrecq opened this issue Jun 3, 2019 · 14 comments · Fixed by patternfly/patternfly-org#1671, #3651 or #5315
Labels
infrastructure PF4 React issues for the PF4 core effort

Comments

@dlabrecq
Copy link
Member

dlabrecq commented Jun 3, 2019

The react-charts docs contain some complex object types. For example, the ChartArea component shows AnimatePropTypeInterface as the animate type below.

The Victory docs show the animate type as type: boolean || object.
See https://formidable.com/open-source/victory/docs/victory-area/#animate

Note: There are far more complex examples, but using animate for simplicity.

Screen Shot 2019-06-03 at 2 38 52 PM

I don't want to override the existing Victory property types, just to add a description for react-docs. I would prefer to document properties using an annotation, if possible?

That may allow us to simplify the animate description / type as a boolean instead of AnimatePropTypeInterface. It would also isolate us from Victory changing the underlying property type and breaking our component wrappers.

@dlabrecq dlabrecq changed the title react-docs: type documenttation react-docs: annotate type documentation Jun 3, 2019
@dgutride dgutride added the PF4 React issues for the PF4 core effort label Jun 11, 2019
@redallen redallen self-assigned this Jun 24, 2019
@redallen
Copy link
Contributor

What's wrong with overriding the existing Victory props to make animate?: boolean? What type of @ annotation would you like to use, and how would you like it to render?

@dlabrecq
Copy link
Member Author

If animate were a boolean, that would generate an error because the underlying Victory component has a different type. Ideally, we wouldn't override types at all.

Overriding props to be a simple boolean, string, etc. is not going to work. There are far more complex objects with nested properties.

@redallen
Copy link
Contributor

It wouldn't generate an error if we Omit<VictoryProps, 'animate'> and then pass to victory something like animate ? {object Victory expects} : {}. Still, what type of annotation would you like to use, and how would you like it to render?

@dlabrecq
Copy link
Member Author

dlabrecq commented Jun 28, 2019

We should be able to import Victory interfaces in order to take advantage of existing property types and documentation. Ideally, pass-thru props would remain unchanged -- we shouldn't have to redefine prop types for react-docs.

Currently, we're overridding all Victory property types, and duplicating @type/victory documentation, simply to generate react-docs. It's a pain to keep in sync with Victory changes. And after all that, types like AnimatePropTypeInterface still don't resolve to anything useful.

It may be helpful if we could use some sort of annotation in order to define the type just for our documentation? For example, @type could be used to simplify the property type as boolean | object instead of AnimatePropTypeInterface -- as shown on Victory's site. Similar to how some JS doc tools use @example to format their doc layouts.

If we could at least do that, then we could leave the Victory pass-thru props untouched. Although, I still don't want react-docgen to display boolean | object as union -- that's also not useful.

I don't really have a good solution, but it's a problem we must solve. The react-docs are unreadable as is. Our users must go to Victory's site to view documentation, instead.

@redallen
Copy link
Contributor

Oh, I completely understand that issue. That requires extending react-docgen to follow imports to resolve types. I can open that issue upstream.

@redallen
Copy link
Contributor

redallen commented Jul 1, 2019

Looks like a PR is already opened to add support for this. Awaiting its merge and a new package release.

@redallen
Copy link
Contributor

Still awaiting its update and merge. Can likely dedicate a day this week to fix it upstream.

@stale
Copy link

stale bot commented Nov 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Nov 14, 2019
@dlabrecq
Copy link
Member Author

The unreadable chart docs are still an ongoing issue.

Inheriting types would be ideal, but if we could somehow provide our own prop types, that would help us clarify the docs.

@redallen
Copy link
Contributor

redallen commented Nov 15, 2019

Yeah, this issue has become adding annotations like /* @proptype custom string of type */ and /* @hide */ for internal props. I'd like to follow Javadoc syntax or something of the like.

Are there any more annotations you think might be useful @dlabrecq @dlabaj @tlabaj ?

@tlabaj
Copy link
Contributor

tlabaj commented Nov 15, 2019

@redallen I agree with following Javadoc syntax . @deprecated would be very useful to have.

@dlabrecq
Copy link
Member Author

That would be fine by me.

@deprecated, @hide, etc. would be a good start. If we could add them, just when we chose to override, that would be even better.

@dlabrecq
Copy link
Member Author

I'm going to reopen this to ensure we apply annotations to the chart docs.

These are the supported annotations: https://github.com/patternfly/patternfly-org/blob/feat/org-redesign/packages

@dlabrecq dlabrecq reopened this Aug 12, 2020
@dlabrecq dlabrecq changed the title react-docs: annotate type documentation Chart docs: annotate types Aug 12, 2020
@redallen redallen assigned dlabrecq and unassigned redallen Sep 22, 2020
@dlabrecq dlabrecq removed their assignment Sep 22, 2020
@stale stale bot added the wontfix label Dec 4, 2020
@patternfly patternfly deleted a comment from stale bot Dec 6, 2020
@stale stale bot removed the wontfix label Dec 6, 2020
@dlabrecq
Copy link
Member Author

Tried using @propType, but does not appear to work. Created https://github.com/patternfly/patternfly-react/issues/5304 to track it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure PF4 React issues for the PF4 core effort
Projects
None yet
4 participants