Is it possible to control the order of methods that appears in a crate's docs?

#1

I have this (simplified):

// plan/mod.rs
impl Plan {
    pub fn default()
    pub fn is_empty()
}
// plan/parse.rs
impl Plan {
    pub fn new_from_rt()
    pub fn_new_from_rt_filtered()
}
// plan/process.rs
impl Plan {
    pub fn apply()
    pub fn retest()
}
// plan/builder.rs
impl Plan {
    pub fn push()
    pub fn build()
}

When I build the docs with cargo doc --release --no-deps the order in which these methods appear is:

  • push()
  • build()
  • new_from_rt()
  • new_from_rt_filtered()
  • apply()
  • retest()
  • default()
  • is_empty()

I would like the order to be:

  • new_from_rt()
  • new_from_rt_filtered()
  • default()
  • push()
  • build()
  • apply()
  • retest()
  • is_empty()

Is it possible to do this? If not, I guess I’ll just put some text at the start of the plan module.

#2

It’s in the order that the impl's are encountered, I assume plan/mod.rs has

mod builder;
mod parse;
mod process;

impl Plan { ... }

to get what you want you would have to rearrange those modules and where the different functions are defined so that they are encountered in the correct order (in this case it looks like you can’t keep your current separate impl blocks and have the order you want, one workaround would be to have free-functions in the sub-modules and have stub methods in the main module in the correct order that calls those functions).

#3

I’ve now got it pretty well as I want and understand now. Thanks!