mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Rust: generate test code from schema docstrings
This generates test source files from code blocks in class docstrings.
By default the test code is generated as is, but it can optionally:
* be wrapped in a function providing an adequate context using
`@rust.doc_test_function(name, *, lifetimes=(), return_type="()", **kwargs)`,
with `kwargs` providing both generic and normal params depending on
capitalization
* be skipped altogether using `@rust.skip_doc_test`
So for example an annotation like
```python
@rust.doc_test_function("foo",
lifetimes=("a",),
T="Eq",
x="&'a T",
y="&'a T",
return_type="&'a T")
```
will result in the following wrapper:
```rust
fn foo<'a, T: Eq>(x: &'a T, y: &'a T) -> &'a T {
// example code here
}
```
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from . import dbschemegen, qlgen, trapgen, cppgen, rustgen
|
||||
from . import dbschemegen, trapgen, cppgen, rustgen, rusttestgen, qlgen
|
||||
|
||||
|
||||
def generate(target, opts, renderer):
|
||||
|
||||
Reference in New Issue
Block a user