Skip to content

Commit 98c57c2

Browse files
committed
feat: add doc for cxx mark feature
1 parent 324e861 commit 98c57c2

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```cpp cxx-mark
2+
// syntax of for statement
3+
/*$s:attr*//*$opt*/ for ( /*$s:init-statement*/ /*$s:condition*//*$opt*/ ; /*$s:expression*//*$opt*/ ) /*$s:statement*/
4+
5+
// exposition only alias template of conditionally const type
6+
template< bool Const, class T >
7+
using /*$e:maybe-const*/ = std::conditional_t<Const, const T, T>;
8+
```

src/content/docs/development/guide/doc-everything.mdx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,75 @@ import declDocExample3 from "@src/assets/examples/development/guide/decl-doc-3.m
139139
Don't forget the `autorevSince` attribute on the `DeclDoc` component! Presence of this attribute allows [autorev](./revision#autorev) to automatically show and hide the `DeclDoc` component according to the user-selected revision.
140140
</Aside>
141141

142+
## Code block inline markers
143+
144+
Special comments can be embedded within Markdown code blocks to specify part of codes has special meanings. Enable this feature by adding `cxx-mark` after the language name of code block's opening fence:
145+
146+
import cxxMarkExample1 from "@src/assets/examples/development/guide/cxx-mark-1.mdx?raw";
147+
148+
<Code code={cxxMarkExample1} lang="mdx" />
149+
150+
<Card title="Preview">
151+
```cpp cxx-mark
152+
// syntax of for statement
153+
/*$s:attr*//*$opt*/ for ( /*$s:init-statement*/ /*$s:condition*//*$opt*/ ; /*$s:expression*//*$opt*/ ) /*$s:statement*/
154+
155+
// exposition only alias template of conditionally const type
156+
template< bool Const, class T >
157+
using /*$e:maybe-const*/ = std::conditional_t<Const, const T, T>;
158+
```
159+
</Card>
160+
161+
Three kinds of markers are supported:
162+
163+
<DeclDoc>
164+
<Decl slot="decl">
165+
```
166+
/*$s:something*/
167+
```
168+
</Decl>
169+
170+
Marks part of code to be a syntax notation.
171+
172+
Rendered as:
173+
174+
```cpp cxx-mark
175+
/*$s:something*/
176+
```
177+
</DeclDoc>
178+
179+
<DeclDoc>
180+
<Decl slot="decl">
181+
```
182+
/*$e:something*/
183+
```
184+
</Decl>
185+
186+
Marks part of code to be exposition only.
187+
188+
Rendered as:
189+
190+
```cpp cxx-mark
191+
/*$e:something*/
192+
```
193+
</DeclDoc>
194+
195+
<DeclDoc>
196+
<Decl slot="decl">
197+
```
198+
something/*$opt*/
199+
```
200+
</Decl>
201+
202+
Mark the previous part of code (often a syntax notation) to be optional.
203+
204+
Rendered as:
205+
206+
```cpp cxx-mark
207+
something/*$opt*/
208+
```
209+
</DeclDoc>
210+
142211
## Description list
143212

144213
### Basic Usage

0 commit comments

Comments
 (0)