forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
204 changed files
with
539,771 additions
and
593,170 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
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.codeBlock { | ||
pre { | ||
margin-bottom: 0; | ||
border: 1px solid var(--color-border-default); | ||
max-height: 32rem; | ||
overflow: auto; | ||
} | ||
} |
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,29 @@ | ||
import cx from 'classnames' | ||
|
||
import styles from './CodeBlock.module.scss' | ||
|
||
type Props = { | ||
verb?: string | ||
codeBlock: string | ||
setHTML?: boolean | ||
} | ||
|
||
export function CodeBlock({ verb, codeBlock, setHTML = false }: Props) { | ||
return setHTML ? ( | ||
<div | ||
className={cx(styles.codeBlock, 'rounded')} | ||
dangerouslySetInnerHTML={{ __html: codeBlock }} | ||
/> | ||
) : ( | ||
<pre className={cx(styles.methodCodeBlock, 'mb-3 rounded-1 border')}> | ||
<code> | ||
{verb && ( | ||
<span className="color-bg-accent-emphasis color-fg-on-emphasis rounded-1 px-2 py-1 text-uppercase"> | ||
{verb} | ||
</span> | ||
)}{' '} | ||
{codeBlock} | ||
</code> | ||
</pre> | ||
) | ||
} |
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,48 @@ | ||
import { xCodeSample } from './types' | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
import { CodeBlock } from './CodeBlock' | ||
|
||
type Props = { | ||
slug: string | ||
xCodeSamples: Array<xCodeSample> | ||
} | ||
|
||
export function RestCodeSamples({ slug, xCodeSamples }: Props) { | ||
const { t } = useTranslation('products') | ||
|
||
return ( | ||
<> | ||
<h4 className="pt-3 my-4" id={`${slug}--code-samples`}> | ||
<a href={`#${slug}--code-samples`}>{`${t('rest.reference.code_samples')}`}</a> | ||
</h4> | ||
{xCodeSamples.map((sample: xCodeSample, index: number) => { | ||
const sampleElements: JSX.Element[] = [] | ||
if (sample.lang !== 'Ruby') { | ||
sampleElements.push( | ||
sample.lang === 'JavaScript' ? ( | ||
<h5 key={`${sample.lang}-${index}`} className="pt-3"> | ||
{sample.lang} ( | ||
<a className="text-underline" href="https://github.com/octokit/core.js#readme"> | ||
@octokit/core.js | ||
</a> | ||
) | ||
</h5> | ||
) : ( | ||
<h5 key={`${sample.lang}-${index}`} className="pt-3"> | ||
{sample.lang} | ||
</h5> | ||
) | ||
) | ||
sampleElements.push( | ||
<CodeBlock | ||
key={sample.lang + index} | ||
codeBlock={sample.sourceHTML} | ||
setHTML={true} | ||
></CodeBlock> | ||
) | ||
} | ||
return sampleElements | ||
})} | ||
</> | ||
) | ||
} |
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,10 @@ | ||
import { CodeBlock } from './CodeBlock' | ||
|
||
type Props = { | ||
verb: string | ||
requestPath: string | ||
} | ||
|
||
export function RestHTTPMethod({ verb, requestPath }: Props) { | ||
return <CodeBlock verb={verb} codeBlock={requestPath}></CodeBlock> | ||
} |
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,26 @@ | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
|
||
type Props = { | ||
notes: Array<string> | ||
enabledForGitHubApps: boolean | ||
} | ||
|
||
export function RestNotes({ notes, enabledForGitHubApps }: Props) { | ||
const { t } = useTranslation('products') | ||
|
||
return ( | ||
<> | ||
<h4 className="pt-4">{t('rest.reference.notes')}</h4> | ||
<ul className="mt-2 pl-3 pb-2"> | ||
{enabledForGitHubApps && ( | ||
<li> | ||
<a href="/developers/apps">Works with GitHub Apps</a> | ||
</li> | ||
)} | ||
{notes.map((note: string) => { | ||
return <li>{note}</li> | ||
})} | ||
</ul> | ||
</> | ||
) | ||
} |
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,53 @@ | ||
import { RestOperationHeading } from './RestOperationHeading' | ||
import { RestHTTPMethod } from './RestHTTPMethod' | ||
import { RestParameterTable } from './RestParameterTable' | ||
import { RestCodeSamples } from './RestCodeSamples' | ||
import { RestResponse } from './RestResponse' | ||
import { Operation } from './types' | ||
import { RestNotes } from './RestNotes' | ||
import { RestPreviewNotice } from './RestPreviewNotice' | ||
|
||
type Props = { | ||
operation: Operation | ||
index: number | ||
} | ||
|
||
export function RestOperation({ operation }: Props) { | ||
const previews = operation['x-github'].previews | ||
const hasRequiredPreviews = previews | ||
? previews.filter((preview) => preview.required).length > 0 | ||
: false | ||
|
||
return ( | ||
<div> | ||
<RestOperationHeading | ||
slug={operation.slug} | ||
summary={operation.summary} | ||
descriptionHTML={operation.descriptionHTML} | ||
/> | ||
<RestHTTPMethod verb={operation.verb} requestPath={operation.requestPath} /> | ||
{operation.parameters && ( | ||
<RestParameterTable | ||
slug={operation.slug} | ||
hasRequiredPreviews={hasRequiredPreviews} | ||
xGitHub={operation['x-github']} | ||
parameters={operation.parameters} | ||
bodyParameters={operation.bodyParameters} | ||
/> | ||
)} | ||
{operation['x-codeSamples'] && operation['x-codeSamples'].length > 0 && ( | ||
<RestCodeSamples slug={operation.slug} xCodeSamples={operation['x-codeSamples']} /> | ||
)} | ||
<RestResponse responses={operation.responses} /> | ||
{(operation.notes.length > 0 || operation['x-github'].enabledForGitHubApps) && ( | ||
<RestNotes | ||
notes={operation.notes} | ||
enabledForGitHubApps={operation['x-github'].enabledForGitHubApps} | ||
/> | ||
)} | ||
{previews && ( | ||
<RestPreviewNotice slug={operation.slug} previews={operation['x-github'].previews} /> | ||
)} | ||
</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,21 @@ | ||
import { LinkIcon } from '@primer/octicons-react' | ||
|
||
type Props = { | ||
slug: string | ||
summary: string | ||
descriptionHTML: string | ||
} | ||
|
||
export function RestOperationHeading({ slug, summary, descriptionHTML }: Props) { | ||
return ( | ||
<> | ||
<h3 id={slug}> | ||
<a href={`#${slug}`}> | ||
<LinkIcon size={16} className="m-1" /> | ||
</a> | ||
{summary} | ||
</h3> | ||
<div dangerouslySetInnerHTML={{ __html: descriptionHTML }} /> | ||
</> | ||
) | ||
} |
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,43 @@ | ||
.parameterTable { | ||
display: table; | ||
border-collapse: collapse; | ||
position: relative; | ||
width: 100%; | ||
line-height: 1.5; | ||
table-layout: auto; | ||
|
||
thead { | ||
tr { | ||
border-top: none; | ||
|
||
th { | ||
border: 0; | ||
font-weight: normal; | ||
} | ||
} | ||
} | ||
|
||
tr:nth-child(2n) { | ||
background: none !important; | ||
} | ||
|
||
td { | ||
padding: 0.75rem 0.5rem !important; | ||
border: 0 !important; | ||
vertical-align: top; | ||
} | ||
|
||
tbody { | ||
tr td:first-child { | ||
font-weight: bold; | ||
} | ||
|
||
table tr td:not(:first-child) { | ||
font-weight: normal; | ||
} | ||
} | ||
|
||
code { | ||
background-color: var(--color-canvas-subtle); | ||
} | ||
} |
Oops, something went wrong.