giblish 0.7.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -2
- data/.ruby-version +1 -1
- data/giblish.gemspec +8 -7
- data/lib/giblish/application.rb +27 -24
- data/lib/giblish/buildgraph.rb +37 -39
- data/lib/giblish/buildindex.rb +96 -101
- data/lib/giblish/cmdline.rb +68 -68
- data/lib/giblish/core.rb +89 -80
- data/lib/giblish/docconverter.rb +57 -59
- data/lib/giblish/docid.rb +4 -12
- data/lib/giblish/docinfo.rb +14 -39
- data/lib/giblish/gititf.rb +4 -6
- data/lib/giblish/indexheadings.rb +35 -39
- data/lib/giblish/pathtree.rb +2 -5
- data/lib/giblish/utils.rb +73 -75
- data/lib/giblish/version.rb +1 -1
- metadata +32 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a797e1a9f716863a0aa11f0fa22eb83da66d42d2d3d4e2ed722def41b2b79f59
|
4
|
+
data.tar.gz: f3eaee6f9a9e2478401e9fadeb60ef0e22233352f49e5b6d20162adc3b301241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d671ffe2adbdd555e8a0253ccaa0a2ccb3756bfed0745642e7de47d5786bc65556b996cb4d7bd3d11a7ce0477c395b5f675970b61be47db1d128a52d87295201
|
7
|
+
data.tar.gz: 44874cd2385f1b263389255a2ee2d8bb18a644c4937aea661b2739a9b7b2d605bf1b6e3ff05954b7b915c290183b8f890507ce4ffda9bc0b21135a331fa76839
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.3
|
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.
|
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.
|
44
|
-
spec.add_runtime_dependency "asciidoctor-diagram", ["~> 1
|
45
|
-
spec.add_runtime_dependency "asciidoctor-pdf", ["~> 1.
|
46
|
-
spec.add_runtime_dependency "git", "~> 1.
|
47
|
-
spec.add_runtime_dependency "rouge", "~> 3.
|
48
|
-
spec.add_runtime_dependency "prawn-svg", "~> 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
|
data/lib/giblish/application.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
37
|
-
|
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
|
-
|
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(
|
57
|
+
def log_error(exc)
|
55
58
|
Giblog.logger.error do
|
56
59
|
<<~ERR_MSG
|
57
|
-
Error: #{
|
60
|
+
Error: #{exc.message}
|
58
61
|
Backtrace:
|
59
|
-
\t#{
|
62
|
+
\t#{exc.backtrace.join("\n\t")}
|
60
63
|
|
61
64
|
cmdline.usage
|
62
65
|
ERR_MSG
|
data/lib/giblish/buildgraph.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
38
|
-
|
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
|
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(
|
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
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
140
|
-
title = lines.select { |l| l.length
|
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
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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
|
-
|
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
|
-
|
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 = {},
|
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
|
-
|
data/lib/giblish/buildindex.rb
CHANGED
@@ -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
|
-
|
23
|
-
|
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
|
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
|
-
|
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 #{
|
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
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
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
|
-
|
96
|
+
[largest, duplicates]
|
86
97
|
end
|
87
98
|
|
88
|
-
def
|
89
|
-
largest,duplicates =
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
124
|
+
def generate_tree
|
124
125
|
# output tree intro
|
125
|
-
tree_string =
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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(
|
157
|
-
return "" if
|
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 =
|
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(
|
227
|
+
def generate_history_info(_doc_info)
|
226
228
|
""
|
227
229
|
end
|
228
230
|
|
229
|
-
def generate_detail_fail(
|
231
|
+
def generate_detail_fail(doc_info)
|
230
232
|
<<~FAIL_INFO
|
231
|
-
=== #{
|
233
|
+
=== #{doc_info.src_file}
|
232
234
|
|
233
235
|
#{display_source_file(d)}
|
234
236
|
|
235
237
|
Error detail::
|
236
|
-
#{
|
238
|
+
#{doc_info.stderr}
|
237
239
|
|
238
240
|
''''
|
239
241
|
|
240
242
|
FAIL_INFO
|
241
243
|
end
|
242
244
|
|
243
|
-
def generate_detail(
|
245
|
+
def generate_detail(doc_info)
|
244
246
|
# Generate detail info
|
245
|
-
purpose_str = if
|
247
|
+
purpose_str = if doc_info.purpose_str.nil?
|
246
248
|
""
|
247
249
|
else
|
248
|
-
"Purpose::\n#{
|
250
|
+
"Purpose::\n#{doc_info.purpose_str}"
|
249
251
|
end
|
250
252
|
|
251
|
-
doc_id_str = if !
|
252
|
-
"Doc id::\n_#{
|
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(
|
259
|
-
=== #{
|
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
|
267
|
+
#{generate_conversion_info doc_info}
|
266
268
|
|
267
|
-
#{display_source_file(
|
269
|
+
#{display_source_file(doc_info)}
|
268
270
|
|
269
|
-
#{generate_history_info
|
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
|
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
|
-
|
333
|
-
|
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
|
-
|
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(
|
354
|
-
str =
|
355
|
-
|
347
|
+
def generate_history_info(doc_info)
|
348
|
+
str = String.new(
|
349
|
+
<<~HISTORY_HEADER
|
350
|
+
File history::
|
356
351
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
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
|
-
|
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
|