{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiapumskvln6cr2ad2asw5carlouyjsbjjkoh5obtgdpzoasodyz2y",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mg6tfehcuzd2"
},
"path": "/t/alternative-to-cargo-new-templates-examples-as-build-target-templates/24047#post_6",
"publishedAt": "2026-03-03T21:32:35.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"https://docs.rs/clap/latest/clap",
"https://docs.rs/crate/clap/latest/source/examples/",
"https://docs.rs/crate/clap/latest/examples/"
],
"textContent": "epage:\n\n> `{crate}` likely should support the fully Package Id Spec format which would is a URL.\n\nIt's not exactly the prettiest solution, but we could require that `{proto}://{hostname-and-path}` package ids include the `#` section, e.g.\n\n\n spec := pkgname [ \"/\" template-name ] |\n [ kind \"+\" ] proto \"://\" hostname-and-path [ \"?\" query ]\n [ \"#\" [ pkgname | semver ] [ \"/\" template-name ] ]\n\n\nTo make that nicer, we could allow the `registry+` kind to directly serve packages/templates, such that something like `https://crates.internal/clap/full` is shorthand for `registry+https://crates.internal#clap:*/full`.\n\nepage:\n\n> Also, any thoughts on how we help with example discovery?\n\nThe rustdoc feature to show package examples in API documentation is a big one. Examples marked as templates should be surfaced in _some_ manner on the cratesio page, although I don't have any real suggestions as to how. (Perhaps just by name and top-level doc comment? In a subpage, like for versions/dependencies/etc. Plus linking to the docs page below, or to the source page until such exists.)\n\nA longshot idea would be for docsrs to, alongside https://docs.rs/clap/latest/clap for the API documentation and https://docs.rs/crate/clap/latest/source/examples/ for the examples' source directory, create a page https://docs.rs/crate/clap/latest/examples/ for browsing examples with nicer navigation than the source view (i.e. closer to what you get if you abuse `mod` API documentation to present examples). Bonus points if this allows for some form of literate programming, interleaving rendered markdown content and code snippets. Once this exists, then crate resources and documentation can link it if it's useful to downstream consumers.",
"title": "Alternative to `cargo new` templates: examples as build-target templates"
}