Skip to content

Commit 0da70fa

Browse files
committed
Fix python page for metadata
1 parent a58d474 commit 0da70fa

File tree

2 files changed

+83
-78
lines changed

2 files changed

+83
-78
lines changed

src/app/docs/python/page.tsx

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
'use client'
2-
import {
3-
renderCodeTable,
4-
renderExamples,
5-
formatShortHandAnchorIds,
6-
formatAnchorIds,
7-
} from '../../../utils'
8-
import props from '../../../../schema/python.json'
9-
import { OnThisPageContent } from '@/components/_onThisPage'
10-
import { useEffect, useState } from 'react'
111
import { Metadata } from 'next'
2+
import PythonArticle from './python'
123

134
export const metadata: Metadata = {
145
title: 'TerminusDB Python Client API Reference',
@@ -20,76 +11,10 @@ export const metadata: Metadata = {
2011
}
2112

2213
export default function Python() {
23-
const [onPageContent, setOnPageContent] = useState<JSX.Element | null>(null)
24-
useEffect(() => {
25-
setOnPageContent(<OnThisPageContent />)
26-
}, [])
27-
const modules = props.modules
28-
const layout = modules.map((mod) => {
29-
const classes = mod.classes
30-
.filter((x) => x.memberFunctions.length > 0)
31-
.map((class_) => {
32-
const functions = class_.memberFunctions.map((func) => {
33-
let args = null
34-
let shortArgs = null
35-
if (
36-
typeof func.parameters !== 'undefined' &&
37-
func.parameters.length > 0
38-
) {
39-
args = renderCodeTable(func.parameters)
40-
shortArgs = func.parameters.map((x) => x.name).join(', ')
41-
}
42-
let examples = null
43-
if (
44-
typeof func.examples !== 'undefined' &&
45-
(func.examples?.length??0) > 0
46-
) {
47-
examples = renderExamples(func.examples, 'python', func.name)
48-
}
49-
return (
50-
<div key={func.name}>
51-
<h4
52-
className="divider"
53-
id={formatAnchorIds(
54-
formatShortHandAnchorIds(func.name, shortArgs),
55-
)}
56-
>
57-
{func.name}({shortArgs})
58-
</h4>
59-
<div data-accordion="collapse">
60-
<p>{func.summary}</p>
61-
{args}
62-
{examples}
63-
</div>
64-
</div>
65-
)
66-
})
67-
return (
68-
<div key={class_.name}>
69-
<h3 id={formatAnchorIds(class_.name)}>{class_.name}</h3>
70-
{functions}
71-
</div>
72-
)
73-
})
74-
return <div key={mod.name}>{classes}</div>
75-
})
14+
7615
return (
7716
<main id="content-wrapper" className="w-full max-w-2xl min-w-0 flex-auto px-4 py-16 lg:max-w-none lg:pr-0 lg:pl-8 xl:px-16">
78-
<article className="w-full flex flex-row">
79-
<div id="mainContent" className="overflow-x-scroll">
80-
<h1 className="tdb__subtitle font-display text-3xl tracking-tight text-slate-900 dark:text-white">
81-
Python
82-
</h1>
83-
<div className="prose dark:prose-invert">
84-
{layout}
85-
</div>
86-
</div>
87-
<div className='hidden lg:block sm:mr-64 w-32 lg:mr-40 relative '>
88-
</div>
89-
<div className="fixed md:right-12 top-24 lg:right-12 w-64 flex-none pl-8 text-xs xl:block xl:text-sm">
90-
{onPageContent}
91-
</div>
92-
</article>
17+
<PythonArticle/>
9318
</main>
9419
)
9520
}

src/app/docs/python/python.tsx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
'use client'
2+
import {
3+
renderCodeTable,
4+
renderExamples,
5+
formatShortHandAnchorIds,
6+
formatAnchorIds,
7+
} from '../../../utils'
8+
import props from '../../../../schema/python.json'
9+
import { OnThisPageContent } from '@/components/_onThisPage'
10+
import { useEffect, useState } from 'react'
11+
12+
export default function PythonArticle() {
13+
const [onPageContent, setOnPageContent] = useState<JSX.Element | null>(null)
14+
useEffect(() => {
15+
setOnPageContent(<OnThisPageContent />)
16+
}, [])
17+
const modules = props.modules
18+
const layout = modules.map((mod) => {
19+
const classes = mod.classes
20+
.filter((x) => x.memberFunctions.length > 0)
21+
.map((class_) => {
22+
const functions = class_.memberFunctions.map((func) => {
23+
let args = null
24+
let shortArgs = null
25+
if (
26+
typeof func.parameters !== 'undefined' &&
27+
func.parameters.length > 0
28+
) {
29+
args = renderCodeTable(func.parameters)
30+
shortArgs = func.parameters.map((x) => x.name).join(', ')
31+
}
32+
let examples = null
33+
if (
34+
typeof func.examples !== 'undefined' &&
35+
(func.examples?.length ?? 0) > 0
36+
) {
37+
examples = renderExamples(func.examples, 'python', func.name)
38+
}
39+
return (
40+
<div key={func.name}>
41+
<h4
42+
className="divider"
43+
id={formatAnchorIds(
44+
formatShortHandAnchorIds(func.name, shortArgs),
45+
)}
46+
>
47+
{func.name}({shortArgs})
48+
</h4>
49+
<div data-accordion="collapse">
50+
<p>{func.summary}</p>
51+
{args}
52+
{examples}
53+
</div>
54+
</div>
55+
)
56+
})
57+
return (
58+
<div key={class_.name}>
59+
<h3 id={formatAnchorIds(class_.name)}>{class_.name}</h3>
60+
{functions}
61+
</div>
62+
)
63+
})
64+
return <div key={mod.name}>{classes}</div>
65+
})
66+
return (
67+
<article className="flex w-full flex-row">
68+
<div id="mainContent" className="overflow-x-scroll">
69+
<h1 className="tdb__subtitle font-display text-3xl tracking-tight text-slate-900 dark:text-white">
70+
Python
71+
</h1>
72+
<div className="prose dark:prose-invert">{layout}</div>
73+
</div>
74+
<div className="relative hidden w-32 sm:mr-64 lg:mr-40 lg:block"></div>
75+
<div className="fixed top-24 w-64 flex-none pl-8 text-xs md:right-12 lg:right-12 xl:block xl:text-sm">
76+
{onPageContent}
77+
</div>
78+
</article>
79+
)
80+
}

0 commit comments

Comments
 (0)