atom-doc 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +150 -0
- data/atom.rdoc +5 -0
- data/bin/atom +118 -0
- data/lib/atom.rb +10 -0
- data/lib/atom/generate.rb +59 -0
- data/lib/atom/helpers.rb +82 -0
- data/lib/atom/plugger.rb +20 -0
- data/lib/atom/plugin.rb +11 -0
- data/lib/atom/scaffold.rb +144 -0
- data/lib/atom_version.rb +3 -0
- metadata +159 -0
data/README.textile
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
h1. Atom
|
2
|
+
|
3
|
+
Atom is a command suite for generating text-based documentation, and is loosely based on the "Darwin Information Typing Architecture":http://en.wikipedia.org/wiki/Darwin_Information_Typing_Architecture (DITA).
|
4
|
+
|
5
|
+
DITA is XML-based, and content is created as small *topic* items rather than long books or chapters and listed in *maps* to produce a document. Topics should be __atomic__ in that they contain the smallest amount of information that makes sense with no further context. A DITA map contains links to topics, organized in the sequence (which may be hierarchical) in which they are intended to appear in finished documents.
|
6
|
+
|
7
|
+
Instead of being XML-based, *atom* uses *textile* as the markup language. This avoids having to use a special editor or hand coding XML. It also allows the source documents to be read more easily by a human. It's open source and has a simple plug-in system that allows the content creator to create scripts that hook in to the processing stream.
|
8
|
+
|
9
|
+
h2. The Basics
|
10
|
+
|
11
|
+
Creating documentation is simple.
|
12
|
+
|
13
|
+
# Initialize a repository with the @init@ command
|
14
|
+
# Add version control with @git@ (optional)
|
15
|
+
# Add *maps* and *topics* with the @new@ command
|
16
|
+
# Edit your *maps* to include *topics*
|
17
|
+
# Build your *maps* with the @build@ command
|
18
|
+
|
19
|
+
h3. The Repository
|
20
|
+
|
21
|
+
We can initialize a new repository by running the following command:
|
22
|
+
|
23
|
+
bc. $ atom init docs
|
24
|
+
>
|
25
|
+
create [Dir]: docs/source
|
26
|
+
create [Dir]: docs/source/topics
|
27
|
+
create [Dir]: docs/source/maps
|
28
|
+
create [Dir]: docs/config
|
29
|
+
create [Dir]: docs/temp
|
30
|
+
create [Dir]: docs/output
|
31
|
+
create [Dir]: docs/output/html
|
32
|
+
create [Dir]: docs/templates
|
33
|
+
create [Dir]: docs/plugins
|
34
|
+
create [File]: docs/.atom
|
35
|
+
create [File]: docs/.gitignore
|
36
|
+
create [File]: docs/config/atom.yml
|
37
|
+
create [File]: docs/templates/concept.textile
|
38
|
+
create [File]: docs/templates/procedure.textile
|
39
|
+
create [File]: docs/templates/map.textile
|
40
|
+
create [File]: docs/templates/default.html
|
41
|
+
|
42
|
+
This will create a series of directories and files that will be used as a framework to store and build your documentation. From inside the *docs* directory, you can run the rest of the *atom* commands.
|
43
|
+
|
44
|
+
Note that several *template* files are created:
|
45
|
+
|
46
|
+
* concept.textile
|
47
|
+
* map.textile
|
48
|
+
* procedure.textile
|
49
|
+
* default.html
|
50
|
+
|
51
|
+
These templates contain basic skeletons to generate documents from and are meant to be edited to suit the needs of the particular project. When you run the @new@ command, the files are generated from these templates.
|
52
|
+
|
53
|
+
To generate a map, run:
|
54
|
+
|
55
|
+
bc. $ atom new -m 'Working with Vagrant'
|
56
|
+
>
|
57
|
+
create [File]: source/maps/m_working_with_vagrant.textile
|
58
|
+
|
59
|
+
The @new@ command takes a switch indicating the type of document you want to create [concept, procedure, map] and a title. It will create the document in the *source* directory, either under topics or maps. In the example above, a new *map* is created with a title of *Working with Vagrant*.
|
60
|
+
|
61
|
+
Next we should create some topics to be included in the map:
|
62
|
+
|
63
|
+
bc. $ atom new -c 'VirtualBox'
|
64
|
+
>
|
65
|
+
create [File]: source/topics/c_virtualbox.textile
|
66
|
+
|
67
|
+
bc. $ atom new -p 'Installing VirtualBox'
|
68
|
+
>
|
69
|
+
create [File]: source/topics/p_installing_virtualbox.textile
|
70
|
+
|
71
|
+
Notice that the @-c@ creates a *concept* and the @-p@ creates a *procedure* and that the respective files are prefixed witha a *c* and a *p* and placed in the @source/topics@ directory.
|
72
|
+
|
73
|
+
Now that we have a few topics, we can include them in the map with the following lines:
|
74
|
+
|
75
|
+
bc. =1 VirtualBox
|
76
|
+
=2 Installing VirtualBox
|
77
|
+
|
78
|
+
The @=@ sign includes the topic that matches the given title, and the number tells *atom* where this topic fits in the hierarchy with @0@ being the root and the default. Even though the @c_virtualbox.textile@ file has an @h1@ header, it will have an @h2@ in the final document.
|
79
|
+
|
80
|
+
Now that we have some topics in our map, we can build it.
|
81
|
+
|
82
|
+
bc. $ atom build 'Working with Vagrant'
|
83
|
+
>
|
84
|
+
create [File]: output/html/working_with_vagrant.html
|
85
|
+
|
86
|
+
We now have an html document that contains our documentation.
|
87
|
+
|
88
|
+
h2. Advanced Usage
|
89
|
+
|
90
|
+
h3. Plugins
|
91
|
+
|
92
|
+
*Atom* allows users to create plugins that hook in to the build process at two points. The first hook is after the map and subtopics have been assembeled into one document, but is still a textile document. The second hook is after the html document is created.
|
93
|
+
|
94
|
+
To create a plugin, create a new file in the *plugins* directory. I'll create a file named *contents.rb*.
|
95
|
+
|
96
|
+
bc. class Contents < Atom::Plugin
|
97
|
+
def run(text)
|
98
|
+
# logic here
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
Your class must inherit from @Atom::Plugin@ and override the @run@ method. You'll be passed the text of the file your hooking in to, which should be manipulated and returned.
|
103
|
+
|
104
|
+
In order to run this plugin, you'll have to tell *atom* about it in the @config/atom.yml@ file. When you first start an *atom* project, no plugins will be configured to run and the yaml file will contain the following line:
|
105
|
+
|
106
|
+
bc. plugins: { pre: [], post: [] }
|
107
|
+
|
108
|
+
I want my plugin to run after the html has been generated, so I'll place the name of my plugin in the *post* array.
|
109
|
+
|
110
|
+
bc. plugins: { pre: [], post: [contents] }
|
111
|
+
|
112
|
+
Now let's modify the plugin to do something useful:
|
113
|
+
|
114
|
+
bc.. require 'nokogiri'
|
115
|
+
|
116
|
+
class Contents < Atom::Plugin
|
117
|
+
def run(text)
|
118
|
+
doc = Nokogiri::HTML.parse(text)
|
119
|
+
return create_table(doc, 4)
|
120
|
+
end
|
121
|
+
|
122
|
+
def create_table(doc, depth=3)
|
123
|
+
# The following line creates an array like ["h1", "h2", "h3"]
|
124
|
+
hs = (1..depth).to_a.reduce([]) {|r, e| r << "h#{e}"}
|
125
|
+
table_node = Nokogiri::XML::Node.new('table', doc)
|
126
|
+
|
127
|
+
doc.css(hs.join(',')).each_with_index do |h, i|
|
128
|
+
anchor_node = Nokogiri::XML::Node.new('a',doc)
|
129
|
+
link_node = Nokogiri::XML::Node.new('a',doc)
|
130
|
+
row_node = Nokogiri::XML::Node.new('tr', doc)
|
131
|
+
data_node = Nokogiri::XML::Node.new('td', doc)
|
132
|
+
|
133
|
+
link_node['href'] = "##{i}"
|
134
|
+
anchor_node['name'] = "#{i}"
|
135
|
+
h.add_previous_sibling(anchor_node)
|
136
|
+
link_node.content = h.content
|
137
|
+
data_node.add_child(link_node)
|
138
|
+
row_node.add_child(data_node)
|
139
|
+
|
140
|
+
table_node.add_child(row_node)
|
141
|
+
end
|
142
|
+
|
143
|
+
body = doc.at_css "body"
|
144
|
+
body.children.first.add_previous_sibling(table_node)
|
145
|
+
|
146
|
+
return doc
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
p. The above plugin will create a table listing all headings up to the depth specified with a link to each heading.
|
data/atom.rdoc
ADDED
data/bin/atom
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
|
3
|
+
# have this method, so we add it so we get resolved symlinks
|
4
|
+
# and compatibility
|
5
|
+
unless File.respond_to? :realpath
|
6
|
+
class File #:nodoc:
|
7
|
+
def self.realpath path
|
8
|
+
return realpath(File.readlink(path)) if symlink?(path)
|
9
|
+
path
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
14
|
+
require 'rubygems'
|
15
|
+
require 'gli'
|
16
|
+
require 'atom_version'
|
17
|
+
require 'atom'
|
18
|
+
|
19
|
+
include GLI
|
20
|
+
|
21
|
+
program_desc 'tool for creating "atomic" text-based documentation'
|
22
|
+
|
23
|
+
version Atom::VERSION
|
24
|
+
|
25
|
+
# init command
|
26
|
+
desc 'create a new document repository'
|
27
|
+
arg_name 'list of repository names'
|
28
|
+
skips_pre
|
29
|
+
command :init do |c|
|
30
|
+
|
31
|
+
c.action do |global_options,options,args|
|
32
|
+
proj_names = args
|
33
|
+
|
34
|
+
if args.length < 1
|
35
|
+
raise 'You must provide a project name'
|
36
|
+
elsif File.exist? '.atom'
|
37
|
+
raise 'This appears to be an atom directory'
|
38
|
+
end
|
39
|
+
|
40
|
+
proj_names.each do |proj_name|
|
41
|
+
Atom::Scaffold.create(proj_name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# new commmand
|
47
|
+
desc 'create a new document'
|
48
|
+
arg_name "'document title'"
|
49
|
+
command :new do |c|
|
50
|
+
c.desc 'create concept document'
|
51
|
+
c.switch [:c, :concept]
|
52
|
+
|
53
|
+
c.desc 'create map document'
|
54
|
+
c.switch [:m, :map]
|
55
|
+
|
56
|
+
c.desc 'create procedure document'
|
57
|
+
c.switch [:p, :procedure]
|
58
|
+
|
59
|
+
c.action do |global_options,options,args|
|
60
|
+
|
61
|
+
if options[:c]
|
62
|
+
Atom::Generate.from_template('concept', args[0])
|
63
|
+
end
|
64
|
+
|
65
|
+
if options[:m]
|
66
|
+
Atom::Generate.from_template('map', args[0])
|
67
|
+
end
|
68
|
+
|
69
|
+
if options[:p]
|
70
|
+
Atom::Generate.from_template('procedure', args[0])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# build command
|
76
|
+
desc 'output source map to html'
|
77
|
+
arg_name "'document title'"
|
78
|
+
command :build do |c|
|
79
|
+
c.action do |global_options,options,args|
|
80
|
+
temp_file = Atom::Generate.temp_file('map', args[0])
|
81
|
+
|
82
|
+
Atom::Plugger.load_plugins("#{Atom::PATH}/plugins", Atom::PLUGINS)
|
83
|
+
|
84
|
+
Atom::Plugger.run(Atom::PRE_PLUGINS, temp_file)
|
85
|
+
|
86
|
+
html_file = Atom::Generate.html(temp_file)
|
87
|
+
|
88
|
+
Atom::Plugger.run(Atom::POST_PLUGINS, html_file)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
pre do |global,command,options,args|
|
93
|
+
if command.name == :help # allow help command to run
|
94
|
+
true
|
95
|
+
elsif File.exist?('.atom')
|
96
|
+
Atom::load_config
|
97
|
+
|
98
|
+
true
|
99
|
+
else
|
100
|
+
raise "This command needs to run in an atom directory"
|
101
|
+
|
102
|
+
false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
post do |global,command,options,args|
|
107
|
+
# Post logic here
|
108
|
+
# Use skips_post before a command to skip this
|
109
|
+
# block on that command only
|
110
|
+
end
|
111
|
+
|
112
|
+
on_error do |exception|
|
113
|
+
# Error logic here
|
114
|
+
# return false to skip default error handling
|
115
|
+
true
|
116
|
+
end
|
117
|
+
|
118
|
+
exit GLI.run(ARGV)
|
data/lib/atom.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Atom
|
2
|
+
class Generate
|
3
|
+
def self.from_template(type, title)
|
4
|
+
dest = type == 'map' ? "source/maps" : "source/topics"
|
5
|
+
file_name = Atom::name(type, title)
|
6
|
+
template = File.read("#{Atom::PATH}/templates/#{type}.textile")
|
7
|
+
|
8
|
+
if File.exist?(File.join(dest, file_name))
|
9
|
+
raise "File already exists"
|
10
|
+
else
|
11
|
+
$stdout.puts "create [File]: #{File.join(dest, file_name)}"
|
12
|
+
|
13
|
+
Atom::write_file(
|
14
|
+
File.join(dest, file_name),
|
15
|
+
Mustache.render(
|
16
|
+
template, :title => title, :author => Atom::CONFIG[:author]
|
17
|
+
)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.temp_file(type, title)
|
23
|
+
file_name = Atom::name(type, title)
|
24
|
+
|
25
|
+
Atom::write_file(
|
26
|
+
"#{Atom::PATH}/temp/#{file_name}",
|
27
|
+
Atom::sub_topics(Atom::get_src_file_by_title(title, 'maps'))
|
28
|
+
)
|
29
|
+
|
30
|
+
return "#{Atom::PATH}/temp/#{file_name}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.html(file)
|
34
|
+
out_file_name = "#{File.basename(file, ".textile").split('_')[1..-1].join('_')}.html"
|
35
|
+
out_file_path = File.join(Atom::PATH, "output/html")
|
36
|
+
out_file = File.join(out_file_path, out_file_name)
|
37
|
+
template = File.read(File.join(Atom::PATH, "templates/default.html"))
|
38
|
+
|
39
|
+
doc = File.read(file)
|
40
|
+
rc = RedCloth.new(doc)
|
41
|
+
|
42
|
+
if File.exist? out_file
|
43
|
+
$stdout.puts "overwrite [File]: output/html/#{out_file_name}"
|
44
|
+
else
|
45
|
+
$stdout.puts "create [File]: output/html/#{out_file_name}"
|
46
|
+
end
|
47
|
+
|
48
|
+
Atom::write_file(
|
49
|
+
out_file,
|
50
|
+
Mustache.render(
|
51
|
+
template, :body => rc.to_html,
|
52
|
+
:title => File.basename(file)
|
53
|
+
)
|
54
|
+
)
|
55
|
+
|
56
|
+
return out_file
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/atom/helpers.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
module Atom
|
2
|
+
def self.load_config
|
3
|
+
const_set(:PATH, Dir.pwd)
|
4
|
+
const_set(:CONFIG, YAML.load_file("#{PATH}/config/atom.yml"))
|
5
|
+
const_set(:PRE_PLUGINS, CONFIG['plugins']['pre'])
|
6
|
+
const_set(:POST_PLUGINS, CONFIG['plugins']['post'])
|
7
|
+
const_set(:PLUGINS, PRE_PLUGINS | POST_PLUGINS)
|
8
|
+
|
9
|
+
unless CONFIG[:author]
|
10
|
+
begin
|
11
|
+
CONFIG[:author] = `git config --get user.name`.chomp
|
12
|
+
rescue
|
13
|
+
CONFIG[:author] = 'unknown'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.read_yaml(content)
|
19
|
+
begin
|
20
|
+
if content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
21
|
+
content = $'
|
22
|
+
data = YAML.load($1)
|
23
|
+
end
|
24
|
+
rescue => e
|
25
|
+
$stderr.puts "YAML Exception: #{e.message}"
|
26
|
+
end
|
27
|
+
|
28
|
+
data ||= {}
|
29
|
+
return [data, content]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.sub_topics(file)
|
33
|
+
map_data, content = Atom::read_yaml(File.read(file))
|
34
|
+
new_file = ''
|
35
|
+
|
36
|
+
content.split("\n").each do |line|
|
37
|
+
if line.match(/^=/)
|
38
|
+
depth, title = line.match(/^=(\d)? (.*)/)[1..2]
|
39
|
+
depth ||= 0
|
40
|
+
data, content = Atom::read_yaml(
|
41
|
+
File.read(
|
42
|
+
Atom::get_src_file_by_title(title, 'topics')
|
43
|
+
).gsub(/^h(\d)(.*)/) { "h#{($1.to_i + depth.to_i).to_s}#{$2}" }
|
44
|
+
)
|
45
|
+
|
46
|
+
new_file += "<section class=\"#{data['class']}\" author=\"#{data['author']}\">\n"
|
47
|
+
new_file += "\n#{content}\n"
|
48
|
+
new_file += "</section>"
|
49
|
+
new_file += "\n"
|
50
|
+
else
|
51
|
+
new_file += "#{line}\n"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
return new_file
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.get_src_file_by_title(title, src_dir)
|
59
|
+
file_title = title.downcase.split.join('_')
|
60
|
+
result = Dir.glob("#{Atom::PATH}/source/#{src_dir}/?_#{file_title}.*")
|
61
|
+
if result.size == 1
|
62
|
+
result.first
|
63
|
+
elsif result.size == 0
|
64
|
+
raise "Title '#{title}' not found"
|
65
|
+
else
|
66
|
+
raise "Ambiguous title '#{title}'"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.name(type, title)
|
71
|
+
# TODO abastract file extension to accomodate markup choice
|
72
|
+
"#{type.split('').first}_#{title.chomp.downcase.split.join('_')}.textile"
|
73
|
+
end
|
74
|
+
|
75
|
+
# Ensure files are written in a consistant manner
|
76
|
+
def self.write_file(path, content)
|
77
|
+
file = File.open(path, "w")
|
78
|
+
file.write(content)
|
79
|
+
file.flush
|
80
|
+
file.close
|
81
|
+
end
|
82
|
+
end
|
data/lib/atom/plugger.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Atom
|
2
|
+
class Plugger
|
3
|
+
def self.load_plugins(plugin_path, plugins)
|
4
|
+
plugins.each do |plugin|
|
5
|
+
require File.join("#{plugin_path}", "#{plugin}.rb")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.run(plugins, file_path)
|
10
|
+
text = File.read(file_path)
|
11
|
+
|
12
|
+
plugins.each do |plugin|
|
13
|
+
classname = plugin.split('_').map(&:capitalize).join
|
14
|
+
text = Kernel.const_get(classname).new(text).to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
Atom::write_file(file_path, text)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/atom/plugin.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
module Atom
|
2
|
+
class Scaffold
|
3
|
+
def self.create(root_dir)
|
4
|
+
dirs = [
|
5
|
+
'source',
|
6
|
+
['source', 'topics'],
|
7
|
+
['source', 'maps'],
|
8
|
+
'config',
|
9
|
+
'temp',
|
10
|
+
'output',
|
11
|
+
['output', 'html'],
|
12
|
+
'templates',
|
13
|
+
'plugins'
|
14
|
+
]
|
15
|
+
|
16
|
+
if mkdirs(root_dir, dirs)
|
17
|
+
mk_dotatom(root_dir)
|
18
|
+
mk_dotgitignore(root_dir)
|
19
|
+
mk_atom(root_dir)
|
20
|
+
mk_concept(root_dir)
|
21
|
+
mk_procedure(root_dir)
|
22
|
+
mk_map(root_dir)
|
23
|
+
mk_html_skeleton(root_dir)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.mk_dotatom(root_dir)
|
28
|
+
$stdout.puts "create [File]: #{root_dir}/.atom"
|
29
|
+
FileUtils.touch "#{root_dir}/.atom"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.mk_dotgitignore(root_dir)
|
33
|
+
$stdout.puts "create [File]: #{root_dir}/.gitignore"
|
34
|
+
File.open("#{root_dir}/.gitignore", "w") do |file|
|
35
|
+
file.puts <<EOS
|
36
|
+
config/
|
37
|
+
output/
|
38
|
+
temp/
|
39
|
+
EOS
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.mk_atom(root_dir)
|
44
|
+
$stdout.puts "create [File]: #{root_dir}/config/atom.yml"
|
45
|
+
File.open("#{root_dir}/config/atom.yml", "w") do |file|
|
46
|
+
file.puts <<EOS
|
47
|
+
markup: textile
|
48
|
+
|
49
|
+
plugins: { pre: [], post: [] }
|
50
|
+
|
51
|
+
EOS
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.mk_concept(root_dir)
|
56
|
+
$stdout.puts "create [File]: #{root_dir}/templates/concept.textile"
|
57
|
+
File.open("#{root_dir}/templates/concept.textile", "w") do |file|
|
58
|
+
file.puts <<EOS
|
59
|
+
---
|
60
|
+
author: {{author}}
|
61
|
+
class: concept
|
62
|
+
---
|
63
|
+
|
64
|
+
h1(topic-title). {{title}}
|
65
|
+
|
66
|
+
EOS
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.mk_procedure(root_dir)
|
71
|
+
$stdout.puts "create [File]: #{root_dir}/templates/procedure.textile"
|
72
|
+
File.open("#{root_dir}/templates/procedure.textile", "w") do |file|
|
73
|
+
file.puts <<EOS
|
74
|
+
---
|
75
|
+
author: {{author}}
|
76
|
+
class: procedure
|
77
|
+
---
|
78
|
+
|
79
|
+
h1(topic-title). {{title}}
|
80
|
+
|
81
|
+
p(preparation). Before you begin
|
82
|
+
|
83
|
+
h2. Procedure
|
84
|
+
|
85
|
+
# Step 1
|
86
|
+
|
87
|
+
p(result). Result of procedure
|
88
|
+
|
89
|
+
EOS
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.mk_map(root_dir)
|
94
|
+
$stdout.puts "create [File]: #{root_dir}/templates/map.textile"
|
95
|
+
File.open("#{root_dir}/templates/map.textile", "w") do |file|
|
96
|
+
file.puts <<EOS
|
97
|
+
---
|
98
|
+
author: {{author}}
|
99
|
+
class: map
|
100
|
+
---
|
101
|
+
|
102
|
+
h1(map-title). {{title}}
|
103
|
+
|
104
|
+
To include topics in this document, begin a line with @=@ followed by a space and the title of the topic. Like so:
|
105
|
+
|
106
|
+
bc. = Title of My Topic
|
107
|
+
|
108
|
+
EOS
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.mk_html_skeleton(root_dir)
|
113
|
+
$stdout.puts "create [File]: #{root_dir}/templates/default.html"
|
114
|
+
File.open("#{root_dir}/templates/default.html", "w") do |file|
|
115
|
+
file.puts <<EOS
|
116
|
+
<!DOCTYPE html>
|
117
|
+
<html>
|
118
|
+
<head>
|
119
|
+
<meta charset="utf-8" />
|
120
|
+
<title>{{title}}</title>
|
121
|
+
</head>
|
122
|
+
<body>
|
123
|
+
{{{body}}}
|
124
|
+
</body>
|
125
|
+
</html>
|
126
|
+
EOS
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.mkdirs(root_dir, dirs)
|
131
|
+
if File.exist? root_dir
|
132
|
+
raise "'#{root_dir}' already exists"
|
133
|
+
return false
|
134
|
+
end
|
135
|
+
|
136
|
+
FileUtils.mkdir root_dir
|
137
|
+
|
138
|
+
dirs.each do |dir|
|
139
|
+
$stdout.puts "create [Dir]: #{File.join(root_dir, dir)}"
|
140
|
+
FileUtils.mkdir "#{File.join(root_dir, dir)}"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/lib/atom_version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atom-doc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael Wood
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: aruba
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.4.6
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.4.6
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: gli
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mustache
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: RedCloth
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description:
|
111
|
+
email: octant.coder@gmail.com
|
112
|
+
executables:
|
113
|
+
- atom
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- README.textile
|
117
|
+
- atom.rdoc
|
118
|
+
files:
|
119
|
+
- bin/atom
|
120
|
+
- lib/atom_version.rb
|
121
|
+
- lib/atom.rb
|
122
|
+
- lib/atom/scaffold.rb
|
123
|
+
- lib/atom/generate.rb
|
124
|
+
- lib/atom/helpers.rb
|
125
|
+
- lib/atom/plugin.rb
|
126
|
+
- lib/atom/plugger.rb
|
127
|
+
- README.textile
|
128
|
+
- atom.rdoc
|
129
|
+
homepage: http://github.com/octant/atom
|
130
|
+
licenses: []
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options:
|
133
|
+
- --title
|
134
|
+
- atom
|
135
|
+
- --main
|
136
|
+
- README.rdoc
|
137
|
+
- -ri
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.24
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Command line tool for generating text-based documentation
|
159
|
+
test_files: []
|