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

the example code is repeated #44

Open
faassen opened this issue Jan 28, 2025 · 1 comment
Open

the example code is repeated #44

faassen opened this issue Jan 28, 2025 · 1 comment

Comments

@faassen
Copy link
Collaborator

faassen commented Jan 28, 2025

The basic example code is currently repeated in three places:

  • README.md
  • examples/example.rs
  • src/lib.rs (in the docstring)

Moreover the src/lib.rs docstring repeats a lot of material in the README.md.

This is rather annoying to maintain. Are there some clever tricks possible so we can reuse the code?

Moreover, the README.md code is never type-checked (the rest is), and the example code is never actually executed.

@ajalab
Copy link
Owner

ajalab commented Jan 29, 2025

Regarding the type-check and tests on README.md, it looks rustdoc offers a feature to run tests based on the code in README.md.

This will include your README as documentation on the hidden struct ReadmeDoctests, which will then be tested alongside the rest of your doctests.
https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#include-items-only-when-collecting-doctests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants