summary refs log tree commit diff
path: root/src/librustdoc/html/markdown.rs
AgeCommit message (Collapse)AuthorLines
2023-09-27rustdoc: while -> ifMatthias Krüger-1/+1
we will always return once we step inside the while-loop thus `if` is sufficient here
2023-09-19Allow more characters in custom classesGuillaume Gomez-9/+27
2023-09-18Use old parser if `custom_code_classes_in_docs` feature is not enabledGuillaume Gomez-104/+135
2023-09-17Don't emit an error if the `custom_code_classes_in_docs` feature is disabled ↵Guillaume Gomez-16/+79
when its syntax is used.
2023-09-15Add `custom` tag for markdown codeblocksGuillaume Gomez-3/+5
2023-09-15Update to new `emit_error` APIGuillaume Gomez-8/+8
2023-09-15Improve error emitting codeGuillaume Gomez-6/+10
2023-09-15Add eBNF and documentation on TagIteratorGuillaume Gomez-0/+30
2023-09-15Implement new eBNF for codeblock attributesGuillaume Gomez-83/+189
2023-09-15Add support for double quotes in markdown codeblock attributesGuillaume Gomez-49/+72
2023-09-15Implement custom classes for rustdoc code blocks with ↵Guillaume Gomez-45/+191
`custom_code_classes_in_docs` feature
2023-09-11Add missing ID into the ID mapGuillaume Gomez-0/+1
2023-09-07rustdoc: remove unused ID `mainThemeStyle`Michael Howell-1/+0
This was added in 003b2bc1c65251ec2fc80b78ed91c43fb35402ec and used to build the URL of the theme stylesheets. It isn't used any more, because f9e1f6ffdf03ec33cb29e20c88fc7bcc938c7f42 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-08-18narrow down the lint trigger constraintKyle Lin-9/+26
2023-08-18Fix resolution cachingKyle Lin-0/+1
2023-08-18rework link parsing loopKyle Lin-24/+65
2023-08-16Use more named format argsGuillaume Gomez-6/+6
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-16/+16
2023-07-30Remove some unneeded `clone()` callsGuillaume Gomez-2/+0
2023-06-27Replace `id` attribute with `name` for `<meta>` tagGuillaume Gomez-1/+0
2023-06-01Rollup merge of #108459 - benediktwerner:rustdoc-fix-link-match, ↵Dylan DPC-5/+10
r=GuillaumeGomez rustdoc: Fix LinkReplacer link matching It currently just uses the first link with the same href which might not necessarily be the matching one. This fixes replacements when there are several links to the same item but with different text (e.g. `[X] and [struct@X]`). It also fixes replacements in summaries since those use a links list with empty hrefs, so currently all links would always match the first link by href but then not match its text. This could also lead to a panic in the `original_lext[1..len() - 1]` part when the first link only has a single character, which is why the new code uses `.get(..)` instead.
2023-05-30rustdoc: Fix LinkReplacer link matchingbenediktwerner-5/+10
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-26rustdoc: get unnormalized link destination for suggestionsMichael Howell-9/+111
Fixes #110111 This bug, and the workaround in this commit, is closely linked to [raphlinus/pulldown-cmark#441], getting offsets of link components. In particular, pulldown-cmark doesn't provide the offsets of the contents of a link. To work around this, rustdoc parser parts of a link definition itself. [raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441
2023-05-21rustdoc: include strikethrough in item summaryLukas Markeffsky-1/+9
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-2/+2
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-04-16Spelling librustdocJosh Soref-1/+1
* associated * collected * correspondence * inlining * into * javascript * multiline * variadic Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-12remove some unneeded importsKaDiWa-1/+0
2023-03-19Remove footnote references from doc summaryGuillaume Gomez-1/+13
2023-02-28Auto merge of #108098 - notriddle:notriddle/rustdoc-tooltip-alloc, ↵bors-4/+4
r=GuillaumeGomez rustdoc: reduce allocations when generating tooltips An attempt to reduce the perf regression in https://github.com/rust-lang/rust/pull/108052#issuecomment-1430631861
2023-02-23rustdoc: avoid including `<li>` tags in item table short descMichael Howell-4/+1
Fixes a bug seen at https://docs.rs/gl_constants/0.1.1/gl_constants/index.html
2023-02-22rustdoc: reduce allocations when generating tooltipsMichael Howell-4/+4
An attempt to reduce the perf regression in https://github.com/rust-lang/rust/pull/108052#issuecomment-1430631861
2023-02-18doc links: Filter away autolinks in both rustc and rustdocVadim Petrochenkov-16/+8
2023-02-18rustdoc: Cleanup broken link callbacksVadim Petrochenkov-29/+17
2023-02-18rustdoc: Do not use Footnotes and HeadingLinks when extracting doc linksVadim Petrochenkov-8/+3
they do not add any `Link` events
2023-02-13rustdoc: add more tooltips to intra-doc linksMichael Howell-5/+11
This commit makes intra-doc link tooltips consistent with generated links in function signatures and item tables, with the format `itemtype foo::bar::baz`. This way, you can tell if a link points at a trait or a type (for example) by mousing over it. See also fce944d4e79b3a87ddf511206724edf33acfd704
2023-02-12Rollup merge of #107934 - ↵Matthias Krüger-2/+11
notriddle:notriddle/intra-doc-link-meta-description, r=camelid,GuillaumeGomez rustdoc: account for intra-doc links in `<meta name="description">` Similar to #86451, but for the SEO descriptions instead of the search descriptions.
2023-02-11rustdoc: account for intra-doc links in `<meta name="description">`Michael Howell-2/+11
2023-02-11Rollup merge of #107909 - notriddle:notriddle/register-header-empty-cond, ↵Matthias Krüger-5/+1
r=camelid rustdoc: remove redundant `if s.is_empty()` from `find_testable_code`
2023-02-10rustdoc: remove redundant `if s.is_empty()` from `find_testable_code`Michael Howell-5/+1
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-9/+1
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-09Rollup merge of #107655 - notriddle:notriddle/small-url-encode, r=GuillaumeGomezDylan DPC-41/+2
rustdoc: use the same URL escape rules for fragments as for examples Carries over improvements from #107284
2023-02-06Turn MarkdownWithToc into a struct with named fieldsGuillaume Gomez-9/+9
2023-02-03rustdoc: use the same URL escape rules for fragments as for examplesMichael Howell-41/+2
2023-01-27Remove from librustdoc and clippy tooScott McMurray-3/+3
2023-01-27Rollup merge of #107325 - petrochenkov:hiddoc2, r=GuillaumeGomezYuki Okushi-32/+12
rustdoc: Stop using `HirId`s Use `LocalDefId`s instead. Rustdoc doesn't work with item bodies, so it almost never needs fine-grained HIR IDs.
2023-01-26rustdoc: use smarter encoding for playground URLMichael Howell-1/+18
The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`. Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}> In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031% $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html 759235 after.dir/std/vec/struct.Vec.html 781842 before.dir/std/vec/struct.Vec.html 100*((759235-781842)/781842)=-2.8 $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html 3194173 after.dir/std/num/struct.Wrapping.html 3204351 before.dir/std/num/struct.Wrapping.html 100*((3194173-3204351)/3204351)=-0.031 $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html 8151 after.dir/std/keyword.match.html 8495 before.dir/std/keyword.match.html 100*((8151-8495)/8495)=-4.0 Gzipped tarball sizes seem shrunk, but not by much. du -s before.tar.gz after.tar.gz 69600 before.tar.gz 69480 after.tar.gz 100*((69480-69600)/69600)=-0.17
2023-01-26rustdoc: Stop using `HirId`sVadim Petrochenkov-32/+12
Use `LocalDefId`s instead
2023-01-13Playground.crate_name String -> Symbolklensy-3/+3
2022-12-16Don't add "Read more" link if there is no extra contentGuillaume Gomez-6/+21