mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
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
}
```
7 lines
187 B
Python
7 lines
187 B
Python
from . import dbschemegen, trapgen, cppgen, rustgen, rusttestgen, qlgen
|
|
|
|
|
|
def generate(target, opts, renderer):
|
|
module = globals()[f"{target}gen"]
|
|
module.generate(opts, renderer)
|