/tutorial/external_tool/eiffeldoc_like.e

http://github.com/tybor/Liberty · Specman e · 108 lines · 82 code · 17 blank · 9 comment · 8 complexity · 6f4b9a1e353aace6b5986a88a7dac711 MD5 · raw file

  1. class EIFFELDOC_LIKE
  2. -- This example illustrates how to make a tool that works like eiffeldoc.
  3. -- It lists all the classes of all clusters
  4. --*** Currently broken. You'll probably want to use CLUSTER.read_classes and then find some way to get at the
  5. --*** data in CLUSTER.pool . ACE.for_all and ACE.for_all_clusters may be helpful in the process. <FM-30/07/2007>
  6. inherit
  7. CLUSTER_VISITOR
  8. VISITOR
  9. insert
  10. EXTERNAL_TOOL
  11. create {ANY}
  12. make
  13. feature {}
  14. make
  15. do
  16. root_class_name := as_any
  17. bootstrap
  18. ace.for_all_clusters(agent visit_cluster(?))
  19. end
  20. parse_arguments
  21. local
  22. argi: INTEGER; arg: STRING
  23. do
  24. -- Only called in non-ace mode
  25. search_for_verbose_flag
  26. from
  27. argi := 1
  28. until
  29. argi > argument_count
  30. loop
  31. arg := argument(argi)
  32. -- The `is_xxx_flag' functions have side effects (they are not pure queries)
  33. if is_help_flag(arg) then
  34. elseif is_version_flag(arg) then
  35. elseif is_verbose_flag(arg) then
  36. elseif is_style_warning_flag(arg) then
  37. elseif is_no_warning_flag(arg) then
  38. elseif add_loadpath(arg) then
  39. else
  40. system_tools.bad_use_exit(command_name, usage)
  41. end
  42. argi := argi + 1
  43. end
  44. end
  45. add_loadpath (loadpath: STRING): BOOLEAN
  46. do
  47. if loadpath.has_suffix(once ".ace") or else loadpath.has_suffix(once ".ACE") then
  48. -- nothing to do: bootstrap takes care of that
  49. Result := True
  50. elseif loadpath.has_suffix(once ".se") or else loadpath.has_suffix(once ".SE") then
  51. system_tools.add_loadpath_file(loadpath)
  52. Result := True
  53. end
  54. end
  55. is_valid_argument_for_ace_mode (arg: STRING): BOOLEAN
  56. do
  57. -- This is called by smart_eiffel.ace from a loop similar to the one in parse_arguments
  58. Result := is_version_flag(arg) or else is_style_warning_flag(arg) or else is_no_warning_flag(arg) or else is_verbose_flag(arg)
  59. end
  60. valid_argument_for_ace_mode: STRING "Only the flags -verbose, -version and -help are allowed%Nin ACE file mode.%N"
  61. use_short_mode: BOOLEAN True
  62. usage: STRING "[
  63. Usage: eiffeldoc_like [options] <LoadPathFileName>.se ...
  64. or: eiffeldoc_like [options] <ACEfileName>.ace
  65. Option summary:
  66. Information:
  67. -help Display this help information
  68. -version Display Liberty Eiffel version information
  69. -verbose Display detailed information about what
  70. eiffeldoc_like is doing
  71. Warning levels:
  72. -style_warning Print warnings about style violations
  73. -no_warning Don't print any warnings
  74. ]"
  75. feature {CLUSTER}
  76. visit_cluster (a_cluster: CLUSTER)
  77. -- For each class in `a_cluster' print its name
  78. local
  79. path: STRING; directory: DIRECTORY
  80. do
  81. io.put_string(once "Cluster: ")
  82. io.put_line(a_cluster.name)
  83. path := a_cluster.directory_path
  84. if path /= Void and then not path.is_empty then
  85. create directory.scan(path)
  86. directory.for_each(agent io.put_line(?))
  87. else
  88. io.put_line(once "Path void or empty")
  89. end
  90. end
  91. end -- class EIFFELDOC_LIKE