bookbindery 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bookbinder/cli.rb +2 -2
- data/lib/bookbinder/command_runner.rb +1 -1
- data/lib/bookbinder/commands/bind.rb +50 -134
- data/lib/bookbinder/config/bind_config_factory.rb +30 -0
- data/lib/bookbinder/config/local_bind_configuration.rb +23 -0
- data/lib/bookbinder/config/remote_bind_configuration.rb +52 -0
- data/lib/bookbinder/configuration.rb +5 -1
- data/lib/bookbinder/dita_html_to_middleman_formatter.rb +1 -1
- data/lib/bookbinder/dita_preprocessor.rb +66 -0
- data/lib/bookbinder/dita_section_gatherer_factory.rb +23 -0
- data/lib/bookbinder/{local_dita_to_html_converter.rb → dita_to_html_converter.rb} +7 -3
- data/lib/bookbinder/local_dita_section_gatherer.rb +31 -0
- data/lib/bookbinder/local_file_system_accessor.rb +10 -10
- data/lib/bookbinder/pdf_generator.rb +1 -1
- data/lib/bookbinder/publisher.rb +3 -3
- data/lib/bookbinder/remote_dita_section_gatherer.rb +35 -0
- data/lib/bookbinder/repositories/command_repository.rb +12 -5
- data/lib/bookbinder/repositories/section_repository.rb +1 -1
- data/lib/bookbinder/values/dita_section.rb +10 -1
- data/lib/bookbinder/values/output_locations.rb +61 -10
- data/master_middleman/bookbinder_helpers.rb +5 -15
- metadata +10 -5
- data/lib/bookbinder/dita_section_gatherer.rb +0 -30
- data/lib/bookbinder/local_dita_preprocessor.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e569c8b49b909c17b4b30acd65b3986b07ab304b
|
4
|
+
data.tar.gz: a55e74657a1f9e2e12c13de88fb9ae7e53d069d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19a3737931f428d599b991f09422bb307fb4749aa28729dcf8139a89e3b175c583497cafa28a0c68fcdd26baf0421318b05840d30d8dd16d4d29a9d7aab26b60
|
7
|
+
data.tar.gz: b3e5e09c41cf9db7dae8b231176b1ede5efa7a1e41c2472d01511ff54c44fb80be9a4540d6aee995df113151c944651577ca7d1c6c5e4363032738ba196f67fc
|
data/lib/bookbinder/cli.rb
CHANGED
@@ -39,7 +39,7 @@ module Bookbinder
|
|
39
39
|
begin
|
40
40
|
command_runner.run command_name, command_arguments
|
41
41
|
|
42
|
-
rescue
|
42
|
+
rescue Config::RemoteBindConfiguration::VersionUnsupportedError => e
|
43
43
|
logger.error "config.yml at version '#{e.message}' has an unsupported API."
|
44
44
|
1
|
45
45
|
rescue Configuration::CredentialKeyError => e
|
@@ -58,7 +58,7 @@ module Bookbinder
|
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
61
|
-
|
61
|
+
|
62
62
|
attr_reader :version_control_system
|
63
63
|
|
64
64
|
end
|
@@ -1,24 +1,22 @@
|
|
1
|
+
require_relative '../dita_section_gatherer_factory'
|
1
2
|
require_relative '../archive_menu_configuration'
|
2
|
-
require_relative '../
|
3
|
+
require_relative '../values/output_locations'
|
4
|
+
require_relative '../values/dita_section'
|
3
5
|
require_relative '../errors/cli_error'
|
4
|
-
require_relative '../directory_helpers'
|
5
|
-
require_relative '../publisher'
|
6
6
|
require_relative '../values/section'
|
7
|
-
require_relative '../
|
8
|
-
require_relative '../
|
9
|
-
require_relative '../values/output_locations'
|
7
|
+
require_relative '../publisher'
|
8
|
+
require_relative '../book'
|
10
9
|
require_relative 'naming'
|
11
10
|
|
12
11
|
module Bookbinder
|
13
12
|
module Commands
|
14
13
|
class Bind
|
15
|
-
VersionUnsupportedError = Class.new(RuntimeError)
|
16
|
-
|
17
14
|
include Bookbinder::DirectoryHelperMethods
|
18
15
|
include Commands::Naming
|
19
16
|
|
20
17
|
def initialize(logger,
|
21
18
|
config_fetcher,
|
19
|
+
config_factory,
|
22
20
|
archive_menu_config,
|
23
21
|
version_control_system,
|
24
22
|
file_system_accessor,
|
@@ -28,9 +26,11 @@ module Bookbinder
|
|
28
26
|
server_director,
|
29
27
|
context_dir,
|
30
28
|
dita_preprocessor,
|
31
|
-
cloner_factory
|
29
|
+
cloner_factory,
|
30
|
+
dita_section_gatherer_factory)
|
32
31
|
@logger = logger
|
33
32
|
@config_fetcher = config_fetcher
|
33
|
+
@config_factory = config_factory
|
34
34
|
@archive_menu_config = archive_menu_config
|
35
35
|
@version_control_system = version_control_system
|
36
36
|
@file_system_accessor = file_system_accessor
|
@@ -41,6 +41,7 @@ module Bookbinder
|
|
41
41
|
@context_dir = context_dir
|
42
42
|
@dita_preprocessor = dita_preprocessor
|
43
43
|
@cloner_factory = cloner_factory
|
44
|
+
@dita_section_gatherer_factory = dita_section_gatherer_factory
|
44
45
|
end
|
45
46
|
|
46
47
|
def usage
|
@@ -61,74 +62,39 @@ module Bookbinder
|
|
61
62
|
|
62
63
|
@section_repository = Repositories::SectionRepository.new(logger)
|
63
64
|
@gem_root = File.expand_path('../../../../', __FILE__)
|
64
|
-
|
65
|
+
publisher = Publisher.new(logger, sitemap_generator, static_site_generator, server_director, file_system_accessor)
|
65
66
|
|
66
67
|
bind_source, *options = cli_arguments
|
67
68
|
|
68
|
-
bind_config =
|
69
|
+
bind_config = config_factory.produce(bind_source)
|
70
|
+
|
69
71
|
@versions = bind_config.fetch(:versions, [])
|
70
72
|
@book_repo = bind_config[:book_repo]
|
71
73
|
|
72
|
-
output_paths = output_directory_paths(bind_source)
|
73
|
-
master_middleman_dir = output_paths.fetch(:master_middleman_dir)
|
74
|
-
output_dir = output_paths.fetch(:output_dir)
|
75
|
-
master_dir = File.join output_dir, 'master_middleman'
|
76
|
-
|
77
74
|
output_locations = OutputLocations.new(
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
formatted_dir = File.join(dita_home_dir, 'site_generator_ready'),
|
83
|
-
subnavs_for_layout_dir = File.join(workspace_dir, 'subnavs'),
|
84
|
-
dita_subnav_template_path = File.join(workspace_dir, 'subnavs', '_dita_subnav_template.erb')
|
75
|
+
context_dir: context_dir,
|
76
|
+
final_app_dir: final_app_directory,
|
77
|
+
layout_repo_dir: layout_repo_path(generate_local_repo_dir(context_dir, bind_source)),
|
78
|
+
local_repo_dir: generate_local_repo_dir(context_dir, bind_source)
|
85
79
|
)
|
86
80
|
|
87
|
-
prepare_directories(
|
88
|
-
output_dir,
|
89
|
-
workspace_dir,
|
90
|
-
master_middleman_dir,
|
91
|
-
master_dir,
|
92
|
-
dita_home_dir)
|
93
|
-
|
94
|
-
dita_section_config_hash = config.dita_sections || {}
|
95
|
-
dita_sections = dita_section_config_hash.map do |dita_section_config|
|
96
|
-
relative_path_to_dita_map = dita_section_config['ditamap_location']
|
97
|
-
full_name = dita_section_config.fetch('repository', {}).fetch('name')
|
98
|
-
target_ref = dita_section_config.fetch('repository', {})['ref']
|
99
|
-
directory = dita_section_config['directory']
|
100
|
-
|
101
|
-
DitaSection.new(nil, relative_path_to_dita_map, full_name, target_ref, directory, output_locations)
|
102
|
-
end
|
103
|
-
|
104
|
-
if bind_source == 'github'
|
105
|
-
dita_section_gatherer = DitaSectionGatherer.new(version_control_system, output_locations, logger)
|
106
|
-
gathered_dita_sections = dita_section_gatherer.gather(dita_sections, to: cloned_dita_dir)
|
107
|
-
else
|
108
|
-
gathered_dita_sections = dita_sections.map do |dita_section|
|
109
|
-
relative_path_to_dita_map = dita_section.ditamap_location
|
110
|
-
full_name = dita_section.full_name
|
111
|
-
target_ref = dita_section.target_ref
|
112
|
-
directory = dita_section.directory
|
81
|
+
prepare_directories(output_locations)
|
113
82
|
|
114
|
-
|
115
|
-
|
116
|
-
DitaSection.new(path_to_local_copy, relative_path_to_dita_map, full_name, target_ref, directory, output_locations)
|
117
|
-
end
|
118
|
-
end
|
83
|
+
dita_gatherer = dita_section_gatherer_factory.produce(bind_source, output_locations)
|
84
|
+
gathered_dita_sections = dita_gatherer.gather(config.dita_sections)
|
119
85
|
|
120
86
|
gathered_dita_sections.each do |dita_section|
|
121
87
|
dita_preprocessor.preprocess(dita_section,
|
122
|
-
subnavs_for_layout_dir,
|
123
|
-
dita_subnav_template_path)
|
88
|
+
output_locations.subnavs_for_layout_dir,
|
89
|
+
output_locations.dita_subnav_template_path)
|
124
90
|
end
|
125
91
|
|
126
92
|
cloner = cloner_factory.produce(
|
127
93
|
bind_source,
|
128
|
-
|
94
|
+
output_locations.local_repo_dir
|
129
95
|
)
|
130
96
|
sections = gather_sections(
|
131
|
-
|
97
|
+
output_locations.source_for_site_generator,
|
132
98
|
cloner,
|
133
99
|
('master' if options.include?('--ignore-section-refs'))
|
134
100
|
)
|
@@ -138,7 +104,7 @@ module Bookbinder
|
|
138
104
|
success = publisher.publish(
|
139
105
|
subnavs,
|
140
106
|
{verbose: cli_arguments.include?('--verbose')},
|
141
|
-
|
107
|
+
output_locations,
|
142
108
|
archive_menu_config.generate(bind_config, sections)
|
143
109
|
)
|
144
110
|
|
@@ -147,9 +113,9 @@ module Bookbinder
|
|
147
113
|
|
148
114
|
private
|
149
115
|
|
150
|
-
attr_reader :
|
151
|
-
:version_control_system,
|
116
|
+
attr_reader :version_control_system,
|
152
117
|
:config_fetcher,
|
118
|
+
:config_factory,
|
153
119
|
:archive_menu_config,
|
154
120
|
:logger,
|
155
121
|
:file_system_accessor,
|
@@ -159,7 +125,12 @@ module Bookbinder
|
|
159
125
|
:server_director,
|
160
126
|
:context_dir,
|
161
127
|
:dita_preprocessor,
|
162
|
-
:cloner_factory
|
128
|
+
:cloner_factory,
|
129
|
+
:dita_section_gatherer_factory
|
130
|
+
|
131
|
+
def generate_local_repo_dir(context_dir, bind_source)
|
132
|
+
File.expand_path('..', context_dir) if bind_source == 'local'
|
133
|
+
end
|
163
134
|
|
164
135
|
def gather_sections(workspace, cloner, ref_override)
|
165
136
|
config.sections.map do |attributes|
|
@@ -172,36 +143,24 @@ module Bookbinder
|
|
172
143
|
ref: target_ref,
|
173
144
|
parent_dir: workspace,
|
174
145
|
dir_name: directory)
|
175
|
-
@section_repository.get_instance(
|
176
|
-
|
177
|
-
|
178
|
-
|
146
|
+
@section_repository.get_instance(
|
147
|
+
attributes,
|
148
|
+
vcs_repo: vcs_repo,
|
149
|
+
destination_dir: workspace
|
150
|
+
) { |*args| Section.new(*args) }
|
179
151
|
end
|
180
152
|
end
|
181
153
|
|
182
|
-
def prepare_directories(
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
middleman_dir,
|
187
|
-
dita_processing_dir)
|
188
|
-
forget_sections(output_dir)
|
189
|
-
file_system_accessor.remove_directory File.join final_app, '.'
|
190
|
-
file_system_accessor.remove_directory dita_processing_dir
|
191
|
-
|
192
|
-
copy_directory_from_gem 'template_app', final_app
|
193
|
-
copy_directory_from_gem 'master_middleman', middleman_dir
|
194
|
-
file_system_accessor.copy File.join(master_middleman_dir, '.'), middleman_dir
|
195
|
-
|
196
|
-
copy_version_master_middleman(middleman_source)
|
197
|
-
end
|
154
|
+
def prepare_directories(locations)
|
155
|
+
forget_sections(locations.output_dir)
|
156
|
+
file_system_accessor.remove_directory(File.join(locations.final_app_dir, '.'))
|
157
|
+
file_system_accessor.remove_directory(locations.dita_home_dir)
|
198
158
|
|
199
|
-
|
200
|
-
|
201
|
-
|
159
|
+
copy_directory_from_gem('template_app', locations.final_app_dir)
|
160
|
+
copy_directory_from_gem('master_middleman', locations.site_generator_home)
|
161
|
+
file_system_accessor.copy(File.join(locations.layout_repo_dir, '.'), locations.site_generator_home)
|
202
162
|
|
203
|
-
|
204
|
-
file_system_accessor.copy File.join(@gem_root, "#{dir}/."), output_dir
|
163
|
+
copy_version_master_middleman(locations.source_for_site_generator)
|
205
164
|
end
|
206
165
|
|
207
166
|
# Copy the index file from each version into the version's directory. Because version
|
@@ -226,61 +185,18 @@ module Bookbinder
|
|
226
185
|
end
|
227
186
|
end
|
228
187
|
|
229
|
-
def
|
230
|
-
|
231
|
-
|
232
|
-
{
|
233
|
-
final_app_dir: final_app_directory,
|
234
|
-
local_repo_dir: local_repo_dir,
|
235
|
-
output_dir: File.join(context_dir, output_dir_name),
|
236
|
-
master_middleman_dir: layout_repo_path(local_repo_dir)
|
237
|
-
}
|
188
|
+
def forget_sections(middleman_scratch)
|
189
|
+
file_system_accessor.remove_directory File.join middleman_scratch, '.'
|
238
190
|
end
|
239
191
|
|
240
|
-
def
|
241
|
-
|
242
|
-
sections: config.sections,
|
243
|
-
book_repo: config.book_repo,
|
244
|
-
host_for_sitemap: config.public_host,
|
245
|
-
archive_menu: config.archive_menu
|
246
|
-
}
|
247
|
-
|
248
|
-
optional_arguments = {}
|
249
|
-
optional_arguments.merge!(template_variables: config.template_variables) if config.respond_to?(:template_variables)
|
250
|
-
if binding_from_github? bind_source
|
251
|
-
config.versions.each { |version| arguments[:sections].concat sections_from version }
|
252
|
-
optional_arguments.merge!(versions: config.versions)
|
253
|
-
end
|
254
|
-
|
255
|
-
arguments.merge! optional_arguments
|
192
|
+
def copy_directory_from_gem(dir, output_dir)
|
193
|
+
file_system_accessor.copy File.join(@gem_root, "#{dir}/."), output_dir
|
256
194
|
end
|
257
195
|
|
258
196
|
def config
|
259
197
|
config_fetcher.fetch_config
|
260
198
|
end
|
261
199
|
|
262
|
-
def sections_from(version)
|
263
|
-
Dir.mktmpdir('book_checkout') do |temp_workspace|
|
264
|
-
book = Book.from_remote(logger: logger,
|
265
|
-
full_name: config.book_repo,
|
266
|
-
destination_dir: temp_workspace,
|
267
|
-
ref: version,
|
268
|
-
git_accessor: version_control_system,
|
269
|
-
)
|
270
|
-
|
271
|
-
book_checkout_value = File.join temp_workspace, book.directory
|
272
|
-
config_file = File.join book_checkout_value, 'config.yml'
|
273
|
-
attrs = YAML.load(File.read(config_file))['sections']
|
274
|
-
raise VersionUnsupportedError.new(version) if attrs.nil?
|
275
|
-
|
276
|
-
attrs.map do |section_hash|
|
277
|
-
section_hash['repository']['ref'] = version
|
278
|
-
section_hash['directory'] = File.join(version, section_hash['directory'])
|
279
|
-
section_hash
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
200
|
def layout_repo_path(local_repo_dir)
|
285
201
|
if config.has_option?('layout_repo')
|
286
202
|
if local_repo_dir
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'local_bind_configuration'
|
2
|
+
require_relative 'remote_bind_configuration'
|
3
|
+
|
4
|
+
module Bookbinder
|
5
|
+
module Config
|
6
|
+
class BindConfigFactory
|
7
|
+
def initialize(logger, version_control_system, config_fetcher)
|
8
|
+
@logger = logger
|
9
|
+
@version_control_system = version_control_system
|
10
|
+
@config_fetcher = config_fetcher
|
11
|
+
end
|
12
|
+
|
13
|
+
def produce(bind_source)
|
14
|
+
if bind_source == 'github' && config.has_option?('versions')
|
15
|
+
RemoteBindConfiguration.new(logger, version_control_system, config).to_h
|
16
|
+
else
|
17
|
+
LocalBindConfiguration.new(config).to_h
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def config
|
24
|
+
config_fetcher.fetch_config
|
25
|
+
end
|
26
|
+
|
27
|
+
attr_reader :logger, :version_control_system, :config_fetcher
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Bookbinder
|
2
|
+
module Config
|
3
|
+
class LocalBindConfiguration
|
4
|
+
def initialize(base_config)
|
5
|
+
@base_config = base_config
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_h
|
9
|
+
{
|
10
|
+
sections: base_config.sections,
|
11
|
+
book_repo: base_config.book_repo,
|
12
|
+
host_for_sitemap: base_config.public_host,
|
13
|
+
archive_menu: base_config.archive_menu,
|
14
|
+
template_variables: base_config.template_variables
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :base_config
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Bookbinder
|
2
|
+
module Config
|
3
|
+
class RemoteBindConfiguration
|
4
|
+
VersionUnsupportedError = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def initialize(logger, version_control_system, base_config)
|
7
|
+
@logger = logger
|
8
|
+
@version_control_system = version_control_system
|
9
|
+
@base_config = base_config
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
sections = base_config.sections
|
14
|
+
base = {
|
15
|
+
sections: sections,
|
16
|
+
book_repo: base_config.book_repo,
|
17
|
+
host_for_sitemap: base_config.public_host,
|
18
|
+
archive_menu: base_config.archive_menu,
|
19
|
+
versions: base_config.versions,
|
20
|
+
template_variables: base_config.template_variables
|
21
|
+
}
|
22
|
+
base_config.versions.each { |version| sections.concat(sections_from(version)) }
|
23
|
+
base
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :logger, :version_control_system, :base_config
|
29
|
+
|
30
|
+
def sections_from(version)
|
31
|
+
Dir.mktmpdir('book_checkout') do |temp_workspace|
|
32
|
+
book = Book.from_remote(logger: logger,
|
33
|
+
full_name: base_config.book_repo,
|
34
|
+
destination_dir: temp_workspace,
|
35
|
+
ref: version,
|
36
|
+
git_accessor: version_control_system)
|
37
|
+
|
38
|
+
book_checkout_value = File.join temp_workspace, book.directory
|
39
|
+
config_file = File.join book_checkout_value, 'config.yml'
|
40
|
+
attrs = YAML.load(File.read(config_file))['sections']
|
41
|
+
raise VersionUnsupportedError.new(version) if attrs.nil?
|
42
|
+
|
43
|
+
attrs.map do |section_hash|
|
44
|
+
section_hash['repository']['ref'] = version
|
45
|
+
section_hash['directory'] = File.join(version, section_hash['directory'])
|
46
|
+
section_hash
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -132,7 +132,7 @@ module Bookbinder
|
|
132
132
|
end
|
133
133
|
|
134
134
|
CONFIG_REQUIRED_KEYS = %w(book_repo public_host)
|
135
|
-
CONFIG_OPTIONAL_KEYS = %w(archive_menu
|
135
|
+
CONFIG_OPTIONAL_KEYS = %w(archive_menu layout_repo versions pdf_index cred_repo pdf)
|
136
136
|
|
137
137
|
CONFIG_REQUIRED_KEYS.each do |method_name|
|
138
138
|
define_method(method_name) do
|
@@ -150,6 +150,10 @@ module Bookbinder
|
|
150
150
|
config.fetch('sections', [])
|
151
151
|
end
|
152
152
|
|
153
|
+
def dita_sections
|
154
|
+
config.fetch('dita_sections', {})
|
155
|
+
end
|
156
|
+
|
153
157
|
def has_option?(key)
|
154
158
|
@config.has_key?(key)
|
155
159
|
end
|
@@ -10,7 +10,7 @@ module Bookbinder
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def format_html(src, dest)
|
13
|
-
all_files_with_ext = file_system_accessor.find_files_with_ext('
|
13
|
+
all_files_with_ext = file_system_accessor.find_files_with_ext('html', src)
|
14
14
|
|
15
15
|
all_files_with_ext.map do |filepath|
|
16
16
|
file_text = file_system_accessor.read filepath
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'values/subnav'
|
2
|
+
|
3
|
+
module Bookbinder
|
4
|
+
class DitaPreprocessor
|
5
|
+
|
6
|
+
ACCEPTED_IMAGE_FORMATS = %w(png jpeg jpg svg gif bmp tif tiff eps)
|
7
|
+
|
8
|
+
def initialize(dita_converter, dita_formatter, local_fs_accessor)
|
9
|
+
@dita_converter = dita_converter
|
10
|
+
@dita_formatter = dita_formatter
|
11
|
+
@local_fs_accessor = local_fs_accessor
|
12
|
+
end
|
13
|
+
|
14
|
+
def preprocess(dita_section,
|
15
|
+
subnavs_dir,
|
16
|
+
dita_subnav_template_path)
|
17
|
+
if dita_section.ditamap_location
|
18
|
+
dita_converter.convert_to_html dita_section, write_to: dita_section.html_from_dita_section_dir
|
19
|
+
|
20
|
+
generate_subnav(dita_section, dita_subnav_template_path, subnavs_dir)
|
21
|
+
end
|
22
|
+
|
23
|
+
dita_formatter.format_html dita_section.html_from_dita_section_dir, dita_section.formatted_section_dir
|
24
|
+
|
25
|
+
copy_images(dita_section)
|
26
|
+
|
27
|
+
local_fs_accessor.copy_contents(dita_section.formatted_section_dir,
|
28
|
+
dita_section.section_source_for_site_generator)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :dita_converter, :dita_formatter, :local_fs_accessor
|
34
|
+
|
35
|
+
def generate_subnav(dita_section, dita_subnav_template_path, subnavs_dir)
|
36
|
+
dita_subnav_template_text = local_fs_accessor.read(dita_subnav_template_path)
|
37
|
+
|
38
|
+
tocjs_text = local_fs_accessor.read(File.join dita_section.html_from_dita_section_dir, 'index.html')
|
39
|
+
json_props_location = File.join('dita-subnav-props.json')
|
40
|
+
props_file_location = File.join(subnavs_dir, json_props_location)
|
41
|
+
|
42
|
+
subnav = dita_formatter.format_subnav(dita_section,
|
43
|
+
dita_subnav_template_text,
|
44
|
+
json_props_location,
|
45
|
+
tocjs_text)
|
46
|
+
|
47
|
+
local_fs_accessor.write text: subnav.json_links, to: props_file_location
|
48
|
+
|
49
|
+
local_fs_accessor.write text: subnav.text,
|
50
|
+
to: File.join(subnavs_dir, "dita_subnav.erb")
|
51
|
+
end
|
52
|
+
|
53
|
+
def copy_images(dita_section)
|
54
|
+
image_paths = ACCEPTED_IMAGE_FORMATS.map do |format|
|
55
|
+
local_fs_accessor.find_files_with_ext(format, dita_section.path_to_local_repo)
|
56
|
+
end.flatten
|
57
|
+
|
58
|
+
image_paths.each do |image_path|
|
59
|
+
local_fs_accessor.copy_including_intermediate_dirs(image_path,
|
60
|
+
dita_section.path_to_local_repo,
|
61
|
+
dita_section.section_source_for_site_generator)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'local_dita_section_gatherer'
|
2
|
+
require_relative 'remote_dita_section_gatherer'
|
3
|
+
|
4
|
+
module Bookbinder
|
5
|
+
class DitaSectionGathererFactory
|
6
|
+
def initialize(version_control_system, view_updater)
|
7
|
+
@version_control_system = version_control_system
|
8
|
+
@view_updater = view_updater
|
9
|
+
end
|
10
|
+
|
11
|
+
def produce(source_location, output_locations)
|
12
|
+
if source_location == 'github'
|
13
|
+
RemoteDitaSectionGatherer.new(version_control_system, view_updater, output_locations)
|
14
|
+
else
|
15
|
+
LocalDitaSectionGatherer.new(output_locations)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :version_control_system, :view_updater
|
22
|
+
end
|
23
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../bookbinder/values/dita_section'
|
2
2
|
|
3
3
|
module Bookbinder
|
4
|
-
class
|
4
|
+
class DitaToHtmlConverter
|
5
5
|
DitaToHtmlLibraryFailure = Class.new(RuntimeError)
|
6
6
|
|
7
7
|
def initialize(sheller, path_to_dita_ot_library)
|
@@ -10,7 +10,6 @@ module Bookbinder
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def convert_to_html(dita_section, write_to: nil)
|
13
|
-
absolute_path_to_ditamap = File.join dita_section.path_to_local_repo, dita_section.ditamap_location
|
14
13
|
classpath = "#{path_to_dita_ot_library}/lib/xercesImpl.jar:" +
|
15
14
|
"#{path_to_dita_ot_library}/lib/xml-apis.jar:" +
|
16
15
|
"#{path_to_dita_ot_library}/lib/resolver.jar:" +
|
@@ -27,7 +26,12 @@ module Bookbinder
|
|
27
26
|
"-Doutput.dir=#{write_to} " +
|
28
27
|
"-Dtranstype='tocjs' " +
|
29
28
|
"-Ddita.temp.dir='/tmp/bookbinder_dita' " +
|
30
|
-
"-
|
29
|
+
"-Dgenerate.copy.outer='2' " +
|
30
|
+
"-Dargs.input=#{dita_section.absolute_path_to_ditamap} "
|
31
|
+
|
32
|
+
if dita_section.absolute_path_to_ditaval
|
33
|
+
command += "-Dargs.filter=#{dita_section.absolute_path_to_ditaval} "
|
34
|
+
end
|
31
35
|
|
32
36
|
begin
|
33
37
|
sheller.run_command(command)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Bookbinder
|
2
|
+
class LocalDitaSectionGatherer
|
3
|
+
def initialize(output_locations)
|
4
|
+
@output_locations = output_locations
|
5
|
+
end
|
6
|
+
|
7
|
+
def gather(dita_section_config_hash)
|
8
|
+
dita_section_config_hash.map do |dita_section_config|
|
9
|
+
relative_path_to_dita_map = dita_section_config['ditamap_location']
|
10
|
+
relative_path_to_dita_val = dita_section_config['ditaval_location']
|
11
|
+
full_name = dita_section_config.fetch('repository', {}).fetch('name')
|
12
|
+
target_ref = dita_section_config.fetch('repository', {})['ref']
|
13
|
+
directory = dita_section_config['directory']
|
14
|
+
path_to_local_copy = output_locations.local_repo_dir.join(directory)
|
15
|
+
|
16
|
+
DitaSection.new(path_to_local_copy,
|
17
|
+
relative_path_to_dita_map,
|
18
|
+
relative_path_to_dita_val,
|
19
|
+
full_name,
|
20
|
+
target_ref,
|
21
|
+
directory,
|
22
|
+
output_locations)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :output_locations
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -40,20 +40,20 @@ module Bookbinder
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def copy_contents(src, dest)
|
43
|
-
|
43
|
+
unless File.directory?(dest)
|
44
|
+
FileUtils.mkdir_p(dest)
|
45
|
+
end
|
46
|
+
|
47
|
+
contents = Dir.glob File.join(src, '**/*')
|
44
48
|
contents.each do |dir|
|
45
49
|
FileUtils.cp_r dir, dest
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
extended_dest = File.join dest, relative_path_to_dir
|
54
|
-
FileUtils.mkdir_p extended_dest
|
55
|
-
copy_contents dir, extended_dest
|
56
|
-
end
|
53
|
+
def copy_including_intermediate_dirs(file, root, dest)
|
54
|
+
path_within_destination = relative_path_from(root, file)
|
55
|
+
extended_dest = File.dirname(File.join dest, path_within_destination)
|
56
|
+
copy file, extended_dest
|
57
57
|
end
|
58
58
|
|
59
59
|
def rename_file(path, new_name)
|
@@ -62,7 +62,7 @@ module Bookbinder
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def find_files_with_ext(ext, path)
|
65
|
-
Dir[File.join path, '**/*'].select { |file| File.basename(file).
|
65
|
+
Dir[File.join path, '**/*'].select { |file| File.basename(file).include?(".#{ext}") }
|
66
66
|
end
|
67
67
|
|
68
68
|
def relative_path_from(src, target)
|
data/lib/bookbinder/publisher.rb
CHANGED
@@ -17,8 +17,8 @@ module Bookbinder
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def publish(subnavs, cli_options, output_paths, publish_config)
|
20
|
-
intermediate_directory = output_paths.
|
21
|
-
final_app_dir = output_paths.
|
20
|
+
intermediate_directory = output_paths.output_dir
|
21
|
+
final_app_dir = output_paths.final_app_dir
|
22
22
|
master_dir = File.join intermediate_directory, 'master_middleman'
|
23
23
|
workspace_dir = File.join master_dir, 'source'
|
24
24
|
build_directory = File.join master_dir, 'build/.'
|
@@ -50,7 +50,7 @@ module Bookbinder
|
|
50
50
|
@static_site_generator.run(middleman_dir,
|
51
51
|
workspace_dir,
|
52
52
|
publish_config.fetch(:template_variables, {}),
|
53
|
-
output_paths
|
53
|
+
output_paths.local_repo_dir,
|
54
54
|
cli_options[:verbose],
|
55
55
|
subnavs,
|
56
56
|
publish_config[:host_for_sitemap],
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../../lib/bookbinder/deprecated_logger'
|
2
|
+
require_relative '../../lib/bookbinder/values/dita_section'
|
3
|
+
|
4
|
+
module Bookbinder
|
5
|
+
class RemoteDitaSectionGatherer
|
6
|
+
def initialize(version_control_system, view_updater, output_locations)
|
7
|
+
@version_control_system = version_control_system
|
8
|
+
@view_updater = view_updater
|
9
|
+
@cloned_dita_dir = output_locations.cloned_dita_dir
|
10
|
+
@output_locations = output_locations
|
11
|
+
end
|
12
|
+
|
13
|
+
def gather(dita_section_config_hash)
|
14
|
+
dita_section_config_hash.map do |dita_section_config|
|
15
|
+
view_updater.log "Gathering " + "#{dita_section_config.fetch('repository', {}).fetch('name')}".cyan
|
16
|
+
version_control_system.clone("git@github.com:#{dita_section_config.fetch('repository', {}).fetch('name')}",
|
17
|
+
dita_section_config['directory'],
|
18
|
+
path: cloned_dita_dir)
|
19
|
+
|
20
|
+
DitaSection.new(cloned_dita_dir.join(dita_section_config['directory']),
|
21
|
+
dita_section_config['ditamap_location'],
|
22
|
+
dita_section_config['ditaval_location'],
|
23
|
+
dita_section_config.fetch('repository', {}).fetch('name'),
|
24
|
+
dita_section_config.fetch('repository', {})['ref'],
|
25
|
+
dita_section_config['directory'],
|
26
|
+
output_locations)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :version_control_system, :view_updater, :cloned_dita_dir, :output_locations
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -4,15 +4,16 @@ end
|
|
4
4
|
require_relative '../configuration_fetcher'
|
5
5
|
require_relative '../configuration_validator'
|
6
6
|
require_relative '../dita_html_to_middleman_formatter'
|
7
|
+
require_relative '../dita_preprocessor'
|
7
8
|
require_relative '../html_document_manipulator'
|
8
9
|
require_relative '../ingest/cloner_factory'
|
9
|
-
require_relative '../
|
10
|
-
require_relative '../local_dita_to_html_converter'
|
10
|
+
require_relative '../dita_to_html_converter'
|
11
11
|
require_relative '../local_file_system_accessor'
|
12
12
|
require_relative '../middleman_runner'
|
13
13
|
require_relative '../spider'
|
14
14
|
require_relative '../subnav_formatter'
|
15
15
|
require_relative '../yaml_loader'
|
16
|
+
require_relative '../config/bind_config_factory'
|
16
17
|
|
17
18
|
module Bookbinder
|
18
19
|
module Repositories
|
@@ -69,6 +70,7 @@ module Bookbinder
|
|
69
70
|
@bind ||= Commands::Bind.new(
|
70
71
|
logger,
|
71
72
|
configuration_fetcher,
|
73
|
+
bind_config_factory,
|
72
74
|
ArchiveMenuConfiguration.new(
|
73
75
|
loader: config_loader,
|
74
76
|
config_filename: 'bookbinder.yml'
|
@@ -81,7 +83,8 @@ module Bookbinder
|
|
81
83
|
server_director,
|
82
84
|
File.absolute_path('.'),
|
83
85
|
dita_preprocessor,
|
84
|
-
Ingest::ClonerFactory.new(logger, version_control_system)
|
86
|
+
Ingest::ClonerFactory.new(logger, version_control_system),
|
87
|
+
DitaSectionGathererFactory.new(version_control_system, logger)
|
85
88
|
)
|
86
89
|
end
|
87
90
|
|
@@ -135,14 +138,14 @@ module Bookbinder
|
|
135
138
|
|
136
139
|
def dita_preprocessor
|
137
140
|
@dita_preprocessor ||=
|
138
|
-
|
141
|
+
DitaPreprocessor.new(local_dita_processor,
|
139
142
|
dita_html_to_middleman_formatter,
|
140
143
|
local_file_system_accessor)
|
141
144
|
end
|
142
145
|
|
143
146
|
def local_dita_processor
|
144
147
|
@local_dita_processor ||=
|
145
|
-
|
148
|
+
DitaToHtmlConverter.new(Sheller.new(logger),
|
146
149
|
ENV['PATH_TO_DITA_OT_LIBRARY'])
|
147
150
|
end
|
148
151
|
|
@@ -163,6 +166,10 @@ module Bookbinder
|
|
163
166
|
def local_file_system_accessor
|
164
167
|
@local_file_system_accessor ||= LocalFileSystemAccessor.new
|
165
168
|
end
|
169
|
+
|
170
|
+
def bind_config_factory
|
171
|
+
@bind_config_factory ||= Config::BindConfigFactory.new(logger, version_control_system, configuration_fetcher)
|
172
|
+
end
|
166
173
|
end
|
167
174
|
end
|
168
175
|
end
|
@@ -10,7 +10,7 @@ module Bookbinder
|
|
10
10
|
def get_instance(attributes,
|
11
11
|
vcs_repo: nil,
|
12
12
|
destination_dir: Dir.mktmpdir,
|
13
|
-
build
|
13
|
+
&build)
|
14
14
|
repository_config = attributes['repository']
|
15
15
|
raise "section repository '#{repository_config}' is not a hash" unless repository_config.is_a?(Hash)
|
16
16
|
raise "section repository '#{repository_config}' missing name key" unless repository_config['name']
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Bookbinder
|
2
2
|
DitaSection = Struct.new(:path_to_local_repo,
|
3
3
|
:ditamap_location,
|
4
|
+
:ditaval_location,
|
4
5
|
:full_name,
|
5
6
|
:target_ref,
|
6
7
|
:directory,
|
7
8
|
:output_locations) do
|
8
9
|
def subnav
|
9
10
|
namespace = directory.gsub('/', '_')
|
10
|
-
template = "
|
11
|
+
template = "dita_subnav"
|
11
12
|
{namespace => template}
|
12
13
|
end
|
13
14
|
|
@@ -22,5 +23,13 @@ module Bookbinder
|
|
22
23
|
def section_source_for_site_generator
|
23
24
|
File.join(output_locations.source_for_site_generator, directory)
|
24
25
|
end
|
26
|
+
|
27
|
+
def absolute_path_to_ditamap
|
28
|
+
ditamap_location ? File.join(path_to_local_repo, ditamap_location) : nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def absolute_path_to_ditaval
|
32
|
+
ditaval_location ? File.join(path_to_local_repo, ditaval_location) : nil
|
33
|
+
end
|
25
34
|
end
|
26
35
|
end
|
@@ -1,11 +1,62 @@
|
|
1
|
+
require_relative '../directory_helpers'
|
2
|
+
|
1
3
|
module Bookbinder
|
2
|
-
OutputLocations
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
class OutputLocations
|
5
|
+
attr_reader :final_app_dir, :layout_repo_dir
|
6
|
+
|
7
|
+
include DirectoryHelperMethods
|
8
|
+
|
9
|
+
def initialize(final_app_dir: nil, layout_repo_dir: nil, context_dir: nil, local_repo_dir: nil)
|
10
|
+
@final_app_dir = final_app_dir
|
11
|
+
@layout_repo_dir = layout_repo_dir
|
12
|
+
@context_dir = context_dir
|
13
|
+
@local_repo_dir = local_repo_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_dir
|
17
|
+
context_dir.join(output_dir_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def local_repo_dir
|
21
|
+
Pathname(@local_repo_dir) if @local_repo_dir
|
22
|
+
end
|
23
|
+
|
24
|
+
def dita_home_dir
|
25
|
+
output_dir.join('dita')
|
26
|
+
end
|
27
|
+
|
28
|
+
def cloned_dita_dir
|
29
|
+
dita_home_dir.join('dita_sections')
|
30
|
+
end
|
31
|
+
|
32
|
+
def html_from_dita_dir
|
33
|
+
dita_home_dir.join('html_from_dita')
|
34
|
+
end
|
35
|
+
|
36
|
+
def formatted_dir
|
37
|
+
dita_home_dir.join('site_generator_ready')
|
38
|
+
end
|
39
|
+
|
40
|
+
def site_generator_home
|
41
|
+
output_dir.join('master_middleman')
|
42
|
+
end
|
43
|
+
|
44
|
+
def source_for_site_generator
|
45
|
+
site_generator_home.join('source')
|
46
|
+
end
|
47
|
+
|
48
|
+
def subnavs_for_layout_dir
|
49
|
+
source_for_site_generator.join('subnavs')
|
50
|
+
end
|
51
|
+
|
52
|
+
def dita_subnav_template_path
|
53
|
+
source_for_site_generator.join('subnavs', '_dita_subnav_template.erb')
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def context_dir
|
59
|
+
Pathname(@context_dir)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -30,26 +30,16 @@ module Bookbinder
|
|
30
30
|
attributes,
|
31
31
|
local_repo_dir,
|
32
32
|
git_accessor).
|
33
|
-
|
33
|
+
tap { |repo| repo.copy_from_local(workspace) }
|
34
34
|
else
|
35
35
|
GitHubRepository.
|
36
36
|
build_from_remote(bookbinder_logger, attributes, git_accessor).
|
37
37
|
tap { |repo| repo.copy_from_remote(workspace, 'master') }
|
38
38
|
end
|
39
|
-
example = code_example_repo.get_instance(attributes,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
copied,
|
44
|
-
_,
|
45
|
-
destination_dir,
|
46
|
-
directory_name) {
|
47
|
-
CodeExample.new(path_to_repository,
|
48
|
-
full_name,
|
49
|
-
copied,
|
50
|
-
destination_dir,
|
51
|
-
directory_name)
|
52
|
-
})
|
39
|
+
example = code_example_repo.get_instance(attributes, vcs_repo: vcs_repo) {
|
40
|
+
|path, name, copied, _, dest, directory|
|
41
|
+
CodeExample.new(path, name, copied, dest, directory)
|
42
|
+
}
|
53
43
|
snippet, language = code_example_reader.get_snippet_and_language_at(at,
|
54
44
|
example.path_to_repository,
|
55
45
|
example.copied,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookbindery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Grafton
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: install_bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2015-03-
|
18
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: fog-aws
|
@@ -329,6 +329,9 @@ files:
|
|
329
329
|
- lib/bookbinder/commands/tag.rb
|
330
330
|
- lib/bookbinder/commands/update_local_doc_repos.rb
|
331
331
|
- lib/bookbinder/commands/version.rb
|
332
|
+
- lib/bookbinder/config/bind_config_factory.rb
|
333
|
+
- lib/bookbinder/config/local_bind_configuration.rb
|
334
|
+
- lib/bookbinder/config/remote_bind_configuration.rb
|
332
335
|
- lib/bookbinder/configuration.rb
|
333
336
|
- lib/bookbinder/configuration_fetcher.rb
|
334
337
|
- lib/bookbinder/configuration_validator.rb
|
@@ -337,7 +340,9 @@ files:
|
|
337
340
|
- lib/bookbinder/directory_helpers.rb
|
338
341
|
- lib/bookbinder/distributor.rb
|
339
342
|
- lib/bookbinder/dita_html_to_middleman_formatter.rb
|
340
|
-
- lib/bookbinder/
|
343
|
+
- lib/bookbinder/dita_preprocessor.rb
|
344
|
+
- lib/bookbinder/dita_section_gatherer_factory.rb
|
345
|
+
- lib/bookbinder/dita_to_html_converter.rb
|
341
346
|
- lib/bookbinder/errors/cli_error.rb
|
342
347
|
- lib/bookbinder/git_accessor.rb
|
343
348
|
- lib/bookbinder/git_client.rb
|
@@ -346,13 +351,13 @@ files:
|
|
346
351
|
- lib/bookbinder/ingest/cloner_factory.rb
|
347
352
|
- lib/bookbinder/ingest/git_hub_repository_cloner.rb
|
348
353
|
- lib/bookbinder/ingest/local_filesystem_cloner.rb
|
349
|
-
- lib/bookbinder/
|
350
|
-
- lib/bookbinder/local_dita_to_html_converter.rb
|
354
|
+
- lib/bookbinder/local_dita_section_gatherer.rb
|
351
355
|
- lib/bookbinder/local_file_system_accessor.rb
|
352
356
|
- lib/bookbinder/middleman_runner.rb
|
353
357
|
- lib/bookbinder/pdf_generator.rb
|
354
358
|
- lib/bookbinder/publisher.rb
|
355
359
|
- lib/bookbinder/pusher.rb
|
360
|
+
- lib/bookbinder/remote_dita_section_gatherer.rb
|
356
361
|
- lib/bookbinder/remote_yaml_credential_provider.rb
|
357
362
|
- lib/bookbinder/repositories/command_repository.rb
|
358
363
|
- lib/bookbinder/repositories/section_repository.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Bookbinder
|
2
|
-
class DitaSectionGatherer
|
3
|
-
def initialize(version_control_system, output_locations, view_updater)
|
4
|
-
@version_control_system = version_control_system
|
5
|
-
@output_locations = output_locations
|
6
|
-
@view_updater = view_updater
|
7
|
-
end
|
8
|
-
|
9
|
-
def gather(dita_sections, to: nil)
|
10
|
-
dita_sections.map do |dita_section|
|
11
|
-
view_updater.log "Gathering " + "#{dita_section.full_name}".cyan
|
12
|
-
version_control_system.clone("git@github.com:#{dita_section.full_name}",
|
13
|
-
dita_section.directory,
|
14
|
-
path: to)
|
15
|
-
|
16
|
-
DitaSection.new(File.join(to, dita_section.directory),
|
17
|
-
dita_section.ditamap_location,
|
18
|
-
dita_section.full_name,
|
19
|
-
dita_section.target_ref,
|
20
|
-
dita_section.directory,
|
21
|
-
output_locations)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
attr_reader :version_control_system, :view_updater, :output_locations
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require_relative 'values/subnav'
|
2
|
-
|
3
|
-
module Bookbinder
|
4
|
-
class LocalDitaPreprocessor
|
5
|
-
|
6
|
-
def initialize(dita_converter, dita_formatter, local_file_system_accessor)
|
7
|
-
@dita_converter = dita_converter
|
8
|
-
@dita_formatter = dita_formatter
|
9
|
-
@local_file_system_accessor = local_file_system_accessor
|
10
|
-
end
|
11
|
-
|
12
|
-
def preprocess(dita_section,
|
13
|
-
subnavs_dir,
|
14
|
-
dita_subnav_template_path)
|
15
|
-
dita_converter.convert_to_html dita_section, write_to: dita_section.html_from_dita_section_dir
|
16
|
-
|
17
|
-
dita_formatter.format_html dita_section.html_from_dita_section_dir, dita_section.formatted_section_dir
|
18
|
-
|
19
|
-
dita_subnav_template_text = local_file_system_accessor.read(dita_subnav_template_path)
|
20
|
-
tocjs_text = local_file_system_accessor.read(File.join dita_section.html_from_dita_section_dir, 'index.html')
|
21
|
-
|
22
|
-
json_props_location = File.join(dita_section.directory + '-props.json')
|
23
|
-
props_file_location = File.join(subnavs_dir, json_props_location)
|
24
|
-
|
25
|
-
subnav = dita_formatter.format_subnav(dita_section,
|
26
|
-
dita_subnav_template_text,
|
27
|
-
json_props_location,
|
28
|
-
tocjs_text)
|
29
|
-
|
30
|
-
local_file_system_accessor.write text: subnav.json_links, to: props_file_location
|
31
|
-
|
32
|
-
local_file_system_accessor.write text: subnav.text,
|
33
|
-
to: File.join(subnavs_dir,
|
34
|
-
filename="#{dita_section.directory}_subnav.erb")
|
35
|
-
|
36
|
-
local_file_system_accessor.copy_named_directory_with_path('images',
|
37
|
-
dita_section.html_from_dita_section_dir,
|
38
|
-
dita_section.section_source_for_site_generator)
|
39
|
-
|
40
|
-
local_file_system_accessor.copy_contents(dita_section.formatted_section_dir,
|
41
|
-
dita_section.section_source_for_site_generator)
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
attr_reader :dita_converter, :dita_formatter, :local_file_system_accessor
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|