{"record":{"id":"5b695d2fc51ec85c","repo":"astral-sh/ruff","slug":"expected-doc-attribute","errorCode":null,"errorMessage":"Expected doc attribute.","messagePattern":"Expected doc attribute\\.","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/config.rs","lineNumber":151,"sourceCode":"                \"Expected `Option<_>`  as type.\",\n            )),\n        },\n        _ => Err(syn::Error::new(ident.span(), \"Expected type.\")),\n    }\n}\n\n/// Parse a `doc` attribute into it a string literal.\nfn parse_doc(doc: &Attribute) -> syn::Result<String> {\n    match &doc.meta {\n        syn::Meta::NameValue(syn::MetaNameValue {\n            value:\n                syn::Expr::Lit(ExprLit {\n                    lit: Lit::Str(lit_str),\n                    ..\n                }),\n            ..\n        }) => Ok(lit_str.value()),\n        _ => Err(syn::Error::new(doc.span(), \"Expected doc attribute.\")),\n    }\n}\n\n/// Parse an `#[option(doc=\"...\", default=\"...\", value_type=\"...\",\n/// example=\"...\")]` attribute and return data in the form of an `OptionField`.\nfn handle_option(field: &Field, attr: &Attribute) -> syn::Result<proc_macro2::TokenStream> {\n    let docs: Vec<&Attribute> = field\n        .attrs\n        .iter()\n        .filter(|attr| attr.path().is_ident(\"doc\"))\n        .collect();\n\n    if docs.is_empty() {\n        return Err(syn::Error::new(\n            field.span(),\n            \"Missing documentation for field\",\n        ));\n    }","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/config.rs#L133-L169","documentation":"A syn compile error from parse_doc in the ConfigurationOptions derive: an attribute expected to be a doc comment is not a name-value string literal (e.g. it is a list-shaped or non-string attribute). Doc text is extracted only from #[doc = \"...\"] forms.","triggerScenarios":"Thrown at crates/ruff_macros/src/config.rs:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use standard /// doc comments on the field","Remove malformed doc attributes that are not string literals"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}