Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ unwrap_used = "warn"
expect_used = "warn"
panic = "warn"
todo = "warn"
missing_docs_in_private_items = "warn"
unimplemented = "warn"
dbg_macro = "warn"
# Every exception names its lint with `#[expect]` and says why.
Expand Down
4 changes: 2 additions & 2 deletions apps/auth-service/src/cli/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pub(super) trait Report {
fn human(&self, out: &mut HumanWriter<'_>) -> io::Result<()>;
}

// Implements `Report` for a type, with its JSON the value itself and the block
// as `human`: `report!(Type, self, out, { ... })`.
/// Implements `Report` for a type, with its JSON the value itself and the block
/// as `human`: `report!(Type, self, out, { ... })`.
macro_rules! report {
($ty:ty, $this:ident, $out:ident, $body:block) => {
impl $crate::cli::output::Report for $ty {
Expand Down
5 changes: 4 additions & 1 deletion apps/auth-service/src/security/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ pub(crate) enum CacheClass {
Immutable,
/// Public, credential-free data, the same for every caller and readable from any
/// origin. Its route must accept any `Origin` and never read the session.
Public { max_age: StdDuration },
Public {
/// How long a cache may keep it.
max_age: StdDuration,
},
}

impl CacheClass {
Expand Down
25 changes: 21 additions & 4 deletions apps/web/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ const DOCUMENTATION: &str = "https://docs.sourceorigin.dev";

/// The body of `page`; the homepage links auth's pages at `links`.
#[component]
pub(crate) async fn page_body(page: Page, links: HomeLinks<'_>) -> Result<impl View> {
pub(crate) async fn page_body(
/// The page.
page: Page,
/// Where the homepage links.
links: HomeLinks<'_>,
) -> Result<impl View> {
Ok(view! {
match page {
Page::Home => home(links: links),
Expand All @@ -72,7 +77,10 @@ pub(crate) async fn page_body(page: Page, links: HomeLinks<'_>) -> Result<impl V
/// A policy, whose `text` is a fragment of trusted HTML, embedded at compile time
/// so it reads and diffs as a document.
#[component]
async fn policy(text: &'static str) -> Result<impl View> {
async fn policy(
/// The policy, as trusted HTML.
text: &'static str,
) -> Result<impl View> {
Ok(view! {
<article class="policy">
(ViewHandle::unescaped_unchecked(text))
Expand All @@ -82,7 +90,10 @@ async fn policy(text: &'static str) -> Result<impl View> {

/// The homepage: what Origin Auth, SourceOrigin's sign-in, is, and each part of it.
#[component]
async fn home(links: HomeLinks<'_>) -> Result<impl View> {
async fn home(
/// Where the homepage links.
links: HomeLinks<'_>,
) -> Result<impl View> {
Ok(view! {
<section class="hero">
<p class="eyebrow">"SourceOrigin"</p>
Expand All @@ -107,11 +118,17 @@ async fn home(links: HomeLinks<'_>) -> Result<impl View> {
/// its link, labelled `label`, to `href`. A `wide` card spans the grid.
#[component]
async fn feature<'a>(
/// What the part is called.
title: &'a str,
/// What it does.
text: &'a str,
/// What its link says.
label: &'a str,
/// Where its link leads.
href: &'a str,
#[default] wide: bool,
/// Whether the card spans the grid.
#[default]
wide: bool,
) -> Result<impl View> {
Ok(view! {
<article class=(class!("card", "wide" if wide))>
Expand Down
3 changes: 0 additions & 3 deletions crates/ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
//! # }
//! ```

// Every private item, a component's parameters included, says what it takes and does.
#![warn(clippy::missing_docs_in_private_items)]

/// The admin dashboard, and auth's page handing administrators off to it.
mod admin;
/// Files pages link, embedded in the executable: the stylesheet and the
Expand Down
4 changes: 3 additions & 1 deletion docs/dev/rust-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ ever to need it, every block would carry a `// SAFETY:` comment

## Documentation and tests

Give every item a concise, useful doc comment, private items included. Explain
Give every item a concise, useful doc comment, private items included, a
component's parameters too: it says what goes in and what comes out or happens
(`missing_docs_in_private_items` enforces it). Explain
security reasoning, protocol quirks, ordering and locking where they are not obvious.
Keep documentation current. Tests should cover meaningful logic and boundaries;
avoid repeated smoke tests. Run checks relevant to changed code while iterating,
Expand Down
10 changes: 10 additions & 0 deletions tools/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ use std::{
/// The TypeScript SDK's directory, relative to the workspace root.
const NPM_PACKAGE: &str = "packages/auth";

/// The command line.
#[derive(Parser)]
#[command(about = "Development tasks for the SourceOrigin workspace")]
struct Cli {
/// The task to run.
#[command(subcommand)]
task: Task,
}

/// The development tasks.
#[derive(Subcommand)]
enum Task {
/// Publish the SDKs: the Rust crates to crates.io, in dependency order, then
Expand Down Expand Up @@ -73,8 +76,11 @@ struct Workspace {
/// The fields of a crate's `cargo metadata` this reads.
#[derive(Deserialize)]
struct Package {
/// The crate's name.
name: String,
/// Its version.
version: String,
/// Its license, if it declares one.
license: Option<String>,
/// The registries it may be published to: empty for `publish = false`.
publish: Option<Vec<String>>,
Expand All @@ -83,17 +89,21 @@ struct Package {
/// The TypeScript SDK's `package.json`, as far as this reads it.
#[derive(Deserialize)]
struct NpmPackage {
/// The package's name.
name: String,
/// Its version.
version: String,
}

/// The fields of `cargo metadata` this reads.
#[derive(Deserialize)]
struct Metadata {
/// The workspace's crates.
packages: Vec<Package>,
}

impl Workspace {
/// The workspace the command runs in, from `git` and `cargo metadata`.
fn current() -> Result<Self> {
let root = PathBuf::from(
Command::new("git")
Expand Down
1 change: 1 addition & 0 deletions tools/xtask/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const LICENSE: &str = "Apache-2.0";

/// A publish of the SDKs at their current versions.
pub struct Publish<'a> {
/// The workspace whose SDKs are published.
pub workspace: &'a Workspace,
/// Packages and builds everything without uploading, even versions already
/// published, so it checks the packages whatever the registries hold.
Expand Down
7 changes: 7 additions & 0 deletions tools/xtask/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{fmt::Write as _, fs};

/// A release of the workspace version, from `HEAD`.
pub struct Release<'a> {
/// The workspace released.
workspace: &'a Workspace,
/// The workspace version, such as `0.2.0`.
version: String,
Expand All @@ -16,6 +17,10 @@ pub struct Release<'a> {
}

impl<'a> Release<'a> {
/// A release of `workspace`'s current version, which only prints what it would do when `dry_run`.
///
/// # Errors
/// Fails if the published crates do not share one version.
pub fn new(workspace: &'a Workspace, dry_run: bool) -> Result<Self> {
Ok(Self {
workspace,
Expand Down Expand Up @@ -242,8 +247,10 @@ enum Section {
}

impl Section {
/// Every section, in the order the notes list them.
const ALL: [Self; 4] = [Self::Breaking, Self::Features, Self::Fixes, Self::Other];

/// The section's heading in the release notes.
fn title(self) -> &'static str {
match self {
Self::Breaking => "Breaking changes",
Expand Down
Loading