yarrow 0.4.0 → 0.5.1

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: 7fd14f8e13517f2b5dc5499f970f884a252d0a729dab6c2e893b22045f086683
4
- data.tar.gz: 30881c8098e7a3efa8be1e7bb0654f2b0aa5a8a8e1f14214ab3c26fef826eb7a
3
+ metadata.gz: cf4a0ff53beff8749c36f82844efeefec5463ec6ea6ebc9126fc4e0928b4d4c0
4
+ data.tar.gz: 2d4c1e187e40f5e6f6e6316e5908c1630129c28fa419c4216f06c6566d27854b
5
5
  SHA512:
6
- metadata.gz: 244f3d91ee39ec802011365f3bcc2c679df6062a7c394d79c7814fea31bf50c8ff064666c746fbec0d8f6081f82cc0ff5d0a79485346544797c6c95f36c7e159
7
- data.tar.gz: 619417887033f98b74c7febdacd41eea3c25ccdc648e769d7ae1de91700a2c700f869c0d2fd99c82e5d0ddb9e374b5d4abe44f71e5a773865fdcb830c724dac3
6
+ metadata.gz: 9624eb95caeb74e736c561d1bdfc18387d2e308427661073147b46377f35add1fd5aa7b03f758107e902fbbb741b6a7a070fd1cfc71a2371f3965774d1ddb128
7
+ data.tar.gz: 3ae340c7e995e51b6a09ef86bf1faa191565a73bd61660d8276f9f77c6722633717dd027e137b0de2eab3f8a320befc1903ed2ef3f5287a83e99ad6d0eda761b
@@ -0,0 +1,23 @@
1
+ name: Ruby
2
+ on:
3
+ push:
4
+ branches: [ master ]
5
+ pull_request:
6
+ branches: [ master ]
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os: [ubuntu-latest, macos-latest]
13
+ ruby: [2.7, '3.0', jruby]
14
+ runs-on: ${{ matrix.os }}
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - name: Run tests
23
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.tgz
2
+ fabfile.py
3
+ fabfile.pyc
4
+ pirum.xml
5
+ Gemfile.lock
6
+ yarrow-*.gem
7
+ coverage
8
+ bin/scripts
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2010-2014 by Mark Rickerby <http://maetl.net>.
2
+ All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ Yarrow
2
+ ======
3
+
4
+ [![Gem Version](http://img.shields.io/gem/v/yarrow.svg)][gem]
5
+ [![Build Status](http://img.shields.io/travis/maetl/yarrow.svg)][travis]
6
+ [![Dependency Status](http://img.shields.io/gemnasium/maetl/yarrow.svg)][gemnasium]
7
+ [![Code Climate](http://img.shields.io/codeclimate/github/maetl/yarrow.svg)][codeclimate]
8
+ [![Coverage Status](http://img.shields.io/coveralls/maetl/yarrow.svg)][coveralls]
9
+
10
+ [gem]: https://rubygems.org/gems/yarrow
11
+ [travis]: https://travis-ci.org/maetl/yarrow
12
+ [gemnasium]: https://gemnasium.com/maetl/yarrow
13
+ [codeclimate]: https://codeclimate.com/github/maetl/yarrow
14
+ [coveralls]: https://coveralls.io/r/maetl/yarrow
15
+
16
+ Yarrow is a tool for generating well structured documentation from a variety of input sources.
17
+
18
+ Unlike most static site generators and code documentation tools, Yarrow is written with design and content-strategy in mind. It does not impose its own structure on your content. This makes it appropriate for building static sites and blogs as well as style guides and API docs.
19
+
20
+ Installation
21
+ ------------
22
+
23
+ Install the library and command line tool via RubyGems:
24
+
25
+ ```
26
+ gem install yarrow
27
+ ```
28
+
29
+ Or embed it in an existing Ruby project by adding the following line to the `Gemfile` and running `bundle`:
30
+
31
+ ```
32
+ gem 'yarrow'
33
+ ```
34
+
35
+ Status
36
+ ------
37
+
38
+ Yarrow is an extraction from several existing private documentation projects. This repo is in alpha state, which means that many of the useful features are not yet folded into this codebase.
39
+
40
+ Yarrow is being slowly developed as a part-time project to scratch a few itches. New features and bugfixes are pushed straight to master, and releases of the Gem are kept more or less in sync with the planned roadmap.
41
+
42
+ Roadmap
43
+ -------
44
+
45
+ A rough sketch of the project direction.
46
+
47
+ | Version | Features |
48
+ |---------|----------|
49
+ | `0.3` | **[Local dev server and asset pipeline](https://github.com/maetl/yarrow/issues/48)** |
50
+ | `0.4` | Default media type mapping, collector, markup converters |
51
+ | `0.5` | Content model/object mapping, template/site context |
52
+ | `0.6` | HTML tag helpers, default layout templates |
53
+ | `0.7` | Rake integration, task library |
54
+ | `0.8` | Generic command line runner |
55
+ | `0.9` | Refactoring, performance fixes, lock down API |
56
+
57
+ License
58
+ -------
59
+
60
+ MIT. See the `LICENSE` file in the source distribution.
61
+
62
+ Contact
63
+ -------
64
+
65
+ Author: Mark Rickerby <me@maetl.net>
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+
2
+ task :clean do
3
+ sh 'rm yarrow-*.gem'
4
+ end
data/SERVER.md ADDED
@@ -0,0 +1,41 @@
1
+ # Local Dev Server
2
+
3
+ Yarrow provides a local dev server for quick previews and incremental development of documentation.
4
+
5
+ ## Getting Started
6
+
7
+ To start the server in the current working directory, run `yarrow-server`:
8
+
9
+ ```
10
+ $ yarrow-server
11
+ ```
12
+
13
+ ## Directory Indexes
14
+
15
+ There are several options that control the behavior of directory indexes:
16
+
17
+ - `default_index` sets the name of the file used as a default directory index (usually `index.html`).
18
+ - `auto_index` generates a listing of files in the directory when no default index is provided.
19
+
20
+ ## Default Content Type
21
+
22
+ To set a default content type for files without an automatically detected MIME type or extension, use `default_type`:
23
+
24
+ ```
25
+ default_type: 'text/html'
26
+ ```
27
+
28
+ ## Rack Configuration
29
+
30
+ The following options are available under the `server` entry in the main configuration:
31
+
32
+ |Option|Type|Description|Default|
33
+ |-|-|-|-|
34
+ |**port**|Integer|Local port for the server to listen on|`8888`|
35
+ |**host**|String|Local host for the server to listen on|`localhost`|
36
+ |**handler**|Symbol (one of `:thin`, `:webrick`, etc)|Specifies the webserver implementation that handles requests|`:thin`|
37
+ |**middleware**|Array|List of Rack middleware to be injected as plugins|
38
+
39
+ Additional configuration options that are relevant:
40
+
41
+ `config.output_dir`: If specified, determines the docroot. Otherwise the server defaults to the current working directory.
data/lib/yarrow.rb CHANGED
@@ -1,21 +1,34 @@
1
1
  require 'hashie'
2
2
  require 'yaml'
3
+ require 'active_support/inflector'
3
4
 
4
5
  require 'yarrow/version'
5
6
  require 'yarrow/logging'
6
7
  require 'yarrow/configuration'
7
8
  require 'yarrow/console_runner'
8
9
  require 'yarrow/generator'
10
+ require 'yarrow/assets'
11
+ require 'yarrow/tools/front_matter'
12
+ require 'yarrow/content/graph'
13
+ require 'yarrow/content/content_type'
14
+ require 'yarrow/content/source'
15
+ require 'yarrow/content/source_collector'
16
+ require 'yarrow/content/collection_expander'
9
17
  require 'yarrow/html/asset_tags'
10
18
  require 'yarrow/output/mapper'
11
19
  require 'yarrow/output/generator'
12
20
  require 'yarrow/output/context'
13
21
  require 'yarrow/content_map'
14
- require 'yarrow/assets'
15
22
  require 'yarrow/html'
16
- require 'yarrow/tools/front_matter'
17
23
  require 'yarrow/server'
18
24
  require 'yarrow/server/livereload'
25
+ require 'yarrow/schema'
26
+
27
+ require 'yarrow/process/workflow'
28
+ require 'yarrow/process/step_processor'
29
+ require 'yarrow/process/expand_content'
30
+ require 'yarrow/process/extract_source'
31
+ require 'yarrow/process/project_manifest'
19
32
 
20
33
  # Dir[File.dirname(__FILE__) + '/yarrow/generators/*.rb'].each do |generator|
21
34
  # require generator
@@ -0,0 +1,219 @@
1
+ puts "CollectionExpander!!!"
2
+
3
+ module Yarrow
4
+ module Content
5
+ class CollectionExpander
6
+ include Yarrow::Tools::FrontMatter
7
+
8
+ def initialize(content_types=nil)
9
+ @content_types = content_types || [
10
+ Yarrow::Content::ContentType.from_name(:pages)
11
+ ]
12
+ end
13
+
14
+ def expand(graph)
15
+ @content_types.each do |content_type|
16
+ expand_nested(graph, content_type)
17
+ end
18
+ end
19
+
20
+ def expand_nested(graph, content_type)
21
+ type = content_type.collection
22
+ exts = content_type.extensions
23
+
24
+ # If match path represents entire content dir, then include the entire
25
+ # content dir instead of scanning from a subfolder matching the name of
26
+ # the collection.
27
+ start_node = if content_type.match_path == "."
28
+ graph.n(:root)
29
+ else
30
+ graph.n(:root).out(name: type.to_s)
31
+ end
32
+
33
+ # Extract metadata from given start node
34
+ data = extract_metadata(start_node, type)
35
+
36
+ # Collects all nested collections in the subgraph for this content type
37
+ subcollections = {}
38
+ index = nil
39
+
40
+ # Define alias for accessing metadata in the loop
41
+ metadata = data
42
+
43
+ # Scan and collect all nested directories under the top level source
44
+ start_node.depth_first.each do |node|
45
+ if node.label == :directory
46
+ # Check if this entry has metadata defined at the top level
47
+ if data[:collections]
48
+ item = data[:collections].find { |c| c[:slug] == node.props[:slug] }
49
+ metadata = item if item
50
+ end
51
+
52
+ # Create a collection node representing a collection of documents
53
+ index = graph.create_node do |collection_node|
54
+ collection_node.label = :collection
55
+ collection_node.props[:type] = type
56
+ collection_node.props[:name] = node.props[:name]
57
+ collection_node.props[:slug] = node.props[:slug]
58
+ collection_node.props[:title] = metadata[:title]
59
+
60
+ # Override default status so that mapped index collections always show
61
+ # up in the resulting document manifest, when they don’t have
62
+ # associated metadata. This is the opposite of how individual pieces
63
+ # of content behave (default to draft status if one isn’t supplied).
64
+ collection_node.props[:status] = if data[:status]
65
+ data[:status]
66
+ else
67
+ "published"
68
+ end
69
+
70
+ # TODO: URL generation might need to happen elsewhere
71
+ collection_node.props[:url] = if data[:url]
72
+ data[:url]
73
+ else
74
+ "#{node.props[:path].split('./content').last}/"
75
+ end
76
+ end
77
+
78
+ # Add this collection id to the lookup table for edge construction
79
+ subcollections[node.props[:path]] = index
80
+
81
+ # Join the collection to its parent
82
+ unless node.props[:slug] == type.to_s || !subcollections.key?(node.props[:entry].parent.to_s)
83
+ graph.create_edge do |edge|
84
+ edge.label = :child
85
+ edge.from = subcollections[node.props[:entry].parent.to_s].id
86
+ edge.to = index.id
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ subcollections.each do |path, index|
93
+ # Group files matching the same slug under a common key
94
+ objects = graph.n(path: path).out(:file).all.select do |file|
95
+ file.props[:name].end_with?(*exts)
96
+ end.group_by do |file|
97
+ file.props[:slug]
98
+ end
99
+
100
+ build_content_nodes(graph, objects, type, index)
101
+ end
102
+ end
103
+
104
+ # Extract collection level configuration/metadata from the root node for
105
+ # this content type.
106
+ def extract_metadata(node, type)
107
+ # TODO: support _index or _slug convention as well
108
+ meta_file = node.out(slug: type.to_s).first
109
+
110
+ if meta_file
111
+ # Process metadata and add it to the collection node
112
+ # TODO: pass in content converter object
113
+ # TODO: index/body content by default if extracted from frontmatter
114
+ body, data = process_content(meta_file.props[:entry])
115
+ else
116
+ # Otherwise, assume default collection behaviour
117
+ data = {}
118
+ end
119
+
120
+ # Generate a default title if not provided in metadata
121
+ unless data.key?(:title)
122
+ data[:title] = type.to_s.capitalize
123
+ end
124
+
125
+ data
126
+ end
127
+
128
+ def build_content_nodes(graph, objects, type, parent_index)
129
+ # TODO: this may need to use a strategy that can be overriden
130
+ content_type = ActiveSupport::Inflector.singularize(type).to_sym
131
+
132
+ # Process collected content objects and generate entity nodes
133
+ objects.each do |name, sources|
134
+ item_node = graph.create_node do |node|
135
+ # TODO: Rename this to :entry and support similar fields to Atom
136
+ node.label = :item
137
+ node.props[:name] = name
138
+ node.props[:type] = content_type
139
+
140
+ meta = {}
141
+ content = ""
142
+
143
+ sources.each do |source|
144
+ body, data = process_content(source.props[:entry])
145
+ meta.merge!(data) unless data.nil?
146
+ content << body unless body.nil?
147
+ end
148
+
149
+ if meta[:url]
150
+ # If a URL is explicitly proided in metadata then use it
151
+ node.props[:url] = meta[:url]
152
+ elsif meta[:permalink]
153
+ # Support for legacy permalink attribute
154
+ node.props[:url] = meta[:permalink]
155
+ else
156
+ # Default URL generation strategy when no explicit URL is provided
157
+ # TODO: collection nodes need URL generation too
158
+ # TODO: replace this with URL generation strategy
159
+ # TODO: slug vs name - why do some nodes have 2 and some 3 props?
160
+ node.props[:url] = if parent_index.props[:name].to_sym == parent_index.props[:type]
161
+ "/#{parent_index.props[:type]}/#{name}"
162
+ else
163
+ "/#{parent_index.props[:type]}/#{parent_index.props[:slug]}/#{name}"
164
+ end
165
+ end
166
+
167
+ # For now, we are storing title, url, etc on the top-level item.
168
+ node.props[:title] = meta[:title]
169
+
170
+ # TODO: What belongs on the entity and what belongs on the item?
171
+ entity_props = meta.merge(body: content, name: meta[:id], url: node.props[:url])
172
+
173
+
174
+ # TODO: consider whether to provide `body` on the item/document or at
175
+ # the custom content type level.
176
+ begin
177
+ content_struct = Object.const_get(ActiveSupport::Inflector.classify(content_type))
178
+ rescue
179
+ require "ostruct"
180
+ content_struct = OpenStruct
181
+ end
182
+
183
+ node.props[:entity] = content_struct.new(entity_props)
184
+ end
185
+
186
+ # Connect entity with source content
187
+ sources.each do |source|
188
+ graph.create_edge do |edge|
189
+ edge.label = :source
190
+ edge.from = item_node
191
+ edge.to = source.id
192
+ end
193
+ end
194
+
195
+ # Connect entity with parent collection
196
+ graph.create_edge do |edge|
197
+ edge.label = :child
198
+ edge.from = parent_index
199
+ edge.to = item_node
200
+ end
201
+ end
202
+ end
203
+
204
+ # Workaround for handling meta and content source in multiple files or a single
205
+ # file with front matter.
206
+ def process_content(path)
207
+ case path.extname
208
+ when '.htm', '.md'
209
+ read_split_content(path.to_s, symbolize_keys: true)
210
+ # when '.md'
211
+ # body, data = read_split_content(path.to_s, symbolize_keys: true)
212
+ # [Kramdown::Document.new(body).to_html, data]
213
+ when '.yml'
214
+ [nil, YAML.load(File.read(path.to_s), symbolize_names: true)]
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
@@ -0,0 +1,38 @@
1
+ module Yarrow
2
+ module Content
3
+ class ContentType
4
+ DEFAULT_EXTENSIONS = [".md", ".yml", ".htm"]
5
+
6
+ def self.from_name(name)
7
+ new(Yarrow::Configuration.new(collection: name.to_sym))
8
+ end
9
+
10
+ def initialize(properties)
11
+ unless properties.respond_to?(:collection) || properties.respond_to?(:entity)
12
+ raise "Must provide a collection name or entity name"
13
+ end
14
+
15
+ @properties = properties
16
+ end
17
+
18
+ def collection
19
+ return @properties.collection if @properties.respond_to?(:collection)
20
+ ActiveSupport::Inflector.pluralize(@properties.entity).to_sym
21
+ end
22
+
23
+ def entity
24
+ return @properties.entity if @properties.respond_to?(:entity)
25
+ ActiveSupport::Inflector.singularize(@properties.collection).to_sym
26
+ end
27
+
28
+ def extensions
29
+ return @properties.extensions if @properties.respond_to?(:extensions)
30
+ DEFAULT_EXTENSIONS
31
+ end
32
+
33
+ def match_path
34
+ "."
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,58 @@
1
+ require "mementus"
2
+
3
+ module Mementus
4
+ module Pipeline
5
+ class Step
6
+ # Monkeypatch extension to ensure each pipeline step supports enumerable
7
+ # methods. Mostly used for #map. API needs to be fixed in the gem itself.
8
+ include Enumerable
9
+ end
10
+ end
11
+ module Structure
12
+ class IncidenceList
13
+ def inspect
14
+ "<Mementus::Structure::IncidenceList>"
15
+ end
16
+ end
17
+ end
18
+ class Graph
19
+ def inspect
20
+ "<Mementus::Graph @structure=#{@structure.inspect} " +
21
+ "nodes_count=#{nodes_count} edges_count=#{edges_count}>"
22
+ end
23
+ end
24
+ end
25
+
26
+ module Yarrow
27
+ module Content
28
+ # A directed graph of every element of content in the project.
29
+ class Graph
30
+ # Construct a graph collected from source content files.
31
+ def self.from_source(config)
32
+ new(SourceCollector.collect(config.input_dir), config)
33
+ end
34
+
35
+ attr_reader :graph, :config
36
+
37
+ def initialize(graph, config)
38
+ @graph = graph
39
+ @config = config
40
+ end
41
+
42
+ def expand_pages
43
+ expander = Yarrow::Content::CollectionExpander.new(config.content_types)
44
+ expander.expand(graph)
45
+ end
46
+
47
+ # List of source files.
48
+ def files
49
+ graph.nodes(:file)
50
+ end
51
+
52
+ # List of source directories.
53
+ def directories
54
+ graph.nodes(:directory)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,11 @@
1
+ module Yarrow
2
+ module Content
3
+ class Source
4
+ attr_reader :input_dir
5
+
6
+ def initialize(config)
7
+ @input_dir = config[:input_dir]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,55 @@
1
+ module Yarrow
2
+ module Content
3
+ # Collects a digraph of all directories and files underneath the given input
4
+ # directory.
5
+ class SourceCollector
6
+ def self.collect(input_dir)
7
+ Mementus::Graph.new(is_mutable: true) do
8
+ root = create_node do |root|
9
+ root.label = :root
10
+ end
11
+
12
+ directories = {
13
+ Pathname.new(input_dir).to_s => root.id
14
+ }
15
+
16
+ Pathname.glob("#{input_dir}/**/**").each do |entry|
17
+ if entry.directory?
18
+ #puts "Reading directory: #{entry}"
19
+
20
+ content_node = create_node do |dir|
21
+ 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
26
+ end
27
+
28
+ directories[entry.to_s] = content_node.id
29
+ else
30
+ #puts "Reading file: #{entry} (#{entry.basename.sub_ext('')})"
31
+
32
+ content_node = create_node do |file|
33
+ 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
38
+ end
39
+ end
40
+
41
+ if directories.key?(entry.dirname.to_s)
42
+ #puts "Create parent edge: #{directories[entry.dirname.to_s]}"
43
+
44
+ create_edge do |edge|
45
+ edge.label = :child
46
+ edge.from = directories[entry.dirname.to_s]
47
+ edge.to = content_node
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,15 +1,12 @@
1
1
  module Yarrow
2
2
  module Output
3
-
4
- ##
5
3
  # Provides a data context for rendering a template.
6
4
  #
7
- # Methods provided by this class become available as named variables in Mustache templates.
8
- #
9
- # Includes the library of helpers for dynamically generating HTML tags.
5
+ # Methods provided by this class become available as named variables in
6
+ # Mustache templates.
10
7
  #
8
+ # Includes the library of helpers for dynamically generating HTML tags.
11
9
  class Context
12
-
13
10
  include Yarrow::HTML::AssetTags
14
11
 
15
12
  def initialize(attributes)
@@ -19,6 +16,5 @@ module Yarrow
19
16
  end
20
17
  end
21
18
  end
22
-
23
19
  end
24
20
  end
@@ -0,0 +1,12 @@
1
+ module Yarrow
2
+ module Process
3
+ class ExpandContent < StepProcessor
4
+ accepts String
5
+ provides String
6
+
7
+ def step(source)
8
+ "#{source} | ExpandContent::Result"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Yarrow
2
+ module Process
3
+ class ExtractSource < StepProcessor
4
+ accepts String
5
+ provides String
6
+
7
+ def step(source)
8
+ "#{source} | ExtractSource::Result"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ module Yarrow
2
+ module Process
3
+ class ProjectManifest < StepProcessor
4
+ accepts String
5
+ provides String
6
+
7
+ def before_step(content)
8
+
9
+ end
10
+
11
+ def step(content)
12
+ "#{content} | ProjectManifest::Result"
13
+ end
14
+
15
+ def after_step(content)
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ module Yarrow
2
+ module Process
3
+ class StepProcessor
4
+ attr_reader :source
5
+
6
+ class << self
7
+ attr_reader :accepted_input, :provided_output
8
+
9
+ def accepts(input_const)
10
+ @accepted_input = input_const.to_s
11
+ end
12
+
13
+ def provides(output_const)
14
+ @provided_output = output_const.to_s
15
+ end
16
+ end
17
+
18
+ def initialize
19
+ @source = nil
20
+ end
21
+
22
+ def accepts
23
+ self.class.accepted_input
24
+ end
25
+
26
+ def provides
27
+ self.class.provided_output
28
+ end
29
+
30
+ def can_accept?(provided)
31
+ accepts == provided
32
+ end
33
+
34
+ def process(source)
35
+ # begin
36
+ result = step(source)
37
+ # log.info("<Result source=#{result}>")
38
+ # rescue
39
+ result
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module Yarrow
2
+ module Process
3
+ class Workflow
4
+ def initialize(input)
5
+ @input = input
6
+ @processors = []
7
+ end
8
+
9
+ def connect(processor)
10
+ provided_input = if @processors.any?
11
+ @processors.last.provides
12
+ else
13
+ @input.class.to_s
14
+ end
15
+
16
+ if processor.can_accept?(provided_input)
17
+ @processors << processor
18
+ else
19
+ raise ArgumentError.new(
20
+ "`#{processor.class}` accepts `#{processor.accepts}` but was connected to `#{provided_input}`"
21
+ )
22
+ end
23
+ end
24
+
25
+ def process(&block)
26
+ result = @input
27
+
28
+ @processors.each do |processor|
29
+ result = processor.process(result)
30
+ end
31
+
32
+ block.call(result)
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/yarrow/server.rb CHANGED
@@ -16,6 +16,7 @@ module Yarrow
16
16
  # Rack Middleware for detecting and serving an 'index.html' file
17
17
  # instead of a directory index.
18
18
  #
19
+ # TODO: Fix bug where a directory /index.html/ causes this to crash
19
20
  # TODO: Add configurable mapping and media types for README files as an alternative
20
21
  class DirectoryIndex
21
22
  def initialize(app, options={})
@@ -0,0 +1,6 @@
1
+ module Yarrow
2
+ module Source
3
+ class Graph
4
+ end
5
+ end
6
+ end
@@ -13,7 +13,7 @@ module Yarrow
13
13
 
14
14
  begin
15
15
  if options.key?(:symbolize_keys)
16
- meta = symbolize_keys(YAML.load($1))
16
+ meta = YAML.load($1, symbolize_names: true)
17
17
  else
18
18
  meta = YAML.load($1)
19
19
  end
@@ -30,22 +30,6 @@ module Yarrow
30
30
 
31
31
  [text, nil]
32
32
  end
33
-
34
- def symbolize_keys(hash)
35
- hash.inject({}) do |result, (key, value)|
36
- new_key = case key
37
- when String then key.to_sym
38
- else key
39
- end
40
- new_value = case value
41
- when Hash then symbolize_keys(value)
42
- when Array then value.map { |entry| symbolize_keys(entry) }
43
- else value
44
- end
45
- result[new_key] = new_value
46
- result
47
- end
48
- end
49
33
  end
50
34
  end
51
35
  end
@@ -1,4 +1,4 @@
1
1
  module Yarrow
2
2
  APP_NAME = 'Yarrow'.freeze
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.5.1'.freeze
4
4
  end
data/yarrow.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ require 'yarrow/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'yarrow'
7
+ spec.version = Yarrow::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.summary = 'Documentation generator based on a fluent data model.'
10
+ spec.description = 'Yarrow is a tool for generating well structured documentation from a variety of input sources.'
11
+ spec.authors = ['Mark Rickerby']
12
+ spec.email = 'me@maetl.net'
13
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
14
+ spec.executables << 'yarrow'
15
+ spec.executables << 'yarrow-server'
16
+ spec.add_runtime_dependency 'hashie', '~> 3.5'
17
+ spec.add_runtime_dependency 'mementus', '~> 0.8'
18
+ spec.add_runtime_dependency 'activesupport', '~> 5.1'
19
+ spec.add_runtime_dependency 'rack', '~> 2.0'
20
+ spec.add_runtime_dependency 'rack-livereload', '~> 0.3'
21
+ spec.add_runtime_dependency 'eventmachine', '~> 1.2'
22
+ spec.add_runtime_dependency 'em-websocket', '~> 0.5.1'
23
+ spec.add_runtime_dependency 'sprockets', '~> 3.7'
24
+ spec.add_development_dependency 'bundler', '~> 2.2.9'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.10'
27
+ spec.add_development_dependency 'coveralls', '~> 0.8.23'
28
+ spec.add_development_dependency 'rack-test', '~> 0.8'
29
+ spec.homepage = 'http://rubygemspec.org/gems/yarrow'
30
+ spec.license = 'MIT'
31
+ end
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.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rickerby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -108,62 +108,76 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.5.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: sprockets
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.7'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.7'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '1.3'
131
+ version: 2.2.9
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '1.3'
138
+ version: 2.2.9
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '12.3'
145
+ version: '13.0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '12.3'
152
+ version: '13.0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rspec
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '3.7'
159
+ version: '3.10'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '3.7'
166
+ version: '3.10'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: coveralls
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '0.8'
173
+ version: 0.8.23
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '0.8'
180
+ version: 0.8.23
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rack-test
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +201,13 @@ executables:
187
201
  extensions: []
188
202
  extra_rdoc_files: []
189
203
  files:
204
+ - ".github/workflows/ruby.yml"
205
+ - ".gitignore"
206
+ - Gemfile
207
+ - LICENSE
208
+ - README.md
209
+ - Rakefile
210
+ - SERVER.md
190
211
  - bin/yarrow
191
212
  - bin/yarrow-server
192
213
  - lib/yarrow.rb
@@ -195,6 +216,11 @@ files:
195
216
  - lib/yarrow/assets/pipeline.rb
196
217
  - lib/yarrow/configuration.rb
197
218
  - lib/yarrow/console_runner.rb
219
+ - lib/yarrow/content/collection_expander.rb
220
+ - lib/yarrow/content/content_type.rb
221
+ - lib/yarrow/content/graph.rb
222
+ - lib/yarrow/content/source.rb
223
+ - lib/yarrow/content/source_collector.rb
198
224
  - lib/yarrow/content_map.rb
199
225
  - lib/yarrow/defaults.yml
200
226
  - lib/yarrow/generator.rb
@@ -205,11 +231,18 @@ files:
205
231
  - lib/yarrow/output/context.rb
206
232
  - lib/yarrow/output/generator.rb
207
233
  - lib/yarrow/output/mapper.rb
234
+ - lib/yarrow/process/expand_content.rb
235
+ - lib/yarrow/process/extract_source.rb
236
+ - lib/yarrow/process/project_manifest.rb
237
+ - lib/yarrow/process/step_processor.rb
238
+ - lib/yarrow/process/workflow.rb
208
239
  - lib/yarrow/server.rb
209
240
  - lib/yarrow/server/livereload.rb
241
+ - lib/yarrow/source/graph.rb
210
242
  - lib/yarrow/tools/front_matter.rb
211
243
  - lib/yarrow/tools/output_file.rb
212
244
  - lib/yarrow/version.rb
245
+ - yarrow.gemspec
213
246
  homepage: http://rubygemspec.org/gems/yarrow
214
247
  licenses:
215
248
  - MIT
@@ -229,8 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
262
  - !ruby/object:Gem::Version
230
263
  version: '0'
231
264
  requirements: []
232
- rubyforge_project:
233
- rubygems_version: 2.7.6
265
+ rubygems_version: 3.1.2
234
266
  signing_key:
235
267
  specification_version: 4
236
268
  summary: Documentation generator based on a fluent data model.