Skip to content

Commit 5dc0cf9

Browse files
committed
More site work
1 parent 014954e commit 5dc0cf9

File tree

7 files changed

+105
-8
lines changed

7 files changed

+105
-8
lines changed

docs/for-contributors/README.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: "Overview"
33
---
44

55
import DocCardList from '@theme/DocCardList';
6+
import { useCurrentSidebarCategory } from '@docusaurus/theme-common';
67

78
# The Silk.NET Contributors Guide
89

@@ -61,4 +62,4 @@ where the values for the `-s` arguments are replaced with the job names (the key
6162
For more information on SilkTocuh arguments, consult the [SilkTouch User Guide](../silktouch) or use
6263
`dotnet run --project sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj -- --help`.
6364

64-
<DocCardList />
65+
<DocCardList items={useCurrentSidebarCategory().items.filter((e) => e.label != "Overview")} />

docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jumping-off point for new users to Silk.NET - regardless of whether you've used
7171
or you've never seen anything about it before! To that end, you can find our own documentation indexed below or
7272
throughout this site.
7373

74-
<DocCardList items={useDocsSidebar().items} />
74+
<DocCardList items={useDocsSidebar().items.filter((e) => e.label != "Welcome")} />
7575

7676
Have fun! We always look forward to seeing what people can create with Silk.NET and would love to hear how you get on in
7777
our Discord server.

docs/vulkan/structure-chaining/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ If you are creating a chain once, and then throwing it away, it can be done so s
109109
create never leave the stack. Silk.NET provides fluent extension methods that allow you to manipulate `IChainable`
110110
structures directly, performing the pointer logic for you, and providing compile-time type validation. Although,
111111
avoiding the heap entirely, there are some scenarios where this may still be slower than
112-
using [Managed Chains](managed-chains.md), and so this approach should only be considered when looking to optimise hot
112+
using [Managed Chains](managed-chaining.md), and so this approach should only be considered when looking to optimise hot
113113
paths. For example:
114114

115115
```csharp

docs/vulkan/structure-chaining/raw_chaining.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ API.
1515

1616
The easiest way to prevent pointers moving is to ensure that structures are created and used locally in the same
1717
function. This ensures that they remain in the current stack frame, preventing the runtime from moving any data.
18-
Sometimes, it is desirable to store structures for later use, in which case [Managed Chaining](managed-chains.md) should
18+
Sometimes, it is desirable to store structures for later use, in which case [Managed Chaining](managed-chaining.md) should
1919
be considered.
2020

2121
Each structure defines a constructor which accepts the fields as parameters and specifies defaults, including the
@@ -83,4 +83,4 @@ than either of the other two methodologies, depending on the exact use case. In
8383
if the chain ends up be passed around and copy operations are triggerred inadvertently on larger structures. For this
8484
reason, it is usually better to start with [Managed Chaining](managed-chaining.md), and optimise hot paths were
8585
necessary, using benchmarking to validate results. Starting with one of the other two approaches will usually make it
86-
easier to validate chain types, and improve compile time checking during development.
86+
easier to validate chain types, and improve compile time checking during development.

sources/Website/docusaurus.config.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,45 @@ import {themes as prismThemes} from 'prism-react-renderer';
22
import type {Config} from '@docusaurus/types';
33
import type * as Preset from '@docusaurus/preset-classic';
44
import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-directives";
5+
import { visit } from 'unist-util-visit';
6+
import { pathToFileURL } from 'node:url';
7+
import path from 'node:path';
58

69
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
710

11+
const ABS_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
12+
function isAbsolute(url) {
13+
return path.isAbsolute(url) || ABS_URL_REGEX.test(url);
14+
}
15+
16+
const rewriteSourceLinks = (options) => {
17+
const transformer = async (ast, vfile) => {
18+
let fileDirPath = path.resolve(path.dirname(vfile.path));
19+
let repoRoot = path.resolve("../../");
20+
let docsRoot = path.join(repoRoot, "docs");
21+
let silk2Src = path.join(repoRoot, "src");
22+
visit(ast, 'link', (node) => {
23+
if (isAbsolute(node.url)) {
24+
return;
25+
}
26+
let resolvedUrlPath = path.join(fileDirPath, node.url);
27+
console.log(resolvedUrlPath + " - " + node.url + " - " + fileDirPath);
28+
if (!path.relative(resolvedUrlPath, docsRoot).startsWith("..")) {
29+
return;
30+
}
31+
let silk2Rel = path.relative(resolvedUrlPath, silk2Src);
32+
if (!silk2Rel.startsWith("..")) {
33+
node.url = `https://github.com/dotnet/Silk.NET/blob/main/src/${silk2Rel}`
34+
}
35+
let silk3Rel = path.relative(resolvedUrlPath, repoRoot);
36+
if (!silk3Rel.startsWith("..")) {
37+
node.url = `https://github.com/dotnet/Silk.NET/blob/develop/3.0/${silk3Rel}`
38+
}
39+
});
40+
};
41+
return transformer;
42+
};
43+
844
const config: Config = {
945
title: 'Silk.NET',
1046
tagline: 'Your one-stop-shop for high performance .NET graphics & compute.',
@@ -46,7 +82,10 @@ const config: Config = {
4682
// editUrl:
4783
// 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
4884
exclude: ["README.md"],
49-
beforeDefaultRemarkPlugins: [remarkGithubAdmonitionsToDirectives],
85+
beforeDefaultRemarkPlugins: [
86+
remarkGithubAdmonitionsToDirectives,
87+
rewriteSourceLinks
88+
],
5089
},
5190
blog: {
5291
showReadingTime: true,

sources/Website/package-lock.json

Lines changed: 57 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/Website/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"react": "^18.0.0",
2424
"react-dom": "^18.0.0",
2525
"react-responsive-3d-carousel": "^2.1.1",
26-
"remark-github-admonitions-to-directives": "^2.1.0"
26+
"remark-github-admonitions-to-directives": "^2.1.0",
27+
"unist-util-visit": "^5.0.0"
2728
},
2829
"devDependencies": {
2930
"@docusaurus/module-type-aliases": "3.6.3",

0 commit comments

Comments
 (0)