asciidoctor-dita-map 0.9.1 → 0.9.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4eb319b4d8423d61539d7ec4816ccfac5499656cc15b739542ddb68023d210a0
4
- data.tar.gz: 768371877af9214c0d80db4e19f29db88ab85c00821a5965480bd7f5304c3f2a
3
+ metadata.gz: 7868b5b984e99b8e02f45f267b4d493943d4232c1dc69e52169e39076f42bc01
4
+ data.tar.gz: 664073302552d392ba455a64fa4f28affd2b3fa890dfb333620b077094291835
5
5
  SHA512:
6
- metadata.gz: d251c66f265772f85a48aee4e8da5c4f9902870e991074dfe10c12977fcbb5921c3a6b695108bfa0025becb1d97bd8cb19bd92fbbeee958b3a5958ed8cfead5f
7
- data.tar.gz: 0ed486763aa0b355ef4ec931ce87181ab2a6ca9c024e55d9ec03b2782c9ceed05f321ef396378e9421ad10a1ef13200fb05c954e30081af25397ab6905fe0846
6
+ metadata.gz: c707f1e3aedc8aaec0b8be683eb9b01df94c1ce7812a994d5d6d09e727de1bd4e3c2e66a4cd84fbb06cfcb0e7fdbc0528e3b6d992c4787d1e6537450aa2f2130
7
+ data.tar.gz: f7cfb07b8374bd7f5d20fcde17b2b9221a019bb236592860a09a73b87b9483f47eb65ee2e113a979a0268756f6d384fe4d463aa7a4048dd843261b8f5aebb8e9
@@ -30,11 +30,15 @@ class CatalogIncludeDirectives < Asciidoctor::Extensions::IncludeProcessor
30
30
 
31
31
  def process doc, reader, target, attributes
32
32
  offset = attributes['leveloffset'].to_i
33
+ chunk = attributes['chunk'] or nil
34
+ toc = attributes['toc'] or nil
33
35
 
34
36
  doc.catalog[:include_files] = [] unless doc.catalog[:include_files]
35
37
  doc.catalog[:include_files].append({
36
38
  :target => target,
37
- :offset => offset
39
+ :offset => offset,
40
+ :chunk => chunk,
41
+ :toc => toc
38
42
  })
39
43
 
40
44
  reader
data/lib/dita-map/cli.rb CHANGED
@@ -33,13 +33,16 @@ module AsciidoctorDitaMap
33
33
  def initialize name, argv
34
34
  @attr = []
35
35
  @opts = {
36
+ :chunk => true,
36
37
  :id => true,
37
38
  :navtitle => true,
38
39
  :output => false,
39
40
  :title => true,
41
+ :toc => true,
40
42
  :type => true,
41
43
  :self => false,
42
- :verbose => false
44
+ :verbose => false,
45
+ :zero_offset => false
43
46
  }
44
47
  @prep = []
45
48
  @name = name
@@ -82,16 +85,28 @@ module AsciidoctorDitaMap
82
85
  @opts[:title] = false
83
86
  end
84
87
 
88
+ opt.on('-C', '--no-chunk', 'do not generate the chunk attribute') do
89
+ @opts[:chunk] = false
90
+ end
91
+
85
92
  opt.on('-N', '--no-navtitle', 'do not generate the navtitle attribute') do
86
93
  @opts[:navtitle] = false
87
94
  end
88
95
 
96
+ opt.on('-O', '--no-toc', 'do not generate the toc attribute') do
97
+ @opts[:toc] = false
98
+ end
99
+
89
100
  opt.on('-T', '--no-type', 'do not generate the type attribute') do
90
101
  @opts[:type] = false
91
102
  end
92
103
 
93
104
  opt.separator ''
94
105
 
106
+ opt.on('-z', '--zero-offset', 'allow include directives with zero leveloffset') do
107
+ @opts[:zero_offset] = true
108
+ end
109
+
95
110
  opt.on('-v', '--verbose', 'report additional problems in the supplied files') do
96
111
  @opts[:verbose] = true
97
112
  end
@@ -123,20 +138,23 @@ module AsciidoctorDitaMap
123
138
  return args
124
139
  end
125
140
 
126
- def compose_mapref_attributes file_name, type
127
- target_file = file_name.sub(/\.adoc$/, '.ditamap')
128
- attributes = { 'href' => target_file, 'format' => 'ditamap' }
129
- attributes['type'] = type if @opts[:type]
141
+ def compose_mapref_attributes file_info, type
142
+ target_file = file_info[:target].sub(/\.adoc$/, '.ditamap')
143
+ attributes = { 'href' => target_file, 'format' => 'ditamap' }
144
+ attributes['type'] = type if @opts[:type]
145
+ attributes['chunk'] = file_info[:chunk] if @opts[:chunk] and file_info[:chunk]
146
+ attributes['toc'] = file_info[:toc] if @opts[:toc] and file_info[:toc]
130
147
 
131
148
  return attributes
132
149
  end
133
150
 
134
- def compose_topicref_attributes file_name, title, type
135
- target_file = file_name.sub(/\.adoc$/, '.dita')
136
-
151
+ def compose_topicref_attributes file_info, title, type
152
+ target_file = file_info[:target].sub(/\.adoc$/, '.dita')
137
153
  attributes = { 'href' => target_file }
138
154
  attributes['navtitle'] = title if @opts[:navtitle] and title
139
155
  attributes['type'] = type if @opts[:type] and type and ['concept', 'reference', 'task'].include? type
156
+ attributes['chunk'] = file_info[:chunk] if @opts[:chunk] and file_info[:chunk]
157
+ attributes['toc'] = file_info[:toc] if @opts[:toc] and file_info[:toc]
140
158
 
141
159
  return attributes
142
160
  end
@@ -210,16 +228,16 @@ module AsciidoctorDitaMap
210
228
  end
211
229
 
212
230
  if @opts[:self] and file
213
- attributes = compose_topicref_attributes file, map[:title], map[:type]
231
+ attributes = compose_topicref_attributes({ :target => file }, map[:title], map[:type])
214
232
  xml_self = xml_root.add_element('topicref', attributes)
215
233
  stack = [{ :offset => 0, :element => xml_self }]
216
234
  else
217
235
  stack = [{ :offset => 0, :element => xml_root }]
218
236
  end
219
237
 
220
- include_files.each do |file|
221
- target = file[:target]
222
- offset = file[:offset]
238
+ include_files.each do |file_info|
239
+ target = file_info[:target]
240
+ offset = file_info[:offset]
223
241
  last_offset = stack.last[:offset]
224
242
  full_path = base_dir + target
225
243
 
@@ -236,24 +254,28 @@ module AsciidoctorDitaMap
236
254
  end
237
255
 
238
256
  if offset == 0
239
- warn "#{@name}: warning: invalid leveloffset - expected 1, got 0: #{target}"
240
- offset = 1
257
+ if @opts[:zero_offset]
258
+ offset = 0
259
+ else
260
+ warn "#{@name}: warning: invalid leveloffset - expected 1, got 0: #{target}"
261
+ offset = 1
262
+ end
241
263
  elsif offset > last_offset and offset - last_offset > 1
242
264
  expected_offset = last_offset + 1
243
265
  warn "#{@name}: warning: invalid leveloffset - expected #{expected_offset}, got #{offset}: #{target}"
244
266
  end
245
267
 
246
- while stack.last[:offset] >= offset
268
+ while stack.length > 1 and stack.last[:offset] >= offset
247
269
  stack.pop
248
270
  end
249
271
 
250
272
  xml_parent = stack.last[:element]
251
273
 
252
274
  if include_type == 'map'
253
- attributes = compose_mapref_attributes target, include_type
275
+ attributes = compose_mapref_attributes file_info, include_type
254
276
  xml_element = xml_parent.add_element('mapref', attributes)
255
277
  else
256
- attributes = compose_topicref_attributes target, include_title, include_type
278
+ attributes = compose_topicref_attributes file_info, include_title, include_type
257
279
  xml_element = xml_parent.add_element('topicref', attributes)
258
280
  end
259
281
 
@@ -24,5 +24,5 @@
24
24
  # frozen_string_literal: true
25
25
 
26
26
  module AsciidoctorDitaMap
27
- VERSION = '0.9.1'
27
+ VERSION = '0.9.3'
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-dita-map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek