@@ -129,6 +129,9 @@ pub struct SharedContext {
129129 /// The directories that have already been created in this doc run. Used to reduce the number
130130 /// of spurious `create_dir_all` calls.
131131 pub created_dirs : RefCell < FxHashSet < PathBuf > > ,
132+ /// This flag indicates whether listings of modules (in the side bar and documentation itself)
133+ /// should be ordered alphabetically or in order of appearance (in the source code).
134+ pub sort_modules_alphabetically : bool ,
132135}
133136
134137impl SharedContext {
@@ -491,7 +494,8 @@ pub fn run(mut krate: clean::Crate,
491494 passes : FxHashSet < String > ,
492495 css_file_extension : Option < PathBuf > ,
493496 renderinfo : RenderInfo ,
494- render_type : RenderType ) -> Result < ( ) , Error > {
497+ render_type : RenderType ,
498+ sort_modules_alphabetically : bool ) -> Result < ( ) , Error > {
495499 let src_root = match krate. src {
496500 FileName :: Real ( ref p) => match p. parent ( ) {
497501 Some ( p) => p. to_path_buf ( ) ,
@@ -514,6 +518,7 @@ pub fn run(mut krate: clean::Crate,
514518 css_file_extension : css_file_extension. clone ( ) ,
515519 markdown_warnings : RefCell :: new ( vec ! [ ] ) ,
516520 created_dirs : RefCell :: new ( FxHashSet ( ) ) ,
521+ sort_modules_alphabetically,
517522 } ;
518523
519524 // If user passed in `--playground-url` arg, we fill in crate name here
@@ -1654,8 +1659,10 @@ impl Context {
16541659 . push ( ( myname, Some ( plain_summary_line ( item. doc_value ( ) ) ) ) ) ;
16551660 }
16561661
1657- for ( _, items) in & mut map {
1658- items. sort ( ) ;
1662+ if self . shared . sort_modules_alphabetically {
1663+ for ( _, items) in & mut map {
1664+ items. sort ( ) ;
1665+ }
16591666 }
16601667 map
16611668 }
@@ -2013,7 +2020,9 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
20132020 name_key ( lhs) . cmp ( & name_key ( rhs) )
20142021 }
20152022
2016- indices. sort_by ( |& i1, & i2| cmp ( & items[ i1] , & items[ i2] , i1, i2) ) ;
2023+ if cx. shared . sort_modules_alphabetically {
2024+ indices. sort_by ( |& i1, & i2| cmp ( & items[ i1] , & items[ i2] , i1, i2) ) ;
2025+ }
20172026 // This call is to remove reexport duplicates in cases such as:
20182027 //
20192028 // ```
0 commit comments