dylint

missing_doc_comment_openai

⚠️ DO NOT RUN THIS LINT ON PRIVATE SOURCE CODE ⚠️

What it does

Checks for functions missing doc comments.

Why is this bad?

Understanding what a function does is easier given a description of the function rather than just its code.

Known problems

The lint is currently enabled only for functions.

Example

pub fn foo() {}

Use instead:

/// A doc comment generated by OpenAI.
pub fn foo() {}

OpenAI

If the environment variable OPENAI_API_KEY is set to an OpenAI API key, the lint will suggest a doc comment generated by OpenAI. The prompt sent to OpenAI has the following form:

```rust
<function declaration>
```
An elaborate, high quality rustdoc comment for the above function:
```rust

The prompt’s stop parameter is set to ["\n``”]`. Thus, OpenAI should stop generating tokens once the second code block is complete. The suggested doc comment is the one that appears in that code block, if any.

The phrase “An elaborate…” is configurable (see below).

Configuration

Certain OpenAI parameters can be configured by setting them in the missing_doc_comment_openai table of the linted workspace’s dylint.toml file. Example:

[missing_doc_comment_openai]
prompt = "A rustdoc comment for the above function with a \"Motivation\" section:"
temperature = 1.0

The following parameters are supported: