Skip to content

Commit f8ba23c

Browse files
committed
Fixed docs site build issues
1 parent 5006e16 commit f8ba23c

File tree

9 files changed

+58
-47
lines changed

9 files changed

+58
-47
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. See [standa
44

55
## [1.11.0](https://github.com/elilambnz/react-py/compare/v1.10.7...v1.11.0) (2024-08-05)
66

7+
### Features
8+
9+
- Added `autoImportPackages` prop to automatically import packages in a code chunk
10+
711
### [1.10.7](https://github.com/elilambnz/react-py/compare/v1.10.6...v1.10.7) (2024-02-13)
812

913
### [1.10.6](https://github.com/elilambnz/react-py/compare/v1.10.5...v1.10.6) (2023-09-21)

website/docs/examples/custom-modules.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ By default, Python modules are cached. If you intend to make changes to an impor
1010

1111
Create a module using the file system APIs or write the file using Python, [examples here](file-system).
1212

13-
Then call `watchModules()` to automatically reload the module before running code. For more info, see the [API reference docs](../introduction/api-reference#watchModules).
13+
Then call `watchModules()` to automatically reload the module before running code. For more info, see the [API reference docs](../introduction/api-reference.md#watchmodules).
1414

1515
The following example shows this in action. To try it out:
1616

website/docs/examples/file-system.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import MultiFileExample from '../../src/components/MultiFileExample'
88

99
Some internal Pyodide file system methods are exposed.
1010

11-
For more info, see the [API reference docs](../introduction/api-reference#usepython-hook).
11+
For more info, see the [API reference docs](../introduction/api-reference#readfile).
1212

1313
```tsx
1414
import { usePython } from 'react-py'

website/docs/introduction/usage.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ render(<App />, document.getElementById('root'))
2727

2828
## `usePython` Hook
2929

30-
Use the `usePython` hook to run code and access both stdout and stderr. For props, see the [API reference docs](../introduction/api-reference#usepython-hook).
30+
Use the `usePython` hook to run code and access both stdout and stderr. For props, see the [API reference docs](../introduction/api-reference#usepython-and-usepythonconsole-hooks).
3131

3232
Try the example, [Basic Example](../examples/basic-example.md).
3333

@@ -74,7 +74,7 @@ function Codeblock() {
7474

7575
## `usePythonConsole` Hook
7676

77-
Use the `usePythonConsole` hook to emulate a Python console to run code and access both stdout and stderr. For props, see the [API reference docs](../introduction/api-reference#usepython-hook).
77+
Use the `usePythonConsole` hook to emulate a Python console to run code and access both stdout and stderr. For props, see the [API reference docs](../introduction/api-reference#usepython-and-usepythonconsole-hooks).
7878

7979
Try the example, [REPL](../examples/repl.mdx).
8080

website/src/components/Editor.tsx

+37-31
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,53 @@
1-
import AceEditor from "react-ace";
2-
3-
import "ace-builds/src-noconflict/mode-python";
4-
import "ace-builds/src-noconflict/theme-textmate";
5-
import "ace-builds/src-noconflict/theme-twilight";
6-
import "ace-builds/src-noconflict/ext-language_tools";
1+
import BrowserOnly from '@docusaurus/BrowserOnly'
72

83
const editorOptions = {
94
enableBasicAutocompletion: true,
105
enableLiveAutocompletion: true,
116
highlightActiveLine: false,
12-
showPrintMargin: false,
13-
};
7+
showPrintMargin: false
8+
}
149

1510
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1611
const editorOnLoad = (editor: any) => {
17-
editor.renderer.setScrollMargin(10, 10, 0, 0);
18-
editor.moveCursorTo(0, 0);
19-
};
12+
editor.renderer.setScrollMargin(10, 10, 0, 0)
13+
editor.moveCursorTo(0, 0)
14+
}
2015

2116
export default function Editor({
2217
theme,
2318
input,
24-
onChange,
19+
onChange
2520
}: {
26-
theme: string;
27-
input: string;
28-
onChange: (value: string) => void;
21+
theme: string
22+
input: string
23+
onChange: (value: string) => void
2924
}) {
3025
return (
31-
<AceEditor
32-
value={input}
33-
mode="python"
34-
name="CodeBlock"
35-
fontSize="0.9rem"
36-
className="flex-1 overflow-clip"
37-
theme={theme === "dark" ? "twilight" : "textmate"}
38-
onChange={onChange}
39-
width="100%"
40-
height="100%"
41-
onLoad={editorOnLoad}
42-
editorProps={{ $blockScrolling: true }}
43-
setOptions={editorOptions}
44-
wrapEnabled={true}
45-
/>
46-
);
26+
<BrowserOnly fallback={<div>Loading...</div>}>
27+
{() => {
28+
const AceEditor = require('react-ace').default
29+
require('ace-builds/src-noconflict/mode-python')
30+
require('ace-builds/src-noconflict/theme-textmate')
31+
require('ace-builds/src-noconflict/theme-twilight')
32+
require('ace-builds/src-noconflict/ext-language_tools')
33+
return (
34+
<AceEditor
35+
value={input}
36+
mode="python"
37+
name="CodeBlock"
38+
fontSize="0.9rem"
39+
className="flex-1 overflow-clip"
40+
theme={theme === 'dark' ? 'twilight' : 'textmate'}
41+
onChange={onChange}
42+
width="100%"
43+
height="100%"
44+
onLoad={editorOnLoad}
45+
editorProps={{ $blockScrolling: true }}
46+
setOptions={editorOptions}
47+
wrapEnabled={true}
48+
/>
49+
)
50+
}}
51+
</BrowserOnly>
52+
)
4753
}

website/src/components/Environment.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useRef, useState } from 'react'
2-
import { usePythonConsole } from 'react-py'
2+
import { usePythonConsole } from '@site/../dist'
33

44
import Editor from './Editor'
55
import Output from './Output'

website/src/components/Output.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useEffect, useRef, useState } from 'react'
2-
import { ConsoleState } from 'react-py/dist/types/Console'
2+
3+
import { ConsoleState } from '@site/../dist/types/Console'
4+
35
import clsx from 'clsx'
46

57
const ps1 = '>>> '

website/src/pages/index.tsx

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useState } from 'react'
22
import Link from '@docusaurus/Link'
33
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
44
import Layout from '@theme/Layout'
5-
import { useColorMode } from '@docusaurus/theme-common'
65

76
import Logo from '../../static/img/logo.svg'
87

@@ -24,14 +23,7 @@ import {
2423
import clsx from 'clsx'
2524

2625
function HomepageHeader() {
27-
const [isDarkMode, setIsDarkMode] = useState(false)
28-
2926
const { siteConfig } = useDocusaurusContext()
30-
const { colorMode } = useColorMode()
31-
32-
useEffect(() => {
33-
setIsDarkMode(colorMode === 'dark')
34-
}, [colorMode])
3527

3628
return (
3729
<div>

website/src/pages/playground/index.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ import Layout from '@theme/Layout'
44
import { useColorMode } from '@docusaurus/theme-common'
55

66
import Environment from '@site/src/components/Environment'
7+
import BrowserOnly from '@docusaurus/BrowserOnly'
78

89
function EnvironmentContainer() {
910
const { colorMode } = useColorMode()
1011

11-
return <Environment theme={colorMode} />
12+
return (
13+
<BrowserOnly fallback={<div>Loading...</div>}>
14+
{() => {
15+
return <Environment theme={colorMode} />
16+
}}
17+
</BrowserOnly>
18+
)
1219
}
1320

1421
export default function Playground(): JSX.Element {

0 commit comments

Comments
 (0)