Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Add support for local resources #107640

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ pub struct Markdown<'a> {
pub heading_offset: HeadingOffset,
}
/// A tuple struct like `Markdown` that renders the markdown with a table of contents.
pub(crate) struct MarkdownWithToc<'a>(
pub(crate) &'a str,
pub(crate) &'a mut IdMap,
pub(crate) ErrorCodes,
pub(crate) Edition,
pub(crate) &'a Option<Playground>,
);
pub(crate) struct MarkdownWithToc<'a> {
pub(crate) content: &'a str,
pub(crate) ids: &'a mut IdMap,
pub(crate) error_codes: ErrorCodes,
pub(crate) edition: Edition,
pub(crate) playground: &'a Option<Playground>,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'm afraid that this PR might take awhile to approve, can you please separate 62e7207 into its own PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
/// and includes no paragraph tags.
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
Expand Down Expand Up @@ -1048,7 +1048,7 @@ impl Markdown<'_> {

impl MarkdownWithToc<'_> {
pub(crate) fn into_string(self) -> String {
let MarkdownWithToc(md, ids, codes, edition, playground) = self;
let MarkdownWithToc { content: md, ids, error_codes: codes, edition, playground } = self;

let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();

Expand Down
9 changes: 8 additions & 1 deletion src/librustdoc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ pub(crate) fn render<P: AsRef<Path>>(
let mut ids = IdMap::new();
let error_codes = ErrorCodes::from(options.unstable_features.is_nightly_build());
let text = if !options.markdown_no_toc {
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
MarkdownWithToc {
content: text,
ids: &mut ids,
error_codes,
edition,
playground: &playground,
}
.into_string()
} else {
Markdown {
content: text,
Expand Down