summary refs log tree commit diff
path: root/src/librustdoc/html/markdown.rs
AgeCommit message (Collapse)AuthorLines
2020-10-28rustdoc: Provide a way to set the default settings from Rust codeIan Jackson-0/+1
rustdoc has various user-configurable preferences. These are recorded in web Local Storage (where available). But we want to provide a way to configure the default default, including for when web storage is not available. getSettingValue is the function responsible for looking up these settings. Here we make it fall back some in-DOM data, which ultimately comes from RenderOptions.default_settings. Using HTML data atrtributes is fairly convenient here, dsspite the need to transform between snake and kebab case to avoid the DOM converting kebab case to camel case (!) We cache the element and dataset lookup in a global variable, to ensure that getSettingValue remains fast. The DOM representation has to be in an element which precedes the inclusion of storage.js. That means it has to be in the <head> and we should not use an empty <div> as the container (although most browsers will accept that). An empty <script> element provides a convenient and harmless container object. <meta> would be another possibility but runs a greater risk of having unwanted behaviours on weird browsers. We trust the RenderOptions not to contain unhelpful setting names, which don't fit nicely into an HTML attribute. It's awkward to quote dataset keys. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-03Add `unclosed_html_tags` lintGuillaume Gomez-1/+1
2020-09-13Use `.as_str()` instead of `CowStr::Borrowed`Joshua Nelson-2/+2
2020-09-13Don't use `link.span` yetJoshua Nelson-1/+3
This shows the span of the _whole_ link, including the brackets. But rustdoc only wants to warn about the link text.
2020-09-13Upgrade to pulldown-cmark 0.8.0Joshua Nelson-16/+18
Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs! - Get rid of unnecessary `RefCell` - Fix duplicate warnings for broken implicit reference link - Remove unnecessary copy of links
2020-09-05Rollup merge of #76078 - jyn514:no-disambiguator, r=manishearthDylan DPC-20/+97
Remove disambiguators from intra doc link text Closes https://github.com/rust-lang/rust/issues/65354. r? @Manishearth The commits are mostly atomic, but there might be some mix between them here and there. I recommend reading 'refactor ItemLink' and 'refactor RenderedLink' on their own though, lots of churn without any logic changes.
2020-09-04Misc cleanupJoshua Nelson-23/+42
- Preserve suffixes when displaying - Rename test file to match `intra-link*` - Remove unnecessary .clone()s - Improve comments and naming - Fix more bugs and add tests - Escape intra-doc link example in public documentation
2020-09-03Auto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomezbors-33/+22
rustdoc: do not use plain summary for trait impls Fixes #38386. Fixes #48332. Fixes #49430. Fixes #62741. Fixes #73474. Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy. (In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.) Ideally this could be fixed with intra-doc links ~~but it isn't working for me: I am currently investigating if it's possible to solve it this way.~~ Opened #73829. EDIT: This is now ready!
2020-09-03Remove disambiguators from link textJoshua Nelson-16/+73
Related to https://github.com/rust-lang/rust/issues/65354 - Pass through the replacement text to `markdown.rs` - Add some tests - Add a state machine that actually replaces the text when parsing Markdown
2020-09-03Refactor RenderedLink into its own typeJoshua Nelson-10/+11
2020-08-31Fix strings indentGuillaume Gomez-2/+1
2020-08-30rustdoc: do not use plain summary for trait implsAndy Russell-33/+22
Fixes #38386. Fixes #48332. Fixes #49430. Fixes #62741. Fixes #73474.
2020-08-27Rename rustdoc/test -> rustdoc/doctestAleksey Kladov-3/+3
This modules contains the implementation of doctests, and not the tests of rustdoc itself. This name is confusing, so let's rename it to doctest for clarity.
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-1/+1
2020-07-16Rollup merge of #74359 - lzutao:rustdoc-tostring, r=GuillaumeGomezManish Goregaokar-5/+5
rustdoc: Rename internal API fns to `into_string` to avoid surprising listed in API guidelines.
2020-07-15rustdoc: Rename internal API fns to `into_string`Lzu Tao-5/+5
to avoid surprising listed in API guidelines.
2020-07-14rustdoc: glue tokens before highlightingAndy Russell-2/+2
Fixes #72684. This commit also modifies the signature of `Classifier::new` to avoid copying the source being highlighted.
2020-07-07rustdoc: Rename invalid_codeblock_attribute lint to be pluralOliver Middleton-1/+1
2020-06-18Added tooltip for should_panic code examples.Jake Degen-0/+8
Previously, compile_fail and ignore code examples displayed a tooltip indicating this in the documentation. This tooltip has now also been added to should_panic examples.
2020-05-12Rollup merge of #71928 - mibac138:strikethrough, r=GuillaumeGomezDylan DPC-3/+11
Add strikethrough support to rustdoc Implements uncontroversial part of #71183. r? @GuillaumeGomez
2020-05-06Add strikethrough support to rustdocmibac138-3/+11
2020-05-05Index IDs already used by rustdoc templateGuillaume Gomez-2/+29
2020-04-23Fix librustdoc error due to `as_local_hir_id` changesmarmeladema-2/+2
2020-04-23Create new rustdoc lint to check for code blocks tagsGuillaume Gomez-4/+114
2020-04-16Dogfood or_patterns in rustdocJosh Stone-2/+2
2020-03-31more clippy fixesMatthias Krüger-64/+59
use is_empty() instead of len comparison (clippy::len_zero) use if let instead of while let loop that never loops (clippy::never_loop) remove redundant returns (clippy::needless_return) remove redundant closures (clippy::redundant_closure) use if let instead of match and wildcard pattern (clippy::single_match) don't repeat field names redundantly (clippy::redundant_field_names)
2020-03-07Use ?-operator in more places (clippy::question_mark, had some false ↵Matthias Krüger-5/+1
negatives fixed recently)
2020-03-07rustdoc: don't call into_iter() on iterator. (clippy::identity_conversion)Matthias Krüger-1/+1
2020-03-05Rollup merge of #69736 - matthiaskrgr:even_more_clippy, r=Dylan-DPCDylan DPC-6/+2
even more clippy cleanups * Don't pass &mut where immutable reference (&) is sufficient (clippy::unnecessary_mut_passed) * Use more efficient &&str to String conversion (clippy::inefficient_to_string) * Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call) * Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) * Use simple 'for i in x' loops instead of 'while let Some(i) = x.next()' loops on iterators. (clippy::while_let_on_iterator) * Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes) * Remove redundant patterns when matching ( x @ _ to x) (clippy::redundant_pattern)
2020-03-05Use simple 'for i in x' loops instead of 'while let Some(x) = x.next()' ↵Matthias Krüger-6/+2
loops on iterators. (clippy::while_let_on_iterator)
2020-03-04Use .as_deref() instead of .as_ref().map(Deref::deref) ↵Matthias Krüger-2/+2
(clippy::option_as_ref_deref)
2020-02-29use .iter() instead of .into_iter() on references.Matthias Krüger-2/+2
2020-02-27use char instead of &str for single char patternsMatthias Krüger-1/+1
2020-02-24don't explicitly compare against true or falseMatthias Krüger-2/+2
2020-02-14Update pulldown-cmark dependencyGuillaume Gomez-75/+95
2020-01-16Don't keep link title either, text is generated outside of the link tagGuillaume Gomez-2/+1
2020-01-14Prevent urls in headingsGuillaume Gomez-2/+6
2020-01-02Normalize `syntax::edition` imports.Mazdak Farrokhzad-3/+3
2019-12-22Format the worldMark Rousskov-126/+118
2019-11-08rustdoc: Stabilize `edition` annotation.Eric Huss-3/+1
2019-09-13Move Toc printing from fmt::DisplayMark Rousskov-1/+1
2019-09-10Auto merge of #60387 - Goirad:test-expansion, r=ollie27bors-11/+32
Allow cross-compiling doctests This PR allows doctest to receive a --runtool argument, as well as possibly many --runtool-arg arguments, which are then used to run cross compiled doctests. Also, functionality has been added to rustdoc to allow it to skip testing doctests on a per-target basis, in the same way that compiletest does it. For example, tagging the doctest with "ignore-sgx" disables testing on any targets that contain "sgx". A plain "ignore" still skips testing on all targets. See [here](https://github.com/rust-lang/cargo/pull/6892) for the companion PR in the cargo project that extends functionality in Cargo so that it passes the appropriate parameters to rustdoc when cross compiling and testing doctests. Part of [#6460](https://github.com/rust-lang/cargo/issues/6460)
2019-09-07rustdoc: fix diagnostic with mixed code block stylesEric Huss-1/+4
2019-09-03added rustdoc book documentation, improved behavior when unstable flag not ↵Dario Gonzalez-10/+4
present
2019-09-03added feature gate enable-per-target-ignoresDario Gonzalez-6/+11
updated and augmented tests in html/markdown.rs
2019-09-03Added ability to crosscompile doctestsDario Gonzalez-6/+28
2019-08-26Shorten line during rendering instead of in markdownMark Rousskov-19/+1
2019-08-11Drop RefCell from IdMap in markdown renderingMark Rousskov-12/+7
2019-08-11Remove fmt::Display impls on Markdown structsMark Rousskov-31/+26
These impls prevent ergonomic use of the config (e.g., forcing us to use RefCell) despite all usecases for these structs only using their Display impls once.
2019-08-11Remove thread-local for playground configMark Rousskov-93/+110