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: LayoutActive page layout (controls relative path shape).
book_root: StringmdBook project root used when resolving relative links.
markdown_root: StringMarkdown 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
impl LinkContext
Sourcepub fn empty(
layout: Layout,
book_root: impl Into<String>,
markdown_root: impl Into<String>,
) -> Self
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.
Sourcepub fn from_manual(manual: &ReferenceManual, opts: &Options) -> Self
pub fn from_manual(manual: &ReferenceManual, opts: &Options) -> Self
Builds a link context from a reference manual and render options.
Sourcepub fn register_stored_entity(
&mut self,
module: &str,
group: &str,
group_dir: &str,
entity: &StoredEntity,
is_protobuf: bool,
layout: Layout,
markdown_root: &str,
)
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.
Sourcepub fn layout_entity_keys(&self) -> impl Iterator<Item = &LayoutEntityKey>
pub fn layout_entity_keys(&self) -> impl Iterator<Item = &LayoutEntityKey>
Iterate layout entity keys registered in this context.
Sourcepub fn package_page_rel(&self, package: &str) -> PathBuf
pub fn package_page_rel(&self, package: &str) -> PathBuf
Relative path to a package rollup page.
Sourcepub fn package_index_rel(&self, package: &str) -> PathBuf
pub fn package_index_rel(&self, package: &str) -> PathBuf
Relative path to a package index page.
Sourcepub fn layout_entity_path(
&self,
package: &str,
kind: ProtobufEntityKind,
name: &str,
) -> Option<&PathBuf>
pub fn layout_entity_path( &self, package: &str, kind: ProtobufEntityKind, name: &str, ) -> Option<&PathBuf>
Lookup layout entity path.
Sourcepub fn entity_path(&self, entity_ref: &EntityRef) -> Option<&PathBuf>
pub fn entity_path(&self, entity_ref: &EntityRef) -> Option<&PathBuf>
Lookup entity path by EntityRef.
Sourcepub fn link_from(
&self,
from: &Path,
package: &str,
kind: ProtobufEntityKind,
name: &str,
) -> String
pub fn link_from( &self, from: &Path, package: &str, kind: ProtobufEntityKind, name: &str, ) -> String
Format a markdown link to an entity from from.
Sourcepub fn link_entity(&self, from: &Path, entity_ref: &EntityRef) -> String
pub fn link_entity(&self, from: &Path, entity_ref: &EntityRef) -> String
Format a markdown link to a stored entity from from.
Trait Implementations§
Source§impl Clone for LinkContext
impl Clone for LinkContext
Source§fn clone(&self) -> LinkContext
fn clone(&self) -> LinkContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LinkContext
impl Debug for LinkContext
Source§impl Default for LinkContext
impl Default for LinkContext
Source§fn default() -> LinkContext
fn default() -> LinkContext
impl Eq for LinkContext
Source§impl PartialEq for LinkContext
impl PartialEq for LinkContext
Source§fn eq(&self, other: &LinkContext) -> bool
fn eq(&self, other: &LinkContext) -> bool
self and other values to be equal, and is used by ==.