jekyll-sheafy 0.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 +7 -0
- data/CHANGELOG.md +18 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/lib/jekyll/sheafy/directed_graph.rb +87 -0
- data/lib/jekyll/sheafy/version.rb +5 -0
- data/lib/jekyll/sheafy.rb +1 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d4d015eba5703cb9cc20923e78d52aa6e34581793348d3283e2652f375947d4
|
4
|
+
data.tar.gz: 87eb2cde0952ff0887a711d6c00d93101f3b67072953946cdcdbfaa196f8a58a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e193c3aefb25940bb7d905bca9cb6090a9b2c64614f589eeaf7366299768ef79895dff96966c52f18abe3fb281f2404e207f89582eb05da173a30207d0ca0795
|
7
|
+
data.tar.gz: 3f8a4517fd4c1e5dcc7fbb3a6cbe4c56e3b9512607756ca66f2f7d951a63185d4152266ec6c274eb69c11e935dd5a5e7aefac5e0d73c4b8ec6b0be9ddf9d044c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.1.0] - 2022-01-28
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Structure to represent directed graphs.
|
15
|
+
- Topological checks for rooted forests.
|
16
|
+
|
17
|
+
[unreleased]: https://github.com/paolobrasolin/jekyll-sheafy/compare/0.1.0...HEAD
|
18
|
+
[0.1.0]: https://github.com/paolobrasolin/jekyll-sheafy/releases/tag/0.1.0
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Paolo Brasolin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# jekyll-sheafy
|
2
|
+
|
3
|
+
[![CI tests status badge][build-shield]][build-url]
|
4
|
+
[![Latest release badge][rubygems-shield]][rubygems-url]
|
5
|
+
[![License badge][license-shield]][license-url]
|
6
|
+
[![Maintainability badge][cc-maintainability-shield]][cc-maintainability-url]
|
7
|
+
[![Test coverage badge][cc-coverage-shield]][cc-coverage-url]
|
8
|
+
|
9
|
+
[build-shield]: https://img.shields.io/github/workflow/status/paolobrasolin/jekyll-sheafy/CI/main?label=tests&logo=github
|
10
|
+
[build-url]: https://github.com/paolobrasolin/jekyll-sheafy/actions/workflows/main.yml "CI tests status"
|
11
|
+
[rubygems-shield]: https://img.shields.io/gem/v/jekyll-sheafy?logo=ruby
|
12
|
+
[rubygems-url]: https://rubygems.org/gems/jekyll-sheafy "Latest release"
|
13
|
+
[license-shield]: https://img.shields.io/github/license/paolobrasolin/jekyll-sheafy
|
14
|
+
[license-url]: https://github.com/paolobrasolin/jekyll-sheafy/blob/main/LICENSE "License"
|
15
|
+
[cc-maintainability-shield]: https://img.shields.io/codeclimate/maintainability/paolobrasolin/jekyll-sheafy?logo=codeclimate
|
16
|
+
[cc-maintainability-url]: https://codeclimate.com/github/paolobrasolin/jekyll-sheafy "Maintainability"
|
17
|
+
[cc-coverage-shield]: https://img.shields.io/codeclimate/coverage/paolobrasolin/jekyll-sheafy?logo=codeclimate&label=test%20coverage
|
18
|
+
[cc-coverage-url]: https://codeclimate.com/github/paolobrasolin/jekyll-sheafy/coverage "Test coverage"
|
19
|
+
|
20
|
+
`jekyll-sheafy` is a [Jekyll][jekyll-url] plugin inspired by [Gerby][gerby-url] which allows you to setup websites similar to [the Stacks project][stacks-url] and [Kerodon][kerodon-url].
|
21
|
+
|
22
|
+
## Getting started
|
23
|
+
|
24
|
+
TODO
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
TODO
|
29
|
+
|
30
|
+
## Roadmap
|
31
|
+
|
32
|
+
TODO
|
33
|
+
|
34
|
+
## Acknowledgements
|
35
|
+
|
36
|
+
- Thanks to [@jonsterling](https://github.com/jonsterling) for [having the idea][math-url] and letting me collaborate and spin it off.
|
37
|
+
|
38
|
+
[jekyll-url]: https://jekyllrb.com/
|
39
|
+
[math-url]: https://github.com/jonsterling/math
|
40
|
+
[gerby-url]: https://gerby-project.github.io/
|
41
|
+
[stacks-url]: https://stacks.math.columbia.edu/
|
42
|
+
[kerodon-url]: https://kerodon.net/
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "tsort"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Sheafy
|
5
|
+
class DirectedGraph < Hash
|
6
|
+
class PayloadError < StandardError
|
7
|
+
attr_reader :payload
|
8
|
+
|
9
|
+
def initialize(payload)
|
10
|
+
@payload = payload
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class MissingKeysError < PayloadError; end
|
16
|
+
class InvalidValuesError < PayloadError; end
|
17
|
+
class MultipleEdgesError < PayloadError; end
|
18
|
+
class LoopsError < PayloadError; end
|
19
|
+
class CyclesError < PayloadError; end
|
20
|
+
class IndegreeError < PayloadError; end
|
21
|
+
|
22
|
+
def ensure_rooted_forest!
|
23
|
+
ensure_valid!
|
24
|
+
ensure_simple!
|
25
|
+
ensure_acyclic!
|
26
|
+
ensure_transposed_pseudoforest!
|
27
|
+
end
|
28
|
+
|
29
|
+
def ensure_valid!
|
30
|
+
invalid_values = values.reject { |v| v.is_a? Array }
|
31
|
+
raise InvalidValuesError.new(invalid_values) if invalid_values.any?
|
32
|
+
missing_keys = values.flat_map { |v| v - keys }.uniq
|
33
|
+
raise MissingKeysError.new(missing_keys) if missing_keys.any?
|
34
|
+
end
|
35
|
+
|
36
|
+
def ensure_simple!
|
37
|
+
multiple_edges =
|
38
|
+
transform_values { |cs| cs.tally.filter { |_, v| v > 1 }.keys }.
|
39
|
+
reject { |_, cs| cs.empty? }
|
40
|
+
raise MultipleEdgesError.new(multiple_edges) if multiple_edges.any?
|
41
|
+
loops = filter { |k, v| v.include?(k) }.keys.map { |k| [k, [k]] }.to_h
|
42
|
+
raise LoopsError.new(loops) if loops.any?
|
43
|
+
end
|
44
|
+
|
45
|
+
def ensure_acyclic!
|
46
|
+
cycles = TSort.strongly_connected_components(method(:tsort_each_node), method(:tsort_each_child)).reject(&:one?)
|
47
|
+
raise CyclesError.new(cycles) if cycles.any?
|
48
|
+
end
|
49
|
+
|
50
|
+
def ensure_transposed_pseudoforest!
|
51
|
+
# Note that
|
52
|
+
# "transposed graph is a pseudoforest"
|
53
|
+
# = "transposed graph has outdegrees <= 1"
|
54
|
+
# = "graph has indegrees <= 1"
|
55
|
+
t_graph = self.class.transpose(self)
|
56
|
+
t_edges_from_high_outdeg = t_graph.filter { |_, ns| ns.size > 1 }
|
57
|
+
return if t_edges_from_high_outdeg.empty?
|
58
|
+
edges_to_high_indeg = self.class.transpose(t_edges_from_high_outdeg)
|
59
|
+
raise IndegreeError.new(edges_to_high_indeg)
|
60
|
+
end
|
61
|
+
|
62
|
+
def topologically_sorted
|
63
|
+
# TODO: cache tsort calculation
|
64
|
+
ensure_acyclic!
|
65
|
+
TSort.tsort(method(:tsort_each_node), method(:tsort_each_child))
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.transpose(adjacency_list)
|
69
|
+
Hash.new { |h, k| h[k] = [] }.tap do |transposed_adjacency_list|
|
70
|
+
adjacency_list.each_pair do |parent, children|
|
71
|
+
children.each { |child| transposed_adjacency_list[child] << parent }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def tsort_each_node(&block)
|
79
|
+
each_key(&block)
|
80
|
+
end
|
81
|
+
|
82
|
+
def tsort_each_child(node, &block)
|
83
|
+
fetch(node).each(&block)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "jekyll/sheafy/version"
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-sheafy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paolo Brasolin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: byebug
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 11.1.3
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 11.1.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.10.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.10.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rufo
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.13.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.13.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: simplecov
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.21.2
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.21.2
|
89
|
+
description: This Jekyll plugin is heavily inspired by Gerby, the tool used to build
|
90
|
+
the Stacks Project and Kerodon. It allows you to build math textbooks as static
|
91
|
+
websites which require no complex infrastructure to run.
|
92
|
+
email:
|
93
|
+
- paolo.brasolin@gmail.com
|
94
|
+
executables: []
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- CHANGELOG.md
|
99
|
+
- LICENSE
|
100
|
+
- README.md
|
101
|
+
- lib/jekyll/sheafy.rb
|
102
|
+
- lib/jekyll/sheafy/directed_graph.rb
|
103
|
+
- lib/jekyll/sheafy/version.rb
|
104
|
+
homepage: https://github.com/paolobrasolin/jekyll-sheafy
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata:
|
108
|
+
bug_tracker_uri: https://github.com/paolobrasolin/jekyll-sheafy/issues
|
109
|
+
changelog_uri: https://github.com/paolobrasolin/jekyll-sheafy/blob/main/CHANGELOG.md
|
110
|
+
documentation_uri: https://github.com/paolobrasolin/jekyll-sheafy#readme
|
111
|
+
homepage_uri: https://github.com/paolobrasolin/jekyll-sheafy
|
112
|
+
source_code_uri: https://github.com/paolobrasolin/jekyll-sheafy
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 2.6.0
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubygems_version: 3.1.4
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Brew your own Stacks Project with Jekyll!
|
132
|
+
test_files: []
|