Repository navigation
Add mechanism to verify that source code in documentation is valid #7951
Copy link
Copy link
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
Activity
- changed the title
[-]Make sure that all code samples in the documentation are tested automatically[/-][+]Add mechanism to verify that source code in documentation is valid[/+]on Oct 28, 2023 I believe this is now handled via the
doctestmacro, for example:datafusion/datafusion/core/src/lib.rs
Lines 618 to 643 in 37e54ee
// Instructions for Documentation Examples // // The following commands test the examples from the user guide as part of // `cargo test --doc` // // # Adding new tests: // // Simply add code like this to your .md file and ensure your md file is // included in the lists below. // // ```rust // <code here will be tested> // ``` // // Note that sometimes it helps to author the doctest as a standalone program // first, and then copy it into the user guide. // // # Debugging Test Failures // // Unfortunately, the line numbers reported by doctest do not correspond to the // line numbers of in the .md files. Thus, if a doctest fails, use the name of // the test to find the relevant file in the list below, and then find the // example in that file to fix. // // For example, if `user_guide_expressions(line 123)` fails, // go to `docs/source/user-guide/expressions.md` to find the relevant problem. - addeddocumentationImprovements or additions to documentationImprovements or additions to documentation
on Aug 20, 2024
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Is your feature request related to a problem or challenge?
Our user guide and library guide contain code samples, but these can quickly become outdated and stop compiling and we have to automated way to check if they still compile.
Describe the solution you'd like
I propose that code samples be written as unit tests and that we then use a script to insert these code samples into the documentation when we publish the docs.
Describe alternatives you've considered
No response
Additional context
No response