giblish 0.7.5 → 0.8.2

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
  SHA256:
3
- metadata.gz: 19bcb7fd2f476219f4f104e6e86a8688a3729225444e18d8c0c67e9288a42835
4
- data.tar.gz: 2c1d85d59fe970d2fd5739fc1e1f2aa3099d128514bea3e3d8fb810205b11491
3
+ metadata.gz: 56f7e50e079748482350108862650f943cd6266864b285a1845808443dd46489
4
+ data.tar.gz: '0911983f515dd0e8719ef9836b69182f5e148b17101414cc703c080ee4681370'
5
5
  SHA512:
6
- metadata.gz: d56e1b40199396e95ad66f9a1f319ff42efd6aac68db62e3e9c5b8ff593ef79f6e155999ad83fce8666c04e8f674dd8c073b305e0a33d5dde738c04a4f09fb4a
7
- data.tar.gz: df30010468ce07b912cb4d2f75e66db05a3396452d15436e52b18516408b9b67b052829520d149c0c101be12615752a4fcfb4ef0950aecef91eb990132cc34c9
6
+ metadata.gz: 57c8f2974c53343bca7b7bd92e2417441e1c203acbac40e3e35df0502a72eb8d305bc611850c8772675f75938df61c7f4c8032124273677c7ed7e95249066ef3
7
+ data.tar.gz: 056b23e064ec6b71c96ef6071e5e8fe870693c0950999bea083c23e45d678287c8390f1da4343710ec853e5969632fb1e940fc9177ed7d1a5d430bcff3faa3f6
data/.rubocop.yml CHANGED
@@ -1,7 +1,6 @@
1
1
 
2
2
  AllCops:
3
- TargetRubyVersion: 2.3
4
- Enabled: true
3
+ TargetRubyVersion: 2.7
5
4
 
6
5
  Style/StringLiterals:
7
6
  EnforcedStyle: double_quotes
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.7.3
data/docs/README.adoc CHANGED
@@ -12,7 +12,7 @@ a destination directory tree containing the corresponding html or pdf files
12
12
  and adds some handy tools for easier navigation of the resulting files.
13
13
 
14
14
  An example of how giblish can generate the master branch of the official asciidoc.org
15
- documentation git repo can be found at http://www.rillbert.se/adoc/examples/adocorg/master/myindex.html
15
+ documentation git repo can be found at https://www.rillbert.se/asciidoctor_docs/master/myindex.html
16
16
 
17
17
  The added tools include:
18
18
 
@@ -338,10 +338,9 @@ accessible at www.mywebsite.com/cgi-bin/giblish-search.cgi
338
338
 
339
339
  In my case this returns `/var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib/giblish.rb`. This means that I will find the script in the same directory, i.e. `/var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib`.
340
340
 
341
- . Copy the server side script to the /cgi-bin dir on the web server. In this example the cgi-bin dir
342
- is configured to be /var/www/cgi-bin
341
+ . Copy the server side script to the /cgi-bin dir on the web server. In this example the cgi-bin dir is configured to be `/var/www/cgi-bin`
343
342
  +
344
- scp /var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib/giblish-search.rb rillbert@my.web.server.org:/var/www/cgi-bin/giblish-search.cgi
343
+ scp /var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib/giblish-search.cgi rillbert@my.web.server.org:/var/www/cgi-bin/giblish-search.cgi
345
344
 
346
345
  ////
347
346
 
data/giblish.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  EOF
19
19
  spec.homepage = "https://github.com/rillbert/giblish"
20
20
  spec.license = "MIT"
21
- spec.required_ruby_version = ">= 2.3"
21
+ spec.required_ruby_version = ">= 2.7"
22
22
 
23
23
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
24
24
  # delete this section to allow pushing this gem to any host.
@@ -38,12 +38,13 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "rake", "~> 11.0"
39
39
  spec.add_development_dependency "oga", "~> 2.15"
40
40
  spec.add_development_dependency 'thor', '~> 0.20.3'
41
+ spec.add_development_dependency "asciidoctor-mathematical", "~> 0.3.5"
41
42
 
42
43
  # Usage: spec.add_runtime_dependency "[gem name]", [[version]]
43
- spec.add_runtime_dependency "asciidoctor", "~>2.0", ">= 2.0.10"
44
- spec.add_runtime_dependency "asciidoctor-diagram", ["~> 1.5"]
45
- spec.add_runtime_dependency "asciidoctor-pdf", ["~> 1.5", ">= 1.5.3"]
46
- spec.add_runtime_dependency "git", "~> 1.7"
47
- spec.add_runtime_dependency "rouge", "~> 3.24"
48
- spec.add_runtime_dependency "prawn-svg", "~> 0.30.0"
44
+ spec.add_runtime_dependency "asciidoctor", "~>2.0", ">= 2.0.16"
45
+ spec.add_runtime_dependency "asciidoctor-diagram", ["~> 2.1"]
46
+ spec.add_runtime_dependency "asciidoctor-pdf", ["~> 1.6", ">= 1.6.0"]
47
+ spec.add_runtime_dependency "git", "~> 1.9"
48
+ spec.add_runtime_dependency "rouge", "~> 3.0"
49
+ spec.add_runtime_dependency "prawn-svg", "~> 0.32.0"
49
50
  end
@@ -1,19 +1,13 @@
1
-
2
1
  require_relative "cmdline"
3
2
  require_relative "core"
4
3
  require_relative "utils"
5
4
 
6
5
  module Giblish
6
+ # The 'main' class of giblish
7
7
  class Application
8
-
9
- # return exit status (0 for success)
10
- def run_with_args(args)
11
- run args
12
- end
13
-
14
8
  # does not return, exits with status code
15
9
  def run_from_cmd_line
16
- status = run ARGV
10
+ status = run(ARGV)
17
11
  exit(status)
18
12
  end
19
13
 
@@ -27,36 +21,45 @@ module Giblish
27
21
 
28
22
  # Parse cmd line
29
23
  cmdline = CmdLineParser.new args
30
-
31
24
  Giblog.logger.debug { "cmd line args: #{cmdline.args}" }
32
25
 
33
- # Convert using given args
26
+ exit_code = execute_conversion(cmdline)
27
+ Giblog.logger.info { "Giblish is done!" } if exit_code.zero?
28
+ exit_code
29
+ end
30
+
31
+ private
32
+
33
+ # Convert using given args
34
+ # return exit code (0 for success)
35
+ def execute_conversion(cmdline)
34
36
  conv_error = false
35
37
  begin
36
- if cmdline.args[:gitRepoRoot]
37
- Giblog.logger.info { "User asked to parse a git repo" }
38
- gc = GitRepoConverter.new cmdline.args
39
- conv_error = gc.convert
40
- else
41
- tc = FileTreeConverter.new cmdline.args
42
- conv_error = tc.convert
43
- end
44
- Giblog.logger.info { "Giblish is done!" }
45
- rescue Exception => e
38
+ conv_error = converter_factory(cmdline).convert
39
+ rescue StandardError => e
46
40
  log_error e
47
41
  conv_error = true
48
42
  end
49
43
  conv_error ? 1 : 0
50
44
  end
51
45
 
52
- private
46
+ # return the converter corresponding to the given cmd line
47
+ # options
48
+ def converter_factory(cmdline)
49
+ if cmdline.args[:gitRepoRoot]
50
+ Giblog.logger.info { "User asked to parse a git repo" }
51
+ GitRepoConverter.new(cmdline.args)
52
+ else
53
+ FileTreeConverter.new(cmdline.args)
54
+ end
55
+ end
53
56
 
54
- def log_error(ex)
57
+ def log_error(exc)
55
58
  Giblog.logger.error do
56
59
  <<~ERR_MSG
57
- Error: #{ex.message}
60
+ Error: #{exc.message}
58
61
  Backtrace:
59
- \t#{ex.backtrace.join("\n\t")}
62
+ \t#{exc.backtrace.join("\n\t")}
60
63
 
61
64
  cmdline.usage
62
65
  ERR_MSG
@@ -1,4 +1,3 @@
1
-
2
1
  module Giblish
3
2
  # Builds an asciidoc page with an svg image with a
4
3
  # digraph showing how documents reference each other.
@@ -6,16 +5,14 @@ module Giblish
6
5
  # Graphviz is used as the graph generator and must be available
7
6
  # as a valid engine via asciidoctor-diagram for this class to work.
8
7
  class GraphBuilderGraphviz
9
-
10
8
  # the dependency graph relies on graphwiz (dot), check if we can access that
11
9
  def self.supported
12
- return !Giblish.which('dot').nil?
10
+ !Giblish.which("dot").nil?
13
11
  end
14
12
 
15
13
  # Supported options:
16
14
  # :extension - file extension for URL links (default is .html)
17
15
  def initialize(processed_docs, paths, deployment_info, options = {})
18
-
19
16
  # this class relies on graphwiz (dot), make sure we can access that
20
17
  raise "Could not find the 'dot' tool needed to generate a dependency graph!" unless GraphBuilderGraphviz.supported
21
18
 
@@ -28,20 +25,19 @@ module Giblish
28
25
  @paths = paths
29
26
  @deployment_info = deployment_info
30
27
  @converter_options = options.dup
31
- # @options = options.dup
32
28
  @extension = @converter_options.key?(:extension) ? options[:extension] : "html"
33
29
  @docid_cache = DocidCollector.docid_cache
34
30
  @docid_deps = DocidCollector.docid_deps
35
31
  @dep_graph = build_dep_graph
36
32
  @search_opts = {
37
- web_assets_top: @deployment_info.web_path,
38
- search_assets_top: @deployment_info.search_assets_path,
33
+ web_assets_top: @deployment_info.web_path,
34
+ search_assets_top: @deployment_info.search_assets_path
39
35
  }
40
36
  end
41
37
 
42
38
  # get the asciidoc source for the document.
43
- def source(make_searchable = false)
44
- <<~DOC_STR
39
+ def source(make_searchable: false)
40
+ s = <<~DOC_STR
45
41
  #{generate_header}
46
42
  #{add_search_box if make_searchable}
47
43
  #{generate_graph_header}
@@ -49,6 +45,7 @@ module Giblish
49
45
  #{generate_deps}
50
46
  #{generate_footer}
51
47
  DOC_STR
48
+ s
52
49
  end
53
50
 
54
51
  def cleanup
@@ -56,7 +53,7 @@ module Giblish
56
53
  # when creating the document dependency graph
57
54
  adoc_diag_cache = @paths.dst_root_abs.join(".asciidoctor")
58
55
  FileUtils.remove_dir(adoc_diag_cache) if adoc_diag_cache.directory?
59
- Giblog.logger.info {"Removing cached files at: #{@paths.dst_root_abs.join("docdeps.svg").to_s}"}
56
+ Giblog.logger.info { "Removing cached files at: #{@paths.dst_root_abs.join('docdeps.svg')}" }
60
57
  @paths.dst_root_abs.join("docdeps.svg").delete
61
58
  end
62
59
 
@@ -70,13 +67,13 @@ module Giblish
70
67
  doc.src_file.to_s.eql? src_file
71
68
  end
72
69
  raise "Inconsistent docs when building graph!! found no match for #{src_file}" if d.nil?
70
+
73
71
  result[d] = id_array if d.converted
74
72
  end
75
73
  result
76
74
  end
77
75
 
78
76
  def generate_graph_header
79
- t = Time.now
80
77
  <<~DOC_STR
81
78
  Below is a graph that visualizes what documents (by doc-id) a specific
82
79
  document references.
@@ -89,7 +86,7 @@ module Giblish
89
86
  fillcolor="#ebf26680",
90
87
  style="filled,solid"
91
88
  ]
92
-
89
+
93
90
  rankdir="LR"
94
91
 
95
92
  DOC_STR
@@ -115,10 +112,10 @@ module Giblish
115
112
  end
116
113
 
117
114
  def add_search_box
118
- Giblish::generate_search_box_html(
119
- @converter_options[:attributes]["stylesheet"],
120
- "/cgi-bin/giblish-search.cgi",
121
- @search_opts
115
+ Giblish.generate_search_box_html(
116
+ @converter_options[:attributes]["stylesheet"],
117
+ "/cgi-bin/giblish-search.cgi",
118
+ @search_opts
122
119
  )
123
120
  end
124
121
 
@@ -126,18 +123,20 @@ module Giblish
126
123
  # split title into multiple rows if it is too long
127
124
  line_length = 15
128
125
  lines = [""]
129
- info.title.split(" ").inject("") do |l,w|
130
- line = l + " " + w
131
- lines[-1] = line
132
- if line.length > line_length
133
- # create a new, empty, line
134
- lines << ""
135
- ""
136
- else
137
- line
126
+ unless info&.title.nil?
127
+ info.title.split(" ").inject("") do |l, w|
128
+ line = "#{l} #{w}"
129
+ lines[-1] = line
130
+ if line.length > line_length
131
+ # create a new, empty, line
132
+ lines << ""
133
+ ""
134
+ else
135
+ line
136
+ end
138
137
  end
139
- end unless info.title.nil?
140
- title = lines.select { |l| l.length > 0 }.map {|l| l}.join("\n")
138
+ end
139
+ title = lines.select { |l| l.length.positive? }.map { |l| l }.join("\n")
141
140
 
142
141
  # create the label used to display the node in the graph
143
142
  dot_entry = if info.doc_id.nil?
@@ -151,12 +150,12 @@ module Giblish
151
150
  # add clickable links in the case of html output (this is not supported
152
151
  # out-of-the-box for pdf).
153
152
  rp = info.rel_path.sub_ext(".#{@extension}")
154
- case @extension
155
- when "html"
156
- dot_entry += ", URL=\"#{rp}\" ]"
157
- else
158
- dot_entry += " ]"
159
- end
153
+ dot_entry += case @extension
154
+ when "html"
155
+ ", URL=\"#{rp}\" ]"
156
+ else
157
+ " ]"
158
+ end
160
159
  doc_dict[doc_id] = dot_entry
161
160
  end
162
161
 
@@ -172,10 +171,9 @@ module Giblish
172
171
  node_dict = node_dict.sort.reverse.to_h
173
172
 
174
173
  # produce the string with all node entries
175
- node_str = node_dict.map do |k,v|
174
+ node_dict.map do |_k, v|
176
175
  v
177
176
  end.join("\n")
178
- node_str
179
177
  end
180
178
 
181
179
  def generate_deps
@@ -183,7 +181,7 @@ module Giblish
183
181
  @dep_graph.each do |info, targets|
184
182
  # set either the real or the generated id as source
185
183
  src_part = if info.doc_id.nil?
186
- "\"#{@noid_docs[info]}\""
184
+ "\"#{@noid_docs[info]}\""
187
185
  else
188
186
  "\"#{info.doc_id}\""
189
187
  end
@@ -208,11 +206,11 @@ module Giblish
208
206
  end
209
207
  end
210
208
 
209
+ # specializes generation of a document dependency graph for
210
+ # docs rendered from a git repo.
211
211
  class GitGraphBuilderGraphviz < GraphBuilderGraphviz
212
- def initialize(processed_docs, paths, deployment_info, options = {}, git_repo)
212
+ def initialize(processed_docs, paths, deployment_info, options = {}, _git_repo)
213
213
  super(processed_docs, paths, deployment_info, options)
214
214
  end
215
215
  end
216
216
  end
217
-
218
-
@@ -6,7 +6,6 @@ require_relative "gititf"
6
6
  require_relative "docinfo"
7
7
 
8
8
  module Giblish
9
-
10
9
  # Base class with common functionality for all index builders
11
10
  class BasicIndexBuilder
12
11
  # set up the basic index building info
@@ -19,29 +18,42 @@ module Giblish
19
18
  @src_str = ""
20
19
  @manage_docid = handle_docid
21
20
  @search_opts = {
22
- web_assets_top: @deployment_info.web_path,
23
- search_assets_top: @deployment_info.search_assets_path,
21
+ web_assets_top: @deployment_info.web_path,
22
+ search_assets_top: @deployment_info.search_assets_path
24
23
  }
25
24
  end
26
25
 
27
- def source(dep_graph_exists = false, make_searchable = false)
26
+ def source(dep_graph_exists: false, make_searchable: false)
28
27
  <<~DOC_STR
29
28
  #{generate_title_and_header}
29
+
30
30
  #{generate_date_info}
31
+
31
32
  #{add_search_box if make_searchable}
32
- #{generate_tree(dep_graph_exists)}
33
+
34
+ #{add_docid_info if @manage_docid}
35
+
36
+ #{add_depgraph_id if dep_graph_exists}
37
+
38
+ #{generate_tree}
39
+
33
40
  #{generate_details}
41
+
34
42
  #{generate_footer}
35
43
  DOC_STR
36
44
  end
37
45
 
38
46
  protected
47
+
48
+ def source_root
49
+ @paths.src_root_abs
50
+ end
51
+
39
52
  def generate_title_and_header
40
53
  <<~DOC_HEADER
41
54
  = Document index
42
- from #{@paths.src_root_abs}
55
+ from #{source_root}
43
56
  :icons: font
44
-
45
57
  DOC_HEADER
46
58
  end
47
59
 
@@ -50,7 +62,6 @@ module Giblish
50
62
  <<~SRC_FILE_TXT
51
63
  Source file::
52
64
  #{doc_info.src_file}
53
-
54
65
  SRC_FILE_TXT
55
66
  end
56
67
 
@@ -62,14 +73,14 @@ module Giblish
62
73
  end
63
74
 
64
75
  def add_search_box
65
- Giblish::generate_search_box_html(
66
- @converter.converter_options[:attributes]["stylesheet"],
67
- "/cgi-bin/giblish-search.cgi",
68
- @search_opts
76
+ Giblish.generate_search_box_html(
77
+ @converter.converter_options[:attributes]["stylesheet"],
78
+ "/cgi-bin/giblish-search.cgi",
79
+ @search_opts
69
80
  )
70
81
  end
71
82
 
72
- def get_docid_statistics
83
+ def docid_statistics
73
84
  largest = ""
74
85
  clash = []
75
86
  @processed_docs.each do |d|
@@ -82,52 +93,42 @@ module Giblish
82
93
  # find the duplicate doc ids (if any)
83
94
  duplicates = clash.select { |id| clash.count(id) > 1 }.uniq.sort
84
95
 
85
- return largest,duplicates
96
+ [largest, duplicates]
86
97
  end
87
98
 
88
- def generate_doc_id_info(dep_graph_exists)
89
- largest,duplicates = get_docid_statistics
90
- docid_info_str = if ! @manage_docid
91
- ""
92
- else
93
- "The 'largest' document id found when resolving :docid: tags in all documents is *#{largest}*."
94
- end
95
-
96
- docid_warn_str = if duplicates.length.zero?
97
- ""
98
- else
99
- "WARNING: The following document ids are used for more than one document. " +
100
- "_#{duplicates.map {|id| id.to_s}.join(",") }_"
101
- end
99
+ def add_docid_info
100
+ largest, duplicates = docid_statistics
101
+ <<~DOC_ID_INFO
102
+ *Document id numbers:* The 'largest' document id found when resolving
103
+ :docid: tags in all documents is *#{largest}*.
104
+
105
+ #{if duplicates.length.zero?
106
+ ''
107
+ else
108
+ 'WARNING: The following document ids are used for '\
109
+ 'more than one document. '\
110
+ "_#{duplicates.map(&:to_s).join(',')}_"
111
+ end}
112
+
113
+ DOC_ID_INFO
114
+ end
102
115
 
116
+ def add_depgraph_id
103
117
  # include link to dependency graph if it exists
104
- dep_graph_str = if dep_graph_exists
105
- "_(a visual graph of document dependencies can be found " \
106
- "<<./graph.adoc#,here>>)_"
107
- else
108
- ""
109
- end
110
-
111
- if @manage_docid
112
- <<~DOC_ID_INFO
113
- *Document id numbers:* #{docid_info_str} #{dep_graph_str}
114
-
115
- #{docid_warn_str}
116
-
117
- DOC_ID_INFO
118
- else
119
- ""
120
- end
118
+ <<~DEPGRAPH_STR
119
+ _A visual graph of document dependencies can be found
120
+ <<./graph.adoc#,here>>
121
+ DEPGRAPH_STR
121
122
  end
122
123
 
123
- def generate_tree(dep_graph_exists)
124
+ def generate_tree
124
125
  # output tree intro
125
- tree_string = <<~DOC_HEADER
126
- #{generate_doc_id_info dep_graph_exists}
127
-
128
- [subs=\"normal\"]
129
- ----
130
- DOC_HEADER
126
+ tree_string = String.new(
127
+ <<~DOC_HEADER
128
+ [subs=\"normal\"]
129
+ ----
130
+ DOC_HEADER
131
+ )
131
132
 
132
133
  # build up tree of paths
133
134
  root = PathTree.new
@@ -153,10 +154,11 @@ module Giblish
153
154
 
154
155
  private
155
156
 
156
- def generate_conversion_info(d)
157
- return "" if d.stderr.empty?
157
+ def generate_conversion_info(doc_info)
158
+ return "" if doc_info.stderr.empty?
159
+
158
160
  # extract conversion warnings from asciddoctor std err
159
- conv_warnings = d.stderr.gsub(/^/, " * ")
161
+ conv_warnings = doc_info.stderr.gsub(/^/, " * ")
160
162
 
161
163
  # assemble info to index page
162
164
  <<~CONV_INFO
@@ -198,7 +200,7 @@ module Giblish
198
200
 
199
201
  # Calculate padding to get (conv issues) and details aligned between entries
200
202
  padding = 70
201
- [doc_title, prefix_str, warning_label].each {|p| padding -= p.length}
203
+ [doc_title, prefix_str, warning_label].each { |p| padding -= p.length }
202
204
  padding = 0 unless padding.positive?
203
205
  "#{prefix_str} #{doc_link}#{' ' * padding}#{warning_label} #{doc_details}"
204
206
  end
@@ -222,51 +224,51 @@ module Giblish
222
224
  end
223
225
 
224
226
  # Derived classes can override this with useful info
225
- def generate_history_info(_d)
227
+ def generate_history_info(_doc_info)
226
228
  ""
227
229
  end
228
230
 
229
- def generate_detail_fail(d)
231
+ def generate_detail_fail(doc_info)
230
232
  <<~FAIL_INFO
231
- === #{d.src_file}
233
+ === #{doc_info.src_file}
232
234
 
233
235
  #{display_source_file(d)}
234
236
 
235
237
  Error detail::
236
- #{d.stderr}
238
+ #{doc_info.stderr}
237
239
 
238
240
  ''''
239
241
 
240
242
  FAIL_INFO
241
243
  end
242
244
 
243
- def generate_detail(d)
245
+ def generate_detail(doc_info)
244
246
  # Generate detail info
245
- purpose_str = if d.purpose_str.nil?
247
+ purpose_str = if doc_info.purpose_str.nil?
246
248
  ""
247
249
  else
248
- "Purpose::\n#{d.purpose_str}"
250
+ "Purpose::\n#{doc_info.purpose_str}"
249
251
  end
250
252
 
251
- doc_id_str = if !d.doc_id.nil? && @manage_docid
252
- "Doc id::\n_#{d.doc_id}_"
253
+ doc_id_str = if !doc_info.doc_id.nil? && @manage_docid
254
+ "Doc id::\n_#{doc_info.doc_id}_"
253
255
  else
254
256
  ""
255
257
  end
256
258
 
257
259
  <<~DETAIL_SRC
258
- [[#{Giblish.to_valid_id(d.title.encode("utf-8"))}]]
259
- === #{d.title.encode("utf-8")}
260
+ [[#{Giblish.to_valid_id(doc_info.title.encode('utf-8'))}]]
261
+ === #{doc_info.title.encode('utf-8')}
260
262
 
261
263
  #{doc_id_str}
262
264
 
263
265
  #{purpose_str}
264
266
 
265
- #{generate_conversion_info d}
267
+ #{generate_conversion_info doc_info}
266
268
 
267
- #{display_source_file(d)}
269
+ #{display_source_file(doc_info)}
268
270
 
269
- #{generate_history_info d}
271
+ #{generate_history_info doc_info}
270
272
 
271
273
  ''''
272
274
 
@@ -279,7 +281,7 @@ module Giblish
279
281
  root.add_path(d.rel_path.to_s, d)
280
282
  end
281
283
 
282
- details_str = "== Document details\n\n"
284
+ details_str = String.new("== Document details\n\n")
283
285
 
284
286
  root.traverse_top_down do |_level, node|
285
287
  details_str << if node.leaf?
@@ -318,49 +320,43 @@ module Giblish
318
320
  # a git repo root
319
321
  @git_repo = Git.open(git_repo_root)
320
322
  @git_repo_root = git_repo_root
321
- rescue Exception => e
322
- Giblog.logger.error {"No git repo! exception: #{e.message}"}
323
+ rescue StandardError => e
324
+ Giblog.logger.error { "No git repo! exception: #{e.message}" }
323
325
  end
324
326
  end
325
327
 
326
328
  protected
329
+
327
330
  # override basic version and use the relative path to the
328
331
  # git repo root instead
329
332
  def display_source_file(doc_info)
330
333
  # Use the path relative to the git repo root as display
331
- src_file = Pathname.
332
- new(doc_info.src_file).
333
- relative_path_from(@git_repo_root).to_s
334
+ src_file = Pathname
335
+ .new(doc_info.src_file)
336
+ .relative_path_from(@git_repo_root).to_s
334
337
  <<~SRC_FILE_TXT
335
338
  Source file::
336
339
  #{src_file}
337
-
338
340
  SRC_FILE_TXT
339
341
  end
340
342
 
341
-
342
- def generate_title_and_header
343
- t = Time.now
344
- <<~DOC_HEADER
345
- = Document index
346
- #{@git_repo.current_branch}
347
-
348
- :icons:
349
-
350
- DOC_HEADER
343
+ def source_root
344
+ @git_repo.current_branch
351
345
  end
352
346
 
353
- def generate_history_info(d)
354
- str = <<~HISTORY_HEADER
355
- File history::
347
+ def generate_history_info(doc_info)
348
+ str = String.new(
349
+ <<~HISTORY_HEADER
350
+ File history::
356
351
 
357
- [cols=\"2,3,8\",options=\"header\"]
358
- |===
359
- |Date |Author |Message
360
- HISTORY_HEADER
352
+ [cols=\"2,3,8\",options=\"header\"]
353
+ |===
354
+ |Date |Author |Message
355
+ HISTORY_HEADER
356
+ )
361
357
 
362
358
  # Generate table rows of history information
363
- d.history.each do |h|
359
+ doc_info.history.each do |h|
364
360
  str << <<~HISTORY_ROW
365
361
  |#{h.date.strftime('%Y-%m-%d')}
366
362
  |#{h.author}
@@ -431,10 +427,9 @@ module Giblish
431
427
  # get the branch-unique dst-dir
432
428
  str = <<~TAG_INFO
433
429
  == Tags
434
-
435
- |===
436
- |Tag |Tag comment |Creator |Tagged commit
437
430
 
431
+ |===
432
+ |Tag |Tag comment |Creator |Tagged commit
438
433
  TAG_INFO
439
434
 
440
435
  str << @tags.collect do |t|
@@ -443,8 +438,8 @@ module Giblish
443
438
 
444
439
  <<~A_ROW
445
440
  |link:#{dirname}/index.html[#{t.name}]
446
- |#{t.annotated? ? t.message : "-"}
447
- |#{t.annotated? ? t.tagger.name : "-"}
441
+ |#{t.annotated? ? t.message : '-'}
442
+ |#{t.annotated? ? t.tagger.name : '-'}
448
443
  |#{t.sha[0, 8]}... committed at #{c.author.date}
449
444
  A_ROW
450
445
  end.join("\n")
@@ -461,4 +456,4 @@ module Giblish
461
456
  str
462
457
  end
463
458
  end
464
- end
459
+ end