move collapse and unindent docs passes earlier
This commit is contained in:
parent
7f19f161f2
commit
906ec8acce
6 changed files with 40 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::clean::{self, DocFragment, Item};
|
||||
use crate::core::DocContext;
|
||||
use crate::fold;
|
||||
use crate::fold::{DocFolder};
|
||||
use crate::passes::Pass;
|
||||
|
|
@ -6,7 +7,7 @@ use crate::passes::Pass;
|
|||
use std::mem::replace;
|
||||
|
||||
pub const COLLAPSE_DOCS: Pass =
|
||||
Pass::late("collapse-docs", collapse_docs,
|
||||
Pass::early("collapse-docs", collapse_docs,
|
||||
"concatenates all document attributes into one document attribute");
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
|
|
@ -26,7 +27,7 @@ impl DocFragment {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn collapse_docs(krate: clean::Crate) -> clean::Crate {
|
||||
pub fn collapse_docs(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
|
||||
Collapser.fold_crate(krate)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,27 +141,27 @@ pub const PASSES: &'static [Pass] = &[
|
|||
];
|
||||
|
||||
/// The list of passes run by default.
|
||||
pub const DEFAULT_PASSES: &'static [&'static str] = &[
|
||||
pub const DEFAULT_PASSES: &[&str] = &[
|
||||
"collect-trait-impls",
|
||||
"collapse-docs",
|
||||
"unindent-comments",
|
||||
"check-private-items-doc-tests",
|
||||
"strip-hidden",
|
||||
"strip-private",
|
||||
"collect-intra-doc-links",
|
||||
"check-code-block-syntax",
|
||||
"collapse-docs",
|
||||
"unindent-comments",
|
||||
"propagate-doc-cfg",
|
||||
];
|
||||
|
||||
/// The list of default passes run with `--document-private-items` is passed to rustdoc.
|
||||
pub const DEFAULT_PRIVATE_PASSES: &'static [&'static str] = &[
|
||||
pub const DEFAULT_PRIVATE_PASSES: &[&str] = &[
|
||||
"collect-trait-impls",
|
||||
"collapse-docs",
|
||||
"unindent-comments",
|
||||
"check-private-items-doc-tests",
|
||||
"strip-priv-imports",
|
||||
"collect-intra-doc-links",
|
||||
"check-code-block-syntax",
|
||||
"collapse-docs",
|
||||
"unindent-comments",
|
||||
"propagate-doc-cfg",
|
||||
];
|
||||
|
||||
|
|
@ -438,11 +438,11 @@ crate fn source_span_for_markdown_range(
|
|||
.span_to_snippet(span_of_attrs(attrs))
|
||||
.ok()?;
|
||||
|
||||
let starting_line = markdown[..md_range.start].lines().count() - 1;
|
||||
let ending_line = markdown[..md_range.end].lines().count() - 1;
|
||||
let starting_line = markdown[..md_range.start].matches('\n').count();
|
||||
let ending_line = starting_line + markdown[md_range.start..md_range.end].matches('\n').count();
|
||||
|
||||
// We use `split_terminator('\n')` instead of `lines()` when counting bytes so that we only
|
||||
// we can treat CRLF and LF line endings the same way.
|
||||
// We use `split_terminator('\n')` instead of `lines()` when counting bytes so that we treat
|
||||
// CRLF and LF line endings the same way.
|
||||
let mut src_lines = snippet.split_terminator('\n');
|
||||
let md_lines = markdown.split_terminator('\n');
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@ use std::string::String;
|
|||
use std::usize;
|
||||
|
||||
use crate::clean::{self, DocFragment, Item};
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::{self, DocFolder};
|
||||
use crate::passes::Pass;
|
||||
|
||||
pub const UNINDENT_COMMENTS: Pass =
|
||||
Pass::late("unindent-comments", unindent_comments,
|
||||
Pass::early("unindent-comments", unindent_comments,
|
||||
"removes excess indentation on comments in order for markdown to like it");
|
||||
|
||||
pub fn unindent_comments(krate: clean::Crate) -> clean::Crate {
|
||||
pub fn unindent_comments(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
|
||||
CommentCleaner.fold_crate(krate)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ LL | | /// [error]
|
|||
|
|
||||
= note: the link appears in this line:
|
||||
|
||||
[error]
|
||||
^^^^^
|
||||
[error]
|
||||
^^^^^
|
||||
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
|
||||
|
||||
warning: `[error1]` cannot be resolved, ignoring it...
|
||||
|
|
|
|||
12
src/test/rustdoc-ui/issue-58473-2.rs
Normal file
12
src/test/rustdoc-ui/issue-58473-2.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// compile-pass
|
||||
|
||||
#![deny(private_doc_tests)]
|
||||
|
||||
mod foo {
|
||||
/**
|
||||
Does nothing, returns `()`
|
||||
|
||||
yadda-yadda-yadda
|
||||
*/
|
||||
fn foo() {}
|
||||
}
|
||||
10
src/test/rustdoc-ui/issue-58473.rs
Normal file
10
src/test/rustdoc-ui/issue-58473.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// compile-pass
|
||||
|
||||
pub trait Foo {
|
||||
/**
|
||||
Does nothing, returns `()`
|
||||
|
||||
yadda-yadda-yadda
|
||||
*/
|
||||
fn foo() {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue