You can add your own tags in the doctests, and with our patch waiting to use the new rustdoc doctests extraction, it should be pretty easy to plug such a feature into it. We can check it together if you want when the patch is merged to see if we already have everything needed or if I need to add more things on rustdoc side.
Le mar. 4 nov. 2025 à 20:06, Miguel Ojeda <[email protected]> a écrit : > > On Tue, Nov 4, 2025 at 7:35 PM Miguel Ojeda > <[email protected]> wrote: > > > > Orthogonally, the script that generates the doctests could perhaps > > help to automate some of that. For instance, we could have a way to > > specify an "environment" for a given Rust file or Rust `mod` or > > similar, and then every doctests would have the code prefixed to them. > > I guess this could probably best generalized as "tagging" doctests > with custom tags that `rustdoc` just forwards in the generated JSON. > > Something like: > > /// ```tag:foo,tag:bar > > would give us a: > > "tags": ["foo", "bar"] > > in the JSON. Then a custom generator like the one we have could do > whatever it needs with it, including prepending code or other things. > > Now, I see there is already an `unknown` field in the attributes which > already give us the unrecognized ones, which is great and we could > potentially use that. > > However, should there be a particular way/namespace we should create > our custom tags so that we don't conflict in the future with `rustdoc` > ones? > > I have added it to the usual list: > > https://github.com/Rust-for-Linux/linux/issues/350 > > (There is also the question about supporting the old non-JSON way for > things like this, but I am ignoring that for now) > > Cheers, > Miguel
