Skip to main content

SourceBase

Struct SourceBase 

Source
pub struct SourceBase { /* private fields */ }
Expand description

Where a link that leaves the site points instead: the repository’s own web view, at the commit the site was built from.

The Build Plan cites code as evidence for its claims — [sync](../crates/… /sync.rs) — which is correct in a checkout and dead on roteiro.dev, because render docs publishes documents and not source. Six such links were live on the site (issue #456). This is the answer chosen for them: keep the link’s affordance and move its target to the one place the file is actually served.

§Pinned to a commit, not to a branch

blob carries a sha (…/blob/<sha>), not …/blob/main. GitHub serves a blob by sha forever, so the link keeps resolving after the file is renamed or deleted; a main link 404s on the next rename, and this is a retired plan whose citations describe the code as it stood, so drifting them onto today’s main would be wrong even when it resolved. It is also the rule the vault renderer already ships (source_blob_base + head_commit_id), and one repo with two answers to “which commit does a source link mean” is its own defect.

The cost is stated rather than hidden: a site rendered from a commit that was never pushed yields links the host has never heard of. That is a local preview, not the published site — the Website workflow renders from a commit GitHub already has.

§No mappable origin

Construction goes through SourceBase::new, which yields None when the caller has no blob base to offer — no origin remote, or a remote whose URL does not map to a web view. Links are then left exactly as they are: still correct in a checkout, still dead on the site. That is deliberate and is the least-bad of the three: refusing to render would break render docs in any repository without an origin (every test fixture, every fresh git init), and demoting the link to plain text would destroy information to hide a problem the reader can otherwise route around.

§Can the class recur?

Not while a base exists: the rule is structural, not a list of the six links that were found. Any link climbing above the site root is re-aimed, so a new citation added to any rendered document is handled the day it is written, and a_link_out_of_the_site_goes_to_the_repository is what fails if that stops.

It recurs silently in exactly one case — a site rendered where no base can be derived — and nothing catches that, because the output is the authored link and there is no rendered-site link gate (issue #459) to notice. That case is the one the deploy does not hit: the Website workflow checks out with an origin on github.com, and without_an_origin_remote_a_source_link_is_left_as_authored pins the behaviour rather than the absence of a gate.

Implementations§

Source§

impl SourceBase

Source

pub fn new(blob: Option<&str>, dir: &str) -> Option<Self>

A source base for a document at repository-relative directory dir, served from blob. None when blob is None — see the type’s documentation for why that leaves links alone rather than failing.

Trait Implementations§

Source§

impl Clone for SourceBase

Source§

fn clone(&self) -> SourceBase

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceBase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SourceBase

Source§

impl PartialEq for SourceBase

Source§

fn eq(&self, other: &SourceBase) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SourceBase

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.