Skip to content

Commit

Permalink
Fix: Formatting for examples in auto-generated metadata docs
Browse files Browse the repository at this point in the history
Fixes formatting for examples in auto-gnerated metadata docs via refactoring `getExamples()` to properly join multiple examples with linebreaks.
  • Loading branch information
robertjdominguez committed Oct 22, 2024
1 parent 1efc7d6 commit c575fac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
28 changes: 21 additions & 7 deletions docs/supergraph-modeling/permissions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ definition:
operator: _eq
value:
sessionVariable: x-hasura-user-id
```,
```



```yaml
kind: ModelPermissions
Expand Down Expand Up @@ -508,7 +510,9 @@ fieldComparison:
operator: _eq
value:
sessionVariable: x-hasura-user-id
```,
```



```yaml
relationship:
Expand All @@ -519,7 +523,9 @@ relationship:
operator: _eq
value:
sessionVariable: x-hasura-user-id
```,
```



```yaml
and:
Expand All @@ -533,7 +539,9 @@ and:
operator: _eq
value:
literal: Hello World
```,
```



```yaml
not:
Expand Down Expand Up @@ -738,7 +746,9 @@ fieldComparison:
operator: _eq
value:
sessionVariable: x-hasura-user-id
```,
```



```yaml
relationship:
Expand All @@ -749,7 +759,9 @@ relationship:
operator: _eq
value:
sessionVariable: x-hasura-user-id
```,
```



```yaml
and:
Expand All @@ -763,7 +775,9 @@ and:
operator: _eq
value:
literal: Hello World
```,
```



```yaml
not:
Expand Down
6 changes: 3 additions & 3 deletions utilities/generate-metadata-docs/src/logic/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ export function getDescription(metadataObject: JSONSchema7Definition): string {
export function getExamples(metadataObject: JSONSchema7Definition): string {
let examples = '';
if (metadataObject.examples) {
examples = `\n **Example${metadataObject.examples.length > 1 ? 's' : ''}:**${metadataObject.examples.map(
example => `\n\n\`\`\`yaml\n${jsYaml.dump(example)}\`\`\``
)}`;
examples =
`\n **Example${metadataObject.examples.length > 1 ? 's' : ''}:**` +
metadataObject.examples.map(example => `\n\n\`\`\`yaml\n${jsYaml.dump(example)}\`\`\``).join('\n\n');
}

return examples;
Expand Down

0 comments on commit c575fac

Please sign in to comment.