liquidoc 0.9.0 → 0.9.1
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/liquidoc.rb +71 -23
- data/lib/liquidoc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4ca568ce8e9ab2521817401e597d32360a7837ae2181c10e1565ba0de1f1e21
|
4
|
+
data.tar.gz: add8c1533ea4538ec874c1b3d7519a6ff37e0fcb845501dfda01d2e43f26abe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52a72258b29fd0300ae3474f12b7f1c804e752f0b20e6529df94a1f74aa0faec81fec7e60574eebd0f09a6cc22e910e14ae12a208da210266f2b34b9c6a938f8
|
7
|
+
data.tar.gz: f0b0fcd553577991be21cc2c47296f1d4ac07eaa3b0fab2f1b51b66dfffe1f33a3a251f7c6e76a862e0bb119a46deb47245560e9bca06e6c293a0ea0182b387f
|
data/lib/liquidoc.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'liquidoc'
|
2
|
+
require 'optparse'
|
2
3
|
require 'yaml'
|
3
4
|
require 'json'
|
4
|
-
require 'optparse'
|
5
5
|
require 'liquid'
|
6
6
|
require 'asciidoctor'
|
7
7
|
require 'asciidoctor-pdf'
|
@@ -51,6 +51,8 @@ require 'jekyll'
|
|
51
51
|
@verbose = false
|
52
52
|
@quiet = false
|
53
53
|
@explicit = false
|
54
|
+
@search_index = false
|
55
|
+
@search_index_dry = ''
|
54
56
|
|
55
57
|
# Instantiate the main Logger object, which is always running
|
56
58
|
@logger = Logger.new(STDOUT)
|
@@ -344,6 +346,7 @@ class Build
|
|
344
346
|
build['props'] = build['properties'] if build['properties']
|
345
347
|
@build = build
|
346
348
|
@type = type
|
349
|
+
@build['variables'] = {}
|
347
350
|
end
|
348
351
|
|
349
352
|
def template
|
@@ -445,6 +448,18 @@ class Build
|
|
445
448
|
# props['files'].force_array if props['files']
|
446
449
|
# end
|
447
450
|
|
451
|
+
def search
|
452
|
+
props['search']
|
453
|
+
end
|
454
|
+
|
455
|
+
def add_search_prop! prop
|
456
|
+
begin
|
457
|
+
self.search.merge!prop
|
458
|
+
rescue
|
459
|
+
raise "PropertyInsertionError"
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
448
463
|
# NOTE this section repeats in Class.AsciiDocument
|
449
464
|
def attributes
|
450
465
|
@build['attributes']
|
@@ -609,11 +624,7 @@ end
|
|
609
624
|
|
610
625
|
# Pull in a semi-structured data file, converting contents to a Ruby hash
|
611
626
|
def ingest_data datasrc
|
612
|
-
|
613
|
-
unless datasrc.is_a? Object
|
614
|
-
raise "InvalidDataObject"
|
615
|
-
end
|
616
|
-
# This proc should really begin here, once the datasrc object is in order
|
627
|
+
raise "InvalidDataObject" unless datasrc.is_a? Object
|
617
628
|
case datasrc.type
|
618
629
|
when "yml"
|
619
630
|
begin
|
@@ -677,7 +688,7 @@ def parse_regex data_file, pattern
|
|
677
688
|
end
|
678
689
|
end
|
679
690
|
end
|
680
|
-
output =
|
691
|
+
output = records
|
681
692
|
rescue Exception => ex
|
682
693
|
@logger.error "Something went wrong trying to parse the free-form file. #{ex.class} thrown. #{ex.message}"
|
683
694
|
raise "Freeform parse error"
|
@@ -911,8 +922,8 @@ def generate_site doc, build
|
|
911
922
|
when "jekyll"
|
912
923
|
attrs = doc.attributes
|
913
924
|
build.add_config_file("_config.yml") unless build.prop_files_array
|
914
|
-
|
915
|
-
attrs.merge! ({"base_dir" =>
|
925
|
+
jekyll = load_jekyll_data(build) # load the first Jekyll config file locally
|
926
|
+
attrs.merge! ({"base_dir" => jekyll['source']}) # Sets default Asciidoctor base_dir to == Jekyll root
|
916
927
|
# write all AsciiDoc attributes to a config file for Jekyll to ingest
|
917
928
|
attrs.merge!(build.attributes) if build.attributes
|
918
929
|
attrs = {"asciidoctor" => {"attributes" => attrs} }
|
@@ -925,14 +936,31 @@ def generate_site doc, build
|
|
925
936
|
if build.props['arguments']
|
926
937
|
opts_args = build.props['arguments'].to_opts_args
|
927
938
|
end
|
928
|
-
|
939
|
+
base_args = "--config #{config_list} #{opts_args}"
|
940
|
+
command = "bundle exec jekyll build #{base_args} #{quiet}"
|
941
|
+
if @search_index
|
942
|
+
# TODO enable config-based admin api key ingest once config is dynamic
|
943
|
+
command = algolia_index_cmd(build, @search_api_key, base_args)
|
944
|
+
@logger.warn "Search indexing failed." unless command
|
945
|
+
end
|
946
|
+
end
|
947
|
+
if command
|
948
|
+
@logger.info "Running #{command}"
|
949
|
+
@logger.debug "AsciiDoc attributes: #{doc.attributes.to_yaml} "
|
950
|
+
system command
|
929
951
|
end
|
930
|
-
@logger.info "Running #{command}"
|
931
|
-
@logger.debug "AsciiDoc attributes: #{doc.attributes.to_yaml} "
|
932
|
-
system command
|
933
952
|
jekyll_serve(build) if @jekyll_serve
|
934
953
|
end
|
935
954
|
|
955
|
+
def load_jekyll_data build
|
956
|
+
data = {}
|
957
|
+
build.prop_files_array.each do |file|
|
958
|
+
settings = YAML.load_file(file)
|
959
|
+
data.merge!settings if settings
|
960
|
+
end
|
961
|
+
return data
|
962
|
+
end
|
963
|
+
|
936
964
|
# ===
|
937
965
|
# DEPLOY procs
|
938
966
|
# ===
|
@@ -948,6 +976,20 @@ def jekyll_serve build
|
|
948
976
|
system command
|
949
977
|
end
|
950
978
|
|
979
|
+
def algolia_index_cmd build, apikey=nil, args
|
980
|
+
unless build.search and build.search['index']
|
981
|
+
@logger.warn "No index configuration found for build; jekyll-algolia operation skipped for this build."
|
982
|
+
return false
|
983
|
+
else
|
984
|
+
unless apikey
|
985
|
+
@logger.warn "No Algolia admin API key passed; skipping jekyll-algolia operation for this build."
|
986
|
+
return false
|
987
|
+
else
|
988
|
+
return "ALGOLIA_INDEX_NAME='#{build.search['index']}' ALGOLIA_API_KEY='#{apikey}' bundle exec jekyll algolia #{@search_index_dry} #{args} "
|
989
|
+
end
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
951
993
|
# ===
|
952
994
|
# Text manipulation Classes, Modules, procs, etc
|
953
995
|
# ===
|
@@ -1115,7 +1157,7 @@ command_parser = OptionParser.new do|opts|
|
|
1115
1157
|
@quiet = true
|
1116
1158
|
end
|
1117
1159
|
|
1118
|
-
opts.on("--
|
1160
|
+
opts.on("--explain", "Log explicit step descriptions to console as build progresses. (Otherwise writes to file at #{@build_dir}/pre/config-explainer.adoc .)") do |n|
|
1119
1161
|
explainer_init("STDOUT")
|
1120
1162
|
@explainer.level = Logger::INFO
|
1121
1163
|
@logger.level = Logger::WARN # Suppress all those INFO-level messages
|
@@ -1130,21 +1172,27 @@ command_parser = OptionParser.new do|opts|
|
|
1130
1172
|
@jekyll_serve = true
|
1131
1173
|
end
|
1132
1174
|
|
1133
|
-
opts.on("--
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1175
|
+
opts.on("--search-index-push", "Runs any search indexing configured in the build step and pushes to Algolia.") do
|
1176
|
+
@search_index = true
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
opts.on("--search-index-dry", "Runs any search indexing configured in the build step but does NOT push to Algolia.") do
|
1180
|
+
@search_index = true
|
1181
|
+
@search_index_dry = "--dry-run"
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
opts.on("--search-api-key=STRING", "Passes Algolia Admin API key (which you should keep out of Git).") do |n|
|
1185
|
+
@search_api_key = n
|
1138
1186
|
end
|
1139
1187
|
|
1140
|
-
opts.on("-
|
1188
|
+
opts.on("-v", "--var KEY=VALUE", "For passing variables directly to the 'vars.' scope of a template; for dynamic configs, too.") do |n|
|
1141
1189
|
pair = {}
|
1142
1190
|
k,v = n.split('=')
|
1143
1191
|
pair[k] = v
|
1144
|
-
@
|
1192
|
+
@passed_vars.merge!pair
|
1145
1193
|
end
|
1146
1194
|
|
1147
|
-
opts.on("--parse-config", "Preprocess the designated configuration file as a Liquid template. Superfluous when passing -
|
1195
|
+
opts.on("--parse-config", "Preprocess the designated configuration file as a Liquid template. Superfluous when passing -v/--var arguments.") do
|
1148
1196
|
@parseconfig = true
|
1149
1197
|
end
|
1150
1198
|
|
@@ -1176,5 +1224,5 @@ unless @config_file
|
|
1176
1224
|
end
|
1177
1225
|
else
|
1178
1226
|
@logger.debug "Executing... config_build"
|
1179
|
-
config_build(@config_file, @
|
1227
|
+
config_build(@config_file, @passed_vars, @parseconfig)
|
1180
1228
|
end
|
data/lib/liquidoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquidoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Dominick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|