-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from serut/feature/various-improvements
Improve types, doc, allow spec on ApiSchema, fix showExample
- Loading branch information
Showing
25 changed files
with
2,146 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,5 +79,8 @@ | |
"printWidth": 80, | ||
"tabWidth": 2 | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"volta": { | ||
"node": "18.12.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/docusaurus-theme-redoc/src/theme/ApiDocMdx/ApiDocMdx.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 10 additions & 13 deletions
23
packages/docusaurus-theme-redoc/src/theme/Redoc/Redoc.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import '../../global'; | ||
import { RedocStandalone, RedocRawOptions } from 'redoc'; | ||
import { SpecProps } from '../../types/common'; | ||
import { useSpecOptions } from '../../utils/useSpecOptions'; | ||
import { RedocStandalone } from 'redoc'; | ||
import useSpecOptions from '@theme/useSpecOptions'; | ||
import './styles.css'; | ||
import ServerRedoc from './ServerRedoc'; | ||
|
||
function getIsExternalUrl(url = '') { | ||
return ['http://', 'https://'].some((protocol) => url.startsWith(protocol)); | ||
} | ||
|
||
/*! | ||
* Redocusaurus | ||
* https://redocusaurus.vercel.app/ | ||
* (c) 2024 Rohit Gohri | ||
* Released under the MIT License | ||
*/ | ||
function Redoc( | ||
props: Partial<SpecProps> & { | ||
className?: string; | ||
optionsOverrides?: RedocRawOptions; | ||
}, | ||
): JSX.Element { | ||
const { className, optionsOverrides, spec, url, themeId, isSpecFile } = props; | ||
function Redoc(props: RedocProps): JSX.Element { | ||
const { className, optionsOverrides, url, themeId } = props; | ||
const { options } = useSpecOptions(themeId, optionsOverrides); | ||
const isDevMode = process.env.NODE_ENV === 'development'; | ||
|
||
if ((isDevMode && isSpecFile === false) || !spec) { | ||
if (getIsExternalUrl(url)) { | ||
return ( | ||
<div className={clsx(['redocusaurus', className])}> | ||
<RedocStandalone specUrl={url} options={options} /> | ||
</div> | ||
); | ||
} | ||
|
||
return <ServerRedoc {...props} spec={spec} />; | ||
return <ServerRedoc {...props} />; | ||
} | ||
|
||
export default Redoc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
import React from 'react'; | ||
import '../../global'; | ||
import type { RedocRawOptions } from 'redoc'; | ||
import type { ServerStylesProps } from './ServerStyles'; | ||
|
||
/** | ||
* Don't hydrate/replace server styles | ||
* @see https://github.com/facebook/react/issues/10923#issuecomment-338715787 | ||
*/ | ||
export function ServerStyles(_props: { | ||
specProps: SpecProps; | ||
lightThemeOptions: RedocRawOptions; | ||
darkThemeOptions: RedocRawOptions; | ||
}) { | ||
export function ServerStyles(_props: ServerStylesProps) { | ||
return <div className="redocusaurus-styles"></div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { useSpec } from './useSpec'; | ||
|
||
export default useSpec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/docusaurus-theme-redoc/src/theme/useSpecData/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { useSpecData } from './useSpecData'; | ||
|
||
export default useSpecData; |
Oops, something went wrong.