Struct CMarkData

Source
pub struct CMarkData(/* private fields */);
Expand description

A CMarkItems container storing a list of events with multiple transformation functions.

Implementations§

Source§

impl CMarkData

Source

pub fn from_items(items: Vec<Arc<CMarkItem>>) -> Self

Creates CMarkData from CMarkItems.

Source

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

Creates CMarkData from the specified File.

Source

pub fn from_file_docs(file_docs: Arc<FileDocs>) -> Self

Creates CMarkData from the specified FileDocs.

Source

pub fn from_text_source(text_source: TextSource) -> Self

Creates CMarkData from the specified TextSource.

Source

pub fn into_items(self) -> Vec<Arc<CMarkItem>>

Consumes the CMarkData, returning CMarkItems.

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) -> Self

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§

impl CMarkData

Source

pub fn increment_heading_levels(self) -> Self

Increment levels of all headings.

In readme, the first level heading is usually used only for the project title. The second level header is usually used in for text section headings in readme. Rustdoc automatically adds the header of a crate name and the first level headers are used for text sections.

So it is necessary to increase the level of all headings in the documentation in order to synchronize the headings.

Source

pub fn add_title(self, text: &str) -> Self

Add a first level heading with the specified text.

This function could be useful after heading level incremented.

Source

pub fn remove_images_only_paragraph<P>(self, predicate: P) -> Self
where P: 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) -> Self

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_documentation_section(self) -> Self

Remove sections with heading Documentation and level 2.

Source§

impl CMarkData

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

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

Source

pub fn disallow_urls_with_prefix( self, prefix: &str, ) -> Result<Self, DisallowUrlsWithPrefixError>

Returns self if links with the specified prefix not found, otherwise returns an error.

Source

pub fn use_absolute_blob_urls(self, repository_url: &str) -> Self

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

Source

pub fn use_absolute_docs_urls( self, package_name: &str, documentation_url: &str, ) -> Self

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

Source

pub fn with_absolute_urls(self, prefix: &str) -> Self

Convert all relative links into absolute ones using specified url prefix.

Converts all links with function func applied to each link address.

Source§

impl CMarkData

Source

pub fn remove_codeblock_tag(self, tag: &str) -> Self

Remove the specified fenced code block tag.

Source

pub fn remove_codeblock_tags(self, tags: &[&str]) -> Self

Remove the specified fenced code block tags.

Source§

impl CMarkData

Source

pub fn remove_codeblock_rust_test_tags(self) -> Self

Remove fenced code block tags that are used by cargo test.

See https://doc.rust-lang.org/rustdoc/documentation-tests.html for more details.

Source

pub fn use_default_codeblock_tag(self, tag: &str) -> Self

Use the specified codeblock tag, if they are not specified

Source§

impl CMarkData

Source

pub fn use_default_codeblock_rust_tag(self) -> Self

Use rust fenced codeblock highlight as default.

Source

pub fn remove_hidden_rust_code(self) -> Self

Remove hidden rust code from rust fenced codeblocks.

See https://doc.rust-lang.org/rustdoc/documentation-tests.html#hiding-portions-of-the-example for more details.

Trait Implementations§

Source§

impl Clone for CMarkData

Source§

fn clone(&self) -> CMarkData

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 Debug for CMarkData

Source§

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

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

impl Default for CMarkData

Source§

fn default() -> CMarkData

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

impl PartialEq for CMarkData

Source§

fn eq(&self, other: &CMarkData) -> 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 StructuralPartialEq for CMarkData

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.