yarrow 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/lib/yarrow/config.rb +6 -4
- data/lib/yarrow/configuration.rb +4 -4
- data/lib/yarrow/console_runner.rb +5 -8
- data/lib/yarrow/content/collection_expander.rb +66 -43
- data/lib/yarrow/content/expansion.rb +51 -0
- data/lib/yarrow/content/graph.rb +15 -2
- data/lib/yarrow/content/manifest.rb +61 -0
- data/lib/yarrow/content/{content_type.rb → object_type.rb} +1 -1
- data/lib/yarrow/content/source_collector.rb +38 -15
- data/lib/yarrow/content/tree_expansion.rb +83 -0
- data/lib/yarrow/generator.rb +49 -19
- data/lib/yarrow/output/result.rb +13 -0
- data/lib/yarrow/output/web/indexed_file.rb +7 -1
- data/lib/yarrow/version.rb +1 -1
- data/lib/yarrow.rb +7 -3
- data/yarrow.gemspec +2 -2
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395db81bd349ed8e1a6b5cdc67d0fd191f6ede369bd358483611e0b79fb27cec
|
4
|
+
data.tar.gz: '028961b86756cfc6bc1453c6d3ad7789149e8921066fb5429358e1b3b08393eb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f531ff89949b7d1b80e215529f2c6c29d812f958e9af4491d58b7a0f10f9419a9ee26385ac58891cc435053fff31123d2dcfed0e02c8dcd48927d0b47c312f9f
|
7
|
+
data.tar.gz: 8a5bb918411a04ac7d5e8b3c649501346e94d3cc76c17097ec9eed436685b163a04294b40491b38f0ea8539a28722bc8e77043bdab81aec493e04d5ccc0b6e0e
|
data/.github/workflows/ruby.yml
CHANGED
data/lib/yarrow/config.rb
CHANGED
@@ -42,16 +42,18 @@ module Yarrow
|
|
42
42
|
:root_dir
|
43
43
|
)
|
44
44
|
|
45
|
-
# Top level root config namespace.
|
46
|
-
#
|
45
|
+
# Top level root config namespace.
|
46
|
+
#
|
47
|
+
# `content_dir` and `output_dir` are placeholders and should be overriden
|
48
|
+
# with more fine-grained config for web and book outputs in future.
|
47
49
|
#
|
48
50
|
# Additional server config is optional and only needed if running the dev
|
49
51
|
# server locally.
|
50
52
|
#
|
51
53
|
# TODO: meta should be union of Type::Optional and Config::Meta
|
52
54
|
Instance = Yarrow::Schema::Value.new(
|
53
|
-
|
54
|
-
|
55
|
+
project_dir: Pathname,
|
56
|
+
content_dir: Pathname,
|
55
57
|
output_dir: Pathname,
|
56
58
|
meta: Yarrow::Schema::Type::Any,
|
57
59
|
server: Yarrow::Schema::Type::Any
|
data/lib/yarrow/configuration.rb
CHANGED
@@ -52,13 +52,13 @@ module Yarrow
|
|
52
52
|
# automated as part of the schema types or a default value should be
|
53
53
|
# generated here (eg: `"#{Dir.pwd}/docs"`)
|
54
54
|
out_dir_or_string = config[:output_dir] || ""
|
55
|
-
source_dir_or_string = config[:
|
56
|
-
content_dir_or_string = config[:
|
55
|
+
source_dir_or_string = config[:project_dir] || ""
|
56
|
+
content_dir_or_string = config[:content_dir] || ""
|
57
57
|
|
58
58
|
Yarrow::Config::Instance.new(
|
59
59
|
output_dir: Pathname.new(File.expand_path(out_dir_or_string)),
|
60
|
-
|
61
|
-
|
60
|
+
project_dir: Pathname.new(File.expand_path(source_dir_or_string)),
|
61
|
+
content_dir: Pathname.new(File.expand_path(content_dir_or_string)),
|
62
62
|
meta: meta_obj,
|
63
63
|
server: server_obj
|
64
64
|
)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module Yarrow
|
2
|
-
|
3
2
|
class ConsoleRunner
|
4
3
|
|
5
4
|
SUCCESS = 0
|
@@ -100,7 +99,6 @@ module Yarrow
|
|
100
99
|
end
|
101
100
|
|
102
101
|
def normalize_theme_path
|
103
|
-
|
104
102
|
# noop
|
105
103
|
end
|
106
104
|
|
@@ -139,12 +137,11 @@ module Yarrow
|
|
139
137
|
@options.has_key? option
|
140
138
|
end
|
141
139
|
|
142
|
-
def
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
# noop
|
140
|
+
def run_generation_process
|
141
|
+
generator = Generator.new(@config)
|
142
|
+
generator.process do |manifest|
|
143
|
+
p manifest
|
144
|
+
end
|
148
145
|
end
|
149
146
|
|
150
147
|
def print_header
|
@@ -3,19 +3,26 @@ module Yarrow
|
|
3
3
|
class CollectionExpander
|
4
4
|
include Yarrow::Tools::FrontMatter
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
# If a list of object types is not provided, a default `pages` type is
|
7
|
+
# created.
|
8
|
+
def initialize(object_types=nil)
|
9
|
+
@object_types = object_types || [
|
10
|
+
Yarrow::Content::ObjectType.from_name(:pages)
|
9
11
|
]
|
10
12
|
end
|
11
13
|
|
12
14
|
def expand(graph)
|
13
|
-
@
|
14
|
-
expand_nested(graph,
|
15
|
+
@object_types.each do |object_type|
|
16
|
+
expand_nested(graph, object_type)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
def expand_nested(graph, content_type)
|
21
|
+
strategy = TreeExpansion.new(graph)
|
22
|
+
strategy.expand(content_type)
|
23
|
+
end
|
24
|
+
|
25
|
+
def expand_nested_legacy(graph, content_type)
|
19
26
|
type = content_type.collection
|
20
27
|
exts = content_type.extensions
|
21
28
|
|
@@ -87,40 +94,70 @@ module Yarrow
|
|
87
94
|
end
|
88
95
|
end
|
89
96
|
|
90
|
-
subcollections
|
91
|
-
|
92
|
-
|
97
|
+
# If there are no subcollections then we need to look at the start node
|
98
|
+
# TODO: test to verify if this could be used in all cases, not just
|
99
|
+
# the situation where there are subfolders to be mapped.
|
100
|
+
if subcollections.empty?
|
101
|
+
# Collect files that match the content type extension and group them
|
102
|
+
# under a common key for each slug (this is so we can merge multiple
|
103
|
+
# files with the same name together into a single content type, a
|
104
|
+
# specific pattern found in some legacy content folders).
|
105
|
+
#
|
106
|
+
# Ideally, this code should be deleted once we have a clean workflow
|
107
|
+
# and can experiment with decoupling different strategies for
|
108
|
+
# expansion/enrichment of content objects.
|
109
|
+
objects = start_node.out(:file).all.select do |file|
|
93
110
|
file.props[:name].end_with?(*exts)
|
94
111
|
end.group_by do |file|
|
95
112
|
file.props[:slug]
|
96
113
|
end
|
97
114
|
|
115
|
+
# This is a massive hack to deal with situations where we don’t
|
116
|
+
# recurse down the list of directories. The best way to clean it up
|
117
|
+
# will be to document the different supported mapping formats and
|
118
|
+
# URL generation strategies and break these up into separate
|
119
|
+
# traversal objects for each particular style of content organisation.
|
120
|
+
if index.nil?
|
121
|
+
index = graph.create_node do |collection_node|
|
122
|
+
collection_node.label = :collection
|
123
|
+
collection_node.props[:type] = type
|
124
|
+
collection_node.props[:name] = type
|
125
|
+
collection_node.props[:slug] = type.to_s
|
126
|
+
collection_node.props[:title] = metadata[:title]
|
127
|
+
|
128
|
+
# Override default status so that mapped index collections always show
|
129
|
+
# up in the resulting document manifest, when they don’t have
|
130
|
+
# associated metadata. This is the opposite of how individual pieces
|
131
|
+
# of content behave (default to draft status if one isn’t supplied).
|
132
|
+
collection_node.props[:status] = if data[:status]
|
133
|
+
data[:status]
|
134
|
+
else
|
135
|
+
"published"
|
136
|
+
end
|
137
|
+
|
138
|
+
# TODO: URL generation might need to happen elsewhere
|
139
|
+
collection_node.props[:url] = if data[:url]
|
140
|
+
data[:url]
|
141
|
+
else
|
142
|
+
"/#{type}/"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
98
147
|
build_content_nodes(graph, objects, type, index)
|
99
148
|
end
|
100
|
-
end
|
101
149
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
# TODO: pass in content converter object
|
111
|
-
# TODO: index/body content by default if extracted from frontmatter
|
112
|
-
body, data = process_content(meta_file.props[:entry])
|
113
|
-
else
|
114
|
-
# Otherwise, assume default collection behaviour
|
115
|
-
data = {}
|
116
|
-
end
|
150
|
+
# Go through each subcollection and expand content nodes step by step.
|
151
|
+
subcollections.each do |path, index|
|
152
|
+
# Group files matching the same slug under a common key
|
153
|
+
objects = graph.n(path: path).out(:file).all.select do |file|
|
154
|
+
file.props[:name].end_with?(*exts)
|
155
|
+
end.group_by do |file|
|
156
|
+
file.props[:slug]
|
157
|
+
end
|
117
158
|
|
118
|
-
|
119
|
-
unless data.key?(:title)
|
120
|
-
data[:title] = type.to_s.capitalize
|
159
|
+
build_content_nodes(graph, objects, type, index)
|
121
160
|
end
|
122
|
-
|
123
|
-
data
|
124
161
|
end
|
125
162
|
|
126
163
|
def build_content_nodes(graph, objects, type, parent_index)
|
@@ -199,20 +236,6 @@ module Yarrow
|
|
199
236
|
end
|
200
237
|
end
|
201
238
|
end
|
202
|
-
|
203
|
-
# Workaround for handling meta and content source in multiple files or a single
|
204
|
-
# file with front matter.
|
205
|
-
def process_content(path)
|
206
|
-
case path.extname
|
207
|
-
when '.htm', '.md'
|
208
|
-
read_split_content(path.to_s, symbolize_keys: true)
|
209
|
-
# when '.md'
|
210
|
-
# body, data = read_split_content(path.to_s, symbolize_keys: true)
|
211
|
-
# [Kramdown::Document.new(body).to_html, data]
|
212
|
-
when '.yml'
|
213
|
-
[nil, YAML.load(File.read(path.to_s), symbolize_names: true)]
|
214
|
-
end
|
215
|
-
end
|
216
239
|
end
|
217
240
|
end
|
218
241
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module Content
|
3
|
+
class Expansion
|
4
|
+
include Yarrow::Tools::FrontMatter
|
5
|
+
|
6
|
+
attr_reader :graph
|
7
|
+
|
8
|
+
def initialize(graph)
|
9
|
+
@graph = graph
|
10
|
+
end
|
11
|
+
|
12
|
+
# Extract collection level configuration/metadata from the root node for
|
13
|
+
# this content type.
|
14
|
+
def extract_metadata(node, type)
|
15
|
+
# TODO: support _index or _slug convention as well
|
16
|
+
meta_file = node.out(slug: type.to_s).first
|
17
|
+
|
18
|
+
if meta_file
|
19
|
+
# Process metadata and add it to the collection node
|
20
|
+
# TODO: pass in content converter object
|
21
|
+
# TODO: index/body content by default if extracted from frontmatter
|
22
|
+
body, data = process_content(meta_file.props[:entry])
|
23
|
+
else
|
24
|
+
# Otherwise, assume default collection behaviour
|
25
|
+
data = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Generate a default title if not provided in metadata
|
29
|
+
unless data.key?(:title)
|
30
|
+
data[:title] = type.to_s.capitalize
|
31
|
+
end
|
32
|
+
|
33
|
+
data
|
34
|
+
end
|
35
|
+
|
36
|
+
# Workaround for handling meta and content source in multiple files or a single
|
37
|
+
# file with front matter.
|
38
|
+
def process_content(path)
|
39
|
+
case path.extname
|
40
|
+
when '.htm', '.md'
|
41
|
+
read_split_content(path.to_s, symbolize_keys: true)
|
42
|
+
# when '.md'
|
43
|
+
# body, data = read_split_content(path.to_s, symbolize_keys: true)
|
44
|
+
# [Kramdown::Document.new(body).to_html, data]
|
45
|
+
when '.yml'
|
46
|
+
[nil, YAML.load(File.read(path.to_s), symbolize_names: true)]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/yarrow/content/graph.rb
CHANGED
@@ -2,9 +2,12 @@ module Yarrow
|
|
2
2
|
module Content
|
3
3
|
# A directed graph of every element of content in the project.
|
4
4
|
class Graph
|
5
|
-
# Construct a graph collected from
|
5
|
+
# Construct a graph collected from files and directories in the configured
|
6
|
+
# content directory.
|
7
|
+
#
|
8
|
+
# @return [Yarrow::Content::Graph]
|
6
9
|
def self.from_source(config)
|
7
|
-
new(SourceCollector.collect(config.
|
10
|
+
new(SourceCollector.collect(config.content_dir), config)
|
8
11
|
end
|
9
12
|
|
10
13
|
attr_reader :graph, :config
|
@@ -28,6 +31,16 @@ module Yarrow
|
|
28
31
|
def directories
|
29
32
|
graph.nodes(:directory)
|
30
33
|
end
|
34
|
+
|
35
|
+
# List of mapped content object collections
|
36
|
+
def collections
|
37
|
+
graph.nodes(:collection)
|
38
|
+
end
|
39
|
+
|
40
|
+
# List of mapped content object items
|
41
|
+
def items
|
42
|
+
graph.nodes(:item)
|
43
|
+
end
|
31
44
|
end
|
32
45
|
end
|
33
46
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module Content
|
3
|
+
class Manifest
|
4
|
+
def self.build(graph)
|
5
|
+
manifest = new
|
6
|
+
|
7
|
+
graph.n(:collection).each do |collection|
|
8
|
+
|
9
|
+
unless collection.props[:content_only]
|
10
|
+
manifest.add_document(collection_context(collection))
|
11
|
+
end
|
12
|
+
|
13
|
+
unless collection.props[:index_only]
|
14
|
+
collection.out(:item).each do |item|
|
15
|
+
#if item[:entity].status.to_sym == :published
|
16
|
+
manifest.add_document(item_context(item))
|
17
|
+
#end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
manifest
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :documents, :resources
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@documents = []
|
29
|
+
@resources = []
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.collection_context(collection)
|
33
|
+
Yarrow::Output::Context.new(
|
34
|
+
parent: collection.in(:collection).first,
|
35
|
+
name: collection.props[:name],
|
36
|
+
#url: collection.props[:url],
|
37
|
+
title: collection.props[:title],
|
38
|
+
type: collection.props[:type]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.item_context(item)
|
43
|
+
Yarrow::Output::Context.new(
|
44
|
+
parent: item.in(:collection).first,
|
45
|
+
name: item.props[:name],
|
46
|
+
#url: item.props[:url],
|
47
|
+
title: item.props[:title],
|
48
|
+
type: item.props[:type]
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_document(document)
|
53
|
+
@documents << document
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_resource(resource)
|
57
|
+
@resources << resource
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -9,38 +9,61 @@ module Yarrow
|
|
9
9
|
root.label = :root
|
10
10
|
end
|
11
11
|
|
12
|
+
root_dir_entry = Pathname.new(input_dir)
|
13
|
+
|
14
|
+
root_dir = create_node do |dir|
|
15
|
+
dir.label = :directory
|
16
|
+
dir.props = {
|
17
|
+
name: root_dir_entry.basename.to_s,
|
18
|
+
path: root_dir_entry.to_s,
|
19
|
+
entry: root_dir_entry
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
create_edge do |child|
|
24
|
+
child.label = :child
|
25
|
+
child.from = root.id
|
26
|
+
child.to = root_dir.id
|
27
|
+
end
|
28
|
+
|
12
29
|
directories = {
|
13
|
-
|
30
|
+
root_dir_entry.to_s => root_dir.id
|
14
31
|
}
|
15
32
|
|
16
33
|
Pathname.glob("#{input_dir}/**/**").each do |entry|
|
17
34
|
if entry.directory?
|
18
|
-
#puts "Reading directory: #{entry}"
|
19
|
-
|
20
35
|
content_node = create_node do |dir|
|
21
36
|
dir.label = :directory
|
22
|
-
dir.props[:name] = entry.basename.to_s
|
23
|
-
dir.props[:slug] = entry.basename.to_s
|
24
|
-
dir.props[:path] = entry.to_s
|
25
|
-
dir.props[:entry] = entry
|
37
|
+
# dir.props[:name] = entry.basename.to_s
|
38
|
+
# dir.props[:slug] = entry.basename.to_s
|
39
|
+
# dir.props[:path] = entry.to_s
|
40
|
+
# dir.props[:entry] = entry
|
41
|
+
dir.props = {
|
42
|
+
name: entry.basename.to_s,
|
43
|
+
path: entry.to_s,
|
44
|
+
entry: entry
|
45
|
+
}
|
26
46
|
end
|
27
47
|
|
28
48
|
directories[entry.to_s] = content_node.id
|
29
49
|
else
|
30
|
-
#puts "Reading file: #{entry} (#{entry.basename.sub_ext('')})"
|
31
|
-
|
32
50
|
content_node = create_node do |file|
|
33
51
|
file.label = :file
|
34
|
-
file.props[:name] = entry.basename.to_s
|
35
|
-
file.props[:slug] = entry.basename.sub_ext('').to_s
|
36
|
-
file.props[:path] = entry.to_s
|
37
|
-
file.props[:entry] = entry
|
52
|
+
# file.props[:name] = entry.basename.to_s
|
53
|
+
# file.props[:slug] = entry.basename.sub_ext('').to_s
|
54
|
+
# file.props[:path] = entry.to_s
|
55
|
+
# file.props[:entry] = entry
|
56
|
+
|
57
|
+
file.props = {
|
58
|
+
name: entry.basename.to_s,
|
59
|
+
ext: entry.extname.to_s,
|
60
|
+
path: entry.to_s,
|
61
|
+
entry: entry
|
62
|
+
}
|
38
63
|
end
|
39
64
|
end
|
40
65
|
|
41
66
|
if directories.key?(entry.dirname.to_s)
|
42
|
-
#puts "Create parent edge: #{directories[entry.dirname.to_s]}"
|
43
|
-
|
44
67
|
create_edge do |edge|
|
45
68
|
edge.label = :child
|
46
69
|
edge.from = directories[entry.dirname.to_s]
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module Content
|
3
|
+
class TreeExpansion < Expansion
|
4
|
+
def expand(content_type)
|
5
|
+
type = content_type.collection
|
6
|
+
exts = content_type.extensions
|
7
|
+
|
8
|
+
# If match path represents entire content dir, then include the entire
|
9
|
+
# content dir instead of scanning from a subfolder matching the name of
|
10
|
+
# the collection.
|
11
|
+
start_node = if content_type.match_path == "."
|
12
|
+
graph.n(:root)
|
13
|
+
else
|
14
|
+
graph.n(:root).out(name: type.to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Extract metadata from given start node
|
18
|
+
collection_metadata = extract_metadata(start_node, type)
|
19
|
+
|
20
|
+
# Collect all nested collections in the subgraph for this content type
|
21
|
+
subcollections = {}
|
22
|
+
item_links = []
|
23
|
+
index = nil
|
24
|
+
|
25
|
+
# Scan and collect all nested files from the root
|
26
|
+
start_node.depth_first.each do |node|
|
27
|
+
if node.label == :directory
|
28
|
+
# Create a collection node representing a collection of documents
|
29
|
+
index = graph.create_node do |collection_node|
|
30
|
+
collection_node.label = :collection
|
31
|
+
collection_node.props[:type] = type
|
32
|
+
collection_node.props[:name] = node.props[:name]
|
33
|
+
|
34
|
+
# TODO: title needs to be defined from metadata
|
35
|
+
collection_node.props[:title] = node.props[:name].capitalize
|
36
|
+
end
|
37
|
+
|
38
|
+
# Add this collection id to the lookup table for edge construction
|
39
|
+
subcollections[node.props[:path]] = index
|
40
|
+
|
41
|
+
# Join the collection to its parent
|
42
|
+
unless node.props[:slug] == type.to_s || !subcollections.key?(node.props[:entry].parent.to_s)
|
43
|
+
graph.create_edge do |edge|
|
44
|
+
edge.label = :child
|
45
|
+
edge.from = subcollections[node.props[:entry].parent.to_s].id
|
46
|
+
edge.to = index.id
|
47
|
+
end
|
48
|
+
end
|
49
|
+
elsif node.label == :file
|
50
|
+
body, meta = process_content(node.props[:entry])
|
51
|
+
|
52
|
+
# Create an item node representing a file mapped to a unique content object
|
53
|
+
item = graph.create_node do |item_node|
|
54
|
+
item_node.label = :item
|
55
|
+
item_node.props[:type] = content_type.entity
|
56
|
+
item_node.props[:name] = node.props[:entry].basename(node.props[:entry].extname).to_s
|
57
|
+
item_node.props[:body] = body if body
|
58
|
+
item_node.props[:title] = meta[:title] if meta
|
59
|
+
# TODO: better handling of metadata on node props
|
60
|
+
end
|
61
|
+
|
62
|
+
# We may not have an expanded node for the parent collection if this is a
|
63
|
+
# preorder traversal so save it for later
|
64
|
+
item_links << {
|
65
|
+
parent_path: node.props[:entry].parent.to_s,
|
66
|
+
item_id: item.id
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Once all files and directories have been expanded, connect all the child
|
72
|
+
# edges between collections and items
|
73
|
+
item_links.each do |item_link|
|
74
|
+
graph.create_edge do |edge|
|
75
|
+
edge.label = :child
|
76
|
+
edge.from = subcollections[item_link[:parent_path]].id
|
77
|
+
edge.to = item_link[:item_id]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/yarrow/generator.rb
CHANGED
@@ -1,27 +1,57 @@
|
|
1
1
|
module Yarrow
|
2
|
+
class ScanSource < Process::StepProcessor
|
3
|
+
accepts Config::Instance
|
4
|
+
provides Content::Graph
|
5
|
+
|
6
|
+
def step(config)
|
7
|
+
Yarrow::Content::Graph.from_source(config)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ExpandCollections < Process::StepProcessor
|
12
|
+
accepts Content::Graph
|
13
|
+
provides Content::Graph
|
14
|
+
|
15
|
+
def step(content)
|
16
|
+
expander = Content::CollectionExpander.new
|
17
|
+
expander.expand(content.graph)
|
18
|
+
content
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class FlattenManifest < Process::StepProcessor
|
23
|
+
accepts Content::Graph
|
24
|
+
provides Content::Manifest
|
25
|
+
|
26
|
+
def step(content)
|
27
|
+
Content::Manifest.build(content.graph)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class BuildOutput < Process::StepProcessor
|
32
|
+
accepts Content::Manifest
|
33
|
+
provides Output::Result
|
34
|
+
end
|
2
35
|
|
3
36
|
# Generates documentation from a model.
|
4
|
-
#
|
5
|
-
# Subclasses of Generator need to override the template methods,
|
6
|
-
# to specify a particular file structure to output.
|
7
37
|
class Generator
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@target = target
|
12
|
-
@site_tree = site_tree
|
38
|
+
def initialize(config)
|
39
|
+
@config = config
|
40
|
+
@workflow = Process::Workflow.new(config)
|
13
41
|
end
|
14
|
-
|
15
|
-
def
|
16
|
-
|
17
|
-
|
42
|
+
|
43
|
+
def process(&block)
|
44
|
+
workflow.connect(ScanSource.new)
|
45
|
+
workflow.connect(ExpandCollections.new)
|
46
|
+
workflow.connect(FlattenManifest.new)
|
47
|
+
|
48
|
+
workflow.process do |result|
|
49
|
+
block.call(result)
|
18
50
|
end
|
19
51
|
end
|
20
|
-
|
21
|
-
def build_docs
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
52
|
|
27
|
-
|
53
|
+
private
|
54
|
+
|
55
|
+
attr_reader :config, :workflow
|
56
|
+
end
|
57
|
+
end
|
@@ -27,12 +27,18 @@ module Yarrow
|
|
27
27
|
|
28
28
|
target_path = Pathname.new("#{docroot}#{path}")
|
29
29
|
|
30
|
-
|
30
|
+
ensure_dir_exists!(target_path.dirname)
|
31
31
|
|
32
32
|
File.open(target_path.to_s, WRITE_MODE) do |file|
|
33
33
|
file.puts(content)
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
def ensure_dir_exists!(target)
|
38
|
+
unless File.directory?(target)
|
39
|
+
FileUtils.mkdir_p(target)
|
40
|
+
end
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
end
|
data/lib/yarrow/version.rb
CHANGED
data/lib/yarrow.rb
CHANGED
@@ -9,17 +9,19 @@ require 'yarrow/schema'
|
|
9
9
|
require 'yarrow/config'
|
10
10
|
require 'yarrow/configuration'
|
11
11
|
require 'yarrow/console_runner'
|
12
|
-
require 'yarrow/generator'
|
13
12
|
require 'yarrow/tools/front_matter'
|
14
13
|
require 'yarrow/tools/content_utils'
|
15
14
|
require 'yarrow/content/graph'
|
16
|
-
require 'yarrow/content/
|
17
|
-
require 'yarrow/content/source'
|
15
|
+
require 'yarrow/content/object_type'
|
18
16
|
require 'yarrow/content/source_collector'
|
19
17
|
require 'yarrow/content/collection_expander'
|
18
|
+
require 'yarrow/content/expansion'
|
19
|
+
require 'yarrow/content/tree_expansion'
|
20
|
+
require 'yarrow/content/manifest'
|
20
21
|
require 'yarrow/output/mapper'
|
21
22
|
require 'yarrow/output/generator'
|
22
23
|
require 'yarrow/output/context'
|
24
|
+
require 'yarrow/output/result'
|
23
25
|
require 'yarrow/output/web/indexed_file'
|
24
26
|
require 'yarrow/content_map'
|
25
27
|
require 'yarrow/server'
|
@@ -31,6 +33,8 @@ require 'yarrow/process/expand_content'
|
|
31
33
|
require 'yarrow/process/extract_source'
|
32
34
|
require 'yarrow/process/project_manifest'
|
33
35
|
|
36
|
+
require 'yarrow/generator'
|
37
|
+
|
34
38
|
# Dir[File.dirname(__FILE__) + '/yarrow/generators/*.rb'].each do |generator|
|
35
39
|
# require generator
|
36
40
|
# end
|
data/yarrow.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_runtime_dependency 'em-websocket', '~> 0.5.1'
|
21
21
|
spec.add_runtime_dependency 'strings-inflection', '~> 0.1'
|
22
22
|
spec.add_runtime_dependency 'strings-case', '~> 0.3'
|
23
|
-
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
24
|
spec.add_development_dependency 'rake', '~> 13.0'
|
25
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
26
26
|
spec.add_development_dependency 'coveralls', '~> 0.8.23'
|
27
27
|
spec.add_development_dependency 'rack-test', '~> 0.8'
|
28
28
|
spec.homepage = 'http://rubygemspec.org/gems/yarrow'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mementus
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3.
|
145
|
+
version: '3.11'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '3.
|
152
|
+
version: '3.11'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: coveralls
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,10 +204,13 @@ files:
|
|
204
204
|
- lib/yarrow/configuration.rb
|
205
205
|
- lib/yarrow/console_runner.rb
|
206
206
|
- lib/yarrow/content/collection_expander.rb
|
207
|
-
- lib/yarrow/content/
|
207
|
+
- lib/yarrow/content/expansion.rb
|
208
208
|
- lib/yarrow/content/graph.rb
|
209
|
+
- lib/yarrow/content/manifest.rb
|
210
|
+
- lib/yarrow/content/object_type.rb
|
209
211
|
- lib/yarrow/content/source.rb
|
210
212
|
- lib/yarrow/content/source_collector.rb
|
213
|
+
- lib/yarrow/content/tree_expansion.rb
|
211
214
|
- lib/yarrow/content_map.rb
|
212
215
|
- lib/yarrow/defaults.yml
|
213
216
|
- lib/yarrow/extensions.rb
|
@@ -217,6 +220,7 @@ files:
|
|
217
220
|
- lib/yarrow/output/context.rb
|
218
221
|
- lib/yarrow/output/generator.rb
|
219
222
|
- lib/yarrow/output/mapper.rb
|
223
|
+
- lib/yarrow/output/result.rb
|
220
224
|
- lib/yarrow/output/web/indexed_file.rb
|
221
225
|
- lib/yarrow/process/expand_content.rb
|
222
226
|
- lib/yarrow/process/extract_source.rb
|