Skip to content

Commit fa5c063

Browse files
authored
feat: add component NamedReq (#68)
* feat: add component NamedReq * feat: add docs for NamedReq
1 parent a7a5181 commit fa5c063

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

src/components/NamedReq.astro

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
import DocLink from "./DocLink.astro";
3+
4+
interface Props {
5+
name: string;
6+
bold?: boolean;
7+
displayName?: string;
8+
nolink?: boolean;
9+
}
10+
11+
const { name, bold, displayName, nolink } = Astro.props;
12+
const src = `/cpp/named_req/${name}`;
13+
14+
const text = displayName ?? name;
15+
16+
const As = nolink ? Fragment : DocLink;
17+
const asProps = nolink ? {} : { src };
18+
---
19+
20+
<As {...asProps}>
21+
<span class=`named-req${bold ? "-bold" : ""}`>
22+
{text}
23+
</span>
24+
</As>
25+
26+
<style>
27+
.named-req {
28+
font-weight: normal;
29+
font-style: italic;
30+
font-family: Georgia, "DejaVu Serif", serif;
31+
}
32+
.named-req-bold {
33+
font-weight: bold;
34+
font-style: italic;
35+
font-family: Georgia, "DejaVu Serif", serif;
36+
}
37+
</style>

src/content/docs/development/guide/component-docs-for-llm.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,26 @@ import { CppHeader } from "@components/header";
288288

289289
Base component for `CHeader` and `CppHeader`. Not used directly.
290290

291+
### NamedReq
292+
293+
The `NamedReq` component renders an inline link to a named requirement.
294+
295+
#### Props
296+
297+
- `name` (required): The name of the requirement.
298+
- `bold` (optional): If `true`, the text renders bold.
299+
- `displayName` (optional): Custom display text.
300+
- `nolink` (optional): If `true`, renders as plain text without a link.
301+
302+
#### Usage
303+
304+
305+
import NamedReq from "@components/NamedReq.astro"
306+
307+
A <NamedReq name="FunctionObject" /> type is the type of an object
308+
that can be used on the left of the function call operator.
309+
310+
291311
## Feature Test Macros
292312

293313
### FeatureTestMacro

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DocLink from "@components/DocLink.astro";
1313
import { DR, DRList } from "@components/defect-report";
1414
import { FeatureTestMacro, FeatureTestMacroValue } from "@components/feature-test-macro";
1515
import Missing from "@components/Missing.astro";
16+
import NamedReq from "@components/NamedReq.astro"
1617
import { ParamDoc, ParamDocList } from "@components/param-doc";
1718
import { RevisionBlock } from "@components/revision";
1819

@@ -384,6 +385,40 @@ Entities in it can be used in a C++ program by including the header
384385
If documentation for the specified header does not exist yet, the `CHeader` and the `CppHeader` component will render the header name as plain text without a link.
385386
</Aside>
386387

388+
### Link to Named Requirement
389+
390+
The `NamedReq` component renders an inline link to the documentation page of a named requirement.
391+
392+
```mdx
393+
import NamedReq from "@components/NamedReq.astro";
394+
395+
A <NamedReq name="FunctionObject" /> type is the type of an object
396+
that can be used on the left of the function call operator.
397+
```
398+
399+
<Card title="Preview">
400+
A <NamedReq name="FunctionObject" /> type is the type of an object
401+
that can be used on the left of the function call operator.
402+
</Card>
403+
404+
You can set the `bold` attribute to `true`, to make the requirement name appear in bold.
405+
406+
```mdx
407+
import NamedReq from "@components/NamedReq.astro";
408+
409+
A <NamedReq name="FunctionObject" bold /> type is the type of an object
410+
that can be used on the left of the function call operator.
411+
```
412+
413+
<Card title="Preview">
414+
A <NamedReq name="FunctionObject" bold /> type is the type of an object
415+
that can be used on the left of the function call operator.
416+
</Card>
417+
418+
<Aside type="tip">
419+
If documentation for the specified named requirement does not exist yet, the `NamedReq` component will render the requirement name as plain text without a link.
420+
</Aside>
421+
387422
## Feature Test Macros
388423

389424
The `FeatureTestMacro` component renders to a box that shows information about a feature test macro.

0 commit comments

Comments
 (0)