Skip to content

Commit a0119f0

Browse files
DominicGBauerDominicGBauer
andauthored
chore(docs): add improvements (#119)
Co-authored-by: DominicGBauer <[email protected]>
1 parent ecfcd1a commit a0119f0

File tree

7 files changed

+68
-54
lines changed

7 files changed

+68
-54
lines changed

docs/docusaurus.config.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { themes as prismThemes } from 'prism-react-renderer';
2+
import type { TypeDocOptionMap } from 'typedoc';
23
import type { Config } from '@docusaurus/types';
34
import type * as Preset from '@docusaurus/preset-classic';
4-
import { packageMap } from './utils/packageMap';
5+
import type { PluginOptions } from 'docusaurus-plugin-typedoc';
6+
import { DOC_FOLDER, packageMap } from './utils/packageMap';
57
import 'dotenv/config';
68

79
const PROJECT_NAME = process.env.GH_PROJECT_NAME;
@@ -13,8 +15,17 @@ const plugins = Object.entries(packageMap).map(([id, config]) => [
1315
excludeExternals: true,
1416
entryPoints: config.entryPoints,
1517
tsconfig: config.tsconfig,
16-
out: config.dirName
17-
}
18+
out: `${DOC_FOLDER}/${config.dirName}`,
19+
parametersFormat: 'table',
20+
propertiesFormat: 'table',
21+
enumMembersFormat: 'table',
22+
indexFormat: 'table',
23+
typeDeclarationFormat: 'table',
24+
membersWithOwnFile: ['Class', 'Enum', 'Function', 'Interface'],
25+
textContentMappings: {
26+
'title.memberPage': '{name}'
27+
}
28+
} as Partial<PluginOptions | TypeDocOptionMap>
1829
]);
1930

2031
const config: Config = {
@@ -45,7 +56,6 @@ const config: Config = {
4556
defaultLocale: 'en',
4657
locales: ['en']
4758
},
48-
4959
presets: [
5060
[
5161
'classic',

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"@docusaurus/tsconfig": "3.2.1",
2525
"@docusaurus/types": "3.2.1",
2626
"@types/node": "^20.12.5",
27-
"docusaurus-plugin-typedoc": "^0.22.0",
28-
"typedoc": "^0.25.12",
29-
"typedoc-plugin-markdown": "^3.17.1",
27+
"docusaurus-plugin-typedoc": "^1.0.0next.28",
28+
"typedoc": "^0.25.13",
29+
"typedoc-plugin-markdown": "^4.0.0next.55",
3030
"typescript": "~5.4.4"
3131
},
3232
"browserslist": {

docs/sidebars.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';
2-
import { packageMap } from './utils/packageMap';
2+
import { DOC_FOLDER, packageMap } from './utils/packageMap';
33

44
const items = Object.values(packageMap).map((config) => ({
55
type: 'category',
66
label: config.name,
7-
items: [
8-
{
9-
type: 'autogenerated',
10-
dirName: config.dirName
11-
}
12-
]
7+
link: {
8+
type: 'doc',
9+
id: `${config.dirName}/index`
10+
},
11+
items: require(`./${DOC_FOLDER}/${config.dirName}/typedoc-sidebar.cjs`)
1312
})) as unknown as SidebarsConfig;
1413

1514
const sidebars: SidebarsConfig = {

docs/utils/packageMap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const DOC_FOLDER = 'docs';
2+
13
enum Packages {
24
ReactNativeSdk = 'react-native-sdk',
35
ReactSdk = 'react-sdk',

packages/powersync-react/src/hooks/PowerSyncContext.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,21 @@ import { AbstractPowerSyncDatabase } from '@journeyapps/powersync-sdk-common';
22
import React from 'react';
33

44
export const PowerSyncContext = React.createContext<AbstractPowerSyncDatabase | null>(null);
5+
/**
6+
* Custom hook that provides access to the PowerSync context.
7+
* @returns The PowerSync Database instance.
8+
* @example
9+
* const Component = () => {
10+
* const db = usePowerSync();
11+
* const [lists, setLists] = React.useState([]);
12+
*
13+
* React.useEffect(() => {
14+
* powersync.getAll('SELECT * from lists').then(setLists)
15+
* }, []);
16+
*
17+
* return <ul>
18+
* {lists.map(list => <li key={list.id}>{list.name}</li>)}
19+
* </ul>
20+
* };
21+
*/
522
export const usePowerSync = () => React.useContext(PowerSyncContext);

packages/powersync-react/src/hooks/usePowerSyncWatchedQuery.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import { usePowerSync } from './PowerSyncContext';
44

55
/**
66
* A hook to access the results of a watched query.
7+
* @example
8+
* export const Component = () => {
9+
* const lists = usePowerSyncWatchedQuery('SELECT * from lists');
10+
*
11+
* return <View>
12+
* {lists.map((l) => (
13+
* <Text key={l.id}>{JSON.stringify(l)}</Text>
14+
* ))}
15+
* </View>
16+
* }
717
*/
818
export const usePowerSyncWatchedQuery = <T = any>(
919
sqlStatement: string,

pnpm-lock.yaml

Lines changed: 16 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)