about summary refs log tree commit diff
path: root/src/librustdoc/html/markdown.rs
AgeCommit message (Collapse)AuthorLines
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)
2021-05-11Move global click handlers to per-element ones.Jacob Hoffman-Andrews-0/+1
In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplfies the code and avoids reimplementing the browser's bubbling functionality. As part of this change, change from a class to an id for help button. Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex).
2021-05-10Fix line number not being clickable on source pagesGuillaume Gomez-0/+1
2021-04-24Revert "rustdoc: Hide `#text` in doc-tests"David Hewitt-13/+6
This reverts commit af6c3201fc3d5ec2559836454ea4f43eec583fa2.
2021-04-22rustdoc: Hide `#text` in doc-testsJoshua Nelson-6/+13
Since `#![attr]` and `#[attr]` are the only valid syntax that start with `#`, we can just special case those two tokens.
2021-04-03Remove unneeded INITIAL_IDS constGuillaume Gomez-6/+9
2021-04-02Rollup merge of #83721 - GuillaumeGomez:copy-use, r=Nemo157Yuki Okushi-0/+1
Add a button to copy the "use statement" Fixes https://github.com/rust-lang/rust/issues/50239 When clicking on the button, it'll add the elements prepended by "use " and will end with a ";". So in the images below, I now have in my clipboard `use std::fs::OpenOptions;`. A screenshot of the newly added button: ![Screenshot from 2021-03-31 22-12-12](https://user-images.githubusercontent.com/3050060/113205430-90e64500-926e-11eb-8538-529829f611ec.png) A screenshot after it was clicked: ![Screenshot from 2021-03-31 22-15-31](https://user-images.githubusercontent.com/3050060/113205532-ad827d00-926e-11eb-893d-35f2f8f92696.png) r? `@Nemo157`
2021-03-31Add a button to copy the "use statement"Guillaume Gomez-0/+1
2021-03-28Point to disambiguator instead of whole linkCamelid-0/+1
And, now that we do that, we can remove the explanatory note since the error span should make it clear what the disambiguator is.
2021-03-21rustdoc: Replace pair of `Option`s with an enumCamelid-8/+11
They are never both `None` or both `Some`, so it makes more sense to use an enum so that we "make impossible states impossible".
2021-03-09Treat header as first paragraph for shortened markdown descriptionsMichael Howell-0/+1
"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.
2021-03-05Don't unnecessarily clone some fields in `Context`Camelid-4/+0
There was no need to clone `id_map` because it was reset before each item was rendered. `deref_id_map` was not reset, but it was keyed by `DefId` and thus was unlikely to have collisions (at least for now). Now we just clone the fields that need to be cloned, and instead create fresh versions of the others.
2021-03-01Move lint machinery into a separate fileJoshua Nelson-1/+1
2021-03-01Rename rustdoc lints to be a tool lint instead of built-in.Joshua Nelson-2/+1
- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests Otherwise, all `rustdoc::` lints would be ignored. - Register all existing lints as removed This unfortunately doesn't work with `register_renamed` because tool lints have not yet been registered when rustc is running. For similar reasons, `check_backwards_compat` doesn't work either. Call `register_removed` directly instead. - Fix fallout + Rustdoc lints for compiler/ + Rustdoc lints for library/ Note that this does *not* suggest `rustdoc::broken_intra_doc_links` for `rustdoc::intra_doc_link_resolution_failure`, since there was no time when the latter was valid.