@@ -218,12 +218,9 @@ pub(crate) struct RenderOptions {
218
218
///
219
219
/// Be aware: This option can come both from the CLI and from crate attributes!
220
220
pub ( crate ) playground_url : Option < String > ,
221
- /// Whether to sort modules alphabetically on a module page instead of using declaration order.
222
- /// `true` by default.
223
- //
224
- // FIXME(misdreavus): the flag name is `--sort-modules-by-appearance` but the meaning is
225
- // inverted once read.
226
- pub ( crate ) sort_modules_alphabetically : bool ,
221
+ /// What sorting mode to use for module pages.
222
+ /// `ModuleSorting::Alphabetical` by default.
223
+ pub ( crate ) module_sorting : ModuleSorting ,
227
224
/// List of themes to extend the docs with. Original argument name is included to assist in
228
225
/// displaying errors if it fails a theme check.
229
226
pub ( crate ) themes : Vec < StylePath > ,
@@ -281,6 +278,12 @@ pub(crate) struct RenderOptions {
281
278
pub ( crate ) no_emit_shared : bool ,
282
279
}
283
280
281
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
282
+ pub ( crate ) enum ModuleSorting {
283
+ DeclarationOrder ,
284
+ Alphabetical ,
285
+ }
286
+
284
287
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
285
288
pub ( crate ) enum EmitType {
286
289
Unversioned ,
@@ -650,7 +653,11 @@ impl Options {
650
653
let proc_macro_crate = crate_types. contains ( & CrateType :: ProcMacro ) ;
651
654
let playground_url = matches. opt_str ( "playground-url" ) ;
652
655
let maybe_sysroot = matches. opt_str ( "sysroot" ) . map ( PathBuf :: from) ;
653
- let sort_modules_alphabetically = !matches. opt_present ( "sort-modules-by-appearance" ) ;
656
+ let module_sorting = if matches. opt_present ( "sort-modules-by-appearance" ) {
657
+ ModuleSorting :: DeclarationOrder
658
+ } else {
659
+ ModuleSorting :: Alphabetical
660
+ } ;
654
661
let resource_suffix = matches. opt_str ( "resource-suffix" ) . unwrap_or_default ( ) ;
655
662
let enable_minification = !matches. opt_present ( "disable-minification" ) ;
656
663
let markdown_no_toc = matches. opt_present ( "markdown-no-toc" ) ;
@@ -731,7 +738,7 @@ impl Options {
731
738
external_html,
732
739
id_map,
733
740
playground_url,
734
- sort_modules_alphabetically ,
741
+ module_sorting ,
735
742
themes,
736
743
extension_css,
737
744
extern_html_root_urls,
0 commit comments