pub struct CMarkData(/* private fields */);
Expand description
A CMarkItem
s container storing a list of events with multiple transformation functions.
Implementations§
Source§impl CMarkData
impl CMarkData
Sourcepub fn from_items(items: Vec<Arc<CMarkItem>>) -> Self
pub fn from_items(items: Vec<Arc<CMarkItem>>) -> Self
Creates CMarkData
from CMarkItem
s.
Sourcepub fn from_file_docs(file_docs: Arc<FileDocs>) -> Self
pub fn from_file_docs(file_docs: Arc<FileDocs>) -> Self
Creates CMarkData
from the specified FileDocs
.
Sourcepub fn from_text_source(text_source: TextSource) -> Self
pub fn from_text_source(text_source: TextSource) -> Self
Creates CMarkData
from the specified TextSource
.
Sourcepub fn into_items(self) -> Vec<Arc<CMarkItem>>
pub fn into_items(self) -> Vec<Arc<CMarkItem>>
Consumes the CMarkData
, returning CMarkItem
s.
Sourcepub fn iter(&self) -> CMarkDataIter<'_>
pub fn iter(&self) -> CMarkDataIter<'_>
Iterate over CMarkItem
s.
Sourcepub fn iter_events(&self) -> impl Iterator<Item = &Event<'_>>
pub fn iter_events(&self) -> impl Iterator<Item = &Event<'_>>
Iterate over pulldown-cmark events.
Sourcepub fn concat_texts(self) -> Self
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
impl CMarkData
Sourcepub fn increment_heading_levels(self) -> Self
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.
Sourcepub fn add_title(self, text: &str) -> Self
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.
Sourcepub fn remove_images_only_paragraph<P>(self, predicate: P) -> Self
pub fn remove_images_only_paragraph<P>(self, predicate: P) -> Self
Removes first paragraph that contains only images and image-links, if the specified predicate returns true when passing image urls to it.
Sourcepub fn remove_badges_paragraph(self) -> Self
pub fn remove_badges_paragraph(self) -> Self
Removes first paragraph that contains only badges.
Sourcepub fn remove_section(self, heading: &str, level: u32) -> Self
pub fn remove_section(self, heading: &str, level: u32) -> Self
Remove section with the specified heading text and level and its subsections.
Sourcepub fn remove_documentation_section(self) -> Self
pub fn remove_documentation_section(self) -> Self
Remove sections with heading Documentation
and level 2.
Source§impl CMarkData
impl CMarkData
Sourcepub fn disallow_absolute_blob_links(
self,
repository_url: &str,
) -> Result<Self, DisallowUrlsWithPrefixError>
pub fn disallow_absolute_blob_links( self, repository_url: &str, ) -> Result<Self, DisallowUrlsWithPrefixError>
Returns self if absolute blob links to the specified repository not found, otherwise returns an error.
Sourcepub fn disallow_absolute_docs_links(
self,
package_name: &str,
documentation_url: &str,
) -> Result<Self, DisallowUrlsWithPrefixError>
pub fn disallow_absolute_docs_links( self, package_name: &str, documentation_url: &str, ) -> Result<Self, DisallowUrlsWithPrefixError>
Returns self if absolute docs links to the specified repository not found, otherwise returns an error.
Sourcepub fn disallow_urls_with_prefix(
self,
prefix: &str,
) -> Result<Self, DisallowUrlsWithPrefixError>
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.
Sourcepub fn use_absolute_blob_urls(self, repository_url: &str) -> Self
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.
Sourcepub fn use_absolute_docs_urls(
self,
package_name: &str,
documentation_url: &str,
) -> Self
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.
Sourcepub fn with_absolute_urls(self, prefix: &str) -> Self
pub fn with_absolute_urls(self, prefix: &str) -> Self
Convert all relative links into absolute ones using specified url prefix.
Source§impl CMarkData
impl CMarkData
Sourcepub fn remove_codeblock_tag(self, tag: &str) -> Self
pub fn remove_codeblock_tag(self, tag: &str) -> Self
Remove the specified fenced code block tag.
Remove the specified fenced code block tags.
Source§impl CMarkData
impl CMarkData
Remove fenced code block tags that are used by cargo test
.
See https://doc.rust-lang.org/rustdoc/documentation-tests.html for more details.
Sourcepub fn use_default_codeblock_tag(self, tag: &str) -> Self
pub fn use_default_codeblock_tag(self, tag: &str) -> Self
Use the specified codeblock tag, if they are not specified
Source§impl CMarkData
impl CMarkData
Sourcepub fn use_default_codeblock_rust_tag(self) -> Self
pub fn use_default_codeblock_rust_tag(self) -> Self
Use rust fenced codeblock highlight as default.
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.