Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve doctest situation #58

Open
Tehforsch opened this issue Jan 8, 2024 · 2 comments
Open

Improve doctest situation #58

Tehforsch opened this issue Jan 8, 2024 · 2 comments
Labels
code-quality documentation Improvements or additions to documentation

Comments

@Tehforsch
Copy link
Owner

Tehforsch commented Jan 8, 2024

At the moment, the doctests are a bit annoying to maintain and easy to forget about for a few reasons:

  1. Every doctest needs the unstable feature gates as a setup, which is annoying to type.
  2. Due to a namespacing issue that I don't fully understand, I have to wrap any doctest using the unit_system macro in an internal module.
  3. These things conflict with loading the lib.rs doctests directly from the readme (because the lines starting with # won't show when looking up the doctest, but they will show up in the readme).
  4. There are a few features hidden behind feature gates which I currently don't deal with at all and simply ignore those doctests.

For these reasons, many of the doctests are currently set to ignore although they run fine (and I check every now and then by adding their setup code again).

For 1-3 to I am not sure how to deal with this aside from adding a bit of machinery to generate these tests (and possibly generate a readme as well). Unfortunately adding some kind of prelude that can be included easily does not work for 1/2, since feature gates need to be declared on top of the doctest and the module also needs to be defined around the entire doctest.

I think 4 is dealt with by https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which seems easy enough to use.

@Tehforsch Tehforsch added documentation Improvements or additions to documentation code-quality labels Jan 8, 2024
@jedbrown
Copy link
Contributor

jedbrown commented Jan 8, 2024

Have you considered scraping examples for the inline documentation?

https://doc.rust-lang.org/rustdoc/scraped-examples.html

@Tehforsch
Copy link
Owner Author

Have you considered scraping examples for the inline documentation?

Oh, nice - I didn't know about this feature. I don't think it will help with unit_system, since it doesnt seem to scrape usage of proc macros, but this could be very useful for documenting some of the methods on quantity, because we could have many examples in one file and it shows only the small part of the example that applies to the function, so none of the ugly unstable features are shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants