Class: Rascut::Asdoc::Generator
- Inherits:
-
Object
- Object
- Rascut::Asdoc::Generator
show all
- Includes:
- Utils
- Defined in:
- lib/rascut/asdoc/generator.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Utils
asdoc_home, home, path_escape, rascut_db, rascut_db_path, rascut_db_read
Constructor Details
#initialize(logger = nil) ⇒ Generator
Returns a new instance of Generator.
18
19
20
21
22
|
# File 'lib/rascut/asdoc/generator.rb', line 18
def initialize(logger = nil)
@logger = Logger.new(STDOUT)
@logger.level = Logger::DEBUG
@asdoc = 'asdoc'
end
|
Instance Attribute Details
#asdoc ⇒ Object
Returns the value of attribute asdoc.
23
24
25
|
# File 'lib/rascut/asdoc/generator.rb', line 23
def asdoc
@asdoc
end
|
Instance Method Details
#generate_asdoc(source_path) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/rascut/asdoc/generator.rb', line 25
def generate_asdoc(source_path)
@logger.info "generate documents: #{source_path}"
cmd = "#{asdoc} -doc-sources '#{source_path}' -output '#{asdoc_home.join(path_escape(source_path.to_s))}'"
@logger.debug cmd
`#{cmd}`
generate_list_by_source_path(source_path)
end
|
#generate_asdoc_by_config(flex_config) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/rascut/asdoc/generator.rb', line 33
def generate_asdoc_by_config(flex_config)
source = Hpricot(flex_config)
files = source.search('source-path path-element').map {|el| Pathname.new(el.inner_text) }
files.each do |file|
generate_asdoc file.realpath
end
end
|
#generate_json ⇒ Object
72
73
74
75
76
|
# File 'lib/rascut/asdoc/generator.rb', line 72
def generate_json
@logger.info "generate asdoc's index(json)."
json = Rascut::Asdoc::Data.asdoc_json
asdoc_home.join('asdoc.json').open('w') {|f| f.puts json }
end
|
#generate_list(path) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rascut/asdoc/generator.rb', line 45
def generate_list(path)
@logger.info "generate list"
asdoc = asdoc_home.join(path)
@logger.info "#{asdoc}"
Pathname.glob("#{asdoc}/*/**/*.html") do |file|
next if file.to_s.match(/((class-list.html)|(package-detail.html))$/)
r = Rascut::Asdoc::Parser.new(file.read, @logger)
r.parse
list = {
:package => r.package,
:classname => r.classname,
:methods => r.methods,
:filename => file.relative_path_from(asdoc).to_s,
:asdoc_dir => asdoc.basename.to_s,
}
rascut_db do |db|
db[:asdoc] ||= {}
db[:asdoc][list[:asdoc_dir]] ||= []
db[:asdoc][list[:asdoc_dir]] << list
end
end
end
|
#generate_list_by_source_path(source_path) ⇒ Object
41
42
43
|
# File 'lib/rascut/asdoc/generator.rb', line 41
def generate_list_by_source_path(source_path)
generate_list(path_escape(source_path.to_s))
end
|