Skip to content
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

add typescript support and recommended settings #117

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": true,
"singleQuote": false,
"semi": true,
"bracketSameLine": false,
"bracketSpacing": true,
"jsxSingleQuote": false,
"quoteProps": "as-needed",
"endOfLine": "lf"
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"davidanson.vscode-markdownlint",
"unifiedjs.vscode-mdx",
"dbaeumer.vscode-eslint"
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"markdownlint.config": {
"no-inline-html": false,
"link-image-reference-definitions": false,
"fenced-code-language": false,
}
}
8 changes: 5 additions & 3 deletions docusaurus.config.js → docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const math = require('remark-math')
const katex = require('rehype-katex')
import { Config } from "@docusaurus/types";
import type * as Preset from "@docusaurus/preset-classic";

const config = {
const config: Config = {
title: 'Rapier',
tagline: 'Fast 2D and 3D physics engine for the Rust programming language.',
url: 'https://rapier.rs',
Expand Down Expand Up @@ -142,7 +144,7 @@ const config = {
],
// copyright: `Copyright © ${new Date().getFullYear()} Dimforge EURL. Website built with Docusaurus.`,
},
},
} satisfies Preset.ThemeConfig,
plugins: [
[
'@docusaurus/plugin-content-docs',
Expand Down Expand Up @@ -174,7 +176,7 @@ const config = {
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
} satisfies Preset.Options,
],
],
stylesheets: [
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@
"last 1 safari version"
]
},
"packageManager": "yarn@4.3.1"
"packageManager": "yarn@4.3.1",
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.5.2",
"@docusaurus/tsconfig": "^3.5.2",
"@docusaurus/types": "^3.5.2",
"typescript": "^5.5.4"
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions sidebar_docs.js → sidebar_docs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


let template = {
const template = {
'<Templates>': [
'user_guides/templates_injected/getting_started',
'user_guides/templates_injected/getting_started_bevy',
Expand All @@ -23,7 +23,7 @@ let template = {
]
};

let specialized_guides = {
const specialized_guides = {
'Rust': [
'user_guides/rust/getting_started',
'user_guides/rust/introduction_to_nalgebra',
Expand Down
15 changes: 8 additions & 7 deletions src/pages/benchmarks.js → src/pages/benchmarks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

function iframeLoaded() {
if (typeof document !== 'undefined') {
var iFrameID = document.getElementById('bench-iframe');
if (iFrameID) {
let newHeight = (iFrameID.contentWindow.document.body.scrollHeight + 100) + "px";
if (iFrameID.height != newHeight)
iFrameID.height = newHeight;
}
const iFrameID = document.getElementById('bench-iframe');
if (!(iFrameID instanceof HTMLIFrameElement))
throw new Error(`Expected iFrameID to be an HTMLIFrameElement, was ${iFrameID && iFrameID.constructor && iFrameID.constructor.name || iFrameID}`);

const newHeight = (iFrameID.contentWindow.document.body.scrollHeight + 100) + "px";
if (iFrameID.height != newHeight)
iFrameID.height = newHeight;
}
}

function Benchmarks() {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
const {siteConfig} = context;
const benchUrl = "/benchmarks3d/index.html";
setInterval(function(){ iframeLoaded(); }, 3000);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.js → src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Feature({ imageUrl, title, description }) {

function Home() {
const context = useDocusaurusContext();
const { siteConfig = {} } = context;
const { siteConfig } = context;
return (
<Layout
title={`${siteConfig.title} physics engine`}
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://docusaurus.io/docs/typescript-support
// This file is not used in compilation. It is here just for a nice editor experience.
{
"extends": "@docusaurus/tsconfig",
"compilerOptions": {
"baseUrl": ".",
},
"exclude": ["node_modules", "build", ".docusaurus"]
}
69 changes: 69 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,24 @@ __metadata:
languageName: node
linkType: hard

"@docusaurus/module-type-aliases@npm:^3.5.2":
version: 3.5.2
resolution: "@docusaurus/module-type-aliases@npm:3.5.2"
dependencies:
"@docusaurus/types": "npm:3.5.2"
"@types/history": "npm:^4.7.11"
"@types/react": "npm:*"
"@types/react-router-config": "npm:*"
"@types/react-router-dom": "npm:*"
react-helmet-async: "npm:*"
react-loadable: "npm:@docusaurus/react-loadable@6.0.0"
peerDependencies:
react: "*"
react-dom: "*"
checksum: 10c0/5174c8ad4a545b4ef8aa16bae6f6a2d501ab0d4ddd400cca83c55b6b35eac79b1d7cff52d6041da4f0f339a969d72be1f40e57d5ea73a50a61e0688505627e0c
languageName: node
linkType: hard

"@docusaurus/plugin-content-blog@npm:3.4.0":
version: 3.4.0
resolution: "@docusaurus/plugin-content-blog@npm:3.4.0"
Expand Down Expand Up @@ -2194,6 +2212,13 @@ __metadata:
languageName: node
linkType: hard

"@docusaurus/tsconfig@npm:^3.5.2":
version: 3.5.2
resolution: "@docusaurus/tsconfig@npm:3.5.2"
checksum: 10c0/1cde5cfadfc94605ba9a1ec8484bc58700bcff99944fa20c6f6d93599126914dc33f15c3464ee3279cf6becafcea86909d1d25a20f8f97e95c8ddf6b1122eac8
languageName: node
linkType: hard

"@docusaurus/types@npm:3.4.0":
version: 3.4.0
resolution: "@docusaurus/types@npm:3.4.0"
Expand All @@ -2214,6 +2239,26 @@ __metadata:
languageName: node
linkType: hard

"@docusaurus/types@npm:3.5.2, @docusaurus/types@npm:^3.5.2":
version: 3.5.2
resolution: "@docusaurus/types@npm:3.5.2"
dependencies:
"@mdx-js/mdx": "npm:^3.0.0"
"@types/history": "npm:^4.7.11"
"@types/react": "npm:*"
commander: "npm:^5.1.0"
joi: "npm:^17.9.2"
react-helmet-async: "npm:^1.3.0"
utility-types: "npm:^3.10.0"
webpack: "npm:^5.88.1"
webpack-merge: "npm:^5.9.0"
peerDependencies:
react: ^18.0.0
react-dom: ^18.0.0
checksum: 10c0/a06607a8ed96871d9a2c1239e1d94e584acd5c638f7eb4071feb1f18221c25c9b78794b3f804884db201cfdfc67cecdf37a823efe854f435fb4f5a36b28237d4
languageName: node
linkType: hard

"@docusaurus/utils-common@npm:3.4.0":
version: 3.4.0
resolution: "@docusaurus/utils-common@npm:3.4.0"
Expand Down Expand Up @@ -9694,14 +9739,18 @@ __metadata:
resolution: "rapier@workspace:."
dependencies:
"@docusaurus/core": "npm:^3.0"
"@docusaurus/module-type-aliases": "npm:^3.5.2"
"@docusaurus/preset-classic": "npm:^3.0"
"@docusaurus/tsconfig": "npm:^3.5.2"
"@docusaurus/types": "npm:^3.5.2"
"@mdx-js/react": "npm:^3.0"
clsx: "npm:^1.1.1"
react: "npm:^18.2"
react-dom: "npm:^18.2"
rehype-katex: "npm:7"
remark-math: "npm:6"
terminus: "npm:^1.1.0"
typescript: "npm:^5.5.4"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -11239,6 +11288,26 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.5.4":
version: 5.5.4
resolution: "typescript@npm:5.5.4"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.5.4#optional!builtin<compat/typescript>":
version: 5.5.4
resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>::version=5.5.4&hash=379a07"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/73409d7b9196a5a1217b3aaad929bf76294d3ce7d6e9766dd880ece296ee91cf7d7db6b16c6c6c630ee5096eccde726c0ef17c7dfa52b01a243e57ae1f09ef07
languageName: node
linkType: hard

"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
Expand Down