Skip to content

Commit 8511fbc

Browse files
committed
Address review comments regarding website docs
1 parent 5d50b18 commit 8511fbc

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

docs/developer/website-development.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For more elaborate changes, including adding new pages, you will need to clone t
1919

2020
## Editing the Handbook
2121

22-
The handbook is the most updated part of the website and it includes quite a bit of infrastructure to support writing pages that describe features in any or all of the target languages. The root of the handbook pages in the `packages/documentation` part of the repo. That directory has a useful [README file](https://github.com/lf-lang/website-lingua-franca/blob/main/packages/documentation/README.md) that describes the structure and provides instructions for inserting code examples in any target language and target-specific text within a body of target-independent text.
22+
The handbook is the most updated part of the website and it includes quite a bit of infrastructure to support writing pages that describe features in any or all of the target languages. The root of the handbook pages is the `packages/documentation` part of the repo. That directory has a useful [README file](https://github.com/lf-lang/website-lingua-franca/blob/main/packages/documentation/README.md) that describes the structure and provides instructions for inserting code examples in any target language and target-specific text within a body of target-independent text.
2323

2424
## Infrastructure
2525

@@ -37,16 +37,16 @@ For languages other than Lingua Franca, highlighting is handled by Prism, which
3737

3838
For Lingua Franca, highlighting is handled by [Shiki](https://github.com/shikijs/shiki). This is mainly because we only have TextMate grammar definition and it is not easy to convert from it to Prism.
3939

40-
Like Prism, we are running Shiki in browser and the code is updated in browser by React after it is highlighted. Shiki has a relatively large footprint, so its not necessarily encouraged to run in browsers. Yet running it in browser might help SEO and makes maintenance easier.
40+
Like Prism, we are running Shiki in the browser, and the code is updated in the browser by React after it is highlighted. Shiki has a relatively large footprint, so its not necessarily encouraged to run in browsers. However, running it in browser might help SEO and makes maintenance easier.
4141

42-
The component we created is `ShikiLFHighlighter` in `src/components/ShikiLFHighlighter/index.tsx`. As Shiki highlights code asynchorously, the component will display the unhighlighted code first (for a very short period of time), and asynchronously update the HTML to be the one with highlighted code with React. This will not hurt SEO as the highlight will not be considered by search engines.
42+
The component we created is `ShikiLFHighlighter` in `src/components/ShikiLFHighlighter/index.tsx`. As Shiki highlights code asynchronously, the component will display the unhighlighted code first (for a very short period of time), and then asynchronously update the HTML with highlighted code using React. This will not hurt SEO because the highlight will not be considered by search engines.
4343

44-
Upon loading the webpage, Shiki will be initialised in the browser, loading grammars of all target languages and Lingua Franca, as configured in `clientModules` section in `docusaurus.config.js` and `src/components/ShikiLFHighlighter/shikiloader.ts`.
44+
Upon loading the webpage, Shiki will be initialised in the browser, loading grammars of all target languages and Lingua Franca, as configured in `clientModules` section in `docusaurus.config.js` and `src/components/ShikiLFHighlighter/shikiloader.ts`.
4545

46-
We further swizzled Docusaurus' `CodeBlock` to use `ShikiLFHighlighter` if the code language matches a pattern that indicates the code language is Lingua Franca, so using ``` notation in Markdown with language `lf` could give us the correct highlight result. You can check `src/theme/CodeBlock/index.js` for more details.
46+
We further changed Docusaurus' `CodeBlock` to use `ShikiLFHighlighter` if the code language matches a pattern that indicates the code language is Lingua Franca, so using ``` notation in Markdown with language `lf` could give us the correct highlight result. You can check `src/theme/CodeBlock/index.js` for more details.
4747

4848
:::note
49-
Unlike the custom syntax highlighter in our old website, without specifying `target C`, the highlighter will not be able to highlight target language code correctly as it lacks context - even if the language speficied is `lf-c`. This will be solved in future updates to the highlighter.
49+
Unlike the custom syntax highlighter in our old website, without specifying `target C`, the highlighter will not be able to highlight target language code correctly as it lacks context - even if the language specified is `lf-c`. This will be solved in future updates to the highlighter.
5050
:::
5151

5252
#### Syntaxes for Lingua Franca Syntax Highlighting
@@ -70,9 +70,9 @@ We have also created a bunch of useful utility components to aid the target sele
7070

7171
### Multi-Target Utilities
7272

73-
Our whole Multi-Target infrastructure is built on top of docusaurus' [Tabs](https://docusaurus.io/docs/markdown-features/tabs) component.
73+
Our whole Multi-Target infrastructure is built on top of Docusaurus' [Tabs](https://docusaurus.io/docs/markdown-features/tabs) component.
7474

75-
In general, different targets are just a bunch of `Tab` components with `groupId='target-languages'`.
75+
In general, different targets are just a bunch of `Tab` components with `groupId='target-languages'`.
7676

7777
#### LanguageSelector
7878
The target selector, which appears on the top, is a `Tab` component with no content. It is defined in `src/components/LinguaFrancaMultiTargetUtils/LanguageSelector.tsx`.
@@ -150,7 +150,7 @@ Specifically - you MUST use `ShowIf` inside of a `ShowIfs`, and a `ShowIfs` MUST
150150
</ShowIf>
151151
</ShowIfs>
152152
```
153-
Where the target languages could be a subset of all targets which we support but must NOT collide.
153+
Where the target languages could be a subset of all targets which we support but must NOT collide.
154154
As long as you have more than one `ShowIf` inside you can have as many as you like.
155155

156156
##### Example
@@ -185,7 +185,7 @@ As long as you have more than one `ShowIf` inside you can have as many as you li
185185
`ShowOnly` uses hacky Docusaurus-internal methods for the time being. To ensure better compatibility, you should prefer `ShowIf`.
186186
:::
187187

188-
Sometimes, you want to display a piece of information only for one language. While you can use `ShowIfs` and one `ShowIf` inside of it, the issue people typically discover is that the rendered result looks miserable, because each `Tab` will add some sort of padding above and below it.
188+
Sometimes, you want to display a piece of information only for one language. While you can use `ShowIfs` and one `ShowIf` inside of it, the issue people typically discover is that the rendered result looks miserable, because each `Tab` will add some sort of padding above and below it.
189189

190190
For this, we built `ShowOnly` which reads the selected tab from `@docusaurus/theme-common/internal/useTabs` and displays the information inside if the target selected matches, and the output is a `<div>` or a `<span>` so that it looks like it's blended in. This is hacky and could break any time if docusaurus decides to change how their `Tabs` work.
191191

@@ -196,7 +196,7 @@ For this, we built `ShowOnly` which reads the selected tab from `@docusaurus/the
196196
{/* Markdown contents */}
197197
</ShowOnly>
198198
```
199-
Where the target languages could be a subset of all targets which we support.
199+
Where the target languages could be a subset of all targets which we support.
200200
If you include `inline` it will result in a `<span>`, if not, a `<div>`.
201201

202202
##### Examples
@@ -336,4 +336,4 @@ For docusaurus-related question, you should redirect your question to [them](htt
336336

337337
The LF syntax file is fetched [here](https://github.com/lf-lang/vscode-lingua-franca/blob/main/syntaxes/lflang.tmLanguage.json) and should be updated from time to time. If the syntax highlighting is not working properly, check the TextMate grammar, then check with [shiki](https://github.com/shikijs/shiki).
338338

339-
For website-specific utilities, you can open an issue on GitHub or [ask @axmmisaka directly](/community).
339+
For website-specific utilities, you can open an issue on GitHub or [ask @axmmisaka directly](/community).

src/components/LinguaFrancaMultiTargetUtils/DynamicMultiTargetCodeblock.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
/**
2+
* #### DynamicMultiTargetCodeblock
3+
*
4+
* Warnings:
5+
* - This is not working properly with versioning and will have issues with Webpack performance!
6+
* - This is not working properly now! Need to fix the file path in `content` in `DynamicMultiTargetCodeblock.tsx`.
7+
*
8+
* This utility allows you to only supply a LF filename and all files will be dynamically imported. The issue is Webpack is not intelligent enough so if you use it, it will probably load all LF files in `assets`. Also, because relative import appears to be impossible, using it will always get you the latest code examples. See `src/components/LinguaFrancaMultiTargetUtils/DynamicMultiTargetCodeblock.tsx`.
9+
*
10+
* ##### Examples
11+
*
12+
* ```tsx
13+
* <DynamicMultiTargetCodeblock c cpp ts rs py file="HelloWorld" />
14+
* ```
15+
*
16+
* To suppress warnings, add
17+
*
18+
* ```tsx
19+
* <DynamicMultiTargetCodeblock doNotTransformInMDX c cpp ts rs py file="HelloWorld" />
20+
* ```
21+
*
22+
* #### DynamicMultiTargetCodeblock with TransformDynamicLFFileImportToStatic
23+
*
24+
* Warning: This is an experiment and should not be used in production!
25+
*
26+
* A way to make `DynamicMultiTargetCodeblock` more sane is to use remark and preprocess it into a bunch of import statements and a `NoSelectorTargetCodeBlock`.
27+
*
28+
* `src/remark/TransformDynamicLFFileImportToStatic.ts` is a remark plugin that does so. It looks like a disaster and I don't understand it anymore 5 months after writing it.
29+
*
30+
* To use DynamicMultiTargetCodeBlock, add it to `docusaurus.config.ts` as a ReMark preprocessor.
31+
*
32+
* But don't use it.`
33+
*/
34+
135
import React, { useState, useEffect } from "react";
236
import { TargetsType } from "./index";
337
import { NoSelectorTargetCodeBlock } from "./LangSpecific";

0 commit comments

Comments
 (0)