Skip to main content

LinkContext

Struct LinkContext 

Source
pub struct LinkContext {
    pub layout: Layout,
    pub book_root: String,
    pub markdown_root: String,
    pub entity_paths: HashMap<EntityRef, PathBuf>,
    pub render_from: Option<PathBuf>,
    /* private fields */
}
Expand description

Entity output path index used by LinkFormatter.

Fields§

§layout: Layout

Active page layout (controls relative path shape).

§book_root: String

mdBook project root used when resolving relative links.

§markdown_root: String

Markdown output root relative to book_root.

§entity_paths: HashMap<EntityRef, PathBuf>

Resolved output path for each entity in the current render pass.

§render_from: Option<PathBuf>

Current page path used when formatting relative entity links.

Implementations§

Source§

impl LinkContext

Source

pub fn empty( layout: Layout, book_root: impl Into<String>, markdown_root: impl Into<String>, ) -> Self

Creates an empty context with layout and path roots but no entity entries.

Source

pub fn from_manual(manual: &ReferenceManual, opts: &Options) -> Self

Builds a link context from a reference manual and render options.

Source

pub fn register_stored_entity( &mut self, module: &str, group: &str, group_dir: &str, entity: &StoredEntity, is_protobuf: bool, layout: Layout, markdown_root: &str, )

Registers one stored entity in the path index.

Source

pub fn layout_entity_keys(&self) -> impl Iterator<Item = &LayoutEntityKey>

Iterate layout entity keys registered in this context.

Source

pub fn package_page_rel(&self, package: &str) -> PathBuf

Relative path to a package rollup page.

Source

pub fn package_index_rel(&self, package: &str) -> PathBuf

Relative path to a package index page.

Source

pub fn layout_entity_path( &self, package: &str, kind: ProtobufEntityKind, name: &str, ) -> Option<&PathBuf>

Lookup layout entity path.

Source

pub fn entity_path(&self, entity_ref: &EntityRef) -> Option<&PathBuf>

Lookup entity path by EntityRef.

Format a markdown link to an entity from from.

Format a markdown link to a stored entity from from.

Format a markdown link for a protobuf FQN type reference.

SUMMARY nav link from from to target.

Trait Implementations§

Source§

impl Clone for LinkContext

Source§

fn clone(&self) -> LinkContext

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 LinkContext

Source§

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

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

impl Default for LinkContext

Source§

fn default() -> LinkContext

Returns the “default value” for a type. Read more
Source§

impl Eq for LinkContext

Source§

impl PartialEq for LinkContext

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for LinkContext

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<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> 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.