ascii_binder 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f0d4eedad5a44476a05c8b2dfe80341974779e
4
- data.tar.gz: 8efa57a740e9c2f879f02f9e55abd63ea1985080
3
+ metadata.gz: f398f6483700ae88e771ccc52b00b844bf022d26
4
+ data.tar.gz: c731c4527a8d4ed3b25e648e81f68df1d6ba73d4
5
5
  SHA512:
6
- metadata.gz: b286233ac388b2ab379f46d0d0125d12c30260dd0692f2a199d8f9b4ddbe7ebea8ddacd8e803e27960981fe0116b4e89b3f172e880f5a27974ef36e6bbcf4928
7
- data.tar.gz: b622ed29d46c457b40970660083b58ccf4d56c43201a113b392419c563d7857fb4b36a0853f9ee88e0461b64c97fa1054975564a19951d48a6b9bb37054a288c
6
+ metadata.gz: bc7d71d067ff2d9d95e1182e2b28d2823406377211ec3568dec80d4bce8a4f0175b6b842ba89a0bb3345e7dc78832e444ed2f11eb0ab7cc2ebd805615e3c3a92
7
+ data.tar.gz: afc5125f133cc38883091f77e3900d02ec496286b4847e36bec55f1307367712c70554e4070694f91113ebe2eaa9d1f177e4de124bc948e327b033c4e3efc270
@@ -1,221 +1,14 @@
1
1
  = AsciiBinder
2
2
 
3
- This repo contains the documentation for
3
+ image:https://badge.fury.io/rb/ascii_binder.svg["Gem Version", link="https://badge.fury.io/rb/ascii_binder"]
4
4
 
5
- * http://origin.openshift.com/[OpenShift Origin]
6
- * http://openshift.com/[OpenShift Online]
7
- * http://www.redhat.com/products/cloud-computing/openshift-enterprise/[OpenShift Enterprise]
5
+ This repo contains the source code for AsciiBinder, a documentation system for complex software projects. To learn more about AsciiBinder:
8
6
 
9
- The documentation is sourced in http://www.methods.co.nz/asciidoc/[AsciiDoc] and transformed into HTML/CSS and other formats through http://asciidoctor.org/[AsciiDoctor]-based automation.
7
+ * Have a gander at the http://www.asciibinder.org/latest/welcome/[AsciiBinder documentation]
8
+ * Or just take the https://rubygems.org/gems/ascii_binder[ascii_binder Ruby Gem] for a spin
10
9
 
11
- == Repo Organization
10
+ The AsciiBinder system was initially developed for https://github.com/openshift/openshift-docs[OpenShift documentation], but has been revised to work for documenting a wide variety of complex, multi-versioned software projects.
12
11
 
13
- Each directory of the repo represents a different collection of topics (you can think of directories as books). The exceptions to this rule are directories whose names start with an underscore (like `_builder_lib` and `_javascripts`), which contain the assets used to generate the finished documentation. Within each 'book' directory, topics exist as separate asciidoc files and an `images` directory contains any images that are included in the topics.
12
+ == Contributing
13
+ We are using the https://github.com/redhataccess/ascii_binder/issues[Issues] page to track bugs and feature ideas on the code, so have a look and feel free to ask questions there. You can also follow / chat with us on Twitter - https://twitter.com/AsciiBinder[@AsciiBinder]
14
14
 
15
- ----
16
- /
17
- /book1
18
- /book1/topic1.adoc
19
- /book1/topicN.adoc
20
- /book1/images
21
- /book1/images/img1.png
22
- /book1/images/imgN.png
23
- ...
24
- /bookN
25
- ----
26
-
27
- == Version Management
28
- The overlap of documentation across OpenShift Origin, Online and Enterprise is no less than 80%. In many cases, this means that individual topics may need to include or exclude individual paragraphs with respect to a specific OpenShift distribution. While it is _possible_ to accomplish this solely by using git branches to maintain slightly different versions of a given topic, doing so would make the task of maintaining internal consistency extremely difficult for content contributors.
29
-
30
- Git branching is still extremely valuable, and serves the important role of tracking the release versions of documentation for the various OpenShift distributions.
31
-
32
- === Distribution-Specific Conditionals
33
- OpenShift documentation uses AsciiDoc's `ifdef/endif` macro to conditionalize document segments for specific OpenShift distributions down to the single-line level.
34
-
35
- The supported distribution attributes used in the OpenShift document generator are:
36
-
37
- * `openshift-origin`
38
- * `openshift-online`
39
- * `openshift-enterprise`
40
-
41
- These attributes can be used alone or together to conditionalize text within a topic document.
42
-
43
- Here is an example of this concept in use:
44
-
45
- ----
46
- This first line is unconditionalized, and will appear for all versions.
47
-
48
- \ifdef::openshift-online[]
49
- This line will only appear for OpenShift Online.
50
- \endif::[]
51
-
52
- \ifdef::openshift-enterprise[]
53
- This line will only appear for OpenShift Enterprise.
54
- \endif::[]
55
-
56
- \ifdef::openshift-origin,openshift-enterprise[]
57
- This line will appear for OpenShift Origin and Enterprise, but not for OpenShift Online.
58
- \endif::[]
59
- ----
60
-
61
- Two important points to keep in mind:
62
-
63
- * The `ifdef/endif` blocks have no size limit, however they should _not_ be used to conditionalize an entire topic. If an entire topic file is specific to a given OpenShift distribution, refer to the link:#document-set-metadata[Document Set Metadata] section for information on how to conditionalize at the whole-topic level.
64
-
65
- * The `ifdef/endif` blocks _cannot be nested_. In other words, one conditional block cannot contain other conditional blocks.
66
-
67
- === Release Branches
68
- Through the use of link:#distribution-specific-conditionals[Distribution-Specific Conditionals] and link:#document-set-metadata[Document Set Metadata], the master branch of this repository always contains a complete set of documentation that includes all of the OpenShift distributions. However, when and as new versions of the OpenShift distros are released, the master branch is merged down to new or existing release branches. Here is the general naming scheme used in the branches:
69
-
70
- * `master` - OpenShift Origin latest code
71
- * `origin-N.N` - OpenShift Origin most recent stable release
72
- * `online` - OpenShift Online most recent release
73
- * `enterprise-N.N` - OpenShift Enterprise support releases
74
-
75
- On a nightly basis, the documentation web sites are rebuilt for each of these branches. In this manner, documentation for released versions of OpenShift will remain the same even as development continues on master. Additionally, any corrections or additions that are "cherry-picked" into the release branches will show up in the release documentation the next day.
76
-
77
- == Document Set Metadata
78
- In order to construct the documentation site from these sources, the build system looks at the `_build_cfg.yml` metadata file. The build system _only_ looks in this file for information on which files to include, so any new file submissions must be accompanied by an update to this metadata file.
79
-
80
- === File Format
81
- The format of this file is as indicated:
82
-
83
- ----
84
- --- <1>
85
- Name: Origin of the Species <2>
86
- Dir: origin_of_the_species <3>
87
- Distros: all <4>
88
- Topics:
89
- - Name: The Majestic Marmoset <5>
90
- File: the_majestic_marmoset <6>
91
- Distros: all
92
- - Name: The Curious Crocodile
93
- File: the_curious_crocodile
94
- Distros: openshift-online,openshift-enterprise <7>
95
- - Name: The Numerous Nematodes
96
- Dir: the_numerous_nematodes <8>
97
- Topics:
98
- - Name: The Wily Worm <9>
99
- File: the_wily_worm
100
- - Name: The Acrobatic Ascarid <= Sub-topic 2 name
101
- File: the_acrobatic_ascarid <= Sub-topic 2 file under <group dir>/<subtopic dir>
102
- ----
103
- <1> Record separator at the top of each topic group
104
- <2> Display name of topic group
105
- <3> Directory name of topic group
106
- <4> Which OpenShift versions this topic group is part of
107
- <5> Topic name
108
- <6> Topic file under the topic group dir without '.adoc'
109
- <7> Which OpenShift versions this topic is part of
110
- <8> This topic is actually a subtopic group. Instead of a `File` path it has a `Dir` path and `Topics`, just like a top-level topic group.
111
- <9> Topics belonging to a subtopic group are listed just like regular topics with a `Name` and `File`.
112
-
113
- === Notes on "Distros"
114
-
115
- * The "Distros" setting is optional for topic groups and topic items. When the "Distros" setting is absent, the system treats the topic group or topic as though the user had set "Distros: all".
116
- * The "all" value for "Distros" is a synonym for "openshift-origin,openshift-enterprise,openshift-online".
117
- * The "all" value trumps other values, so "openshift-online,all" is treated as "all"
118
-
119
- == Understanding the Complete Distribution Condition Chain
120
- It is important to understand the ordering of distribution conditionals in determining whether or not a specific piece of content appears in the documentation set. The hierarchy is fairly straightforward:
121
-
122
- 1. Topic group "Distros" setting from `_build_cfg.yml`
123
- 2. Topic item "Distros" setting from `_build_cfg.yml`
124
- 3. Document-level `ifdef/endif` blocks
125
-
126
- In this manner:
127
-
128
- * If a topic group is configured with "Distros: openshift-online", the entire group will be skipped for OpenShift Enterprise and OpenShift Origin, regardless of the Topic-level and document-level content rules within that group.
129
-
130
- * When a topic group is available to all Distros, but a specific topic item is limited, the topic group will appear for all distros and the specific topic item will only appear for the indicated distros.
131
-
132
- == Live Editing
133
- If you would like to work on one of the documentation files in an editing environment that automatically redraws the resulting HTML, follow these steps.
134
-
135
- === Prerequisites
136
- You will need the following tools in your editing environment:
137
-
138
- * A bash shell environment (Linux distributions and OS X include these out of the box, for Windows consider http://cygwin.com/[Cygwin])
139
- * https://www.ruby-lang.org/en/[Ruby]
140
- * http://www.git-scm.com/[git]
141
- * A web browser (Firefox, Chrome or Safari) with the http://livereload.com/[LiveReload] extension
142
-
143
- With these tools available, first perform a one-time setup:
144
-
145
- 1. Clone the https://github.com/openshift/openshift-docs[openshift-docs] repo from GitHub:
146
- +
147
- ----
148
- $ git clone https://github.com/openshift/openshift-docs.git
149
- ----
150
- 2. From the cloned directory, run a bundle install:
151
- +
152
- ----
153
- $ cd openshift-docs
154
- $ bundle install
155
- ----
156
- +
157
- TIP: If you don't have bundler installed, you can get it by running `gem install bundler`
158
-
159
- That's it for setup, the next section explains how to run the LiveReload system.
160
-
161
- === Running with LiveReload
162
- Once you've installed the link:#prerequisites[prerequisites] you can fire up the LiveReload setup as follows:
163
-
164
- 1. From the `openshift-docs` directory, run a preliminary build:
165
- +
166
- ----
167
- $ cd openshift-docs
168
- $ bundle exec rake build
169
- ----
170
- 2. Now open the generated HTML file in your browser. It will be under `openshift-docs/_preview/<distro>/<branch>` with the same path and filename as the original file. The only difference will be the name ending in '.html' instead of '.adoc'.
171
- 3. Now start up the `guard` utility:
172
- +
173
- ----
174
- $ bundle exec guard
175
- ----
176
- +
177
- TIP: This utility will run in the terminal where you started it, so you should leave it running off to the side and use other terminals for regular tasks.
178
- 4. Finally, back in your browser, enable the LiveReload plugin in the same tab where the preview file is displayed. You will know this step succeeded if the LiveReload icon changes, and if you see output similar to the following in the terminal where `guard` is running:
179
- +
180
- ----
181
- [1] guard(main)> 17:29:22 - INFO - Browser connected.
182
- ----
183
-
184
- That's it. Now any changes that you make to the source file will automatically trigger a rebuild of the target HTML file.
185
-
186
- === Clean Up
187
- The `.gitignore` file is set up to prevent anything under `_preview` and `_package` from being committed. However, you can reset the environment manually by running:
188
-
189
- ----
190
- $ bundle exec rake clean
191
- ----
192
-
193
- == Creating New Topic Pages
194
- The layout and style rules for new documentation are largely described in an upcoming style guide (delivery date TBD). However, a few important rules are listed here because they affect the way that the pages are rendered.
195
-
196
- The top matter of any new topic page must have the following format:
197
-
198
- ----
199
- = Human-Readable Topic Title
200
- {product-author}
201
- {product-version}
202
- :data-uri:
203
- :icons:
204
- ----
205
-
206
- * The article title goes on the first line with a level 1 header markup (=)
207
- * The [x-]`{product-author}` and [x-]`{product-version}` are AsciiDoc attributes that get replaced dynamically when the docs are generated.
208
- * The `:data-uri:` attribute tells AsciiDoctor to embed any images directly in the HTML.
209
- * The `:icons:` attribute tells AsciiDoctor to use cool icons for admonition blocks.
210
-
211
- After the heading block and a single whitespace line, you can include any content for the topic.
212
-
213
- NOTE: Any section headers within the article must be level 2 (==) or lower. Try to be consistent about level-nesting; it won't break AsciiDoctor to jump from a level 1 section header down to level 3, but it isn't good form.
214
-
215
-
216
- == Contacts
217
-
218
- For questions or comments about the documentation system:
219
-
220
- * OpenShift team members can be found on the http://webchat.freenode.net/?randomnick=1&channels=openshift&uio=d4[#openshift] and http://webchat.freenode.net/?randomnick=1&channels=openshift-dev&uio=d4[#openshift-dev channels] on http://www.freenode.net/[FreeNode].
221
- * You can also join the http://lists.openshift.redhat.com/openshiftmm/listinfo/users[Users] or http://lists.openshift.redhat.com/openshiftmm/listinfo/dev[Developers] mailing list.
@@ -6,11 +6,11 @@ require 'ascii_binder/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ascii_binder"
8
8
  spec.version = AsciiBinder::VERSION
9
- spec.authors = ["N. Harrison Ripps"]
10
- spec.email = ["nhr@redhat.com"]
9
+ spec.authors = ["N. Harrison Ripps","Jason Frey"]
10
+ spec.email = ["nhr@redhat.com","jfrey@redhat.com"]
11
11
  spec.summary = %q{Builder for multi product documention websites.}
12
12
  spec.description = %q{Builder for multi product documention websites.}
13
- spec.homepage = "http://github.com/redhataccess/ascii_binder"
13
+ spec.homepage = "http://asciibinder.org/"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ascii_binder/helpers'
4
+ require 'pathname'
5
+ require 'trollop'
6
+
7
+ include AsciiBinder::Helpers
8
+
9
+ def call_generate(distro,page=nil)
10
+ if page == ''
11
+ page = nil
12
+ end
13
+ begin
14
+ generate_docs(distro,page)
15
+ rescue Exception => e
16
+ Trollop::die "Could not generate docs: #{e.message}"
17
+ end
18
+ end
19
+
20
+ SUB_COMMANDS = %w{help build watch package clean create}
21
+ Trollop::options do
22
+ banner <<-EOF
23
+ Usage:
24
+ #$0 <command> <repo_dir>
25
+
26
+ Commands:
27
+ build (default action)
28
+ Builds the HTML docs in the indicated repo dir
29
+ create
30
+ Generates a new AsciiBinder repo at the indicated dir
31
+ watch
32
+ Starts Guard, which automatically regenerates changed HTML
33
+ files on the working branch in the repo dir
34
+ package
35
+ Builds and packages the static HTML for all of the sites
36
+ defined in the _distro_config.yml file
37
+ clean
38
+ Remove _preview, _publish and _package dirs created by
39
+ other AsciiBinder operations.
40
+
41
+ Options:
42
+ EOF
43
+ stop_on SUB_COMMANDS
44
+ end
45
+
46
+ cmd = ARGV.shift
47
+ repo_dir = nil
48
+
49
+ if cmd.nil?
50
+ cmd = "build"
51
+ elsif not SUB_COMMANDS.include?(cmd)
52
+ if not ARGV.empty?
53
+ Trollop::die "'#{cmd}' is not a valid asciibinder subcommand. Legal values are '#{SUB_COMMANDS.join('\', \'')}'."
54
+ else
55
+ repo_dir = Pathname.new(cmd)
56
+ cmd = "build"
57
+ end
58
+ end
59
+
60
+ cmd_opts = case cmd
61
+ when "build"
62
+ Trollop::options do
63
+ banner <<-EOF
64
+ Usage:
65
+ #$0 build <options> <repo_dir>
66
+
67
+ Description:
68
+ This is the default behavior for the asciibinder utility. When run,
69
+ AsciiBinder reads the _distro_config.yml file out of the working
70
+ branch of the indicated repo directory and based on that, proceeds to
71
+ build the working branch version of the documentation for each distro.
72
+
73
+ Once the working branch version is built, AsciiBinder cycles through
74
+ the other branches named in the _distro_config.yml file until all of
75
+ the permutations have been built.
76
+
77
+ The available options enable you to limit the scope of the build work,
78
+ as described by the options themselves. Note that the format for the
79
+ "--page" option is:
80
+
81
+ <topic_group>:<topic_file>
82
+
83
+ or for subtopics:
84
+
85
+ <topic_group>/<subtopic_group>:<topic_file>
86
+
87
+ However, if you want to use the --page option extensively, then be
88
+ aware of the `asciibinder watch` function, which does this for you
89
+ automatically as you change .adoc files in your working branch.
90
+
91
+ Options:
92
+ EOF
93
+ opt :distro, "Instead of building all distros, build branches only for the specified distro.", :default => ''
94
+ opt :page, "Build only the specified page for all distros and only the current working branch.", :default => ''
95
+ conflicts :distro, :page
96
+ end
97
+ when "create"
98
+ Trollop::options do
99
+ banner <<-EOF
100
+ Usage:
101
+ #$0 create <new_repo_dir>
102
+
103
+ Description:
104
+ Creates a new, bare AsciiBinder repo in the specified directory.
105
+ EOF
106
+ end
107
+ when "watch"
108
+ Trollop::options do
109
+ banner <<-EOF
110
+ Usage:
111
+ #$0 watch <repo_dir>
112
+
113
+ Description:
114
+ In watch mode, AsciiBinder starts a Guard process in the foreground.
115
+ This process watches the repo_dir for changes to the AsciiDoc (.adoc)
116
+ files. When a change occurs, AsciiBinder regenerates the specific
117
+ HTML output of the file that was changed, for the working branch only.
118
+
119
+ This is the equivalent of running:
120
+
121
+ $ asciibinder build --page='<topic_group>:<affected_file>'
122
+
123
+ ...except that the Guardfile automatically detects and runs this as
124
+ you work.
125
+
126
+ This is meant to be used in conjunction with a web browser that is
127
+ running a LiveReload plugin. If you are viewing the output HTML page
128
+ in a browser where LiveReload is active, then every time you save a
129
+ new version of the .adoc file, the new HTML is automatically
130
+ regenerated and your page view is automatically refreshed.
131
+ EOF
132
+ end
133
+ when "package"
134
+ Trollop::options do
135
+ banner <<-EOF
136
+ Usage:
137
+ #$0 package <options> <repo_dir>
138
+
139
+ Description:
140
+ Publish mode is similar to 'build' mode, but once all of the branches' of
141
+ HTML are generated, 'publish' goes on to organize the branch / distro
142
+ combinations that are described in _distro_config.yml into their "site"
143
+ layouts. As a final step, the site layouts are tarred and gzipped for
144
+ easy placement onto a production web server.
145
+
146
+ Options:
147
+ EOF
148
+ opt :site, "Instead of packaging every docs site, package the specified site only.", :default => ''
149
+ end
150
+ when "help"
151
+ Trollop::educate
152
+ end
153
+
154
+ if (not repo_dir.nil? and not ARGV.empty?) or (repo_dir.nil? and ARGV.length > 1)
155
+ Trollop::die "Too many arguments provided to ascii_binder: '#{ARGV.join(' ')}'. Exiting."
156
+ elsif repo_dir.nil?
157
+ if ARGV.length == 1
158
+ repo_dir = Pathname.new(ARGV.shift)
159
+ else
160
+ if not cmd == 'create'
161
+ repo_dir = Pathname.pwd
162
+ else
163
+ Trollop::die "Specify a name for the new repo directory."
164
+ end
165
+ end
166
+ end
167
+
168
+ # Validate the repo_dir path
169
+ if cmd == 'create'
170
+ if repo_dir.exist?
171
+ Trollop::die "The specified new repo directory '#{repo_dir}' already exists."
172
+ end
173
+ else
174
+ if not repo_dir.exist?
175
+ Trollop::die "The specified repo directory '#{repo_dir}' does not exist."
176
+ elsif not repo_dir.directory?
177
+ Trollop::die "The specified repo directory path '#{repo_dir}' is not a directory."
178
+ elsif not repo_dir.readable?
179
+ Trollop::die "The specified repo directory '#{repo_dir}' is not readable."
180
+ elsif not repo_dir.writable?
181
+ Trollop::die "The specified repo directory '#{repo_dir}' cannot be written to."
182
+ else
183
+ ['.git','_build_cfg.yml','_distro_map.yml','_templates'].each do |file|
184
+ if not File.exist?(File.join(repo_dir, file))
185
+ Trollop::die "The specified repo directory '#{repo_dir}' does not appear to be an AsciiBinder repo."
186
+ end
187
+ end
188
+ end
189
+ end
190
+
191
+ # Set the repo root
192
+ set_source_dir(File.expand_path(repo_dir))
193
+
194
+ # Change to the repo dir. This is necessary in order for
195
+ # AsciiDoctor to work properly.
196
+ if not cmd == 'create'
197
+ Dir.chdir source_dir
198
+ end
199
+
200
+ # Do the things with the stuff
201
+ case cmd
202
+ when "build"
203
+ build_distro = cmd_opts[:build] || ''
204
+ refresh_page = cmd_opts[:page] || ''
205
+ call_generate(build_distro,refresh_page)
206
+ when "package"
207
+ clean_up
208
+ call_generate('')
209
+ package_site = cmd_opts[:site] || ''
210
+ package_docs(package_site)
211
+ when "watch"
212
+ if not dir_empty?(preview_dir)
213
+ guardfile_path = File.join(Gem::Specification.find_by_name("ascii_binder").full_gem_path, 'Guardfile')
214
+ exec("guard -G #{guardfile_path}")
215
+ else
216
+ Trollop::die "Run 'asciibinder build' at least once before running 'asciibinder watch'."
217
+ end
218
+ when "clean"
219
+ clean_up
220
+ puts "Cleaned up #{repo_dir}."
221
+ when "create"
222
+ create_new_repo
223
+ puts "Created new repo in #{repo_dir}."
224
+ end
225
+
226
+ exit