Skip to content

Generate documentation for type aliases/definitions #113727

New issue

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

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

Already on GitHub? # to your account

Closed
bobogei81123 opened this issue Jul 15, 2023 · 5 comments
Closed

Generate documentation for type aliases/definitions #113727

bobogei81123 opened this issue Jul 15, 2023 · 5 comments
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@bobogei81123
Copy link

bobogei81123 commented Jul 15, 2023

I'm facing similar problem to this stack overflow question.

Specifically, I made a wrapper class that wraps around an FFI object and creates common functionality like from_ffi, etc.

pub struct FfiWrapper<T>(T);

impl<T> FfiWrapper<T> {
  fn from_ffi(t: T) -> Self { ... }
}

Then, I implemented different methods based on the FFI type:

/// Some docs for type A
type A = FfiWrapper<FfiA>

impl A {
  /// Some docs for method_a
  fn method_a(self) ...
}

Yet, rust doc generate item and doc for type A = FfiWrapper<FfiA>, but not for fn method_a. How can I let the items in the specific implementation show up in docs?

@syphar
Copy link
Member

syphar commented Jul 15, 2023

Hi,
this repo is about docs.rs, which is just a builder & hoster for the documentation generated by rustdoc.

I assume this can be either directly answered by folks more versed with rustdoc, or has to be moved to the rust-lang/rust repo where rustdoc issues are kept.

cc @Nemo157 @GuillaumeGomez ?

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 15, 2023
@Nemo157 Nemo157 transferred this issue from rust-lang/docs.rs Jul 15, 2023
@Nemo157 Nemo157 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 15, 2023
@GuillaumeGomez
Copy link
Member

You need to make method_a public.

@bobogei81123
Copy link
Author

bobogei81123 commented Jul 15, 2023

Hey, sorry for reporting to the wrong place.

I found out that what happened is that the wrapper is private but the type alias is public:
For example:

mod wrapper {
    #[repr(transparent)]
    pub struct Wrapper<T>(T);

    impl<T> Wrapper<T> {
        /// Common method
        pub fn common() {}
    }
}

pub mod a {
    use crate::wrapper::Wrapper;

    pub struct A;
    pub type WA = Wrapper<A>;

    impl WA {
        /// Type specific method
        pub fn method_a() {}
    }
}

The code compiles without any error and warning (See rust playground). Yet, if you run rust doc then no doc will be generated for Wrapper::common and WA::method_a.

@GuillaumeGomez
Copy link
Member

For the missing impl on the type alias, I made #112429 but we needed to revert it because it introduced some bugs. We'll need to wait for the trait system rewrite to be done before I can put back the fix again.

@GuillaumeGomez GuillaumeGomez added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 19, 2023
@fmease
Copy link
Member

fmease commented Sep 23, 2023

Fixed by #115201, right?

@fmease fmease closed this as completed Sep 23, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants