Struct CMarkDocs

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

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

Implementations§

Source§

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

Source

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

Creates docs from package and default config.

First it reads docs file by path specified in the package manifest. Then it parses it with default configuration.

Source

pub fn from_package_and_config( package: &'a Package, config: &Config<'_>, ) -> Result<Self, CMarkDocsFromPackageError>

Creates docs from package and the specified config.

First it reads docs file by path specified in the package manifest. Then it parses it with the specified configuration.

Source§

impl CMarkDocs<(), ()>

Source

pub fn from_file_and_config( file: Arc<File>, config: &Config<'_>, ) -> Result<Self, FileDocsFromFileError>

Creates docs from file and the specified config.

The method parses a file with the specified configuration.

Source§

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

Source

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

Adding the specified package path to the docs.

Source

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

Adding the specified manifest to the docs.

Source

pub fn from_file_and_config_and_package_path_and_manifest( file: Arc<File>, config: &Config<'_>, package_path: P, manifest: M, ) -> Result<Self, FileDocsFromFileError>

Creates docs from file, config, package path and manifest.

Source

pub fn from_file_docs_and_package_path_and_manifest( file_docs: Arc<FileDocs>, package_path: P, manifest: M, ) -> Self

Creates docs from file docs content, package path and manifest.

Source

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

Creates docs 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 CMarkDocs, 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) -> CMarkDocs<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 increment_heading_levels(self) -> CMarkDocs<P, M>

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) -> CMarkDocs<P, M>

Add a first level heading with the specified text.

This function could be useful after heading level incremented.

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) -> CMarkDocs<P, M>

Remove the specified fenced code block tag.

Source

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

Remove the specified fenced code block tags.

Source

pub fn remove_codeblock_rust_test_tags(self) -> CMarkDocs<P, M>

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) -> CMarkDocs<P, M>

Use the specified codeblock tag, if they are not specified

Source

pub fn use_default_codeblock_rust_tag(self) -> CMarkDocs<P, M>

Use rust fenced codeblock highlight as default.

Source

pub fn remove_hidden_rust_code(self) -> CMarkDocs<P, M>

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.

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

Source

pub fn use_absolute_docs_urls( self, package_name: &str, documentation_url: &str, ) -> CMarkDocs<P, M>

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

Source§

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

Source

pub fn add_package_title(self) -> CMarkDocs<P, &'a Manifest>

Add a first level heading with the manifest package name.

This function could be useful after heading level incremented.

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

Source

pub fn use_absolute_package_docs_urls( self, ) -> Result<CMarkDocs<P, &'a Manifest>, UseAbsolutePackageDocsUrlsError>

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

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

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> CMarkDocs<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 CMarkDocs<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 CMarkDocs<P, M>

Source§

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

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

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

Source§

fn eq(&self, other: &CMarkDocs<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 CMarkDocs<P, M>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<P, M> UnwindSafe for CMarkDocs<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.