Method: RDoc::Markup::PreProcess#handle_directive
- Defined in:
- lib/rdoc/markup/pre_process.rb
#handle_directive(prefix, directive, param, code_object = nil, encoding = nil, line = nil) ⇒ Object
Performs the actions described by directive
and its parameter param
.
code_object
is used for directives that operate on a class or module. prefix
is used to ensure the replacement for handled directives is correct. encoding
is used for the include
directive.
For a list of directives in RDoc see RDoc::Markup. – When 1.8.7 support is ditched prefix can be defaulted to ”
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/rdoc/markup/pre_process.rb', line 153 def handle_directive prefix, directive, param, code_object = nil, encoding = nil, line = nil blankline = "#{prefix.strip}\n" directive = directive.downcase case directive when 'arg', 'args' then return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod) code_object.params = param blankline when 'category' then if RDoc::Context === code_object then section = code_object.add_section param code_object.temporary_section = section elsif RDoc::AnyMethod === code_object then code_object.section_title = param end blankline # ignore category if we're not on an RDoc::Context when 'doc' then return blankline unless code_object code_object.document_self = true code_object.force_documentation = true blankline when 'enddoc' then return blankline unless code_object code_object.done_documenting = true blankline when 'include' then filename = param.split(' ', 2).first include_file filename, prefix, encoding when 'main' then .main_page = param if .respond_to? :main_page warn " The :main: directive is deprecated and will be removed in RDoc 7.\n\n You can use these options to specify the initial page displayed instead:\n - `--main=\#{param}` via the command line\n - `rdoc.main = \"\#{param}\"` if you use `RDoc::Task`\n - `main_page: \#{param}` in your `.rdoc_options` file\n MSG\n\n blankline\n when 'nodoc' then\n return blankline unless code_object\n code_object.document_self = nil # notify nodoc\n code_object.document_children = param !~ /all/i\n\n blankline\n when 'notnew', 'not_new', 'not-new' then\n return blankline unless RDoc::AnyMethod === code_object\n\n code_object.dont_rename_initialize = true\n\n blankline\n when 'startdoc' then\n return blankline unless code_object\n\n code_object.start_doc\n code_object.force_documentation = true\n\n blankline\n when 'stopdoc' then\n return blankline unless code_object\n\n code_object.stop_doc\n\n blankline\n when 'title' then\n @options.default_title = param if @options.respond_to? :default_title=\n\n warn <<~MSG\n The :title: directive is deprecated and will be removed in RDoc 7.\n\n You can use these options to specify the title displayed instead:\n - `--title=\#{param}` via the command line\n - `rdoc.title = \"\#{param}\"` if you use `RDoc::Task`\n - `title: \#{param}` in your `.rdoc_options` file\n MSG\n\n blankline\n when 'yield', 'yields' then\n return blankline unless code_object\n # remove parameter &block\n code_object.params = code_object.params.sub(/,?\\s*&\\w+/, '') if code_object.params\n\n code_object.block_params = param || ''\n\n blankline\n else\n result = yield directive, param, line if block_given?\n\n case result\n when nil then\n code_object.metadata[directive] = param if code_object\n\n if RDoc::Markup::PreProcess.registered.include? directive then\n handler = RDoc::Markup::PreProcess.registered[directive]\n result = handler.call directive, param if handler\n else\n result = \"\#{prefix}:\#{directive}: \#{param}\\n\"\n end\n when false then\n result = \"\#{prefix}:\#{directive}: \#{param}\\n\"\n end\n\n result\n end\nend\n" |