Struct CMarkReadme

Source
pub struct CMarkReadme<P, M> { /* private fields */ }
Expand description

Parsed readme Markdown with optionally specified package path and package manifest.

Implementations§

Source§

impl<'a> CMarkReadme<&'a Path, &'a Manifest>

Source

pub fn from_package( package: &'a Package, ) -> Result<Self, CMarkReadmeFromPackageError>

Creates readme from package.

It reads readme file by path specified in the package manifest.

Source§

impl CMarkReadme<(), ()>

Source

pub fn from_file(file: Arc<File>) -> Self

Creates readme from file.

Source§

impl<'a, P, M> CMarkReadme<P, M>

Source

pub fn with_package_path( self, package_path: &'a Package, ) -> CMarkReadme<&'a Package, M>

Adding the specified package path to the readme.

Source

pub fn with_manifest( self, manifest: &'a Manifest, ) -> CMarkReadme<P, &'a Manifest>

Adding the specified manifest to the readme.

Source

pub fn from_file_and_package_path_and_manifest( file: Arc<File>, package_path: P, manifest: M, ) -> Self

Creates readme from file, package path and manifest.

Source

pub fn from_data_and_package_path_and_manifest( data: CMarkData, package_path: P, manifest: M, ) -> Self

Creates readme from CMark items, package path and manifest.

Source

pub fn data(&self) -> &CMarkData

Returns CMark items.

Source

pub fn into_data(self) -> CMarkData

Consumes the CMarkReadme, returning CMarkData.

Source

pub fn package_path(&self) -> &P

Returns the package path.

Source

pub fn manifest(&self) -> &M

Returns the manifest.

Source

pub fn iter(&self) -> CMarkDataIter<'_>

Iterate over CMarkItems.

Source

pub fn iter_events(&self) -> impl Iterator<Item = &Event<'_>>

Iterate over pulldown-cmark events.

Source

pub fn concat_texts(self) -> CMarkReadme<P, M>

Concatenate adjacent text events.

Use this transformation if you deleted some nodes manually and want to merge the neighboring text nodes.

This transformation is always applied right after readme and docs parsing, because some text events remain ununited. For example Rust attribute parser generate seperate text events for every line of source code, and pulldown_cmark generate seperate text events for character entity reference.

Source

pub fn remove_images_only_paragraph<F>(self, predicate: F) -> CMarkReadme<P, M>
where F: FnMut(&[&str]) -> bool,

Removes first paragraph that contains only images and image-links, if the specified predicate returns true when passing image urls to it.

Source

pub fn remove_badges_paragraph(self) -> CMarkReadme<P, M>

Removes first paragraph that contains only badges.

Source

pub fn remove_section(self, heading: &str, level: u32) -> Self

Remove section with the specified heading text and level and its subsections.

Source

pub fn remove_codeblock_tag(self, tag: &str) -> CMarkReadme<P, M>

Remove the specified fenced code block tag.

Source

pub fn remove_codeblock_tags(self, tags: &[&str]) -> CMarkReadme<P, M>

Remove the specified fenced code block tags.

Source

pub fn remove_documentation_section(self) -> Self

Remove sections with heading Documentation and level 2.

Returns self if absolute blob links to the specified repository not found, otherwise returns an error.

Source

pub fn use_absolute_blob_urls(self, repository_url: &str) -> CMarkReadme<P, M>

Convert all relative links into absolute ones using the repository url as the root address.

Source§

impl<'a, P> CMarkReadme<P, &'a Manifest>

Returns self if absolute blob links to the manifest repository not found, otherwise returns an error.

Source

pub fn use_absolute_repository_blob_urls( self, ) -> Result<CMarkReadme<P, &'a Manifest>, UseAbsoluteRepositoryBlobUrlsError>

Convert all relative links into absolute ones using the manifest repository url as the root address.

Trait Implementations§

Source§

impl<P: Clone, M: Clone> Clone for CMarkReadme<P, M>

Source§

fn clone(&self) -> CMarkReadme<P, M>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<P: Debug, M: Debug> Debug for CMarkReadme<P, M>

Source§

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

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

impl<P: Default, M: Default> Default for CMarkReadme<P, M>

Source§

fn default() -> CMarkReadme<P, M>

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

impl<P: PartialEq, M: PartialEq> PartialEq for CMarkReadme<P, M>

Source§

fn eq(&self, other: &CMarkReadme<P, M>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<P, M> StructuralPartialEq for CMarkReadme<P, M>

Auto Trait Implementations§

§

impl<P, M> Freeze for CMarkReadme<P, M>
where P: Freeze, M: Freeze,

§

impl<P, M> RefUnwindSafe for CMarkReadme<P, M>

§

impl<P, M> Send for CMarkReadme<P, M>
where P: Send, M: Send,

§

impl<P, M> Sync for CMarkReadme<P, M>
where P: Sync, M: Sync,

§

impl<P, M> Unpin for CMarkReadme<P, M>
where P: Unpin, M: Unpin,

§

impl<P, M> UnwindSafe for CMarkReadme<P, M>
where P: UnwindSafe, M: UnwindSafe,

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.