Skip to content

Commit

Permalink
Add docs component for API members that are marked as alpha/beta (#11529
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jerelmiller authored Jan 26, 2024
1 parent 2964a13 commit deffc69
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
29 changes: 29 additions & 0 deletions docs/shared/ApiDoc/DocBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export function DocBlock({
example = false,
remarksCollapsible = false,
deprecated = false,
releaseTag = false,
}) {
return (
<Stack spacing="4">
{deprecated && <Deprecated canonicalReference={canonicalReference} />}
{releaseTag && <ReleaseTag canonicalReference={canonicalReference} />}
{summary && <Summary canonicalReference={canonicalReference} />}
{remarks && (
<Remarks
Expand Down Expand Up @@ -130,3 +132,30 @@ Example.propTypes = {
collapsible: PropTypes.bool,
index: PropTypes.number,
};

export function ReleaseTag({ canonicalReference }) {
const getItem = useApiDocContext();
const item = getItem(canonicalReference);
const MDX = useMDXComponents();

if (item.releaseTag === "Public") {
return null;
}

return (
<MDX.ExperimentalFeature>
This is in{" "}
<MDX.PrimaryLink
href="https://www.apollographql.com/docs/resources/product-launch-stages/#alpha--beta"
target="_blank"
>
{item.releaseTag.toLowerCase()} stage
</MDX.PrimaryLink>{" "}
and is subject to breaking changes.
</MDX.ExperimentalFeature>
);
}

ReleaseTag.propTypes = {
canonicalReference: PropTypes.string.isRequired,
};
7 changes: 6 additions & 1 deletion docs/shared/ApiDoc/Function.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ export function FunctionDetails({
headingLevel={headingLevel}
since
/>
<DocBlock canonicalReference={canonicalReference} deprecated remarks />
<DocBlock
canonicalReference={canonicalReference}
deprecated
remarks
releaseTag
/>
{item.comment?.examples.length == 0 ? null : (
<>
<SubHeading
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/ApiDoc/PropertySignatureTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
FunctionSignature,
useApiDocContext,
ApiDocHeading,
SectionHeading,
} from ".";
import { GridItem, Text } from "@chakra-ui/react";
import { ResponsiveGrid } from "./ResponsiveGrid";
Expand Down Expand Up @@ -105,6 +104,7 @@ export function PropertySignatureTable({
summary
remarks
remarkCollapsible
releaseTag
/>
</GridItem>
</React.Fragment>
Expand Down
9 changes: 8 additions & 1 deletion docs/shared/ApiDoc/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export { useApiDocContext } from "./Context";
export { DocBlock, Deprecated, Example, Remarks, Summary } from "./DocBlock";
export {
DocBlock,
Deprecated,
Example,
Remarks,
ReleaseTag,
Summary,
} from "./DocBlock";
export { PropertySignatureTable } from "./PropertySignatureTable";
export { ApiDocHeading, SubHeading, SectionHeading } from "./Heading";
export { InterfaceDetails } from "./InterfaceDetails";
Expand Down

0 comments on commit deffc69

Please sign in to comment.