about summary refs log tree commit diff
path: root/src/librustdoc/doctest/make.rs
AgeCommit message (Collapse)AuthorLines
2025-06-19Extract Translator structCameron Steffen-6/+3
2025-06-10Improve naming of variables in `DocTestBuilder::generate_unique_doctest`Guillaume Gomez-3/+14
Improve code
2025-06-10Give more information into extracted doctest informationGuillaume Gomez-39/+98
2025-05-22Collect and use `#![doc(test(attr(..)))]` at module level tooUrgau-3/+18
2025-05-02Create a builder for DocTestBuilder typeGuillaume Gomez-31/+93
2025-05-02Emit a warning if the doctest `main` function will not be runGuillaume Gomez-6/+22
2025-05-01rustdoc: Fix doctest heuristic for main fn wrappingLeón Orell Valerian Liehr-37/+28
2025-04-27Fix bad handling of macros if there is already a `main` functionGuillaume Gomez-1/+4
2025-04-25If there is a `;` alone, we consider that the doctest needs to be put inside ↵Guillaume Gomez-2/+0
a function
2025-04-25Improve codeGuillaume Gomez-4/+7
2025-04-23Fix detection of `main` function if there are expressions around itGuillaume Gomez-4/+17
2025-04-17Replace infallible `name_or_empty` methods with fallible `name` methods.Nicholas Nethercote-9/+5
I'm removing empty identifiers everywhere, because in practice they always mean "no identifier" rather than "empty identifier". (An empty identifier is impossible.) It's better to use `Option` to mean "no identifier" because you then can't forget about the "no identifier" possibility. Some specifics: - When testing an attribute for a single name, the commit uses the `has_name` method. - When testing an attribute for multiple names, the commit uses the new `has_any_name` method. - When using `match` on an attribute, the match arms now have `Some` on them. In the tests, we now avoid printing empty identifiers by not printing the identifier in the `error:` line at all, instead letting the carets point out the problem.
2025-04-01Move `ast::Item::ident` into `ast::ItemKind`.Nicholas Nethercote-4/+4
`ast::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, `Trait`, `TraitAlias`, `MacroDef`, `Delegation`. - It's always empty for these item kinds: `Use`, `ForeignMod`, `GlobalAsm`, `Impl`, `MacCall`, `DelegationMac`. There is a similar story for `AssocItemKind` and `ForeignItemKind`. Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - `ast::Item` got 8 bytes bigger. This could be avoided by boxing the fields within some of the `ast::ItemKind` variants (specifically: `Struct`, `Union`, `Enum`). I might do that in a follow-up; this commit is big enough already. - For the visitors: `FnKind` no longer needs an `ident` field because the `Fn` within how has one. - In the parser, the `ItemInfo` typedef is no longer needed. It was used in various places to return an `Ident` alongside an `ItemKind`, but now the `Ident` (if present) is within the `ItemKind`. - In a few places I renamed identifier variables called `name` (or `foo_name`) as `ident` (or `foo_ident`), to better match the type, and because `name` is normally used for `Symbol`s. It's confusing to see something like `foo_name.name`.
2025-03-27Only take outer attributes into account when generating content between ↵Guillaume Gomez-3/+5
first non-crate items and the crate items
2025-03-27Remove recursion in `check_item`Guillaume Gomez-16/+4
2025-03-27Improve codeGuillaume Gomez-34/+29
2025-03-27Add `expect` to the list of non-crate attributes for doctest generationGuillaume Gomez-1/+1
2025-03-27Improve code commentGuillaume Gomez-2/+2
2025-03-27Improve comment and test for generated doctest with code commentsGuillaume Gomez-2/+3
2025-03-27Correctly handle line comments in attributes and generate extern cratesGuillaume Gomez-15/+35
outside of wrapping function
2025-03-27Correctly handle `fn main` in macroGuillaume Gomez-13/+30
2025-03-27Greatly simplify doctest parsing and information extractionGuillaume Gomez-323/+136
2025-02-28Fully qualify `Result` in generated doctest codeGuillaume Gomez-1/+1
2025-02-17librustdoc: more usages of `Joined::joined`Yotam Ofek-6/+10
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-3/+3
2024-12-25Improve rustdoc codeGuillaume Gomez-1/+1
2024-12-16Remove unneeded handling of backlines in doctest attributesGuillaume Gomez-2/+0
2024-12-16Also handle cases where attributes are unclosedGuillaume Gomez-16/+40
2024-12-13Correctly handle comments in attributes in doctests source codeGuillaume Gomez-0/+2
2024-10-24Do not consider nested functions as `main` function even if named `main` in ↵Guillaume Gomez-4/+11
doctests
2024-09-28Rename `standalone` doctest attribute into `standalone-crate`Guillaume Gomez-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-08-31Rollup merge of #129774 - nnethercote:rm-extern-crate-tracing-remainder, ↵Matthias Krüger-0/+1
r=GuillaumeGomez Remove `#[macro_use] extern crate tracing` from rustdoc and rustfmt A follow-up to #129767 and earlier PRs doing this for `rustc_*` crates. r? ```@GuillaumeGomez```
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-08-29Fix clippy lintsGuillaume Gomez-1/+1
2024-08-13Run fmtGuillaume Gomez-2/+1
2024-08-13Improve code readabilityGuillaume Gomez-0/+8
2024-08-13If there are crate attributes, we prevent doctest to be merged with othersGuillaume Gomez-27/+4
2024-08-13Rename `DocTest` into `DocTestBuilder`Guillaume Gomez-2/+2
2024-08-13Add documentation on `DocTest` and `RunnableDoctest` structsGuillaume Gomez-0/+2
2024-08-13Correctly handle macros using `$crate` in merged doctestsGuillaume Gomez-3/+14
2024-08-13Correctly handle `internal_features` attributeGuillaume Gomez-1/+13
2024-08-13Don't merge doctests with `#[global_allocator]`Guillaume Gomez-69/+62
2024-08-13Greatly improve handling of doctests attributes, making it possible to merge ↵Guillaume Gomez-43/+105
doctests more efficiently
2024-08-13Simplify `has_main_fn` to be a boolean instead of a `Option<Span>`Guillaume Gomez-28/+30
2024-08-13Correctly handle doctests with invalid ASTGuillaume Gomez-3/+16
2024-08-13If there is any AST error with a doctest, we make it a standalone testGuillaume Gomez-88/+182
To do so, AST error detection was improved in order to not filter out too many doctests.
2024-08-13Split standalone and mergeable doctestsGuillaume Gomez-6/+13
2024-08-13Split doctests between standalone and mergeable onesGuillaume Gomez-4/+2
2024-08-13Add `DocTest` typeGuillaume Gomez-128/+165