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

[addon-docs] Deep linking to "kind" in JSDoc comments #8296

Open
kamranayub opened this issue Oct 4, 2019 · 4 comments
Open

[addon-docs] Deep linking to "kind" in JSDoc comments #8296

kamranayub opened this issue Oct 4, 2019 · 4 comments

Comments

@kamranayub
Copy link

kamranayub commented Oct 4, 2019

Is your feature request related to a problem? Please describe.

In JSDocs for components, we may want to link to another component but it seems the "selectedKind" syntax may not work nicely when specifying | characters, like so:

/**
 * See other component {@link /?selectedKind=Header|Menu | Header Menu}
 */

/**
 * See other component [Component](/?selectedKind=Header|Menu)
 */

The @link JSDoc will not translate to a link anyway, so perhaps that's out-of-scope for this request.

The syntax is also a bit awkward, it would be great to take a page out of something like TypeDoc and support a shorthand:

/**
 * See other component [[Header|Menu]]
 */

The main issue is the pipe (|) character again, as it denotes what the link text will be vs. the path.

The approach probably also needs to take into account props table documentation, not just component documentation.

Describe the solution you'd like

Somehow being able to translate the kind syntax to something compatible with @link or a shorthand notation. It should ideally link to the /docs/ path, not the raw story, since this is within the addon-docs context.

/**
 * See other component [[Header|Menu]]
 */

This would render:

See other component <a href="?path=/docs/header-menu--*">Header | Menu</a>

If it were able to perhaps detect the exported component tied to the stories, you could use the component type itself:

export default {
  title: "Header | Menu",
  component: HeaderMenu
}

/**
 * See other component [[HeaderMenu]]
 */

Storybook build would fail when component/kind doesn't match any known values, to ensure links are kept up-to-date.

Describe alternatives you've considered

You can kind of work around this in an awkward fashion by encoding the pipe using %7C and spaces with %20:

/**
 * See [Menu](/?selectedKind=Header%7CMenu)
 */

This links to the stories, not the docs and it loses any benefits of potential warnings/checks of broken component links.

Are you able to assist bring the feature to reality?

Maybe

Additional context

Using the workaround looks like this when rendered:

image

@shilman
Copy link
Member

shilman commented Oct 4, 2019

Related #8184

@stale stale bot added the inactive label Oct 25, 2019
@shilman shilman added the todo label Oct 26, 2019
@stale stale bot removed the inactive label Oct 26, 2019
@storybookjs storybookjs deleted a comment from stale bot Oct 26, 2019
@shilman shilman added this to the 5.3.0 milestone Oct 26, 2019
@shilman shilman modified the milestones: 5.3.0, 6.0.0 Jan 11, 2020
@mririgoyen
Copy link

This would be a very welcome addition. 👍

@shilman
Copy link
Member

shilman commented Mar 15, 2020

@kamranayub the only separator character is / as of 6.0 (available as opt-in in 5.3). does that solve the problem?

@kamranayub
Copy link
Author

kamranayub commented Mar 15, 2020 via email

@shilman shilman modified the milestones: 6.0, 6.0 docs May 8, 2020
@shilman shilman modified the milestones: 6.0 docs, 6.1 docs Jun 24, 2020
@shilman shilman added P0 and removed P0 labels Oct 12, 2020
@shilman shilman modified the milestones: 6.1 docs, 6.2 docs Oct 13, 2020
@shilman shilman removed this from the 6.2 docs milestone Jun 8, 2021
@shilman shilman removed the P3 label Oct 18, 2022
@shilman shilman removed the todo label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Hotlist
Awaiting triage
Development

No branches or pull requests

3 participants