tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.19k stars 677 forks source link

docs: enable and clean up ignored doc tests #2893

Closed mladedav closed 2 months ago

mladedav commented 5 months ago

Motivation

Some tests were ignored with a TODO to enable them.

The doc-test for Subscriber::record provides misleading code that does not compile.

Solution

I enabled the tests that can be enabled.

I fixed the usage of omitted fields in Subscriber::record docs, but since the example uses a macro from tracing, it cannot be enabled.

kaffarell commented 4 months ago

I think we can also add a few other ones (these all seem to work for me):

hawkw commented 4 months ago

Hi @mladedav , thanks for the fix! Would you mind checking whether these tests are also ignored on themaster branch, and if so, changing this PR to be based on the master branch? We prefer to merge changes that apply to both the v0.1.x and master branches to master, and then backport them to v0.1.x. This helps ensure that bugs fixed in the release version are also fixed in v0.2. Thank you!

If this only applies to v0.1.x, then I'll be happy to merge it as-is.

mladedav commented 4 months ago

@hawkw sure, I opened #2896 for master. I wasn't sure and guessed (wrong) that this branch is the one to do this since this would be most likely the the one from which docs are generated.

There are just two conflicts, one example in subscriber seems to have been simplified and enabled so it didn't need the changes here and a some code seems to have disappeared from the datetime formatting but I didn't dig deeper. Feel free to reuse this or cherry pick the one on master and close this.

Thanks @kaffarell for the check, I greped just for ```rust,ignore, I forgot the rust part is optional. Now this hopefully covers everything.

mladedav commented 2 months ago

Superseded by #2896