-
-
Notifications
You must be signed in to change notification settings - Fork 420
Publish Rust crate API docs with the website #1230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| cd "$repo_root" | ||
|
|
||
| mapfile -t crates < <( | ||
| sed -n '/^publish_crates=(/,/^)/p' scripts/publish-crates.sh \ | ||
| | sed -n 's/^ \([[:alnum:]_-]*\)$/\1/p' | ||
| ) | ||
|
|
||
| if [[ "${#crates[@]}" -eq 0 ]]; then | ||
| echo "No crates found in scripts/publish-crates.sh" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Building Rustdoc for ${#crates[@]} published crates" | ||
|
|
||
| cargo clean --doc | ||
|
|
||
| cargo_args=(doc --locked --no-deps) | ||
| for crate in "${crates[@]}"; do | ||
| cargo_args+=(--package "$crate") | ||
| done | ||
| cargo "${cargo_args[@]}" | ||
|
|
||
| landing_page="" | ||
| if [[ -f docs/crates/index.html ]]; then | ||
| landing_page="$(mktemp)" | ||
| cp docs/crates/index.html "$landing_page" | ||
| fi | ||
|
|
||
| rm -rf docs/crates | ||
| mkdir -p docs/crates | ||
| cp -R target/doc/. docs/crates/ | ||
|
|
||
| if [[ -n "$landing_page" ]]; then | ||
| cp "$landing_page" docs/crates/index.html | ||
| rm -f "$landing_page" | ||
| fi | ||
|
|
||
| echo "Published crate docs to docs/crates/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { readFileSync } from "node:fs"; | ||
|
|
||
| const publishScript = readFileSync(new URL("../../../scripts/publish-crates.sh", import.meta.url), "utf8"); | ||
| const publishList = publishScript.match(/publish_crates=\(([\s\S]*?)\n\)/)?.[1]; | ||
|
|
||
| if (!publishList) { | ||
| throw new Error("Unable to determine the published crate list"); | ||
| } | ||
|
|
||
| const crateNames = Array.from(publishList.matchAll(/^ ([a-z0-9_-]+)$/gm), ([, name]) => name); | ||
|
|
||
| export default crateNames.map((name) => ({ | ||
| name, | ||
| rustdocName: name.replaceAll("-", "_"), | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| layout: docs-base.njk | ||
| title: Crate API reference | ||
| description: Rust API documentation for the crates published by Mesh LLM. | ||
| permalink: /crates/index.html | ||
| --- | ||
| <main class="shell min-w-0 py-12 sm:py-16" data-pagefind-ignore="all"> | ||
| <header class="docs-page-hero"> | ||
| <p class="eyebrow">Rust API</p> | ||
| <h1 class="text-balance font-display text-[clamp(2.5rem,12vw,5rem)] leading-[0.95] text-fg">Crate API reference</h1> | ||
| <p class="lead mt-4 max-w-[42rem] text-pretty text-base leading-7 text-muted sm:text-lg">Browse the current API surface for the crates Mesh LLM publishes to crates.io. For versioned documentation, use the docs.rs link on each crate.</p> | ||
| </header> | ||
|
|
||
| <section class="mt-10 grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3" aria-label="Published crates"> | ||
| {% for crate in crates %} | ||
| <article class="card grid min-w-0 gap-2 rounded-mesh border border-line-soft bg-surface/55 p-[18px] shadow-none"> | ||
| <a class="font-mono text-sm font-semibold text-fg hover:text-blue-3" href="/crates/{{ crate.rustdocName }}/index.html">{{ crate.name }}</a> | ||
| <div class="flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted"> | ||
| <a class="hover:text-blue-3" href="/crates/{{ crate.rustdocName }}/index.html">Current API →</a> | ||
| <a class="external-link hover:text-blue-3" href="https://docs.rs/{{ crate.name }}/latest/" target="_blank" rel="noreferrer">docs.rs ↗</a> | ||
| </div> | ||
| </article> | ||
| {% endfor %} | ||
| </section> | ||
| </main> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Limit the Body Lead width to 650px.
Line 11 sets
max-w-[42rem], which is 672px at the standard root font size. Set the maximum width to 650px or less.Proposed fix
As per coding guidelines, use “Body Lead with max-width 650px.”
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines