method
add_constant
v1_9_3_392 -
Show latest stable
- Class:
RDoc::Context
add_constant(constant)public
Adds constant if not already there. If it is, updates the comment, value and/or is_alias_for of the known constant if they were empty/nil.
# File lib/rdoc/context.rb, line 481
def add_constant constant
return constant unless @document_self
# HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)
# (this is a #ifdef: should be handled by the C parser)
known = @constants_hash[constant.name]
if known then
known.comment = constant.comment if known.comment.empty?
known.value = constant.value if
known.value.nil? or known.value.strip.empty?
known.is_alias_for ||= constant.is_alias_for
else
@constants_hash[constant.name] = constant
add_to @constants, constant
end
constant
end Related methods
- Instance methods
- <=>
- add_alias
- add_attribute
- add_class
- add_class_or_module
- add_constant
- add_include
- add_method
- add_module
- add_module_alias
- add_require
- add_section
- add_to
- any_content
- child_name
- class_attributes
- class_method_list
- classes
- classes_and_modules
- classes_hash
- current_section
- defined_in?
- display
- each_ancestor
- each_attribute
- each_classmodule
- each_constant
- each_include
- each_method
- each_section
- find_attribute
- find_attribute_named
- find_class_method_named
- find_constant_named
- find_enclosing_module_named
- find_external_alias
- find_external_alias_named
- find_file_named
- find_instance_method_named
- find_local_symbol
- find_method
- find_method_named
- find_module_named
- find_symbol
- find_symbol_module
- full_name
- fully_documented?
- http_url
- initialize_methods_etc
- instance_attributes
- instance_method_list
- methods_by_type
- methods_matching
- modules
- modules_hash
- name_for_path
- ongoing_visibility=
- record_location
- remove_from_documentation?
- remove_invisible
- remove_invisible_in
- resolve_aliases
- sections
- sections_hash
- set_current_section
- set_visibility_for
- to_s
- top_level
- upgrade_to_class
- Class methods
- new