From 4211292ffe80dd4737db2450d72df404a9d55051 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 2 Jul 2024 11:14:56 +0100 Subject: [PATCH] Group code object files into the same directory (#1114) It's hard to distinguish code object classes by their file names alone. And given that we have 18 such classes, it'd make the codebase a lot easier to understand if we grouped them into a single directory. Given that these classes are all autoloaded in `lib/rdoc.rb` instead of required individually, this change should have minimum impact on projects using RDoc as they generally just require `rdoc`, not individual files. An example is Rails' `sdoc`: https://github.com/rails/sdoc/blob/main/lib/sdoc/rdoc_monkey_patches.rb --- lib/rdoc.rb | 42 +++++++++---------- lib/rdoc/{ => code_object}/alias.rb | 0 lib/rdoc/{ => code_object}/anon_class.rb | 0 lib/rdoc/{ => code_object}/any_method.rb | 0 lib/rdoc/{ => code_object}/attr.rb | 0 lib/rdoc/{ => code_object}/class_module.rb | 0 lib/rdoc/{ => code_object}/constant.rb | 0 lib/rdoc/{ => code_object}/context.rb | 0 lib/rdoc/{ => code_object}/context/section.rb | 0 lib/rdoc/{ => code_object}/extend.rb | 0 lib/rdoc/{ => code_object}/ghost_method.rb | 0 lib/rdoc/{ => code_object}/include.rb | 0 lib/rdoc/{ => code_object}/meta_method.rb | 0 lib/rdoc/{ => code_object}/method_attr.rb | 0 lib/rdoc/{ => code_object}/mixin.rb | 0 lib/rdoc/{ => code_object}/normal_class.rb | 0 lib/rdoc/{ => code_object}/normal_module.rb | 0 lib/rdoc/{ => code_object}/require.rb | 0 lib/rdoc/{ => code_object}/single_class.rb | 0 lib/rdoc/{ => code_object}/top_level.rb | 0 20 files changed, 21 insertions(+), 21 deletions(-) rename lib/rdoc/{ => code_object}/alias.rb (100%) rename lib/rdoc/{ => code_object}/anon_class.rb (100%) rename lib/rdoc/{ => code_object}/any_method.rb (100%) rename lib/rdoc/{ => code_object}/attr.rb (100%) rename lib/rdoc/{ => code_object}/class_module.rb (100%) rename lib/rdoc/{ => code_object}/constant.rb (100%) rename lib/rdoc/{ => code_object}/context.rb (100%) rename lib/rdoc/{ => code_object}/context/section.rb (100%) rename lib/rdoc/{ => code_object}/extend.rb (100%) rename lib/rdoc/{ => code_object}/ghost_method.rb (100%) rename lib/rdoc/{ => code_object}/include.rb (100%) rename lib/rdoc/{ => code_object}/meta_method.rb (100%) rename lib/rdoc/{ => code_object}/method_attr.rb (100%) rename lib/rdoc/{ => code_object}/mixin.rb (100%) rename lib/rdoc/{ => code_object}/normal_class.rb (100%) rename lib/rdoc/{ => code_object}/normal_module.rb (100%) rename lib/rdoc/{ => code_object}/require.rb (100%) rename lib/rdoc/{ => code_object}/single_class.rb (100%) rename lib/rdoc/{ => code_object}/top_level.rb (100%) diff --git a/lib/rdoc.rb b/lib/rdoc.rb index 9dc4595324..209042ed0e 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -188,26 +188,26 @@ def self.home # programs: classes, modules, methods, and so on. autoload :CodeObject, "#{__dir__}/rdoc/code_object" - autoload :Context, "#{__dir__}/rdoc/context" - autoload :TopLevel, "#{__dir__}/rdoc/top_level" - - autoload :AnonClass, "#{__dir__}/rdoc/anon_class" - autoload :ClassModule, "#{__dir__}/rdoc/class_module" - autoload :NormalClass, "#{__dir__}/rdoc/normal_class" - autoload :NormalModule, "#{__dir__}/rdoc/normal_module" - autoload :SingleClass, "#{__dir__}/rdoc/single_class" - - autoload :Alias, "#{__dir__}/rdoc/alias" - autoload :AnyMethod, "#{__dir__}/rdoc/any_method" - autoload :MethodAttr, "#{__dir__}/rdoc/method_attr" - autoload :GhostMethod, "#{__dir__}/rdoc/ghost_method" - autoload :MetaMethod, "#{__dir__}/rdoc/meta_method" - autoload :Attr, "#{__dir__}/rdoc/attr" - - autoload :Constant, "#{__dir__}/rdoc/constant" - autoload :Mixin, "#{__dir__}/rdoc/mixin" - autoload :Include, "#{__dir__}/rdoc/include" - autoload :Extend, "#{__dir__}/rdoc/extend" - autoload :Require, "#{__dir__}/rdoc/require" + autoload :Context, "#{__dir__}/rdoc/code_object/context" + autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level" + + autoload :AnonClass, "#{__dir__}/rdoc/code_object/anon_class" + autoload :ClassModule, "#{__dir__}/rdoc/code_object/class_module" + autoload :NormalClass, "#{__dir__}/rdoc/code_object/normal_class" + autoload :NormalModule, "#{__dir__}/rdoc/code_object/normal_module" + autoload :SingleClass, "#{__dir__}/rdoc/code_object/single_class" + + autoload :Alias, "#{__dir__}/rdoc/code_object/alias" + autoload :AnyMethod, "#{__dir__}/rdoc/code_object/any_method" + autoload :MethodAttr, "#{__dir__}/rdoc/code_object/method_attr" + autoload :GhostMethod, "#{__dir__}/rdoc/code_object/ghost_method" + autoload :MetaMethod, "#{__dir__}/rdoc/code_object/meta_method" + autoload :Attr, "#{__dir__}/rdoc/code_object/attr" + + autoload :Constant, "#{__dir__}/rdoc/code_object/constant" + autoload :Mixin, "#{__dir__}/rdoc/code_object/mixin" + autoload :Include, "#{__dir__}/rdoc/code_object/include" + autoload :Extend, "#{__dir__}/rdoc/code_object/extend" + autoload :Require, "#{__dir__}/rdoc/code_object/require" end diff --git a/lib/rdoc/alias.rb b/lib/rdoc/code_object/alias.rb similarity index 100% rename from lib/rdoc/alias.rb rename to lib/rdoc/code_object/alias.rb diff --git a/lib/rdoc/anon_class.rb b/lib/rdoc/code_object/anon_class.rb similarity index 100% rename from lib/rdoc/anon_class.rb rename to lib/rdoc/code_object/anon_class.rb diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/code_object/any_method.rb similarity index 100% rename from lib/rdoc/any_method.rb rename to lib/rdoc/code_object/any_method.rb diff --git a/lib/rdoc/attr.rb b/lib/rdoc/code_object/attr.rb similarity index 100% rename from lib/rdoc/attr.rb rename to lib/rdoc/code_object/attr.rb diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/code_object/class_module.rb similarity index 100% rename from lib/rdoc/class_module.rb rename to lib/rdoc/code_object/class_module.rb diff --git a/lib/rdoc/constant.rb b/lib/rdoc/code_object/constant.rb similarity index 100% rename from lib/rdoc/constant.rb rename to lib/rdoc/code_object/constant.rb diff --git a/lib/rdoc/context.rb b/lib/rdoc/code_object/context.rb similarity index 100% rename from lib/rdoc/context.rb rename to lib/rdoc/code_object/context.rb diff --git a/lib/rdoc/context/section.rb b/lib/rdoc/code_object/context/section.rb similarity index 100% rename from lib/rdoc/context/section.rb rename to lib/rdoc/code_object/context/section.rb diff --git a/lib/rdoc/extend.rb b/lib/rdoc/code_object/extend.rb similarity index 100% rename from lib/rdoc/extend.rb rename to lib/rdoc/code_object/extend.rb diff --git a/lib/rdoc/ghost_method.rb b/lib/rdoc/code_object/ghost_method.rb similarity index 100% rename from lib/rdoc/ghost_method.rb rename to lib/rdoc/code_object/ghost_method.rb diff --git a/lib/rdoc/include.rb b/lib/rdoc/code_object/include.rb similarity index 100% rename from lib/rdoc/include.rb rename to lib/rdoc/code_object/include.rb diff --git a/lib/rdoc/meta_method.rb b/lib/rdoc/code_object/meta_method.rb similarity index 100% rename from lib/rdoc/meta_method.rb rename to lib/rdoc/code_object/meta_method.rb diff --git a/lib/rdoc/method_attr.rb b/lib/rdoc/code_object/method_attr.rb similarity index 100% rename from lib/rdoc/method_attr.rb rename to lib/rdoc/code_object/method_attr.rb diff --git a/lib/rdoc/mixin.rb b/lib/rdoc/code_object/mixin.rb similarity index 100% rename from lib/rdoc/mixin.rb rename to lib/rdoc/code_object/mixin.rb diff --git a/lib/rdoc/normal_class.rb b/lib/rdoc/code_object/normal_class.rb similarity index 100% rename from lib/rdoc/normal_class.rb rename to lib/rdoc/code_object/normal_class.rb diff --git a/lib/rdoc/normal_module.rb b/lib/rdoc/code_object/normal_module.rb similarity index 100% rename from lib/rdoc/normal_module.rb rename to lib/rdoc/code_object/normal_module.rb diff --git a/lib/rdoc/require.rb b/lib/rdoc/code_object/require.rb similarity index 100% rename from lib/rdoc/require.rb rename to lib/rdoc/code_object/require.rb diff --git a/lib/rdoc/single_class.rb b/lib/rdoc/code_object/single_class.rb similarity index 100% rename from lib/rdoc/single_class.rb rename to lib/rdoc/code_object/single_class.rb diff --git a/lib/rdoc/top_level.rb b/lib/rdoc/code_object/top_level.rb similarity index 100% rename from lib/rdoc/top_level.rb rename to lib/rdoc/code_object/top_level.rb