Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc-json: Path::name docs say it only has the item name, but it has the full name. #134853

Closed
aDotInTheVoid opened this issue Dec 28, 2024 · 2 comments · Fixed by #134880
Closed
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Dec 28, 2024

With this code:

pub mod foo {
    pub struct Bar;
}

pub fn get_bar() -> foo::Bar {
    foo::Bar
}

Running rustdoc +nightly ./demo.rs -wjson -Zunstable-options gives:

    {
      "inner": {
        "function": {
          "sig": {
            "inputs": [],
            "is_c_variadic": false,
            "output": {
              "resolved_path": {
                "args": {"angle_bracketed": {"args": [], "constraints": []}},
                "id": 0,
                "name": "foo::Bar"
              }
            }
          }
        }
      },
      "name": "get_bar",
    }

Where we have "name": "foo::Bar"

However the docs for Path::name say:

The name of the type as declared, e.g. in

mod foo {
    struct Bar;
}

for foo::Bar, this field will be Bar.

Either we need to change the docs, or the how the field is generated. I'm not certain which is better.

version: rustdoc 1.85.0-nightly (dd84b7d 2024-12-27)

Originally reported by @AS1100K as rust-lang/rustdoc-types#45

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 28, 2024
@aDotInTheVoid aDotInTheVoid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-json Area: Rustdoc JSON backend and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 28, 2024
@fmease fmease added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Dec 28, 2024
@AS1100K
Copy link
Contributor

AS1100K commented Dec 28, 2024

I prefer using just the name Bar instead of the full path foo::Bar. The id can be used to retrieve additional information when needed and just having name there is better in my opinion.

@AS1100K
Copy link
Contributor

AS1100K commented Dec 29, 2024

@rustbot claim

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 14, 2025
…h-name, r=aDotInTheVoid

Made `Path::name` only have item name rather than full name

Closes rust-lang#134853

This PR makes `Path::name` to only have item name rather than full name, i.e. with the following code

```rust
pub mod foo {
    pub struct Bar;
}

pub fn get_bar() -> foo::Bar {
    foo::Bar
}
```
and running `./rustdoc ./demo.rs -wjson -Zunstable-options` gives:
```json
{
    "41": {
        "id": 41,
        "name": "get_bar",
        "inner": {
            "function": {
                "sig": {
                    "inputs": [],
                    "output": {
                        "resolved_path": {
                            "name": "Bar",
                            "id": 0,
                            "args": { "angle_bracketed": { "args": [], "constraints": [] }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
_Information which isn't useful here was trimmed_

r? aDotInTheVoid
@bors bors closed this as completed in ca9a9d2 Jan 14, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 14, 2025
Rollup merge of rust-lang#134880 - as1100k-forks:fix-rustdoc-json-path-name, r=aDotInTheVoid

Made `Path::name` only have item name rather than full name

Closes rust-lang#134853

This PR makes `Path::name` to only have item name rather than full name, i.e. with the following code

```rust
pub mod foo {
    pub struct Bar;
}

pub fn get_bar() -> foo::Bar {
    foo::Bar
}
```
and running `./rustdoc ./demo.rs -wjson -Zunstable-options` gives:
```json
{
    "41": {
        "id": 41,
        "name": "get_bar",
        "inner": {
            "function": {
                "sig": {
                    "inputs": [],
                    "output": {
                        "resolved_path": {
                            "name": "Bar",
                            "id": 0,
                            "args": { "angle_bracketed": { "args": [], "constraints": [] }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
_Information which isn't useful here was trimmed_

r? aDotInTheVoid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants