Skip to content

Commit 6166ae2

Browse files
committed
Improve API documentation layout
Signed-off-by: Bradley Dice <bdice@bradleydice.com>
1 parent 22cd055 commit 6166ae2

4 files changed

Lines changed: 58 additions & 22 deletions

File tree

api.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
# RAPIDS API Docs
1+
# RAPIDS API Documentation
22

3-
Access our current docs for the RAPIDS projects below. Docs are available in
4-
both "stable" and "nightly" versions. The description of each is below to help
5-
select the docs that fit your needs.
3+
Explore documentation for current and previous RAPIDS releases. Each project
4+
card links to its available documentation versions and related resources.
65

7-
STABLE
8-
: Current release docs; considered to be stable.
6+
Stable
7+
: Documentation for the current release, recommended for most users.
98

10-
NIGHTLY
11-
: Work-in-progress release docs; considered to be unstable and released nightly.
9+
Nightly
10+
: Documentation for the upcoming release, generated from development branches.
1211

13-
LEGACY
14-
: Previous release docs; available for reference.
12+
Legacy
13+
: Documentation for the previous release, retained for reference.
1514

1615
## RAPIDS APIs
1716

extensions/rapids_docs.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,33 +80,49 @@ def _version_label(project: dict, version_name: str, releases: dict) -> str:
8080

8181

8282
def _api_docs(data: dict, section: str) -> str:
83-
blocks = []
83+
cards = []
8484
for project in data["docs"][section].values():
8585
if project.get("hidden", False):
8686
continue
8787
versions = []
8888
for name in ("stable", "nightly", "legacy"):
8989
if project["versions"].get(name) == 1:
9090
label = _version_label(project, name, data["releases"])
91-
versions.append(f"**[{name} ({label})](/api/{project['path']}/{name}/)**")
91+
versions.append(f"[{name.title()} ({label})](/api/{project['path']}/{name}/)")
9292
links = []
9393
if project.get("cllink"):
94-
links.append(f"**[changelog]({project['cllink']})**")
95-
links.append(f"**[github]({project['ghlink']})**")
96-
blocks.append(
94+
links.append(f"[Changelog]({project['cllink']})")
95+
links.append(f"[GitHub]({project['ghlink']})")
96+
footer = []
97+
if versions:
98+
footer.extend(["**Documentation:** " + " · ".join(versions), ""])
99+
footer.append("**Resources:** " + " · ".join(links))
100+
cards.append(
97101
"\n".join(
98102
[
99-
f"### {project['name']}",
103+
f":::{{grid-item-card}} {project['name']}",
104+
":class-card: rapids-api-card",
105+
":class-title: rapids-api-card-title",
106+
":class-footer: rapids-api-card-footer",
100107
"",
101108
project["desc"],
102109
"",
103-
"#### DOCS" + (" " + " | ".join(versions) if versions else ""),
104-
"",
105-
"#### LINKS " + " | ".join(links),
110+
"+++",
111+
*footer,
112+
":::",
106113
]
107114
)
108115
)
109-
return "\n\n".join(blocks)
116+
return "\n".join(
117+
[
118+
"::::{grid} 1 1 2 2",
119+
":gutter: 2",
120+
":class-container: rapids-api-grid",
121+
"",
122+
"\n\n".join(cards),
123+
"::::",
124+
]
125+
)
110126

111127

112128
def _compute_capability(cuda: dict) -> str:

sphinx/_static/css/custom.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@
5858
height: 100%;
5959
}
6060

61+
.rapids-api-grid .sd-card {
62+
height: 100%;
63+
}
64+
65+
.rapids-api-card-title {
66+
font-size: 1.15rem;
67+
}
68+
69+
.rapids-api-card-footer p {
70+
margin-bottom: 0.35rem;
71+
}
72+
73+
.rapids-api-card-footer p:last-child {
74+
margin-bottom: 0;
75+
}
76+
6177
@media (max-width: 720px) {
6278
.selector-bg .container-padding {
6379
min-width: 40rem;

tests/test_rendering.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ def test_data_driven_content() -> None:
1616
nightly_version = data["releases"]["nightly"]["version"]
1717

1818
api = rapids_docs._api_docs(data, "apis")
19-
assert f"stable ({stable_version})" in api
19+
assert f"Stable ({stable_version})" in api
2020
assert "/api/cudf/stable/" in api
21+
assert "::::{grid} 1 1 2 2" in api
22+
assert ":::{grid-item-card} cuDF" in api
23+
assert "**Documentation:**" in api
24+
assert "[GitHub]" in api
25+
assert "DOCS" not in api
2126

2227
inactive = rapids_docs._api_docs(data, "inactive-projects")
2328
inactive_project = next(
@@ -26,7 +31,7 @@ def test_data_driven_content() -> None:
2631
if not project.get("hidden", False) and project["versions"].get("stable") == 1
2732
)
2833
inactive_version = rapids_docs._version_label(inactive_project, "stable", data["releases"])
29-
assert f"stable ({inactive_version})" in inactive
34+
assert f"Stable ({inactive_version})" in inactive
3035

3136
platform = rapids_docs._platform_support(data)
3237
platform_release = data["platform_support"]["releases"][0]

0 commit comments

Comments
 (0)