-
-
Notifications
You must be signed in to change notification settings - Fork 186
Fill guide documents' source codes from remote URL #1594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Merge branch 'master' of https://github.com/samchon/typia into feat/remote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces inline code blocks in MDX docs with a RemoteSource
component that fetches and compiles remote examples, updates import/style consistency, and fixes a typo in JSON schema programmer metadata handling.
- Introduce
RemoteSource
React component for dynamic MDX code loading - Update all validator and JSON-schema docs to use remote sources
- Correct
medadataList
typo tometadataList
inJsonSchemasProgrammer.ts
Reviewed Changes
Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
website/src/components/RemoteSource.tsx | New component to fetch, compile, and render remote MDX code blocks |
website/pages/docs/**/*.mdx | Replace inline fences with <RemoteSource /> for each example |
src/programmers/json/JsonSchemasProgrammer.ts | Fix typo from medadataList to metadataList |
showLineNumbers?: boolean; | ||
highlight?: string; | ||
}) => { | ||
const [component, setComponent] = useState<React.ReactElement | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Instead of returning null while loading, consider rendering a fallback or loading indicator to improve UX during MDX compilation.
Copilot uses AI. Check for mistakes.
useEffect(() => { | ||
const func = async () => { | ||
const content: string = [ | ||
[ | ||
`${BRACKET}typescript`, | ||
!!props.filename?.length | ||
? ` filename=${JSON.stringify(props.filename)}` | ||
: "", | ||
props.showLineNumbers ? " showLineNumbers" : "", | ||
!!props.highlight?.length ? ` {${props.highlight}}` : "", | ||
].join(""), | ||
await loader.get(props.url), | ||
BRACKET, | ||
].join("\n"); | ||
const result = await compileMdx(content); | ||
setComponent( | ||
<MDXRemote | ||
compiledSource={result.result} | ||
frontmatter={result.frontMatter} | ||
scope={result.structurizedData} | ||
/>, | ||
); | ||
}; | ||
func().catch(console.error); | ||
}, [props.url, props.filename, props.showLineNumbers, props.highlight]); | ||
return component; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Logging errors to console may not be visible to end users. Consider capturing and displaying compilation errors in the UI.
useEffect(() => { | |
const func = async () => { | |
const content: string = [ | |
[ | |
`${BRACKET}typescript`, | |
!!props.filename?.length | |
? ` filename=${JSON.stringify(props.filename)}` | |
: "", | |
props.showLineNumbers ? " showLineNumbers" : "", | |
!!props.highlight?.length ? ` {${props.highlight}}` : "", | |
].join(""), | |
await loader.get(props.url), | |
BRACKET, | |
].join("\n"); | |
const result = await compileMdx(content); | |
setComponent( | |
<MDXRemote | |
compiledSource={result.result} | |
frontmatter={result.frontMatter} | |
scope={result.structurizedData} | |
/>, | |
); | |
}; | |
func().catch(console.error); | |
}, [props.url, props.filename, props.showLineNumbers, props.highlight]); | |
return component; | |
const [error, setError] = useState<string | null>(null); | |
useEffect(() => { | |
const func = async () => { | |
try { | |
const content: string = [ | |
[ | |
`${BRACKET}typescript`, | |
!!props.filename?.length | |
? ` filename=${JSON.stringify(props.filename)}` | |
: "", | |
props.showLineNumbers ? " showLineNumbers" : "", | |
!!props.highlight?.length ? ` {${props.highlight}}` : "", | |
].join(""), | |
await loader.get(props.url), | |
BRACKET, | |
].join("\n"); | |
const result = await compileMdx(content); | |
setComponent( | |
<MDXRemote | |
compiledSource={result.result} | |
frontmatter={result.frontMatter} | |
scope={result.structurizedData} | |
/>, | |
); | |
} catch (err) { | |
setError(err instanceof Error ? err.message : "An unknown error occurred."); | |
} | |
}; | |
func(); | |
}, [props.url, props.filename, props.showLineNumbers, props.highlight]); | |
return error ? <div>Error: {error}</div> : component; |
Copilot uses AI. Check for mistakes.
@@ -5,7 +5,10 @@ import { Tabs } from 'nextra/components' | |||
import Alert from '@mui/material/Alert'; | |||
import AlertTitle from '@mui/material/AlertTitle'; | |||
|
|||
import { RemoteSource } from "../../../src/components/RemoteSource"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Imports of RemoteSource
vary between named and default across MDX files; standardize on one import style to reduce confusion.
Copilot uses AI. Check for mistakes.
commit: |
This pull request introduces enhancements and refinements to the
typia
library, focusing on improving error handling, JSON schema generation, and type safety. Key changes include the addition of detailed documentation for theTypeGuardError
class, corrections to metadata handling in JSON schema generation, and expanded support for OpenAPI specifications in JSON schema types.Enhancements to Error Handling:
src/TypeGuardError.ts
: Added comprehensive documentation for theTypeGuardError
class, including detailed descriptions of its properties (method
,path
,expected
,value
) and constructor. This improves clarity on how errors are reported when type assertions fail. [1] [2]src/TypeGuardError.ts
: Introduced anIProps
interface to define the properties required for constructing aTypeGuardError
, with examples for better usability.Improvements to JSON Schema Support:
src/schemas/json/IJsonSchemaCollection.ts
: Enhanced theIJsonSchemaCollection
type with detailed documentation, highlighting differences between OpenAPI v3.0 and v3.1, and their respective features. Added support for type safety and traceability back to TypeScript definitions. [1] [2]src/schemas/json/IJsonSchemaUnit.ts
: Updated theIJsonSchemaUnit
type with documentation to clarify its purpose for single-schema use cases, emphasizing its lightweight structure and compatibility with OpenAPI standards.Bug Fixes:
src/programmers/json/JsonSchemasProgrammer.ts
: Fixed a typo in thewriteV3_0
function parameter frommedadataList
tometadataList
for consistency and correctness.