Verified Solution[rust-lang/rust] rustdoc-json: Move `#[doc` attribute out of `Attribute::Other` to own well-typed variant
Sponsored Content
### ROOT CAUSE
The `#[doc]` attribute is currently stored in `Attribute::Other` as a string, which is not ideal because it does not have its own variant and might be treated as a regular attribute. This can lead to loss of information or difficulty in processing, especially since `#[doc]` is a special attribute for documentation.
### CODE FIX
Change the `Attribute` enum in the rustdoc_json crate to include a `Doc` variant that holds the entire string of the `#[doc]` attribute. Then, change the attribute parsing function to use the `Doc` variant for attributes with name `doc`. This ensures that the `#[doc]` attribute is properly typed and handled separately.
Specifically, change the `Attribute` enum from:
```rust
pub enum Attribute {
Other(String),
// ... other variants ...
}
```
to:
```rust
pub enum Attribute {
Doc(String),
Other(String),
// ... other variants ...
}
```
Then, change the function that parses attributes (e.g., `parse_attribute`) to:
```rust
pub fn parse_attribute(attr: &Attribute_) -> Attribute {
if attr.name == "doc" {
Attribute::Doc(attr.to_string())
} else {
// ... existing code for other attributes ...
}
}
```
Also, update any code that uses the `Attribute` enum to handle the new `Doc` variant appropriately.
Deploy on DigitalOcean ($200 Credit)
Related Fixes
[golang/go] x/build/cmd/relui: automate process of upstreaming private-track security CLs on release day (for the main branch)
[golang/go] access: may-start-trybots for George Adams
[StackOverflow/kubernetes] spark-submit encounter PKIX path building failed