giblish 2.0.0 → 2.1.0
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/.github/workflows/unit_tests.yml +2 -2
- data/.gitignore +0 -1
- data/.ruby-version +1 -1
- data/Changelog.adoc +18 -3
- data/giblish.gemspec +1 -1
- data/lib/giblish/application.rb +57 -52
- data/lib/giblish/treeconverter.rb +95 -30
- data/lib/giblish/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8408ee3c107d81b67183f08d1da4b5e4aa5edc0cb0050bab222be0c2bc7f2d2e
|
4
|
+
data.tar.gz: d98a66177b686af3f20a46b57c2425ab0c1462296ca27455a1f79c426fd2958d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b392c42daaef6cd52224eaf43687463a0750934ac995d67e529bdb16b2be7498f31fc8dcd2112756873894adf6314a965231e6325460e7458f214c987419fa
|
7
|
+
data.tar.gz: 61afa2acbf3ec664fc289e673e8c5faac55bf1f1d564b0955a1d2eb541e7764333f9ef326d82c4da1fc4db83386c8aa2b0d7024fddbc9962b048d87645baf020
|
@@ -17,9 +17,9 @@ jobs:
|
|
17
17
|
sudo apt -y install binutils
|
18
18
|
- name: Install needed packages
|
19
19
|
run: |
|
20
|
-
sudo apt-get -y install libpango1.0-dev graphviz
|
20
|
+
sudo apt-get -y install libpango1.0-dev graphviz libwebp-dev libzstd-dev
|
21
21
|
- name: Checkout Giblish
|
22
|
-
uses: actions/checkout@
|
22
|
+
uses: actions/checkout@v3
|
23
23
|
- name: Set up Ruby
|
24
24
|
uses: ruby/setup-ruby@v1
|
25
25
|
with:
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.3
|
data/Changelog.adoc
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
= giblish changelog
|
2
2
|
:docid: G-006
|
3
3
|
|
4
|
-
== Not yet in place
|
4
|
+
== Some of the things Not yet in place
|
5
5
|
|
6
6
|
* Investigate how to remove tmp/cache files and dirs during graph generation
|
7
7
|
* Update docs for giblish.
|
8
8
|
** write instructions for github webhook triggered generation
|
9
9
|
* Update the default css for giblish html generation.
|
10
|
+
* Implement a way for a user to customize the index page
|
11
|
+
|
12
|
+
== v2.1.0
|
13
|
+
|
14
|
+
Changes/New functionality::
|
15
|
+
* asciidoctor-diagram is required if it exists, this makes diagrams in documents render.
|
16
|
+
* giblish now complies with these precedence rules for document attributes:
|
17
|
+
.. An attribute passed to the API or CLI whose value does not end in @
|
18
|
+
.. (giblish specific) An attribute defined in an attribute provider for a specific source node
|
19
|
+
.. An attribute defined in the document
|
20
|
+
.. An attribute passed to the API or CLI whose value or name ends in @
|
21
|
+
.. (giblish specific) The default value set by giblish, if applicable
|
22
|
+
.. The default value set by asciidoctor, if applicable
|
23
|
+
+
|
24
|
+
this is an augumentation of the ones found here: https://docs.asciidoctor.org/asciidoc/latest/attributes/assignment-precedence/
|
10
25
|
|
11
26
|
== v2.0.0
|
12
27
|
|
@@ -21,7 +36,7 @@ Breaking changes::
|
|
21
36
|
This release includes a complete refactoring of almost the entire code base.
|
22
37
|
|
23
38
|
Breaking changes::
|
24
|
-
* The '-w' flag is removed
|
39
|
+
* The '-w' flag is removed
|
25
40
|
* The text search parameters interface has changed completely. A written specification of this interface is included in the docs.
|
26
41
|
* The '-r' flag will, for html generation, *copy everything* under the given directory to the target location.
|
27
42
|
** the previous restriction on folder names has been removed.
|
@@ -46,7 +61,7 @@ Changes/New functionality::
|
|
46
61
|
** the implementation of the server-side search tools are written completely in ruby and does no longer depend on an external 'grep' tool.
|
47
62
|
** almost all needed infrastructure for implementing a server-side search script has been implemented within the 'giblish' gem.
|
48
63
|
* The asciidoctor toolchain dependencies are updated to the latest versions (at the time of release).
|
49
|
-
|
64
|
+
|
50
65
|
|
51
66
|
== v0.8.0
|
52
67
|
|
data/giblish.gemspec
CHANGED
@@ -49,7 +49,6 @@ Gem::Specification.new do |spec|
|
|
49
49
|
spec.add_development_dependency "standard", "~> 1.16"
|
50
50
|
spec.add_development_dependency "rake", "~> 13.0"
|
51
51
|
spec.add_development_dependency "oga", "~> 3.3"
|
52
|
-
# spec.add_development_dependency "thor", "~> 0.20.3"
|
53
52
|
spec.add_development_dependency "thor", "~> 1.2"
|
54
53
|
spec.add_development_dependency "asciidoctor-mathematical", "~> 0.3.5"
|
55
54
|
# needed for the sinatra-based apps
|
@@ -61,6 +60,7 @@ Gem::Specification.new do |spec|
|
|
61
60
|
# Run-time deps
|
62
61
|
# 'matrix' needed because of incompatibilities between prawn v2.4
|
63
62
|
# and ruby 3.1
|
63
|
+
# sorbet-runtime
|
64
64
|
spec.add_runtime_dependency "matrix", "~>0.4"
|
65
65
|
spec.add_runtime_dependency "warning", "~>1.2"
|
66
66
|
spec.add_runtime_dependency "asciidoctor", "~>2.0", ">= 2.0.17"
|
data/lib/giblish/application.rb
CHANGED
@@ -5,54 +5,54 @@ require_relative "gitrepos/checkoutmanager"
|
|
5
5
|
|
6
6
|
module Giblish
|
7
7
|
# The app class for the giblish application
|
8
|
-
class Application
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
8
|
+
# class Application
|
9
|
+
# # returns on success, raises otherwise
|
10
|
+
# def run(args)
|
11
|
+
# # force immediate output
|
12
|
+
# $stdout.sync = true
|
13
|
+
|
14
|
+
# # setup logging
|
15
|
+
# Giblog.setup
|
16
|
+
# Giblog.logger.level = Logger::INFO
|
17
|
+
|
18
|
+
# # Parse cmd line
|
19
|
+
# cmdline = CmdLine.new.parse(args)
|
20
|
+
# Giblog.logger.level = cmdline.log_level
|
21
|
+
|
22
|
+
# Giblog.logger.debug { "cmd line args: #{cmdline.inspect}" }
|
23
|
+
|
24
|
+
# # build a tree of files matching user's regexp selection
|
25
|
+
# src_tree = PathTree.build_from_fs(cmdline.srcdir) do |p|
|
26
|
+
# if cmdline.exclude_regex&.match(p.to_s)
|
27
|
+
# false
|
28
|
+
# else
|
29
|
+
# (cmdline.include_regex =~ p.to_s)
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# if src_tree.nil?
|
33
|
+
# Giblog.logger.warn { "Did not find any files to convert" }
|
34
|
+
# return
|
35
|
+
# end
|
36
|
+
|
37
|
+
# app = Configurator.new(cmdline, src_tree)
|
38
|
+
# app.tree_converter.run
|
39
|
+
|
40
|
+
# Giblog.logger.info { "Giblish is done!" }
|
41
|
+
# end
|
42
|
+
|
43
|
+
# # does not return, exits with status code
|
44
|
+
# def run_from_cmd_line
|
45
|
+
# begin
|
46
|
+
# run(ARGV)
|
47
|
+
# exit_code = 0
|
48
|
+
# rescue => exc
|
49
|
+
# Giblog.logger.error { exc.message }
|
50
|
+
# Giblog.logger.error { exc.backtrace }
|
51
|
+
# exit_code = 1
|
52
|
+
# end
|
53
|
+
# exit(exit_code)
|
54
|
+
# end
|
55
|
+
# end
|
56
56
|
|
57
57
|
class DirTreeConvert
|
58
58
|
# This class provides a file as the source for the asciidoc info and
|
@@ -197,15 +197,20 @@ module Giblish
|
|
197
197
|
Giblog.logger.level = Logger::INFO
|
198
198
|
|
199
199
|
# Parse cmd line
|
200
|
-
user_opts = CmdLine.new.parse(args)
|
201
|
-
Giblog.logger.level = user_opts.log_level
|
202
|
-
Giblog.logger.debug { "cmd line args: #{user_opts.inspect}" }
|
200
|
+
@user_opts = CmdLine.new.parse(args)
|
201
|
+
Giblog.logger.level = @user_opts.log_level
|
202
|
+
Giblog.logger.debug { "cmd line args: #{@user_opts.inspect}" }
|
203
203
|
|
204
204
|
# Select the coversion instance to use
|
205
|
-
@converter = select_conversion(user_opts)
|
205
|
+
@converter = select_conversion(@user_opts)
|
206
206
|
end
|
207
207
|
|
208
208
|
def run
|
209
|
+
begin
|
210
|
+
require "asciidoctor-diagram"
|
211
|
+
rescue LoadError
|
212
|
+
Giblog.logger.warn { "Did not find asciidoctor-diagram installed, diagrams will not be rendered." }
|
213
|
+
end
|
209
214
|
# do the conversion
|
210
215
|
@converter.run
|
211
216
|
end
|
@@ -156,20 +156,20 @@ module Giblish
|
|
156
156
|
}
|
157
157
|
|
158
158
|
# see https://docs.asciidoctor.org/asciidoctor/latest/api/options/
|
159
|
-
|
160
|
-
backend: "html5",
|
159
|
+
DEFAULT_ADOC_API_OPTS = {
|
160
|
+
# backend: "html5",
|
161
161
|
# base_dir:
|
162
|
-
catalog_assets: false,
|
162
|
+
# catalog_assets: false,
|
163
163
|
# converter:
|
164
|
-
doctype: "article",
|
164
|
+
# doctype: "article",
|
165
165
|
# eruby:
|
166
166
|
# ignore extention stuff
|
167
|
-
header_only: false,
|
167
|
+
# header_only: false,
|
168
168
|
# logger:
|
169
|
-
mkdirs: false,
|
170
|
-
parse: true,
|
169
|
+
# mkdirs: false,
|
170
|
+
# parse: true,
|
171
171
|
safe: :unsafe,
|
172
|
-
sourcemap: false,
|
172
|
+
# sourcemap: false,
|
173
173
|
# template stuff TBD,
|
174
174
|
# to_file:
|
175
175
|
# to_dir:
|
@@ -192,12 +192,67 @@ module Giblish
|
|
192
192
|
failure: ->(src, dst, dst_rel_path, ex, logstr) { TreeConverter.on_failure(src, dst, dst_rel_path, ex, logstr) }
|
193
193
|
})
|
194
194
|
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
195
|
+
# cache external configuration
|
196
|
+
@config_opts = opts.dup
|
197
|
+
end
|
198
|
+
|
199
|
+
# Resolve the document attributes according to the precedence.
|
200
|
+
#
|
201
|
+
# According to https://docs.asciidoctor.org/asciidoc/latest/attributes/assignment-precedence/
|
202
|
+
# The attribute precedence is:
|
203
|
+
# 1. An attribute passed to the API or CLI whose value does not end in @
|
204
|
+
# 2. An attribute defined in the document
|
205
|
+
# 3. An attribute passed to the API or CLI whose value or name ends in @
|
206
|
+
# 4. The default value of the attribute, if applicable
|
207
|
+
#
|
208
|
+
# giblish adds the following rules:
|
209
|
+
# 1.5 An attribute defined in an attribute provider for a specific source node
|
210
|
+
# 3.5 The default value set by giblish, if applicable
|
211
|
+
def resolve_doc_attributes(doc_src, node_attr)
|
212
|
+
# rule 3.5
|
213
|
+
doc_attr = DEFAULT_ADOC_DOC_ATTRIBS.dup
|
214
|
+
|
215
|
+
# sort attribs into soft and hard (rule 1 and 3)
|
216
|
+
soft_attr = {}
|
217
|
+
hard_attr = {}
|
218
|
+
@config_opts.fetch(:adoc_doc_attribs, {}).each do |k, v|
|
219
|
+
ks = k.to_s.strip
|
220
|
+
vs = v.to_s.strip
|
221
|
+
|
222
|
+
if ks.end_with?("@")
|
223
|
+
soft_attr[ks[0..]] = vs
|
224
|
+
next
|
225
|
+
end
|
226
|
+
if vs.end_with?("@")
|
227
|
+
soft_attr[ks] = vs[0..]
|
228
|
+
next
|
229
|
+
end
|
230
|
+
hard_attr[ks] = vs
|
231
|
+
end
|
232
|
+
|
233
|
+
# rule 3.
|
234
|
+
doc_attr.merge!(soft_attr)
|
235
|
+
|
236
|
+
# rule 2
|
237
|
+
Giblish.process_header_lines(doc_src.lines) do |line|
|
238
|
+
a = /^:(.+):(.*)$/.match(line)
|
239
|
+
next unless a
|
240
|
+
@logger.debug { "got header attr from doc: #{a[1]} : #{a[2]}" }
|
241
|
+
doc_attr[a[1].strip] = a[2].strip
|
242
|
+
end
|
243
|
+
|
244
|
+
@logger.debug { "idprefix before: #{doc_attr["idprefix"]}" }
|
245
|
+
|
246
|
+
# rule 1.5
|
247
|
+
doc_attr.merge!(node_attr)
|
248
|
+
|
249
|
+
# rule 1.
|
250
|
+
doc_attr.merge!(hard_attr)
|
251
|
+
|
252
|
+
@logger.debug { "idprefix after: #{doc_attr["idprefix"]}" }
|
253
|
+
|
254
|
+
# @logger&.debug { "Header attribs: #{doc_attr}" }
|
255
|
+
doc_attr
|
201
256
|
end
|
202
257
|
|
203
258
|
# require the following methods to be available from the src node:
|
@@ -216,34 +271,44 @@ module Giblish
|
|
216
271
|
@logger&.info { "Converting #{src_node.pathname} and store result under #{dst_node.parent.pathname}" }
|
217
272
|
|
218
273
|
# merge the common api opts with node specific
|
219
|
-
api_opts =
|
274
|
+
api_opts = DEFAULT_ADOC_API_OPTS.dup
|
275
|
+
api_opts.merge!(@config_opts.fetch(:adoc_api_opts, {}))
|
220
276
|
api_opts.merge!(src_node.api_options(src_node, dst_node, dst_top)) if src_node.respond_to?(:api_options)
|
221
|
-
api_opts[:attributes].merge!(src_node.document_attributes(src_node, dst_node, dst_top)) if src_node.respond_to?(:document_attributes)
|
222
277
|
|
223
278
|
# use a new logger instance for each conversion
|
224
279
|
adoc_logger = Giblish::AsciidoctorLogger.new(@logger, @adoc_log_level)
|
225
280
|
|
226
281
|
begin
|
227
|
-
|
282
|
+
doc_src = src_node.adoc_source(src_node, dst_node, dst_top)
|
283
|
+
|
284
|
+
node_attr = src_node.respond_to?(:document_attributes) ?
|
285
|
+
src_node.document_attributes(src_node, dst_node, dst_top) : {}
|
286
|
+
doc_attr = resolve_doc_attributes(doc_src, node_attr)
|
287
|
+
# piggy-back our own info on the doc attributes hash so that
|
288
|
+
# asciidoctor extensions can use this info later on
|
289
|
+
doc_attr["giblish-info"] = {
|
290
|
+
src_node: src_node,
|
291
|
+
dst_node: dst_node,
|
292
|
+
dst_top: dst_top
|
293
|
+
}
|
294
|
+
|
295
|
+
# load the source to enable access to doc attributes and properties
|
228
296
|
#
|
229
|
-
# NOTE:
|
297
|
+
# NOTE: 'parse' is set to false to prevent preprocessor extensions to be run as part
|
230
298
|
# of loading the document. We want them to run during the 'convert' call later when
|
231
299
|
# doc attribs have been amended.
|
232
|
-
|
300
|
+
#
|
301
|
+
# NOTE2: by trial-and-error, it seems that some document attributes must be set when
|
302
|
+
# calling 'load' and not added after the call and before the 'convert' call to have
|
303
|
+
# the expected effect (e.g. idprefix).
|
304
|
+
doc = Asciidoctor.load(doc_src, api_opts.merge(
|
233
305
|
{
|
306
|
+
attributes: doc_attr,
|
234
307
|
parse: false,
|
235
308
|
logger: adoc_logger
|
236
309
|
}
|
237
310
|
))
|
238
311
|
|
239
|
-
# piggy-back our own info on the doc attributes hash so that
|
240
|
-
# asciidoctor extensions can use this info later on
|
241
|
-
doc.attributes["giblish-info"] = {
|
242
|
-
src_node: src_node,
|
243
|
-
dst_node: dst_node,
|
244
|
-
dst_top: dst_top
|
245
|
-
}
|
246
|
-
|
247
312
|
# update the destination node with the correct file suffix. This is dependent
|
248
313
|
# on the type of conversion performed
|
249
314
|
dst_node.name = dst_node.name.sub_ext(doc.attributes["outfilesuffix"])
|
@@ -252,11 +317,11 @@ module Giblish
|
|
252
317
|
# make sure the dst dir exists
|
253
318
|
d.dirname.mkpath
|
254
319
|
|
255
|
-
# write the converted doc to
|
256
|
-
output = doc.convert(api_opts
|
320
|
+
# do the conversion and write the converted doc to file
|
321
|
+
output = doc.convert(api_opts)
|
257
322
|
doc.write(output, d.to_s)
|
258
323
|
|
259
|
-
# give user the opportunity to eg store the result of the conversion
|
324
|
+
# give the user the opportunity to eg store the result of the conversion
|
260
325
|
# as data in the destination node
|
261
326
|
@conv_cb[:success]&.call(src_node, dst_node, dst_top, doc, adoc_logger.in_mem_storage.string)
|
262
327
|
true
|
data/lib/giblish/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giblish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anders Rillbert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -383,7 +383,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
383
383
|
- !ruby/object:Gem::Version
|
384
384
|
version: '0'
|
385
385
|
requirements: []
|
386
|
-
rubygems_version: 3.3.
|
386
|
+
rubygems_version: 3.3.26
|
387
387
|
signing_key:
|
388
388
|
specification_version: 4
|
389
389
|
summary: A tool for publishing asciidoc docs stored in git repos
|