summary refs log tree commit diff
path: root/src/librustdoc/html/markdown.rs
AgeCommit message (Collapse)AuthorLines
2022-05-24fix simple clippy lintsklensy-6/+6
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-43/+46
2022-05-14Remove theme picker buttonGuillaume Gomez-2/+0
2022-04-30Move settings into full JSGuillaume Gomez-1/+4
2022-04-21Auto merge of #96260 - Kobzol:rustdoc-idmap, r=petrochenkovbors-44/+48
rustdoc: Optimize IdMap Slightly optimizes `IdMap`, which is hot in `markdown_links` (context [here](https://github.com/rust-lang/rust/pull/96135#issuecomment-1103539052)). There are more improvements that can be made near this place, but this seemed like an easy win locally (although I tried it on top of https://github.com/rust-lang/rust/pull/94857, so let's see what happens without that PR). r? `@petrochenkov`
2022-04-21rustdoc: Optimize IdMapJakub Beránek-44/+48
2022-04-20Remove `<>` links to be potential intra-doc linksGuillaume Gomez-1/+13
2022-04-19rustdoc: Cache preprocessed markdown linksVadim Petrochenkov-4/+6
2022-04-12rustdoc: discr. required+provided assoc consts+tysLeón Orell Valerian Liehr-2/+4
2022-04-09rustdoc: Reduce allocations in a `html::markdown` functionRoc Yu-7/+5
2022-03-10Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, ↵Dylan DPC-1/+1
r=Mark-Simulacrum Use modern formatting for format! macros This updates the standard library's documentation to use the new format_args syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored). `eprintln!("{}", e)` becomes `eprintln!("{e}")`, but `eprintln!("{}", e.kind())` remains untouched.
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-08Unify inherent impl blocks by wrapping them into a divGuillaume Gomez-0/+1
2022-02-16Adopt let_else in even more placesest31-3/+1
2022-02-09Unify headings indent and remove useless anchorGuillaume Gomez-1/+1
2022-01-28remove allow_fail test flagyuhaixin.hx-12/+0
2022-01-15Remove `collect`Roc Yu-3/+1
2021-12-28Update pulldown-cmark version to 0.9Guillaume Gomez-8/+9
2021-12-02Rename ID "main" into "main-content"Guillaume Gomez-1/+1
2021-11-18rustdoc: Avoid using `Iterator::count()` where possibleNoah Lev-1/+1
`count()` iterates over the whole collection. Using `len()` instead, or `.next().is_none()` when comparing to zero, should be faster.
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-35/+26
2021-10-23Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-0/+1
Scrape code examples from examples/ directory for Rustdoc Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123 Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525 Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-16clippy::complexity changesMatthias Krüger-1/+1
2021-10-06Move highlighting logic from JS to RustWill Crichton-0/+1
Continue migrating JS functionality Cleanup Fix compile error Clean up the diff Set toggle font to sans-serif
2021-10-04heading_level: u32 -> heading_offset: HeadingOffsetMukund Lakshman-13/+28
2021-10-04No need to default offset since we always override it.Mukund Lakshman-2/+2
2021-10-04Change `Markdown(...)` to `Markdown { ... }`Mukund Lakshman-12/+30
2021-10-04librustdoc: Use correct heading levels.Mukund Lakshman-8/+13
- Avoid multiple <h1>s on a page. - The <h#> tags should follow a semantic hierarchy. - Cap at h6 (no h7)
2021-09-26Preserve the whole LangSyntax when parsing doctestsJoshua Nelson-15/+8
Previously, only the raw string and the `is_ignore` field were preserved, which made it hard to recover anything else.
2021-09-10Rollup merge of #88742 - GuillaumeGomez:fix-table-in-docblocks, r=nbdd0121Manish Goregaokar-2/+41
Fix table in docblocks "Overwrite" of #88702. Instead of adding a z-index to the sidebar (which only hides the issue, doesn't fix it), I wrap `<table>` elements inside a `<div>` and limit all chidren of `.docblock` elements' width to prevent having the scrollbar on the whole doc block. ![Screenshot from 2021-09-08 15-11-24](https://user-images.githubusercontent.com/3050060/132515740-71796515-e74f-429f-ba98-2596bdbf781c.png) Thanks `@nbdd0121` for `overflow-x: auto;`. ;) r? `@notriddle`
2021-09-10Rollup merge of #88632 - camelid:md-opts, r=CraftSpiderManish Goregaokar-9/+14
Fix issues with Markdown summary options - Use `summary_opts()` for Markdown summaries - Enable all main body Markdown options for summaries
2021-09-08Wrap <table> elements into <div> to prevent breaking layout and widthGuillaume Gomez-2/+41
2021-09-08Auto merge of #87489 - bdalrhm:rustdoc-line-num, r=CraftSpiderbors-0/+6
`rustdoc`: compute correct line number for indented rust code blocks. This PR fixes a bug in `rustdoc` where it computes the wrong line number for indented rust code blocks (and subsequent blocks) it finds in markdown strings. To fix this issue, we decrement the line number if we find characters between the code block and the preceding line ending. I noticed this issue as I was trying to use `rustdoc` to extract examples from The Rust Reference and run them through the [Rust Model Checker](https://github.com/model-checking/rmc).
2021-09-03Enable all main body Markdown options for summariesNoah Lev-2/+6
This fixes odd renderings when these features are used in the first paragraph of documentation for an item. This is an extension of #87270.
2021-09-03Use `summary_opts()` for Markdown summariesNoah Lev-8/+9
It was accidentally changed to use `opts()` in #86451. I also renamed `opts()` to `main_body_opts()` to make this kind of accidental change less likely.
2021-08-29Rollup merge of #88173 - camelid:refactor-markdown-length-limit, ↵Guillaume Gomez-43/+28
r=GuillaumeGomez Refactor Markdown length-limited summary implementation This PR is a new approach to #79749. This PR refactors the implementation of `markdown_summary_with_limit()`, separating the logic of determining when the limit has been reached from the actual rendering process. The main advantage of the new approach is that it guarantees that all HTML tags are closed, whereas the previous implementation could generate tags that were never closed. It also ensures that no empty tags are generated (e.g., `<em></em>`). The new implementation consists of a general-purpose struct `HtmlWithLimit` that manages the length-limiting logic and a function `markdown_summary_with_limit()` that renders Markdown to HTML using the struct. r? `@GuillaumeGomez`
2021-08-21Use the length limit as the initial capacityNoah Lev-1/+0
The length limit turns out to be a surprisingly good heuristic for initial allocation size. See here for more details [1]. [1]: https://github.com/rust-lang/rust/pull/88173#discussion_r692531631
2021-08-19Refactor Markdown length-limited summary implementationNoah Lev-43/+29
This commit refactors the implementation of `markdown_summary_with_limit()`, separating the logic of determining when the limit has been reached from the actual rendering process. The main advantage of the new approach is that it guarantees that all HTML tags are closed, whereas the previous implementation could generate tags that were never closed. It also ensures that no empty tags are generated (e.g., `<em></em>`). The new implementation consists of a general-purpose struct `HtmlWithLimit` that manages the length-limiting logic and a function `markdown_summary_with_limit()` that renders Markdown to HTML using the struct.
2021-08-19[rustdoc] Wrap code blocks in <code> tagJakub Beránek-1/+1
2021-08-05Move extra arguments for highlight URL generation into a new ContextInfo ↵Guillaume Gomez-2/+0
struct for better readability
2021-08-05Add links on source types to go to definitionGuillaume Gomez-0/+3
2021-07-26Pass correct line number for indented code blocks.Abdalrhman Mohamed-0/+6
2021-07-26Rollup merge of #87444 - camelid:flatten-nested-format, r=jyn514Guillaume Gomez-2/+2
Flatten nested `format!` calls
2021-07-24Flatten nested `format!` callsNoah Lev-2/+2
2021-07-24Escape item search summariesNoah Lev-3/+2
I noticed that `Pin::new()`'s search summary looked off, and I realized that the reason is that it has inline code containing `Pin<P>`, which is not escaped and thus renders as a paragraph tag!
2021-07-21Don't render <table> in items' summaryGuillaume Gomez-4/+11
2021-07-15Fix misuse of rev attribute on <a> tagGuillaume Gomez-2/+1
2021-07-14Fix display for non-rust code blocksGuillaume Gomez-18/+33
2021-07-04Clean up rustdoc IDsGuillaume Gomez-4/+11
2021-06-18Resolve intra-doc links in summary descMichael Howell-4/+21
Before: ![rustdoc-intra-doc-link-summary-before](https://user-images.githubusercontent.com/1593513/122623069-9d995e80-d04f-11eb-8d46-ec2ec126bb5e.png) After: ![rustdoc-intra-doc-link-summary](https://user-images.githubusercontent.com/1593513/122623076-a4c06c80-d04f-11eb-967a-f5916871c34b.png)