Skip to content

Commit

Permalink
Merge pull request #1580 from newrelic/zstix/fix-logger-doc
Browse files Browse the repository at this point in the history
Fix `logger` API page
  • Loading branch information
zstix authored Sep 2, 2021
2 parents 145d8f2 + 053becf commit 085c02d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/DevSiteSeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function DevSiteSeo({ description, meta, title, tags, location }) {

return (
<SEO location={location} title={title}>
{validMetadata.map((data) => (
<meta key={data.name} {...data} />
{validMetadata.map((data, index) => (
<meta key={`${data.name}-${index}`} {...data} />
))}
<script src={withPrefix('tessen.min-1.3.0.js')} type="text/javascript" />
</SEO>
Expand Down
28 changes: 20 additions & 8 deletions src/components/FunctionDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ import CodeDef from './CodeDef';
import { graphql } from 'gatsby';

const FunctionDefinition = ({ className, arguments: params, returnValue }) => {
if (!params.length && !returnValue.length) {
const hasParams = params.length;
const isReturnArray = Array.isArray(returnValue);
const hasReturn =
(isReturnArray && returnValue.length) || (!isReturnArray && returnValue);

if (!hasParams && !hasReturn) {
return null;
}

if (!Array.isArray(returnValue)) {
returnValue = [returnValue];
}

return (
<CodeDef className={className}>
<CodeDef.Keyword>function</CodeDef.Keyword>{' '}
Expand All @@ -30,14 +39,19 @@ const FunctionDefinition = ({ className, arguments: params, returnValue }) => {
{params.length > 0 && <CodeDef.Bracket>)</CodeDef.Bracket>}
{returnValue.length > 0 && (
<>
<CodeDef.Operator> => </CodeDef.Operator>
<CodeDef.Operator> =&gt; </CodeDef.Operator>
<CodeDef.Type>{returnValue[0].type}</CodeDef.Type>
</>
)}
</CodeDef>
);
};

const ReturnValueType = PropTypes.shape({
type: PropTypes.string,
description: PropTypes.string,
});

FunctionDefinition.propTypes = {
className: PropTypes.string,
arguments: PropTypes.arrayOf(
Expand All @@ -47,12 +61,10 @@ FunctionDefinition.propTypes = {
description: PropTypes.string,
})
).isRequired,
returnValue: PropTypes.arrayOf(
PropTypes.shape({
type: PropTypes.string,
description: PropTypes.string,
})
).isRequired,
returnValue: PropTypes.oneOfType([
ReturnValueType,
PropTypes.arrayOf(ReturnValueType),
]).isRequired,
};

export const query = graphql`
Expand Down
14 changes: 8 additions & 6 deletions src/components/MethodReference.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ const MethodReference = ({ className, method }) => {
<h3>
<code>{method.name}</code>
</h3>
<Markdown
source={method.description}
css={css`
margin-bottom: 1rem;
`}
/>
{method.description && method.description !== 'undefined' && (
<Markdown
source={method.description}
css={css`
margin-bottom: 1rem;
`}
/>
)}
<FunctionDefinition
arguments={method.arguments}
returnValue={method.returnValue}
Expand Down

0 comments on commit 085c02d

Please sign in to comment.