Skip to content

Commit dbc48b0

Browse files
committed
feat: multiple desc items in a single desc row
1 parent 3beac93 commit dbc48b0

File tree

6 files changed

+98
-13
lines changed

6 files changed

+98
-13
lines changed

src/components/desc-list/Desc.astro

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
---
2+
interface Props {
3+
kind?: string;
4+
}
25
6+
const { kind } = Astro.props;
7+
const hasKind = kind !== undefined;
38
---
49

510
<div class="desc">
6-
<div class="desc-item">
11+
<div class="desc-items">
712
<slot name="item" />
813
</div>
914
<div class="desc-content">
1015
<slot />
16+
{hasKind ? <div class="desc-kind">({kind})</div> : <></>}
1117
</div>
1218
</div>
1319

@@ -22,13 +28,19 @@
2228
padding-bottom: calc(var(--sl-content-gap-y) * 0.35);
2329
}
2430

25-
.desc-content {
31+
.desc > .desc-content {
32+
margin: 0;
33+
}
34+
35+
.desc > .desc-content > .desc-kind {
36+
font-size: var(--cppdoc-font-size-desc-kind);
37+
color: var(--cppdoc-color-desc-kind);
2638
margin: 0;
2739
}
2840
</style>
2941

3042
<style is:global>
31-
.desc-item .revision-tag {
43+
.desc-items .revision-tag {
3244
display: block;
3345
}
3446
</style>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
3+
---
4+
5+
<div class="desc-item">
6+
<slot />
7+
</div>
8+
9+
<style>
10+
.desc-item {
11+
margin: 0;
12+
padding-top: calc(var(--sl-content-gap-y) * 0.35);
13+
padding-bottom: calc(var(--sl-content-gap-y) * 0.35);
14+
}
15+
16+
.desc-item:not(:first-of-type) {
17+
border-top: 1px dashed var(--sl-color-gray-4);
18+
}
19+
20+
.desc-item:first-of-type {
21+
padding-top: 0;
22+
}
23+
24+
.desc-item:last-of-type {
25+
padding-bottom: 0;
26+
}
27+
</style>

src/components/desc-list/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { default as Desc } from "./Desc.astro";
2+
export { default as DescItem } from "./DescItem.astro";
23
export { default as DescList } from "./DescList.astro";

src/components/revision/RevisionBlock.astro

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
import type { RevisionInfo } from "./types";
33
import RevisionTags from "./RevisionTags.astro";
44
5+
type LayoutDirection = "h" | "v";
6+
57
interface Props extends RevisionInfo {
68
noborder?: boolean;
9+
dir?: LayoutDirection;
710
}
811
912
const { noborder } = Astro.props;
13+
const dir = Astro.props.dir ?? "h";
14+
15+
const horizontal = dir === "h";
16+
const vertical = dir === "v";
1017
---
1118

12-
<div class:list={["revision", { noborder }]}>
19+
<div class:list={["revision", { noborder, horizontal, vertical }]}>
1320
<div class="revision-content">
1421
<slot />
1522
</div>
@@ -22,7 +29,6 @@ const { noborder } = Astro.props;
2229
.revision {
2330
display: flex;
2431
align-items: center;
25-
column-gap: 1em;
2632
}
2733

2834
.revision:not(.noborder) {
@@ -33,19 +39,24 @@ const { noborder } = Astro.props;
3339
padding-bottom: calc(var(--sl-content-gap-y) * 0.25);
3440
}
3541

36-
.revision > .revision-content {
42+
.revision .revision-tags {
43+
margin: 0;
44+
}
45+
46+
.revision.horizontal {
47+
column-gap: 1em;
48+
}
49+
50+
.revision.horizontal > .revision-content {
3751
flex-grow: 1;
3852
}
3953

40-
.revision > .revision-tags {
54+
.revision.horizontal > .revision-tags {
4155
flex-shrink: 0;
4256
flex-grow: 0;
43-
margin-top: 0;
4457
}
4558

46-
.revision .revision-tag {
47-
font-size: var(--cppdoc-font-size-revision);
48-
color: var(--cppdoc-color-revision);
49-
margin: 0;
59+
.revision.vertical {
60+
flex-direction: column;
5061
}
5162
</style>

src/content/docs/c/library/strings/byte/memcpy.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cppdoc:
77
import Behavior from "@components/Behavior.astro";
88
import { CHeader } from "@components/header";
99
import { Decl, DeclDoc } from "@components/decl-doc";
10-
import { Desc, DescList } from "@src/components/desc-list";
10+
import { Desc, DescItem, DescList } from "@src/components/desc-list";
1111
import Missing from "@components/Missing.astro";
1212
import { ParamDoc, ParamDocList } from "@components/param-doc";
1313
import { Revision, RevisionBlock } from "@components/revision";
@@ -155,3 +155,34 @@ dst = "\0\0\0\0\0yxyxy", r = 22
155155
- 7.21.2.1 The memcpy function (p: 325)
156156
- C89/C90 standard (ISO/IEC 9899:1990):
157157
- 4.11.2.1 The memcpy function
158+
159+
## See also
160+
161+
<DescList>
162+
<Desc kind="function">
163+
<DescItem slot="item">
164+
<Revision noborder since="C23"><Missing>`memccpy`</Missing></Revision>
165+
</DescItem>
166+
copies one buffer to another, stopping after the specified delimiter
167+
</Desc>
168+
169+
<Desc kind="function">
170+
<DescItem slot="item">
171+
<Missing>`memmove`</Missing>
172+
</DescItem>
173+
<DescItem slot="item">
174+
<RevisionBlock noborder since="C11" dir="v"><Missing>`memmove_s`</Missing></RevisionBlock>
175+
</DescItem>
176+
moves one buffer to another
177+
</Desc>
178+
179+
<Desc kind="function">
180+
<DescItem slot="item">
181+
<RevisionBlock noborder since="C95" dir="v"><Missing>`wmemcpy`</Missing></RevisionBlock>
182+
</DescItem>
183+
<DescItem slot="item">
184+
<RevisionBlock noborder since="C11" dir="v"><Missing>`wmemcpy_s`</Missing></RevisionBlock>
185+
</DescItem>
186+
copies a certain amount of wide characters between two non-overlapping arrays
187+
</Desc>
188+
</DescList>

src/styles/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
--cppdoc-color-revision: var(--sl-color-green);
77
--cppdoc-font-size-revision: 0.8em;
88

9+
--cppdoc-color-desc-kind: var(--sl-color-green);
10+
--cppdoc-font-size-desc-kind: 0.8em;
11+
912
--cppdoc-color-missing-link: #cc6633;
1013
--cppdoc-color-well-def: var(--sl-color-green);
1114
--cppdoc-color-impl-def: var(--sl-color-blue);

0 commit comments

Comments
 (0)