Class: Wrongdoc::Rdoc
Instance Method Summary
collapse
Methods included from ParseXML
#parse_xml
#rdoc_options
Methods included from Readme
#readme_description, #readme_metadata
Constructor Details
#initialize(opts) ⇒ Rdoc
Returns a new instance of Rdoc.
15
16
17
18
|
# File 'lib/wrongdoc/rdoc.rb', line 15
def initialize(opts)
@rdoc_uri = URI.parse(opts[:rdoc_url])
@cgit_uri = URI.parse(opts[:cgit_url])
end
|
Instance Method Details
#add_atom(path, atom_uri) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/wrongdoc/rdoc.rb', line 38
def add_atom(path, atom_uri)
File.open(path, "a+") do |fp|
doc = parse_xml(fp.read)
doc.search("title").each { |t|
t.add_next_sibling(atom_node(doc, atom_uri))
}
fp.truncate 0
fp.write doc.to_xhtml
end
end
|
#atom_node(doc, uri, title = 'Atom feed') ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/wrongdoc/rdoc.rb', line 62
def atom_node(doc, uri, title = 'Atom feed')
link = Nokogiri::XML::Node.new('link', doc)
link['rel'] = 'alternate'
link['title'] = title
link['href'] = uri.to_s
link['type'] = 'application/atom+xml'
link
end
|
#cgit_atom_uri ⇒ Object
49
50
51
52
53
54
|
# File 'lib/wrongdoc/rdoc.rb', line 49
def cgit_atom_uri
uri = @cgit_uri.dup
uri.path += "/atom/"
uri.query = "h=master"
uri
end
|
#news_atom_uri ⇒ Object
56
57
58
59
60
|
# File 'lib/wrongdoc/rdoc.rb', line 56
def news_atom_uri
uri = @rdoc_uri.dup
uri.path += "NEWS.atom.xml"
uri
end
|
#rdoc(argv) ⇒ Object
33
34
35
36
|
# File 'lib/wrongdoc/rdoc.rb', line 33
def rdoc(argv)
r = RDoc::RDoc.new
r.document(rdoc_options.concat(argv))
end
|
#run(argv = []) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/wrongdoc/rdoc.rb', line 20
def run(argv = [])
rdoc(argv)
add_atom("doc/ChangeLog.html", cgit_atom_uri)
add_atom("doc/NEWS.html", news_atom_uri)
add_atom("doc/README.html", news_atom_uri)
rdoc_index = "doc/rdoc_index.html"
File.exist?(rdoc_index) and File.unlink(rdoc_index)
File.rename("doc/index.html", rdoc_index)
File.link("doc/README.html", "doc/index.html")
end
|