Skip to content

Commit

Permalink
feat: generate code samples (#1586)
Browse files Browse the repository at this point in the history
* feat: generate code samples

* chore(release): publish@4.11.15
  • Loading branch information
melissag-ensemble committed Jun 17, 2024
1 parent b786772 commit 7ea5dc2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Using a theme, all of your default configuration lives in an npm package.
- [disableSearch (optional)](#disablesearch-optional)
- [hideTryItPanel (optional)](#hidetryitpanel-optional)
- [jsonSampleExpandLevel (optional)](#jsonsampleexpandlevel-optional)
- [generateCodeSamples (optional)](#generatecodesamples-optional)
- [JSDoc](#jsdoc)
- [MDX](#mdx)
- [Modular Content System](#modular-content-system)
Expand Down Expand Up @@ -1207,6 +1208,17 @@ Defaults to ```2```
https://redocly.com/docs/api-reference-docs/configuration/functionality/#theme-object-openapi-schema
#### generateCodeSamples (optional)
```js
<RedoclyAPIBlock src="URL pointing to your open api yaml file." generateCodeSamples="languages: [{ lang: 'curl' }, { lang: 'Node.js' }, { lang: 'JavaScript' }, {lang: 'Python'}]" />
```
Controls options for generating code samples, including code sample languages.
Defaults to ```languages: [], skipOptionalParameters: false```
https://redocly.com/docs/api-reference-docs/configuration/functionality#theme-object-openapi-schema
### JSDoc
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby-theme-aio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.11.15](https://github.com/adobe/aio-theme/compare/@adobe/gatsby-theme-aio@4.11.14...@adobe/gatsby-theme-aio@4.11.15) (2024-06-17)

### Features
* Add option to generate code samples in RedoclyAPIBlock [f751bb5](https://github.com/adobe/aio-theme/commit/f751bb5f91dbbfd8f78bcdea0ea89093f907bbf2)

## [4.11.14](https://github.com/adobe/aio-theme/compare/@adobe/gatsby-theme-aio@4.11.13...@adobe/gatsby-theme-aio@4.11.14) (2024-05-14)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-theme-aio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/gatsby-theme-aio",
"version": "4.11.14",
"version": "4.11.15",
"description": "The Adobe I/O theme for building markdown powered sites",
"main": "index.js",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const RedoclyAPIBlock = ({
disableSearch = false,
hideTryItPanel = false,
jsonSampleExpandLevel = 2,
generateCodeSamples = 'languages: [], skipOptionalParameters: false,',
}) => {
const [isRedoclyLoading, setIsRedoclyLoading] = useState(true);

Expand Down Expand Up @@ -67,6 +68,7 @@ const RedoclyAPIBlock = ({
disableSearch: ${disableSearch},
hideTryItPanel: ${hideTryItPanel},
jsonSampleExpandLevel: ${jsonSampleExpandLevel === all ? `'${jsonSampleExpandLevel}'` : jsonSampleExpandLevel},
${generateCodeSamples ? "generateCodeSamples: { " + generateCodeSamples + "}," : ''}
hideLoading: true,
theme: {
${typography ? "typography: { " + typography + "}," : ''}
Expand Down Expand Up @@ -97,6 +99,7 @@ RedoclyAPIBlock.propTypes = {
PropTypes.oneOf([all]),
PropTypes.number,
]),
generateCodeSamples: PropTypes.string,
};

export { RedoclyAPIBlock };

0 comments on commit 7ea5dc2

Please sign in to comment.