### ROOT CAUSE
The `#[doc(html_root_url = "...")]` attribute is currently stored in `Attribute::Other` in the rustdoc JSON backend. This is not ideal because `Attribute::Other` is intended for attributes that are not predefined and have a simple string representation. The `html_root_url` attribute, however, has a specific meaning and requires proper handling when generating links. By keeping it in `Attribute::Other`, we lose the ability to specifically process it in the JSON output and downstream tools.
### CODE FIX
1. In the rustdoc JSON backend, modify the `Attribute` enum to include a new variant `DocHtmlRootUrl` (or `HtmlRootUrl`) that holds the URL string.
2. Update the attribute parsing code to recognize the `#[doc(html_root_url = "...")]` attribute and convert it to the new variant.
3. Update the JSON emission code to output the new variant appropriately.
Here is an example of the code changes:
```rust
// In the rustdoc_json crate, modify the Attribute enum:
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSpec)]
#[json_schema::schemas(schema = "rustdoc")]
pub enum Attribute {
// ... other variants ...
DocHtmlRootUrl(String),
Other(String),
}
// Then, in the attribute parsing code (e.g., in the function that processes attributes):
fn process_attribute(attr: &Attribute) -> Result
{
match attr {
// ... other cases ...
Attr::HtmlRootUrl(url) => {
Ok(Attribute::DocHtmlRootUrl(url.clone()))
}
_ => {
Ok(Attribute::Other(attr.to_string()))
}
}
}
// Finally, update the JSON emission code to handle the new variant:
fn emit_attribute(attr: &Attribute) -> String {
match attr {
// ... other cases ...
Attribute::DocHtmlRootUrl(url) => {
format!("\"html_root_url\": \"{}\"", url)
}
Attribute::Other(s) => {
format!("\"other_attribute\": \"{}\"", s)
}
}
}
```
This change ensures that the `html_root_url` attribute is properly typed and can be easily identified and processed by downstream tools.
Related Fixes
[StackOverflow/python] Is it possible to bypass Cloudflare Turnstile from a datacenter IP using Selenium or curl_cffi in 2026? Local works, Docker/Hosted always fails
[StackOverflow/go] calling go net.InterfaceAddrs() fails on Android SDK 30+
[pytorch/pytorch] something regressed torchbench graph breaks